Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gcc.dg/atomic-exchange-5.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
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 | |
13 int | |
14 main () | |
15 { | |
16 v = 0; | |
17 count = 0; | |
18 | |
19 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count) | |
20 abort (); | |
21 count++; | |
22 | |
23 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count) | |
24 abort (); | |
25 count++; | |
26 | |
27 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count) | |
28 abort (); | |
29 count++; | |
30 | |
31 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count) | |
32 abort (); | |
33 count++; | |
34 | |
35 if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count) | |
36 abort (); | |
37 count++; | |
38 | |
39 /* Now test the generic version. */ | |
40 | |
41 count++; | |
42 | |
43 __atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED); | |
44 if (ret != count - 1 || v != count) | |
45 abort (); | |
46 count++; | |
47 | |
48 __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE); | |
49 if (ret != count - 1 || v != count) | |
50 abort (); | |
51 count++; | |
52 | |
53 __atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE); | |
54 if (ret != count - 1 || v != count) | |
55 abort (); | |
56 count++; | |
57 | |
58 __atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL); | |
59 if (ret != count - 1 || v != count) | |
60 abort (); | |
61 count++; | |
62 | |
63 __atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST); | |
64 if (ret != count - 1 || v != count) | |
65 abort (); | |
66 count++; | |
67 | |
68 return 0; | |
69 } |