OSDN Git Service

PR testsuite/50796
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / gcc-have-sync-compare-and-swap.c
1 /* { dg-do link } */
2 /* MIPS only supports these built-in functions for non-MIPS16 mode, and
3    -mflip-mips16 will change the mode of some functions to be different
4    from the command-line setting.  */
5 /* { dg-skip-if "" { mips*-*-* } { "-mflip-mips16" } { "" } } */
6
7 void f1()
8 {
9 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
10   typedef int __attribute__  ((__mode__ (__QI__))) qi_int_type;
11   qi_int_type qi_int;
12   __sync_bool_compare_and_swap (&qi_int, (qi_int_type)0, (qi_int_type)1);
13 #endif
14 }
15
16 void f2()
17 {
18 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
19   typedef int __attribute__ ((__mode__ (__HI__))) hi_int_type;
20   hi_int_type hi_int;
21   __sync_bool_compare_and_swap (&hi_int, (hi_int_type)0, (hi_int_type)1);
22 #endif
23 }
24
25 void f4()
26 {
27 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
28   typedef int __attribute__ ((__mode__ (__SI__))) si_int_type;
29   si_int_type si_int;
30   __sync_bool_compare_and_swap (&si_int, (si_int_type)0, (si_int_type)1);
31 #endif
32 }
33
34 void f8()
35 {
36 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
37   typedef int __attribute__ ((__mode__ (__DI__))) di_int_type;
38   di_int_type di_int;
39   __sync_bool_compare_and_swap (&di_int, (di_int_type)0, (di_int_type)1);
40 #endif
41 }
42
43 void f16()
44 {
45 #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
46   typedef int __attribute__ ((__mode__ (__TI__))) ti_int_type;
47   ti_int_type ti_int;
48   __sync_bool_compare_and_swap (&ti_int, (ti_int_type)0, (ti_int_type)1);
49 #endif
50 }
51
52 int main()
53 {
54   f1();
55   f2();
56   f4();
57   f8();
58   f16();  
59   return 0;
60 }