Debian Codegraph @

gcc/testsuite/gcc.dg/atomic/c23-stdatomic-lockfree-char8_t.c

raw
1 /* Test atomic_is_lock_free for char8_t. */
2 /* { dg-do run } */
3 /* { dg-options "-std=c23 -pedantic-errors" } */
4
5 #include <stdatomic.h>
6 #include <stdint.h>
7
8 extern void abort (void);
9
10 _Atomic __CHAR8_TYPE__ ac8a;
11 atomic_char8_t ac8t;
12
13 #define CHECK_TYPE(MACRO, V1, V2) \
14 do \
15 { \
16 int r1 = MACRO; \
17 int r2 = atomic_is_lock_free (&V1); \
18 int r3 = atomic_is_lock_free (&V2); \
19 if (r1 != 0 && r1 != 1 && r1 != 2) \
20 abort (); \
21 if (r2 != 0 && r2 != 1) \
22 abort (); \
23 if (r3 != 0 && r3 != 1) \
24 abort (); \
25 if (r1 == 2 && r2 != 1) \
26 abort (); \
27 if (r1 == 2 && r3 != 1) \
28 abort (); \
29 if (r1 == 0 && r2 != 0) \
30 abort (); \
31 if (r1 == 0 && r3 != 0) \
32 abort (); \
33 } \
34 while (0)
35
36 int
37 main ()
38 {
39 CHECK_TYPE (ATOMIC_CHAR8_T_LOCK_FREE, ac8a, ac8t);
40
41 return 0;
42 }