1 /* Test generic __atomic routines for proper function calling.
3 /* { dg-options "-w" } */
5 /* { dg-additional-sources "atomic-generic-aux.c" } */
7 /* Test that the generioc atomic builtins execute as expected..
8 sync-mem-generic-aux.c supplies a functional external entry point for
9 the 4 generic functions. */
20 test_struct zero = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
21 test_struct ones = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
24 int size = sizeof (test_struct);
25 /* Test for consistency on sizes 1, 2, 4, 8, 16 and 32. */
30 __atomic_store (&a, &zero, __ATOMIC_RELAXED);
31 if (memcmp (&a, &zero, size))
34 __atomic_exchange (&a, &ones, &c, __ATOMIC_SEQ_CST);
35 if (memcmp (&c, &zero, size))
37 if (memcmp (&a, &ones, size))
40 __atomic_load (&a, &b, __ATOMIC_RELAXED);
41 if (memcmp (&b, &ones, size))
44 if (!__atomic_compare_exchange (&a, &b, &zero, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE))
46 if (memcmp (&a, &zero, size))
49 if (__atomic_compare_exchange (&a, &b, &ones, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE))
51 if (memcmp (&b, &zero, size))