1 /* Test __atomic routines for existence and proper execution on 16 byte
2 values with each valid memory model. */
3 /* { dg-do run } */
4 /* { dg-require-effective-target sync_int_128_runtime } */
5 /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
6
7 /* Test the execution of the __atomic_X builtin for a 16 byte value. */
8
9 extern void abort(void);
10
11 __int128_t v, count, ret;
12
main()13 main ()
14 {
15 v = 0;
16 count = 0;
17
18 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count++)
19 abort ();
20
21 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count++)
22 abort ();
23
24 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count++)
25 abort ();
26
27 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count++)
28 abort ();
29
30 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count++)
31 abort ();
32
33 /* Now test the generic version. */
34
35 count++;
36
37 __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
38 if (ret != count - 1 || v != count)
39 abort ();
40 count++;
41
42 __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
43 if (ret != count - 1 || v != count)
44 abort ();
45 count++;
46
47 __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
48 if (ret != count - 1 || v != count)
49 abort ();
50 count++;
51
52 __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
53 if (ret != count - 1 || v != count)
54 abort ();
55 count++;
56
57 __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
58 if (ret != count - 1 || v != count)
59 abort ();
60 count++;
61
62 return 0;
63 }
64