OSDN Git Service

PR middle-end/51038
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / atomic-flag.c
1 /* Test __atomic routines for existence and execution.  */
2 /* { dg-do run } */
3
4 #include <stdbool.h>
5
6 /* Test that __atomic_test_and_set and __atomic_clear builtins execute.  */
7
8 extern void abort(void);
9 bool a;
10
11 main ()
12 {
13   bool b;
14
15   __atomic_clear (&a, __ATOMIC_RELAXED);
16   if (a != 0)
17     abort ();
18
19   b = __atomic_test_and_set (&a, __ATOMIC_SEQ_CST);
20   if (a != 1 || b != 0)
21     abort ();
22
23   b = __atomic_test_and_set (&a, __ATOMIC_ACQ_REL);
24   if (b != 1 || a != 1)
25     abort ();
26
27   __atomic_clear (&a, __ATOMIC_SEQ_CST);
28   if (a != 0)
29     abort ();
30
31   return 0;
32 }