Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / support / regression / tcc / 125_atomic_misc.c
blob40e7cba84290ee342bf0a6a26e20efa9dba8fb33
1 #include <stdatomic.h>
2 int printf(const char*,...);
4 #if defined test_atomic_compare_exchange
5 int main()
7 _Atomic int a = 12;
8 int b = 77;
9 int r;
11 atomic_store(&a, b + 0);
12 r = atomic_compare_exchange_strong(&a, &b, 99);
13 printf("%d %d %d\n", r, a, b);
15 atomic_store(&a, b + 3);
16 r = atomic_compare_exchange_strong(&a, &b, 99);
17 printf("%d %d %d\n", r, a, b);
19 return 0;
22 #elif defined test_atomic_store
23 int main()
25 int _Atomic i;
26 int r;
27 atomic_store(&i, 12);
28 r = atomic_fetch_add(&i, i);
29 printf("r = %d, i = %d\n", r, i);
32 #elif defined test_atomic_store_pointer
33 typedef struct { char c[4]; } c4;
34 int main()
36 int i = 1;
37 int _Atomic *p = &i;
38 int k = 2;
39 atomic_store(&p, &k);
40 printf("*p = %d\n", *p);
43 #elif defined test_atomic_store_struct
44 typedef struct { char c[4]; } c4;
45 int main()
47 c4 _Atomic p;
48 c4 v = { 1,2,3,4 };
49 atomic_store(&p, v);
50 printf("%d %d %d %d\n", p.c[0], p.c[1], p.c[2], p.c[3]);
53 #elif defined test_atomic_error_1
54 int main()
56 int _Atomic i;
57 atomic_load(i);
60 #elif defined test_atomic_error_2
61 int main()
63 struct { char c[3]; } _Atomic c3;
64 atomic_load(&c3);
67 #elif defined test_atomic_error_3
68 int main()
70 _Atomic int *p = 0;
71 atomic_fetch_add(&p, 1);
74 #elif defined test_atomic_error_4
75 int main()
77 int _Atomic i = 1;
78 char c = 2;
79 atomic_compare_exchange_strong(&i, &c, 0);
82 #elif defined test_atomic_warn_1
83 int main()
85 size_t _Atomic i = 1;
86 /* assignment to integer from pointer */
87 atomic_store(&i, &i);
90 #elif defined test_atomic_warn_2
91 int main()
93 int i = 1;
94 char c = 2;
95 int _Atomic *p = &i;
96 /* assignment from incompatible pointer */
97 atomic_store(&p, &c);
100 #elif defined test_atomic_warn_3
101 int main()
103 int const i = 1;
104 /* assignment to read-only -location */
105 atomic_fetch_add(&i, 2);
108 #endif