+#define do_test(ptr) \
+do { \
+ __typeof__(*ptr) v; \
+ \
+ atomic_add(ptr, 10); \
+ assert(*ptr == 10); \
+ atomic_add(ptr, -11); \
+ assert(*ptr == (__typeof__(*ptr))-1U); \
+ v = cmpxchg(ptr, -1, 22); \
+ assert(*ptr == 22); \
+ assert(v == (__typeof__(*ptr))-1U); \
+ v = cmpxchg(ptr, 33, 44); \
+ assert(*ptr == 22); \
+ assert(v == 22); \
+ v = xchg(ptr, 55); \
+ assert(*ptr == 55); \
+ assert(v == 22); \
+} while (0)
+
+int main(int argc, char **argv)