diff options
Diffstat (limited to 'src/util/u_atomic_test.c')
-rw-r--r-- | src/util/u_atomic_test.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/util/u_atomic_test.c b/src/util/u_atomic_test.c index 8bddf8d1de..939cfe4457 100644 --- a/src/util/u_atomic_test.c +++ b/src/util/u_atomic_test.c @@ -37,9 +37,9 @@ #include "u_atomic.h" -/* Test operations that are supported for all types, including 8 bits types */ -#define test_atomic_8bits(type, ones) \ - static void test_atomic_8bits_##type (void) { \ +/* Test only assignment-like operations, which are supported on all types */ +#define test_atomic_assign(type, ones) \ + static void test_atomic_assign_##type (void) { \ type v, r; \ \ p_atomic_set(&v, ones); \ @@ -56,6 +56,19 @@ assert(v == 0 && "p_atomic_cmpxchg"); \ assert(r == ones && "p_atomic_cmpxchg"); \ \ + (void) r; \ + } + + +/* Test arithmetic operations that are supported on 8 bits integer types */ +#define test_atomic_8bits(type, ones) \ + test_atomic_assign(type, ones) \ + \ + static void test_atomic_8bits_##type (void) { \ + type v, r; \ + \ + test_atomic_assign_##type(); \ + \ v = 23; \ p_atomic_add(&v, 42); \ r = p_atomic_read(&v); \ @@ -65,7 +78,7 @@ } -/* Test operations that are not supported for 8 bits types */ +/* Test all operations */ #define test_atomic(type, ones) \ test_atomic_8bits(type, ones) \ \ @@ -121,7 +134,7 @@ test_atomic(uint64_t, UINT64_C(0xffffffffffffffff)) test_atomic_8bits(int8_t, INT8_C(-1)) test_atomic_8bits(uint8_t, UINT8_C(0xff)) -test_atomic_8bits(bool, true) +test_atomic_assign(bool, true) int main() @@ -138,7 +151,7 @@ main() test_atomic_8bits_int8_t(); test_atomic_8bits_uint8_t(); - test_atomic_8bits_bool(); + test_atomic_assign_bool(); return 0; } |