From: Rainer Orth Date: Tue, 9 Aug 2011 15:40:30 +0000 (+0000) Subject: sync.c: Move to ../libgcc. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c6412d86762ea3c31654c4c72b5e7ef86e66d90e;p=gcc.git sync.c: Move to ../libgcc. gcc: * config/sync.c: Move to ../libgcc. * Makefile.in (libgcc.mvars): Remove LIBGCC_SYNC, LIBGCC_SYNC_CFLAGS. * config/mips/t-libgcc-mips16 (LIBGCC_SYNC, LIBGCC_SYNC_CFLAGS): Remove. libgcc: * sync.c: New file. * config/mips/t-mips16: New file. * config.host (mips64*-*-linux*): Add mips/t-mips16 to tmake_file. (mips*-*-linux*): Likewise. (mips*-sde-elf*): Likewise. (mipsisa32-*-elf*): Join with mipsisa32r2-*-elf*, mipsisa64-*-elf*, mipsisa64r2-*-elf*. Add mips/t-mips16 to tmake_file. (mipsisa64sb1-*-elf*): Add mips/t-mips16 to tmake_file. (mips-*-elf*): Likewise. (mips64-*-elf*): Likewise. (mips64orion-*-elf*): Likewise. (mips*-*-rtems*): Likewise. (mipstx39-*-elf*): Likewise. * Makefile.in: Use SYNC instead of LIBGCC_SYNC. ($(libgcc-sync-size-funcs-o)): Use SYNC_CFLAGS instead of LIBGCC_SYNC_CFLAGS. Use $(srcdir) to refer to sync.c. Use $<. ($(libgcc-sync-funcs-o)): Likewise. ($(libgcc-sync-size-funcs-s-o)): Likewise. ($(libgcc-sync-funcs-s-o)): Likewise. From-SVN: r177601 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a47ca453032..a81bf0877f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2011-08-09 Rainer Orth + + * config/sync.c: Move to ../libgcc. + * Makefile.in (libgcc.mvars): Remove LIBGCC_SYNC, + LIBGCC_SYNC_CFLAGS. + * config/mips/t-libgcc-mips16 (LIBGCC_SYNC, LIBGCC_SYNC_CFLAGS): + Remove. + 2011-08-09 Anatoly Sokolov * config/mmix/mmix.h (REGISTER_MOVE_COST): Remove macro. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index fd9c0c1d620..4e97ea536e1 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1911,8 +1911,6 @@ libgcc.mvars: config.status Makefile $(LIB2ADD) $(LIB2ADD_ST) specs \ echo SHLIB_NM_FLAGS = '$(SHLIB_NM_FLAGS)' >> tmp-libgcc.mvars echo LIBGCC2_CFLAGS = '$(LIBGCC2_CFLAGS)' >> tmp-libgcc.mvars echo TARGET_LIBGCC2_CFLAGS = '$(TARGET_LIBGCC2_CFLAGS)' >> tmp-libgcc.mvars - echo LIBGCC_SYNC = '$(LIBGCC_SYNC)' >> tmp-libgcc.mvars - echo LIBGCC_SYNC_CFLAGS = '$(LIBGCC_SYNC_CFLAGS)' >> tmp-libgcc.mvars echo CRTSTUFF_CFLAGS = '$(CRTSTUFF_CFLAGS)' >> tmp-libgcc.mvars echo CRTSTUFF_T_CFLAGS = '$(CRTSTUFF_T_CFLAGS)' >> tmp-libgcc.mvars echo CRTSTUFF_T_CFLAGS_S = '$(CRTSTUFF_T_CFLAGS_S)' >> tmp-libgcc.mvars diff --git a/gcc/config/mips/t-libgcc-mips16 b/gcc/config/mips/t-libgcc-mips16 index fa3949a2026..772b05ac45e 100644 --- a/gcc/config/mips/t-libgcc-mips16 +++ b/gcc/config/mips/t-libgcc-mips16 @@ -1,4 +1,4 @@ -# Copyright (C) 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2007, 2008, 2011 Free Software Foundation, Inc. # # This file is part of GCC. # @@ -38,8 +38,5 @@ LIB1ASMFUNCS = _m16addsf3 _m16subsf3 _m16mulsf3 _m16divsf3 \ _m16stubdc0 _m16stubdc1 _m16stubdc2 _m16stubdc5 _m16stubdc6 \ _m16stubdc9 _m16stubdc10 -LIBGCC_SYNC = yes -LIBGCC_SYNC_CFLAGS = -mno-mips16 - # Version these symbols if building libgcc.so. SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver diff --git a/gcc/config/sync.c b/gcc/config/sync.c deleted file mode 100644 index eacdce6644e..00000000000 --- a/gcc/config/sync.c +++ /dev/null @@ -1,180 +0,0 @@ -/* Out-of-line libgcc versions of __sync_* builtins. */ -/* Copyright (C) 2008, 2009 Free Software Foundation, Inc. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 3, or (at your option) any later -version. - -GCC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -Under Section 7 of GPL version 3, you are granted additional -permissions described in the GCC Runtime Library Exception, version -3.1, as published by the Free Software Foundation. - -You should have received a copy of the GNU General Public License and -a copy of the GCC Runtime Library Exception along with this program; -see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -. */ - -/* This file is used by targets whose makefiles define LIBGCC_SYNC - to "yes". It is compiled with LIBGCC_SYNC_CFLAGS and provides - out-of-line versions of all relevant __sync_* primitives. - - These routines are intended for targets like MIPS that have two - ISA encodings (the "normal" ISA and the MIPS16 ISA). The normal - ISA provides full synchronization capabilities but the MIPS16 ISA - has no encoding for them. MIPS16 code must therefore call external - non-MIPS16 implementations of the __sync_* routines. - - The file is compiled once for each routine. The following __foo - routines are selected by defining a macro called L: - - __sync_synchronize - - The following __foo_N routines are selected by defining FN=foo - and SIZE=N: - - __sync_fetch_and_add_N - __sync_fetch_and_sub_N - __sync_fetch_and_or_N - __sync_fetch_and_and_N - __sync_fetch_and_xor_N - __sync_fetch_and_nand_N - __sync_add_and_fetch_N - __sync_sub_and_fetch_N - __sync_or_and_fetch_N - __sync_and_and_fetch_N - __sync_xor_and_fetch_N - __sync_nand_and_fetch_N - __sync_bool_compare_and_swap_N - __sync_val_compare_and_swap_N - __sync_lock_test_and_set_N - - SIZE can be 1, 2, 4, 8 or 16. __foo_N is omitted if the target does - not provide __sync_compare_and_swap_N. - - Note that __sync_lock_release does not fall back on external - __sync_lock_release_N functions. The default implementation - of __sync_lock_release is a call to __sync_synchronize followed - by a store of zero, so we don't need separate library functions - for it. */ - -#if defined FN - -/* Define macros for each __sync_* function type. Each macro defines a - local function called _ that acts like ___. - TYPE is a type that has UNITS bytes. */ - -#define DEFINE_V_PV(NAME, UNITS, TYPE) \ - static TYPE \ - NAME##_##UNITS (TYPE *ptr, TYPE value) \ - { \ - return __##NAME (ptr, value); \ - } - -#define DEFINE_V_PVV(NAME, UNITS, TYPE) \ - static TYPE \ - NAME##_##UNITS (TYPE *ptr, TYPE value1, TYPE value2) \ - { \ - return __##NAME (ptr, value1, value2); \ - } - -#define DEFINE_BOOL_PVV(NAME, UNITS, TYPE) \ - static _Bool \ - NAME##_##UNITS (TYPE *ptr, TYPE value1, TYPE value2) \ - { \ - return __##NAME (ptr, value1, value2); \ - } - -/* Map function names to the appropriate DEFINE_* macro. */ - -#define local_sync_fetch_and_add DEFINE_V_PV -#define local_sync_fetch_and_sub DEFINE_V_PV -#define local_sync_fetch_and_or DEFINE_V_PV -#define local_sync_fetch_and_and DEFINE_V_PV -#define local_sync_fetch_and_xor DEFINE_V_PV -#define local_sync_fetch_and_nand DEFINE_V_PV - -#define local_sync_add_and_fetch DEFINE_V_PV -#define local_sync_sub_and_fetch DEFINE_V_PV -#define local_sync_or_and_fetch DEFINE_V_PV -#define local_sync_and_and_fetch DEFINE_V_PV -#define local_sync_xor_and_fetch DEFINE_V_PV -#define local_sync_nand_and_fetch DEFINE_V_PV - -#define local_sync_bool_compare_and_swap DEFINE_BOOL_PVV -#define local_sync_val_compare_and_swap DEFINE_V_PVV - -#define local_sync_lock_test_and_set DEFINE_V_PV - -/* Define the function ___, given that TYPE is a type with - UNITS bytes. */ -#define DEFINE1(NAME, UNITS, TYPE) \ - static int unused[sizeof (TYPE) == UNITS ? 1 : -1] \ - __attribute__((unused)); \ - local_##NAME (NAME, UNITS, TYPE); \ - typeof (NAME##_##UNITS) __##NAME##_##UNITS \ - __attribute__((alias (#NAME "_" #UNITS))); - -/* As above, but performing macro expansion on the arguments. */ -#define DEFINE(NAME, UNITS, TYPE) DEFINE1 (NAME, UNITS, TYPE) - -/* Find an appropriate type TYPE for SIZE and invoke DEFINE (FN, SIZE, TYPE). - - The types chosen here may be incorrect for some targets. - For example, targets with 16-byte atomicity support might not - support OImode. We would need some kind of target-specific - override if that becomes a problem. */ - -#if SIZE == 1 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 - -typedef unsigned int UQItype __attribute__((mode (QI))); -DEFINE (FN, 1, UQItype) - -#elif SIZE == 2 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 - -typedef unsigned int UHItype __attribute__((mode (HI))); -DEFINE (FN, 2, UHItype) - -#elif SIZE == 4 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 - -typedef unsigned int USItype __attribute__((mode (SI))); -DEFINE (FN, 4, USItype) - -#elif SIZE == 8 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 - -typedef unsigned int UDItype __attribute__((mode (DI))); -DEFINE (FN, 8, UDItype) - -#elif SIZE == 16 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 - -typedef unsigned int UOItype __attribute__((mode (OI))); -DEFINE (FN, 8, UOItype) - -#endif - -#elif __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 defined Lsync_synchronize - -static void -sync_synchronize (void) -{ - __sync_synchronize (); -} -typeof (sync_synchronize) __sync_synchronize \ - __attribute__((alias ("sync_synchronize"))); - -#endif - -#endif diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 4ce6e92950c..531181564aa 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,28 @@ +2011-08-09 Rainer Orth + + * sync.c: New file. + * config/mips/t-mips16: New file. + * config.host (mips64*-*-linux*): Add mips/t-mips16 to tmake_file. + (mips*-*-linux*): Likewise. + (mips*-sde-elf*): Likewise. + (mipsisa32-*-elf*): Join with mipsisa32r2-*-elf*, + mipsisa64-*-elf*, mipsisa64r2-*-elf*. + Add mips/t-mips16 to tmake_file. + (mipsisa64sb1-*-elf*): Add mips/t-mips16 to tmake_file. + (mips-*-elf*): Likewise. + (mips64-*-elf*): Likewise. + (mips64orion-*-elf*): Likewise. + (mips*-*-rtems*): Likewise. + (mipstx39-*-elf*): Likewise. + * Makefile.in: Use SYNC instead of LIBGCC_SYNC. + ($(libgcc-sync-size-funcs-o)): Use SYNC_CFLAGS instead of + LIBGCC_SYNC_CFLAGS. + Use $(srcdir) to refer to sync.c. + Use $<. + ($(libgcc-sync-funcs-o)): Likewise. + ($(libgcc-sync-size-funcs-s-o)): Likewise. + ($(libgcc-sync-funcs-s-o)): Likewise. + 2011-08-09 Andreas Schwab * config.host (ia64*-*-linux*): Move ia64/t-glibc after diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index 4a75a37048e..0d3818eacef 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -651,7 +651,7 @@ endif endif -ifeq ($(LIBGCC_SYNC),yes) +ifeq ($(SYNC),yes) libgcc-sync-size-funcs := $(foreach op, add sub or and xor nand, \ sync_fetch_and_$(op) \ sync_$(op)_and_fetch) \ @@ -664,37 +664,37 @@ libgcc-sync-size-funcs := $(foreach prefix, $(libgcc-sync-size-funcs), \ $(prefix)_$(suffix))) libgcc-sync-size-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-size-funcs)) -$(libgcc-sync-size-funcs-o): %$(objext): $(gcc_srcdir)/config/sync.c - $(gcc_compile) $(LIBGCC_SYNC_CFLAGS) \ +$(libgcc-sync-size-funcs-o): %$(objext): $(srcdir)/sync.c + $(gcc_compile) $(SYNC_CFLAGS) \ -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \ -DSIZE=`echo "$*" | sed 's/.*_//'` \ - -c $(gcc_srcdir)/config/sync.c $(vis_hide) + -c $< $(vis_hide) libgcc-objects += $(libgcc-sync-size-funcs-o) libgcc-sync-funcs := sync_synchronize libgcc-sync-funcs-o = $(patsubst %,%$(objext),$(libgcc-sync-funcs)) -$(libgcc-sync-funcs-o): %$(objext): $(gcc_srcdir)/config/sync.c - $(gcc_compile) $(LIBGCC_SYNC_CFLAGS) \ +$(libgcc-sync-funcs-o): %$(objext): $(srcdir)/sync.c + $(gcc_compile) $(SYNC_CFLAGS) \ -DL$* \ - -c $(gcc_srcdir)/config/sync.c $(vis_hide) + -c $< $(vis_hide) libgcc-objects += $(libgcc-sync-funcs-o) ifeq ($(enable_shared),yes) libgcc-sync-size-funcs-s-o = $(patsubst %,%_s$(objext), \ $(libgcc-sync-size-funcs)) -$(libgcc-sync-size-funcs-s-o): %_s$(objext): $(gcc_srcdir)/config/sync.c - $(gcc_s_compile) $(LIBGCC_SYNC_CFLAGS) \ +$(libgcc-sync-size-funcs-s-o): %_s$(objext): $(srcdir)/sync.c + $(gcc_s_compile) $(SYNC_CFLAGS) \ -DFN=`echo "$*" | sed 's/_[^_]*$$//'` \ -DSIZE=`echo "$*" | sed 's/.*_//'` \ - -c $(gcc_srcdir)/config/sync.c + -c $< libgcc-s-objects += $(libgcc-sync-size-funcs-s-o) libgcc-sync-funcs-s-o = $(patsubst %,%_s$(objext),$(libgcc-sync-funcs)) -$(libgcc-sync-funcs-s-o): %_s$(objext): $(gcc_srcdir)/config/sync.c - $(gcc_s_compile) $(LIBGCC_SYNC_CFLAGS) \ +$(libgcc-sync-funcs-s-o): %_s$(objext): $(srcdir)/sync.c + $(gcc_s_compile) $(SYNC_CFLAGS) \ -DL$* \ - -c $(gcc_srcdir)/config/sync.c + -c $< libgcc-s-objects += $(libgcc-sync-funcs-s-o) endif endif diff --git a/libgcc/config.host b/libgcc/config.host index 9972bf0ef7c..24252e07c5b 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -539,12 +539,12 @@ mips*-*-netbsd*) # NetBSD/mips, either endian. ;; mips64*-*-linux* | mipsisa64*-*-linux*) extra_parts="$extra_parts crtfastmath.o" - tmake_file="${tmake_file} t-crtfm mips/t-tpbit" + tmake_file="${tmake_file} t-crtfm mips/t-mips16 mips/t-tpbit" md_unwind_header=mips/linux-unwind.h ;; mips*-*-linux*) # Linux MIPS, either endian. extra_parts="$extra_parts crtfastmath.o" - tmake_file="${tmake_file} t-crtfm" + tmake_file="${tmake_file} t-crtfm mips/t-mips16" md_unwind_header=mips/linux-unwind.h ;; mips*-*-openbsd*) @@ -559,33 +559,38 @@ mips*-sde-elf*) tmake_file=mips/t-sdemtk ;; esac + tmake_file="$tmake_file mips/t-mips16" ;; -mipsisa32-*-elf* | mipsisa32el-*-elf*) - ;; -mipsisa32r2-*-elf* | mipsisa32r2el-*-elf*) - ;; -mipsisa64-*-elf* | mipsisa64el-*-elf*) - ;; +mipsisa32-*-elf* | mipsisa32el-*-elf* | \ +mipsisa32r2-*-elf* | mipsisa32r2el-*-elf* | \ +mipsisa64-*-elf* | mipsisa64el-*-elf* | \ mipsisa64r2-*-elf* | mipsisa64r2el-*-elf*) + tmake_file="$tmake_file mips/t-mips16" ;; mipsisa64sr71k-*-elf*) tmake_file=t-fdpbit ;; mipsisa64sb1-*-elf* | mipsisa64sb1el-*-elf*) + tmake_file="$tmake_file mips/t-mips16" ;; mips-*-elf* | mipsel-*-elf*) + tmake_file="$tmake_file mips/t-mips16" ;; mips64-*-elf* | mips64el-*-elf*) + tmake_file="$tmake_file mips/t-mips16" ;; mips64vr-*-elf* | mips64vrel-*-elf*) ;; mips64orion-*-elf* | mips64orionel-*-elf*) + tmake_file="$tmake_file mips/t-mips16" ;; mips*-*-rtems*) + tmake_file="$tmake_file mips/t-mips16" ;; mips-wrs-vxworks) ;; mipstx39-*-elf* | mipstx39el-*-elf*) + tmake_file="$tmake_file mips/t-mips16" ;; mmix-knuth-mmixware) extra_parts="crti.o crtn.o crtbegin.o crtend.o" diff --git a/libgcc/config/mips/t-mips16 b/libgcc/config/mips/t-mips16 new file mode 100644 index 00000000000..94fa0e94275 --- /dev/null +++ b/libgcc/config/mips/t-mips16 @@ -0,0 +1,2 @@ +SYNC = yes +SYNC_CFLAGS = -mno-mips16 diff --git a/libgcc/sync.c b/libgcc/sync.c new file mode 100644 index 00000000000..3bc0e4a8286 --- /dev/null +++ b/libgcc/sync.c @@ -0,0 +1,180 @@ +/* Out-of-line libgcc versions of __sync_* builtins. */ +/* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +. */ + +/* This file is used by targets whose makefiles define SYNC + to "yes". It is compiled with SYNC_CFLAGS and provides + out-of-line versions of all relevant __sync_* primitives. + + These routines are intended for targets like MIPS that have two + ISA encodings (the "normal" ISA and the MIPS16 ISA). The normal + ISA provides full synchronization capabilities but the MIPS16 ISA + has no encoding for them. MIPS16 code must therefore call external + non-MIPS16 implementations of the __sync_* routines. + + The file is compiled once for each routine. The following __foo + routines are selected by defining a macro called L: + + __sync_synchronize + + The following __foo_N routines are selected by defining FN=foo + and SIZE=N: + + __sync_fetch_and_add_N + __sync_fetch_and_sub_N + __sync_fetch_and_or_N + __sync_fetch_and_and_N + __sync_fetch_and_xor_N + __sync_fetch_and_nand_N + __sync_add_and_fetch_N + __sync_sub_and_fetch_N + __sync_or_and_fetch_N + __sync_and_and_fetch_N + __sync_xor_and_fetch_N + __sync_nand_and_fetch_N + __sync_bool_compare_and_swap_N + __sync_val_compare_and_swap_N + __sync_lock_test_and_set_N + + SIZE can be 1, 2, 4, 8 or 16. __foo_N is omitted if the target does + not provide __sync_compare_and_swap_N. + + Note that __sync_lock_release does not fall back on external + __sync_lock_release_N functions. The default implementation + of __sync_lock_release is a call to __sync_synchronize followed + by a store of zero, so we don't need separate library functions + for it. */ + +#if defined FN + +/* Define macros for each __sync_* function type. Each macro defines a + local function called _ that acts like ___. + TYPE is a type that has UNITS bytes. */ + +#define DEFINE_V_PV(NAME, UNITS, TYPE) \ + static TYPE \ + NAME##_##UNITS (TYPE *ptr, TYPE value) \ + { \ + return __##NAME (ptr, value); \ + } + +#define DEFINE_V_PVV(NAME, UNITS, TYPE) \ + static TYPE \ + NAME##_##UNITS (TYPE *ptr, TYPE value1, TYPE value2) \ + { \ + return __##NAME (ptr, value1, value2); \ + } + +#define DEFINE_BOOL_PVV(NAME, UNITS, TYPE) \ + static _Bool \ + NAME##_##UNITS (TYPE *ptr, TYPE value1, TYPE value2) \ + { \ + return __##NAME (ptr, value1, value2); \ + } + +/* Map function names to the appropriate DEFINE_* macro. */ + +#define local_sync_fetch_and_add DEFINE_V_PV +#define local_sync_fetch_and_sub DEFINE_V_PV +#define local_sync_fetch_and_or DEFINE_V_PV +#define local_sync_fetch_and_and DEFINE_V_PV +#define local_sync_fetch_and_xor DEFINE_V_PV +#define local_sync_fetch_and_nand DEFINE_V_PV + +#define local_sync_add_and_fetch DEFINE_V_PV +#define local_sync_sub_and_fetch DEFINE_V_PV +#define local_sync_or_and_fetch DEFINE_V_PV +#define local_sync_and_and_fetch DEFINE_V_PV +#define local_sync_xor_and_fetch DEFINE_V_PV +#define local_sync_nand_and_fetch DEFINE_V_PV + +#define local_sync_bool_compare_and_swap DEFINE_BOOL_PVV +#define local_sync_val_compare_and_swap DEFINE_V_PVV + +#define local_sync_lock_test_and_set DEFINE_V_PV + +/* Define the function ___, given that TYPE is a type with + UNITS bytes. */ +#define DEFINE1(NAME, UNITS, TYPE) \ + static int unused[sizeof (TYPE) == UNITS ? 1 : -1] \ + __attribute__((unused)); \ + local_##NAME (NAME, UNITS, TYPE); \ + typeof (NAME##_##UNITS) __##NAME##_##UNITS \ + __attribute__((alias (#NAME "_" #UNITS))); + +/* As above, but performing macro expansion on the arguments. */ +#define DEFINE(NAME, UNITS, TYPE) DEFINE1 (NAME, UNITS, TYPE) + +/* Find an appropriate type TYPE for SIZE and invoke DEFINE (FN, SIZE, TYPE). + + The types chosen here may be incorrect for some targets. + For example, targets with 16-byte atomicity support might not + support OImode. We would need some kind of target-specific + override if that becomes a problem. */ + +#if SIZE == 1 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 + +typedef unsigned int UQItype __attribute__((mode (QI))); +DEFINE (FN, 1, UQItype) + +#elif SIZE == 2 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 + +typedef unsigned int UHItype __attribute__((mode (HI))); +DEFINE (FN, 2, UHItype) + +#elif SIZE == 4 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 + +typedef unsigned int USItype __attribute__((mode (SI))); +DEFINE (FN, 4, USItype) + +#elif SIZE == 8 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 + +typedef unsigned int UDItype __attribute__((mode (DI))); +DEFINE (FN, 8, UDItype) + +#elif SIZE == 16 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 + +typedef unsigned int UOItype __attribute__((mode (OI))); +DEFINE (FN, 8, UOItype) + +#endif + +#elif __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 defined Lsync_synchronize + +static void +sync_synchronize (void) +{ + __sync_synchronize (); +} +typeof (sync_synchronize) __sync_synchronize \ + __attribute__((alias ("sync_synchronize"))); + +#endif + +#endif