#include <stdio.h>
#include <assert.h>
-#include <urcu/uatomic_arch.h>
-
-#if (defined(__i386__) || defined(__x86_64__))
-#define HAS_ATOMIC_BYTE
-#define HAS_ATOMIC_SHORT
-#endif
+#include <urcu/uatomic.h>
struct testvals {
-#ifdef HAS_ATOMIC_BYTE
unsigned char c;
-#endif
-#ifdef HAS_ATOMIC_SHORT
unsigned short s;
-#endif
unsigned int i;
unsigned long l;
};
assert(uatomic_read(ptr) == 23); \
uatomic_dec(ptr); \
assert(uatomic_read(ptr) == 22); \
- v = uatomic_add_return(ptr, 100); \
- assert(v == 122); \
+ v = uatomic_add_return(ptr, 74); \
+ assert(v == 96); \
+ assert(uatomic_read(ptr) == 96); \
+ uatomic_or(ptr, 58); \
assert(uatomic_read(ptr) == 122); \
v = uatomic_sub_return(ptr, 1); \
assert(v == 121); \
assert(uatomic_read(ptr) == 121); \
+ uatomic_and(ptr, 129); \
+ assert(uatomic_read(ptr) == 1); \
} while (0)
int main(int argc, char **argv)
{
-#ifdef HAS_ATOMIC_BYTE
+#ifdef UATOMIC_HAS_ATOMIC_BYTE
do_test(&vals.c);
#endif
-#ifdef HAS_ATOMIC_SHORT
+#ifdef UATOMIC_HAS_ATOMIC_SHORT
do_test(&vals.s);
#endif
do_test(&vals.i);