aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xf86atomic.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/xf86atomic.h b/xf86atomic.h
index db2f6195..bc482c92 100644
--- a/xf86atomic.h
+++ b/xf86atomic.h
@@ -96,4 +96,13 @@ typedef struct { uint_t atomic; } atomic_t;
96#error libdrm requires atomic operations, please define them for your CPU/compiler. 96#error libdrm requires atomic operations, please define them for your CPU/compiler.
97#endif 97#endif
98 98
99static inline int atomic_add_unless(atomic_t *v, int add, int unless)
100{
101 int c, old;
102 c = atomic_read(v);
103 while (c != unless && (old = atomic_cmpxchg(v, c, c + add)) != c)
104 c = old;
105 return c == unless;
106}
107
99#endif 108#endif