1 /* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "" { target *-*-* } 0 } */
2 /* { dg-options "-ffat-lto-objects" } */
3 
4 /* Validate that each of the __sync builtins compiles.  This won't
5    necessarily link, since the target might not support the builtin,
6    so this may result in external library calls.  */
7 
test_op_ignore(void)8 void test_op_ignore (void)
9 {
10 signed char sc[2];
11 unsigned char uc[2];
12 signed short ss[2];
13 unsigned short us[2];
14 signed int si[2];
15 unsigned int ui[2];
16 signed long sl[2];
17 unsigned long ul[2];
18 signed long long sll[2];
19 unsigned long long ull[2];
20   (void) __sync_fetch_and_add (&sc[1], -1);
21   (void) __sync_fetch_and_add (&uc[1], -1);
22   (void) __sync_fetch_and_add (&ss[1], -1);
23   (void) __sync_fetch_and_add (&us[1], -1);
24   (void) __sync_fetch_and_add (&si[1], -1);
25   (void) __sync_fetch_and_add (&ui[1], -1);
26   (void) __sync_fetch_and_add (&sl[1], -1);
27   (void) __sync_fetch_and_add (&ul[1], -1);
28   (void) __sync_fetch_and_add (&sll[1], -1);
29   (void) __sync_fetch_and_add (&ull[1], -1);
30 
31   (void) __sync_fetch_and_sub (&sc[1], -1);
32   (void) __sync_fetch_and_sub (&uc[1], -1);
33   (void) __sync_fetch_and_sub (&ss[1], -1);
34   (void) __sync_fetch_and_sub (&us[1], -1);
35   (void) __sync_fetch_and_sub (&si[1], -1);
36   (void) __sync_fetch_and_sub (&ui[1], -1);
37   (void) __sync_fetch_and_sub (&sl[1], -1);
38   (void) __sync_fetch_and_sub (&ul[1], -1);
39   (void) __sync_fetch_and_sub (&sll[1], -1);
40   (void) __sync_fetch_and_sub (&ull[1], -1);
41 
42   (void) __sync_fetch_and_or (&sc[1], -1);
43   (void) __sync_fetch_and_or (&uc[1], -1);
44   (void) __sync_fetch_and_or (&ss[1], -1);
45   (void) __sync_fetch_and_or (&us[1], -1);
46   (void) __sync_fetch_and_or (&si[1], -1);
47   (void) __sync_fetch_and_or (&ui[1], -1);
48   (void) __sync_fetch_and_or (&sl[1], -1);
49   (void) __sync_fetch_and_or (&ul[1], -1);
50   (void) __sync_fetch_and_or (&sll[1], -1);
51   (void) __sync_fetch_and_or (&ull[1], -1);
52 
53   (void) __sync_fetch_and_xor (&sc[1], -1);
54   (void) __sync_fetch_and_xor (&uc[1], -1);
55   (void) __sync_fetch_and_xor (&ss[1], -1);
56   (void) __sync_fetch_and_xor (&us[1], -1);
57   (void) __sync_fetch_and_xor (&si[1], -1);
58   (void) __sync_fetch_and_xor (&ui[1], -1);
59   (void) __sync_fetch_and_xor (&sl[1], -1);
60   (void) __sync_fetch_and_xor (&ul[1], -1);
61   (void) __sync_fetch_and_xor (&sll[1], -1);
62   (void) __sync_fetch_and_xor (&ull[1], -1);
63 
64   (void) __sync_fetch_and_and (&sc[1], -1);
65   (void) __sync_fetch_and_and (&uc[1], -1);
66   (void) __sync_fetch_and_and (&ss[1], -1);
67   (void) __sync_fetch_and_and (&us[1], -1);
68   (void) __sync_fetch_and_and (&si[1], -1);
69   (void) __sync_fetch_and_and (&ui[1], -1);
70   (void) __sync_fetch_and_and (&sl[1], -1);
71   (void) __sync_fetch_and_and (&ul[1], -1);
72   (void) __sync_fetch_and_and (&sll[1], -1);
73   (void) __sync_fetch_and_and (&ull[1], -1);
74 
75   (void) __sync_fetch_and_nand (&sc[1], -1);
76   (void) __sync_fetch_and_nand (&uc[1], -1);
77   (void) __sync_fetch_and_nand (&ss[1], -1);
78   (void) __sync_fetch_and_nand (&us[1], -1);
79   (void) __sync_fetch_and_nand (&si[1], -1);
80   (void) __sync_fetch_and_nand (&ui[1], -1);
81   (void) __sync_fetch_and_nand (&sl[1], -1);
82   (void) __sync_fetch_and_nand (&ul[1], -1);
83   (void) __sync_fetch_and_nand (&sll[1], -1);
84   (void) __sync_fetch_and_nand (&ull[1], -1);
85 }
86 
test_fetch_and_op(void)87 void test_fetch_and_op (void)
88 {
89 signed char sc[2];
90 unsigned char uc[2];
91 signed short ss[2];
92 unsigned short us[2];
93 signed int si[2];
94 unsigned int ui[2];
95 signed long sl[2];
96 unsigned long ul[2];
97 signed long long sll[2];
98 unsigned long long ull[2];
99   sc[1] = __sync_fetch_and_add (&sc[1], -11);
100   uc[1] = __sync_fetch_and_add (&uc[1], -11);
101   ss[1] = __sync_fetch_and_add (&ss[1], -11);
102   us[1] = __sync_fetch_and_add (&us[1], -11);
103   si[1] = __sync_fetch_and_add (&si[1], -11);
104   ui[1] = __sync_fetch_and_add (&ui[1], -11);
105   sl[1] = __sync_fetch_and_add (&sl[1], -11);
106   ul[1] = __sync_fetch_and_add (&ul[1], -11);
107   sll[1] = __sync_fetch_and_add (&sll[1], -11);
108   ull[1] = __sync_fetch_and_add (&ull[1], -11);
109 
110   sc[1] = __sync_fetch_and_sub (&sc[1], -11);
111   uc[1] = __sync_fetch_and_sub (&uc[1], -11);
112   ss[1] = __sync_fetch_and_sub (&ss[1], -11);
113   us[1] = __sync_fetch_and_sub (&us[1], -11);
114   si[1] = __sync_fetch_and_sub (&si[1], -11);
115   ui[1] = __sync_fetch_and_sub (&ui[1], -11);
116   sl[1] = __sync_fetch_and_sub (&sl[1], -11);
117   ul[1] = __sync_fetch_and_sub (&ul[1], -11);
118   sll[1] = __sync_fetch_and_sub (&sll[1], -11);
119   ull[1] = __sync_fetch_and_sub (&ull[1], -11);
120 
121   sc[1] = __sync_fetch_and_or (&sc[1], -11);
122   uc[1] = __sync_fetch_and_or (&uc[1], -11);
123   ss[1] = __sync_fetch_and_or (&ss[1], -11);
124   us[1] = __sync_fetch_and_or (&us[1], -11);
125   si[1] = __sync_fetch_and_or (&si[1], -11);
126   ui[1] = __sync_fetch_and_or (&ui[1], -11);
127   sl[1] = __sync_fetch_and_or (&sl[1], -11);
128   ul[1] = __sync_fetch_and_or (&ul[1], -11);
129   sll[1] = __sync_fetch_and_or (&sll[1], -11);
130   ull[1] = __sync_fetch_and_or (&ull[1], -11);
131 
132   sc[1] = __sync_fetch_and_xor (&sc[1], -11);
133   uc[1] = __sync_fetch_and_xor (&uc[1], -11);
134   ss[1] = __sync_fetch_and_xor (&ss[1], -11);
135   us[1] = __sync_fetch_and_xor (&us[1], -11);
136   si[1] = __sync_fetch_and_xor (&si[1], -11);
137   ui[1] = __sync_fetch_and_xor (&ui[1], -11);
138   sl[1] = __sync_fetch_and_xor (&sl[1], -11);
139   ul[1] = __sync_fetch_and_xor (&ul[1], -11);
140   sll[1] = __sync_fetch_and_xor (&sll[1], -11);
141   ull[1] = __sync_fetch_and_xor (&ull[1], -11);
142 
143   sc[1] = __sync_fetch_and_and (&sc[1], -11);
144   uc[1] = __sync_fetch_and_and (&uc[1], -11);
145   ss[1] = __sync_fetch_and_and (&ss[1], -11);
146   us[1] = __sync_fetch_and_and (&us[1], -11);
147   si[1] = __sync_fetch_and_and (&si[1], -11);
148   ui[1] = __sync_fetch_and_and (&ui[1], -11);
149   sl[1] = __sync_fetch_and_and (&sl[1], -11);
150   ul[1] = __sync_fetch_and_and (&ul[1], -11);
151   sll[1] = __sync_fetch_and_and (&sll[1], -11);
152   ull[1] = __sync_fetch_and_and (&ull[1], -11);
153 
154   sc[1] = __sync_fetch_and_nand (&sc[1], -11);
155   uc[1] = __sync_fetch_and_nand (&uc[1], -11);
156   ss[1] = __sync_fetch_and_nand (&ss[1], -11);
157   us[1] = __sync_fetch_and_nand (&us[1], -11);
158   si[1] = __sync_fetch_and_nand (&si[1], -11);
159   ui[1] = __sync_fetch_and_nand (&ui[1], -11);
160   sl[1] = __sync_fetch_and_nand (&sl[1], -11);
161   ul[1] = __sync_fetch_and_nand (&ul[1], -11);
162   sll[1] = __sync_fetch_and_nand (&sll[1], -11);
163   ull[1] = __sync_fetch_and_nand (&ull[1], -11);
164 }
165 
test_lock(void)166 void test_lock (void)
167 {
168 signed char sc[2];
169 unsigned char uc[2];
170 signed short ss[2];
171 unsigned short us[2];
172 signed int si[2];
173 unsigned int ui[2];
174 signed long sl[2];
175 unsigned long ul[2];
176 signed long long sll[2];
177 unsigned long long ull[2];
178   sc[1] = __sync_lock_test_and_set (&sc[1], -1);
179   uc[1] = __sync_lock_test_and_set (&uc[1], -1);
180   ss[1] = __sync_lock_test_and_set (&ss[1], -1);
181   us[1] = __sync_lock_test_and_set (&us[1], -1);
182   si[1] = __sync_lock_test_and_set (&si[1], -1);
183   ui[1] = __sync_lock_test_and_set (&ui[1], -1);
184   sl[1] = __sync_lock_test_and_set (&sl[1], -1);
185   ul[1] = __sync_lock_test_and_set (&ul[1], -1);
186   sll[1] = __sync_lock_test_and_set (&sll[1], -1);
187   ull[1] = __sync_lock_test_and_set (&ull[1], -1);
188 }
189