diff options
Diffstat (limited to 'xf86atomic.h')
-rw-r--r-- | xf86atomic.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/xf86atomic.h b/xf86atomic.h index 0739ef71..e794af8e 100644 --- a/xf86atomic.h +++ b/xf86atomic.h @@ -75,21 +75,28 @@ typedef struct { #endif -#if defined(__sun) && !defined(HAS_ATOMIC_OPS) /* Solaris & OpenSolaris */ +#if (defined(__sun) || defined(__NetBSD__)) && !defined(HAS_ATOMIC_OPS) /* Solaris & OpenSolaris & NetBSD */ #include <sys/atomic.h> #define HAS_ATOMIC_OPS 1 -typedef struct { uint_t atomic; } atomic_t; +#if defined(__NetBSD__) +#define _ATOMIC_TYPE int +#else +#define _ATOMIC_TYPE uint_t +#endif + +typedef struct { _ATOMIC_TYPE atomic; } atomic_t; # define atomic_read(x) (int) ((x)->atomic) -# define atomic_set(x, val) ((x)->atomic = (uint_t)(val)) +# define atomic_set(x, val) ((x)->atomic = (_ATOMIC_TYPE)(val)) # define atomic_inc(x) (atomic_inc_uint (&(x)->atomic)) # define atomic_dec_and_test(x) (atomic_dec_uint_nv(&(x)->atomic) == 0) # define atomic_add(x, v) (atomic_add_int(&(x)->atomic, (v))) # define atomic_dec(x, v) (atomic_add_int(&(x)->atomic, -(v))) # define atomic_cmpxchg(x, oldv, newv) atomic_cas_uint (&(x)->atomic, oldv, newv) +#undef _ATOMIC_TYPE #endif #if ! HAS_ATOMIC_OPS |