summaryrefslogtreecommitdiffstats
path: root/src/util/u_atomic_test.c
diff options
context:
space:
mode:
authorCarl Worth <[email protected]>2015-02-05 15:36:59 -0800
committerCarl Worth <[email protected]>2015-02-09 10:47:44 -0800
commitb16de0b713fb4d5d1c5600d126e4ce945fc27303 (patch)
tree5515a59772d2fe67ed7a5d1883619c59a2e06071 /src/util/u_atomic_test.c
parent345e8cc8496b4e6c56105c7396e80d85a37e122c (diff)
util/u_atomic: Add new macro p_atomic_add
This provides for atomic addition, which will be used by an upcoming shader-cache patch. A simple test is added to "make check" as well. Note: The various O/S functions differ on whether they return the original value or the value after the addition, so I did not provide an add_return() macro which would be sensitive to that difference. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Aaron Watry <[email protected]> Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src/util/u_atomic_test.c')
-rw-r--r--src/util/u_atomic_test.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/u_atomic_test.c b/src/util/u_atomic_test.c
index 4845e753e6e..c5062750ae4 100644
--- a/src/util/u_atomic_test.c
+++ b/src/util/u_atomic_test.c
@@ -97,6 +97,11 @@
assert(v == ones && "p_atomic_dec_return"); \
assert(r == v && "p_atomic_dec_return"); \
\
+ v = 23; \
+ p_atomic_add(&v, 42); \
+ r = p_atomic_read(&v); \
+ assert(r == 65 && "p_atomic_add"); \
+ \
(void) r; \
(void) b; \
}