Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


  38 
  39 
  40 
  41 #ifndef _SYS_DRM_ATOMIC_H_
  42 #define _SYS_DRM_ATOMIC_H_
  43 
  44 #ifdef  __cplusplus
  45 extern "C" {
  46 #endif
  47 
  48 #include <sys/atomic.h>
  49 
  50 #ifdef __LINT__
  51 #undef inline
  52 #define inline
  53 #endif
  54 typedef uint32_t        atomic_t;
  55 
  56 #define atomic_set(p, v)        (*(p) = (v))
  57 #define atomic_read(p)          (*(p))
  58 #define atomic_inc(p)           atomic_add_int(p, 1)
  59 #define atomic_dec(p)           atomic_dec_uint(p)
  60 #define atomic_add(n, p)        atomic_add_int(p, n)
  61 #define atomic_sub(n, p)        atomic_add_int(p, -n)
  62 #define atomic_set_int(p, bits) atomic_or_uint(p, bits)
  63 #define atomic_clear_int(p, bits)       atomic_and_uint(p, ~(bits))
  64 #define atomic_cmpset_int(p, c, n) \
  65         ((c == atomic_cas_uint(p, c, n)) ? 1 : 0)
  66 
  67 #define set_bit(b, p) \
  68         atomic_set_int(((volatile uint_t *)(void *)p) + (b >> 5), \
  69         1 << (b & 0x1f))
  70 
  71 #define clear_bit(b, p) \
  72         atomic_clear_int(((volatile uint_t *)(void *)p) + (b >> 5), \
  73         1 << (b & 0x1f))
  74 
  75 #define test_bit(b, p) \
  76         (((volatile uint_t *)(void *)p)[b >> 5] & (1 << (b & 0x1f)))
  77 
  78 /*


  38 
  39 
  40 
  41 #ifndef _SYS_DRM_ATOMIC_H_
  42 #define _SYS_DRM_ATOMIC_H_
  43 
  44 #ifdef  __cplusplus
  45 extern "C" {
  46 #endif
  47 
  48 #include <sys/atomic.h>
  49 
  50 #ifdef __LINT__
  51 #undef inline
  52 #define inline
  53 #endif
  54 typedef uint32_t        atomic_t;
  55 
  56 #define atomic_set(p, v)        (*(p) = (v))
  57 #define atomic_read(p)          (*(p))
  58 #define atomic_inc(p)           atomic_inc_uint(p)
  59 #define atomic_dec(p)           atomic_dec_uint(p)
  60 #define atomic_add(n, p)        atomic_add_int(p, n)
  61 #define atomic_sub(n, p)        atomic_add_int(p, -n)
  62 #define atomic_set_int(p, bits) atomic_or_uint(p, bits)
  63 #define atomic_clear_int(p, bits)       atomic_and_uint(p, ~(bits))
  64 #define atomic_cmpset_int(p, c, n) \
  65         ((c == atomic_cas_uint(p, c, n)) ? 1 : 0)
  66 
  67 #define set_bit(b, p) \
  68         atomic_set_int(((volatile uint_t *)(void *)p) + (b >> 5), \
  69         1 << (b & 0x1f))
  70 
  71 #define clear_bit(b, p) \
  72         atomic_clear_int(((volatile uint_t *)(void *)p) + (b >> 5), \
  73         1 << (b & 0x1f))
  74 
  75 #define test_bit(b, p) \
  76         (((volatile uint_t *)(void *)p)[b >> 5] & (1 << (b & 0x1f)))
  77 
  78 /*