annotate gcc/testsuite/gcc.dg/atomic-compare-exchange-5.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test __atomic routines for existence and proper execution on 16 byte
kono
parents:
diff changeset
2 values with each valid memory model. */
kono
parents:
diff changeset
3 /* { dg-do run } */
kono
parents:
diff changeset
4 /* { dg-require-effective-target sync_int_128_runtime } */
kono
parents:
diff changeset
5 /* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 /* Test the execution of __atomic_compare_exchange_n builtin for an int_128. */
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 extern void abort(void);
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 __int128_t v = 0;
kono
parents:
diff changeset
12 __int128_t expected = 0;
kono
parents:
diff changeset
13 __int128_t max = ~0;
kono
parents:
diff changeset
14 __int128_t desired = ~0;
kono
parents:
diff changeset
15 __int128_t zero = 0;
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 #define STRONG 0
kono
parents:
diff changeset
18 #define WEAK 1
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 int
kono
parents:
diff changeset
21 main ()
kono
parents:
diff changeset
22 {
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
kono
parents:
diff changeset
25 abort ();
kono
parents:
diff changeset
26 if (expected != 0)
kono
parents:
diff changeset
27 abort ();
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
kono
parents:
diff changeset
30 abort ();
kono
parents:
diff changeset
31 if (expected != max)
kono
parents:
diff changeset
32 abort ();
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
kono
parents:
diff changeset
35 abort ();
kono
parents:
diff changeset
36 if (expected != max)
kono
parents:
diff changeset
37 abort ();
kono
parents:
diff changeset
38 if (v != 0)
kono
parents:
diff changeset
39 abort ();
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
kono
parents:
diff changeset
42 abort ();
kono
parents:
diff changeset
43 if (expected != 0)
kono
parents:
diff changeset
44 abort ();
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
kono
parents:
diff changeset
47 abort ();
kono
parents:
diff changeset
48 if (expected != 0)
kono
parents:
diff changeset
49 abort ();
kono
parents:
diff changeset
50 if (v != max)
kono
parents:
diff changeset
51 abort ();
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 /* Now test the generic version. */
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 v = 0;
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED))
kono
parents:
diff changeset
58 abort ();
kono
parents:
diff changeset
59 if (expected != 0)
kono
parents:
diff changeset
60 abort ();
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
kono
parents:
diff changeset
63 abort ();
kono
parents:
diff changeset
64 if (expected != max)
kono
parents:
diff changeset
65 abort ();
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
kono
parents:
diff changeset
68 abort ();
kono
parents:
diff changeset
69 if (expected != max)
kono
parents:
diff changeset
70 abort ();
kono
parents:
diff changeset
71 if (v != 0)
kono
parents:
diff changeset
72 abort ();
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
kono
parents:
diff changeset
75 abort ();
kono
parents:
diff changeset
76 if (expected != 0)
kono
parents:
diff changeset
77 abort ();
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
kono
parents:
diff changeset
80 abort ();
kono
parents:
diff changeset
81 if (expected != 0)
kono
parents:
diff changeset
82 abort ();
kono
parents:
diff changeset
83 if (v != max)
kono
parents:
diff changeset
84 abort ();
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 return 0;
kono
parents:
diff changeset
87 }