diff options
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/c-cppbuiltin.c | 27 | ||||
-rw-r--r-- | gcc/doc/cpp.texi | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c | 56 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-1.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-2.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-3.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-4.c | 22 |
9 files changed, 201 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1b41fd4faf0..4dc3cd52536 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2007-05-21 Paolo Bonzini <bonzini@gnu.org> + Paolo Carlini <pcarlini@suse.de> + Uros Bizjak <ubizjak@gmail.com> + + * c-cppbuiltin.c (c_cpp_builtins): Define + __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1, __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2, + __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4, __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8, + __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16, if appropriate. + * doc/cpp.texi ([Standard Predefined Macros]): Document. + 2007-05-21 Mike Stump <mrs@apple.com> * config/darwin.h (LINK_COMMAND_SPEC): Add .cxx for dsymutil diff --git a/gcc/c-cppbuiltin.c b/gcc/c-cppbuiltin.c index 544050a4878..1b52da02975 100644 --- a/gcc/c-cppbuiltin.c +++ b/gcc/c-cppbuiltin.c @@ -547,6 +547,33 @@ c_cpp_builtins (cpp_reader *pfile) if (c_dialect_cxx () && TYPE_UNSIGNED (wchar_type_node)) cpp_define (pfile, "__WCHAR_UNSIGNED__"); + /* Tell source code if the compiler makes sync_compare_and_swap + builtins available. */ +#ifdef HAVE_sync_compare_and_swapqi + if (HAVE_sync_compare_and_swapqi) + cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); +#endif + +#ifdef HAVE_sync_compare_and_swaphi + if (HAVE_sync_compare_and_swaphi) + cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); +#endif + +#ifdef HAVE_sync_compare_and_swapsi + if (HAVE_sync_compare_and_swapsi) + cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"); +#endif + +#ifdef HAVE_sync_compare_and_swapdi + if (HAVE_sync_compare_and_swapdi) + cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); +#endif + +#ifdef HAVE_sync_compare_and_swapti + if (HAVE_sync_compare_and_swapti) + cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16"); +#endif + /* Make the choice of ObjC runtime visible to source code. */ if (c_dialect_objc () && flag_next_runtime) cpp_define (pfile, "__NEXT_RUNTIME__"); diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index fe2a93bf59a..e6786cf8102 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -2179,6 +2179,14 @@ If GCC cannot determine the current date, it will emit a warning message (once per compilation) and @code{__TIMESTAMP__} will expand to @code{@w{"??? ??? ?? ??:??:?? ????"}}. +@item __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 +@itemx __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 +@itemx __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +@itemx __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +@itemx __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 +These macros are defined when the target processor supports atomic compare +and swap operations on operands 1, 2, 4, 8 or 16 bytes in length, respectively. + @end table @node System-specific Predefined Macros diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c08db442f70..af3830f5111 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2007-05-21 Paolo Bonzini <bonzini@gnu.org> + Paolo Carlini <pcarlini@suse.de> + Uros Bizjak <ubizjak@gmail.com> + + * gcc.dg/gcc-have-sync-compare-and-swap.c, + gcc.target/i386/gcc-have-sync-compare-and-swap-1.c, + gcc.target/i386/gcc-have-sync-compare-and-swap-2.c, + gcc.target/i386/gcc-have-sync-compare-and-swap-3.c, + gcc.target/i386/gcc-have-sync-compare-and-swap-4.c, + New testcases. + 2005-05-21 Daniel Franke <franke.daniel@gmail.com> PR fortran/32002 diff --git a/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c b/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c new file mode 100644 index 00000000000..89527f6c361 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gcc-have-sync-compare-and-swap.c @@ -0,0 +1,56 @@ +/* { dg-do link } */ + +void f1() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 + typedef int __attribute__ ((__mode__ (__QI__))) qi_int_type; + qi_int_type qi_int; + __sync_bool_compare_and_swap (&qi_int, (qi_int_type)0, (qi_int_type)1); +#endif +} + +void f2() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 + typedef int __attribute__ ((__mode__ (__HI__))) hi_int_type; + hi_int_type hi_int; + __sync_bool_compare_and_swap (&hi_int, (hi_int_type)0, (hi_int_type)1); +#endif +} + +void f4() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 + typedef int __attribute__ ((__mode__ (__SI__))) si_int_type; + si_int_type si_int; + __sync_bool_compare_and_swap (&si_int, (si_int_type)0, (si_int_type)1); +#endif +} + +void f8() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 + typedef int __attribute__ ((__mode__ (__DI__))) di_int_type; + di_int_type di_int; + __sync_bool_compare_and_swap (&di_int, (di_int_type)0, (di_int_type)1); +#endif +} + +void f16() +{ +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 + typedef int __attribute__ ((__mode__ (__TI__))) ti_int_type; + ti_int_type ti_int; + __sync_bool_compare_and_swap (&ti_int, (ti_int_type)0, (ti_int_type)1); +#endif +} + +int main() +{ + f1(); + f2(); + f4(); + f8(); + f16(); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-1.c b/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-1.c new file mode 100644 index 00000000000..10e83233854 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-1.c @@ -0,0 +1,22 @@ +/* { dg-do preprocess { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-options "-march=i386" } */ + +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 +#error nonono +#endif + +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 +#error nonono +#endif + +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +#error nonono +#endif + +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +#error nonono +#endif + +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 +#error nonono +#endif diff --git a/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-2.c b/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-2.c new file mode 100644 index 00000000000..9ec0088c259 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-2.c @@ -0,0 +1,23 @@ +/* { dg-do preprocess { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-options "-march=i486" } */ + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +#error nonono +#endif + +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +#error nonono +#endif + +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 +#error nonono +#endif + diff --git a/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-3.c b/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-3.c new file mode 100644 index 00000000000..8d1889cb7e5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-3.c @@ -0,0 +1,22 @@ +/* { dg-do preprocess { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-march=i586" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +#error nonono +#endif + +#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 +#error nonono +#endif diff --git a/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-4.c b/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-4.c new file mode 100644 index 00000000000..558483bf49e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/gcc-have-sync-compare-and-swap-4.c @@ -0,0 +1,22 @@ +/* { dg-do preprocess { target { { i?86-*-* x86_64-*-* } && lp64 } } } */ +/* { dg-options "-mcx16" } */ + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +#error nonono +#endif + +#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 +#error nonono +#endif |