OSDN Git Service

PR/51443
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / atomic-store-5.c
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_store_n builtin for a 16 byte value.  */
8
9 extern void abort(void);
10
11 __int128_t v, count;
12
13 main ()
14 {
15   v = 0;
16   count = 0;
17
18   __atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
19   if (v != ++count)
20     abort ();
21
22   __atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
23   if (v != ++count)
24     abort ();
25
26   __atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
27   if (v != ++count)
28     abort ();
29
30   /* Now test the generic variant.  */
31   count++;
32
33   __atomic_store (&v, &count, __ATOMIC_RELAXED);
34   if (v != count++)
35     abort ();
36
37   __atomic_store (&v, &count, __ATOMIC_RELEASE);
38   if (v != count++)
39     abort ();
40
41   __atomic_store (&v, &count, __ATOMIC_SEQ_CST);
42   if (v != count)
43     abort ();
44
45
46   return 0;
47 }
48