Source
79
79
80
80
#include <sys/atomic.h>
81
81
#define HAS_ATOMIC_OPS 1
82
82
83
83
typedef struct { uint_t atomic; } atomic_t;
84
84
85
85
# define atomic_read(x) (int) ((x)->atomic)
86
86
# define atomic_set(x, val) ((x)->atomic = (uint_t)(val))
87
87
# define atomic_inc(x) (atomic_inc_uint (&(x)->atomic))
88
88
# define atomic_dec_and_test(x) (atomic_dec_uint_nv(&(x)->atomic) == 1)
89
-
# define atomic_add(x, v) (atomic_add_uint(&(x)->atomic, (v)))
90
-
# define atomic_dec(x, v) (atomic_dec_uint(&(x)->atomic, (v)))
89
+
# define atomic_add(x, v) (atomic_add_int(&(x)->atomic, (v)))
90
+
# define atomic_dec(x, v) (atomic_add_int(&(x)->atomic, -(v)))
91
91
# define atomic_cmpxchg(x, oldv, newv) atomic_cas_uint (&(x)->atomic, oldv, newv)
92
92
93
93
#endif
94
94
95
95
#if ! HAS_ATOMIC_OPS
96
96
#error libdrm requires atomic operations, please define them for your CPU/compiler.
97
97
#endif
98
98
99
99
#endif