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