1 /* Test atomic_flag routines for existence and execution.  Out-of-line
2    function calls.  */
3 /* The test needs a lockless atomic implementation.  */
4 /* { dg-do run { xfail hppa*-*-hpux* } } */
5 /* { dg-options "-std=c11 -pedantic-errors" } */
6 
7 #include <stdatomic.h>
8 
9 extern void abort (void);
10 atomic_flag a = ATOMIC_FLAG_INIT;
11 
12 int
main()13 main ()
14 {
15   int b;
16 
17   if (!atomic_is_lock_free (&a))
18     abort ();
19 
20   if ((atomic_flag_test_and_set) (&a))
21     abort ();
22   (atomic_flag_clear_explicit) (&a, memory_order_relaxed);
23   if ((atomic_flag_test_and_set) (&a))
24     abort ();
25   (atomic_flag_clear) (&a);
26 
27   b = (atomic_flag_test_and_set_explicit) (&a, memory_order_seq_cst);
28   if (!(atomic_flag_test_and_set) (&a) || b != 0)
29     abort ();
30 
31   b = (atomic_flag_test_and_set_explicit) (&a, memory_order_acq_rel);
32   if (!(atomic_flag_test_and_set) (&a) || b != 1)
33     abort ();
34 
35   (atomic_flag_clear_explicit) (&a, memory_order_seq_cst);
36   if ((atomic_flag_test_and_set) (&a))
37     abort ();
38 
39   return 0;
40 }
41