1 /* Test __atomic routines for existence and proper execution on 1 byte
2 values with each valid memory model. */
3 /* { dg-do run } */
4 /* { dg-require-effective-target sync_char_short } */
5
6
7 /* Test the execution of the __atomic_load_n builtin for a char. */
8
9 extern void abort(void);
10
11 char v, count;
12
13 int
main()14 main ()
15 {
16 v = 0;
17 count = 0;
18
19 if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++)
20 abort();
21 else
22 v++;
23
24 if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++)
25 abort();
26 else
27 v++;
28
29 if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++)
30 abort();
31 else
32 v++;
33
34 if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++)
35 abort();
36 else
37 v++;
38
39 /* Now test the generic variants. */
40
41 __atomic_load (&v, &count, __ATOMIC_RELAXED);
42 if (count != v)
43 abort();
44 else
45 v++;
46
47 __atomic_load (&v, &count, __ATOMIC_ACQUIRE);
48 if (count != v)
49 abort();
50 else
51 v++;
52
53 __atomic_load (&v, &count, __ATOMIC_CONSUME);
54 if (count != v)
55 abort();
56 else
57 v++;
58
59 __atomic_load (&v, &count, __ATOMIC_SEQ_CST);
60 if (count != v)
61 abort();
62 else
63 v++;
64
65 return 0;
66 }
67
68