Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gcc.dg/atomic-generic.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 generic __atomic routines for proper function calling. | |
2 memory model. */ | |
3 /* { dg-options "-w" } */ | |
4 /* { dg-do run } */ | |
5 /* { dg-additional-sources "atomic-generic-aux.c" } */ | |
6 | |
7 /* Test that the generioc atomic builtins execute as expected.. | |
8 sync-mem-generic-aux.c supplies a functional external entry point for | |
9 the 4 generic functions. */ | |
10 | |
11 #include <stdlib.h> | |
12 #include <stdbool.h> | |
13 #include <string.h> | |
14 | |
15 extern void abort(); | |
16 | |
17 typedef struct test { | |
18 int array[10]; | |
19 } test_struct; | |
20 | |
21 test_struct zero = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; | |
22 test_struct ones = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; | |
23 test_struct a,b; | |
24 | |
25 int size = sizeof (test_struct); | |
26 /* Test for consistency on sizes 1, 2, 4, 8, 16 and 32. */ | |
27 int | |
28 main () | |
29 { | |
30 test_struct c; | |
31 | |
32 __atomic_store (&a, &zero, __ATOMIC_RELAXED); | |
33 if (memcmp (&a, &zero, size)) | |
34 abort (); | |
35 | |
36 __atomic_exchange (&a, &ones, &c, __ATOMIC_SEQ_CST); | |
37 if (memcmp (&c, &zero, size)) | |
38 abort (); | |
39 if (memcmp (&a, &ones, size)) | |
40 abort (); | |
41 | |
42 __atomic_load (&a, &b, __ATOMIC_RELAXED); | |
43 if (memcmp (&b, &ones, size)) | |
44 abort (); | |
45 | |
46 if (!__atomic_compare_exchange (&a, &b, &zero, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE)) | |
47 abort(); | |
48 if (memcmp (&a, &zero, size)) | |
49 abort (); | |
50 | |
51 if (__atomic_compare_exchange (&a, &b, &ones, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE)) | |
52 abort(); | |
53 if (memcmp (&b, &zero, size)) | |
54 abort (); | |
55 | |
56 return 0; | |
57 } | |
58 |