1 /* Test __atomic routines for existence and proper execution on 2 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 short. */
8
9 extern void abort(void);
10
11 short v, count;
12
13
14 int
main()15 main ()
16 {
17 v = 0;
18 count = 0;
19
20 if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++)
21 abort();
22 else
23 v++;
24
25 if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++)
26 abort();
27 else
28 v++;
29
30 if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++)
31 abort();
32 else
33 v++;
34
35 if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++)
36 abort();
37 else
38 v++;
39
40 /* Now test the generic variants. */
41
42 __atomic_load (&v, &count, __ATOMIC_RELAXED);
43 if (count != v)
44 abort();
45 else
46 v++;
47
48 __atomic_load (&v, &count, __ATOMIC_ACQUIRE);
49 if (count != v)
50 abort();
51 else
52 v++;
53
54 __atomic_load (&v, &count, __ATOMIC_CONSUME);
55 if (count != v)
56 abort();
57 else
58 v++;
59
60 __atomic_load (&v, &count, __ATOMIC_SEQ_CST);
61 if (count != v)
62 abort();
63 else
64 v++;
65
66
67 return 0;
68 }
69
70