summaryrefslogtreecommitdiff
path: root/xf86atomic.h
diff options
context:
space:
mode:
authorThomas Klausner <wiz@NetBSD.org>2014-07-20 10:23:58 +0200
committerMaarten Lankhorst <maarten.lankhorst@ubuntu.com>2015-01-26 10:08:41 +0100
commit87fdd32c87796482638de54988027d0aca0c4f12 (patch)
tree1bcf3d1debfa73d4bb6d175fae28cf9bfffdf9fa /xf86atomic.h
parent96cf45542503dd4c892c7875340957d5515163ac (diff)
Add NetBSD atomic ops support.
Signed-off-by: Thomas Klausner <wiz@NetBSD.org> Reviewed-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@ubuntu.com>
Diffstat (limited to 'xf86atomic.h')
-rw-r--r--xf86atomic.h13
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