[Mesa-dev] [PATCH] uti/u_atomic: Don't test p_atomic_add with booleans.
Jose Fonseca
jfonseca at vmware.com
Fri Feb 13 01:47:42 PST 2015
Add another class of tests.
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=89112
I failed to spot this in my previous change, because bool was a typedef
for char on the system I tested.
---
src/util/u_atomic_test.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/util/u_atomic_test.c b/src/util/u_atomic_test.c
index 8bddf8d..ffe4703 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 can be 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 8bit 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;
}
--
2.1.4
More information about the mesa-dev
mailing list