From de071d199a8578055edf2722114788ae749823aa Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 11 Sep 2015 20:00:19 +0000 Subject: Move bits/atomic.h to atomic-machine.h (bug 14912). It was noted in that the bits/*.h naming scheme should only be used for installed headers. This patch renames bits/atomic.h to atomic-machine.h to follow that convention. This is the only change in this series that needs to change the filename rather than simply removing a directory level (because both atomic.h and bits/atomic.h exist at present). Tested for x86_64 (testsuite, and that installed stripped shared libraries are unchanged by the patch). [BZ #14912] * sysdeps/aarch64/bits/atomic.h: Move to ... * sysdeps/aarch64/atomic-machine.h: ...here. (_AARCH64_BITS_ATOMIC_H): Rename macro to _AARCH64_ATOMIC_MACHINE_H. * sysdeps/alpha/bits/atomic.h: Move to ... * sysdeps/alpha/atomic-machine.h: ...here. * sysdeps/arm/bits/atomic.h: Move to ... * sysdeps/arm/atomic-machine.h: ...here. Update comments. * bits/atomic.h: Move to ... * sysdeps/generic/atomic-machine.h: ...here. (_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H. * sysdeps/i386/bits/atomic.h: Move to ... * sysdeps/i386/atomic-machine.h: ...here. * sysdeps/ia64/bits/atomic.h: Move to ... * sysdeps/ia64/atomic-machine.h: ...here. * sysdeps/m68k/coldfire/bits/atomic.h: Move to ... * sysdeps/m68k/coldfire/atomic-machine.h: ...here. (_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H. * sysdeps/m68k/m680x0/m68020/bits/atomic.h: Move to ... * sysdeps/m68k/m680x0/m68020/atomic-machine.h: ...here. * sysdeps/microblaze/bits/atomic.h: Move to ... * sysdeps/microblaze/atomic-machine.h: ...here. * sysdeps/mips/bits/atomic.h: Move to ... * sysdeps/mips/atomic-machine.h: ...here. (_MIPS_BITS_ATOMIC_H): Rename macro to _MIPS_ATOMIC_MACHINE_H. * sysdeps/powerpc/bits/atomic.h: Move to ... * sysdeps/powerpc/atomic-machine.h: ...here. Update comments. * sysdeps/powerpc/powerpc32/bits/atomic.h: Move to ... * sysdeps/powerpc/powerpc32/atomic-machine.h: ...here. Update comments. Include instead of . * sysdeps/powerpc/powerpc64/bits/atomic.h: Move to ... * sysdeps/powerpc/powerpc64/atomic-machine.h: ...here. Include instead of . * sysdeps/s390/bits/atomic.h: Move to ... * sysdeps/s390/atomic-machine.h: ...here. * sysdeps/sparc/sparc32/bits/atomic.h: Move to ... * sysdeps/sparc/sparc32/atomic-machine.h: ...here. (_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H. * sysdeps/sparc/sparc32/sparcv9/bits/atomic.h: Move to ... * sysdeps/sparc/sparc32/sparcv9/atomic-machine.h: ...here. * sysdeps/sparc/sparc64/bits/atomic.h: Move to ... * sysdeps/sparc/sparc64/atomic-machine.h: ...here. * sysdeps/tile/bits/atomic.h: Move to ... * sysdeps/tile/atomic-machine.h: ...here. * sysdeps/tile/tilegx/bits/atomic.h: Move to ... * sysdeps/tile/tilegx/atomic-machine.h: ...here. Include instead of . (_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H. * sysdeps/tile/tilepro/bits/atomic.h: Move to ... * sysdeps/tile/tilepro/atomic-machine.h: ...here. Include instead of . (_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H. * sysdeps/unix/sysv/linux/arm/bits/atomic.h: Move to ... * sysdeps/unix/sysv/linux/arm/atomic-machine.h: ...here. Include instead of . * sysdeps/unix/sysv/linux/hppa/bits/atomic.h: Move to ... * sysdeps/unix/sysv/linux/hppa/atomic-machine.h: ...here. (_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H. * sysdeps/unix/sysv/linux/m68k/coldfire/bits/atomic.h: Move to ... * sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h: ...here. (_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H. * sysdeps/unix/sysv/linux/nios2/bits/atomic.h: Move to ... * sysdeps/unix/sysv/linux/nios2/atomic-machine.h: ...here. (_NIOS2_BITS_ATOMIC_H): Rename macro to _NIOS2_ATOMIC_MACHINE_H. * sysdeps/unix/sysv/linux/sh/bits/atomic.h: Move to ... * sysdeps/unix/sysv/linux/sh/atomic-machine.h: ...here. * sysdeps/x86_64/bits/atomic.h: Move to ... * sysdeps/x86_64/atomic-machine.h: ...here. * include/atomic.h: Include instead of . --- sysdeps/m68k/coldfire/atomic-machine.h | 72 ++++++++ sysdeps/m68k/coldfire/bits/atomic.h | 72 -------- sysdeps/m68k/m680x0/m68020/atomic-machine.h | 256 ++++++++++++++++++++++++++++ sysdeps/m68k/m680x0/m68020/bits/atomic.h | 256 ---------------------------- 4 files changed, 328 insertions(+), 328 deletions(-) create mode 100644 sysdeps/m68k/coldfire/atomic-machine.h delete mode 100644 sysdeps/m68k/coldfire/bits/atomic.h create mode 100644 sysdeps/m68k/m680x0/m68020/atomic-machine.h delete mode 100644 sysdeps/m68k/m680x0/m68020/bits/atomic.h (limited to 'sysdeps/m68k') diff --git a/sysdeps/m68k/coldfire/atomic-machine.h b/sysdeps/m68k/coldfire/atomic-machine.h new file mode 100644 index 0000000..48899ce --- /dev/null +++ b/sysdeps/m68k/coldfire/atomic-machine.h @@ -0,0 +1,72 @@ +/* Copyright (C) 2003-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#ifndef _ATOMIC_MACHINE_H +#define _ATOMIC_MACHINE_H 1 + +#include + +/* Coldfire has no atomic compare-and-exchange operation, and the + kernel provides no userspace atomicity operations. Here we just + use generic non-atomic implementations instead. */ + +typedef int8_t atomic8_t; +typedef uint8_t uatomic8_t; +typedef int_fast8_t atomic_fast8_t; +typedef uint_fast8_t uatomic_fast8_t; + +typedef int16_t atomic16_t; +typedef uint16_t uatomic16_t; +typedef int_fast16_t atomic_fast16_t; +typedef uint_fast16_t uatomic_fast16_t; + +typedef int32_t atomic32_t; +typedef uint32_t uatomic32_t; +typedef int_fast32_t atomic_fast32_t; +typedef uint_fast32_t uatomic_fast32_t; + +typedef int64_t atomic64_t; +typedef uint64_t uatomic64_t; +typedef int_fast64_t atomic_fast64_t; +typedef uint_fast64_t uatomic_fast64_t; + +typedef intptr_t atomicptr_t; +typedef uintptr_t uatomicptr_t; +typedef intmax_t atomic_max_t; +typedef uintmax_t uatomic_max_t; + +/* If we have just non-atomic operations, we can as well make them wide. */ +#define __HAVE_64B_ATOMICS 1 +#define USE_ATOMIC_COMPILER_BUILTINS 0 + +/* The only basic operation needed is compare and exchange. */ +#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \ + ({ __typeof (mem) __gmemp = (mem); \ + __typeof (*mem) __gret = *__gmemp; \ + __typeof (*mem) __gnewval = (newval); \ + \ + if (__gret == (oldval)) \ + *__gmemp = __gnewval; \ + __gret; }) + +#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ + ({ __typeof (mem) __gmemp = (mem); \ + __typeof (*mem) __gnewval = (newval); \ + \ + *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; }) + +#endif diff --git a/sysdeps/m68k/coldfire/bits/atomic.h b/sysdeps/m68k/coldfire/bits/atomic.h deleted file mode 100644 index c09bf18..0000000 --- a/sysdeps/m68k/coldfire/bits/atomic.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2003-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#ifndef _BITS_ATOMIC_H -#define _BITS_ATOMIC_H 1 - -#include - -/* Coldfire has no atomic compare-and-exchange operation, and the - kernel provides no userspace atomicity operations. Here we just - use generic non-atomic implementations instead. */ - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - -/* If we have just non-atomic operations, we can as well make them wide. */ -#define __HAVE_64B_ATOMICS 1 -#define USE_ATOMIC_COMPILER_BUILTINS 0 - -/* The only basic operation needed is compare and exchange. */ -#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \ - ({ __typeof (mem) __gmemp = (mem); \ - __typeof (*mem) __gret = *__gmemp; \ - __typeof (*mem) __gnewval = (newval); \ - \ - if (__gret == (oldval)) \ - *__gmemp = __gnewval; \ - __gret; }) - -#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ - ({ __typeof (mem) __gmemp = (mem); \ - __typeof (*mem) __gnewval = (newval); \ - \ - *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; }) - -#endif diff --git a/sysdeps/m68k/m680x0/m68020/atomic-machine.h b/sysdeps/m68k/m680x0/m68020/atomic-machine.h new file mode 100644 index 0000000..9a29022 --- /dev/null +++ b/sysdeps/m68k/m680x0/m68020/atomic-machine.h @@ -0,0 +1,256 @@ +/* Copyright (C) 2003-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include + + +typedef int8_t atomic8_t; +typedef uint8_t uatomic8_t; +typedef int_fast8_t atomic_fast8_t; +typedef uint_fast8_t uatomic_fast8_t; + +typedef int16_t atomic16_t; +typedef uint16_t uatomic16_t; +typedef int_fast16_t atomic_fast16_t; +typedef uint_fast16_t uatomic_fast16_t; + +typedef int32_t atomic32_t; +typedef uint32_t uatomic32_t; +typedef int_fast32_t atomic_fast32_t; +typedef uint_fast32_t uatomic_fast32_t; + +typedef int64_t atomic64_t; +typedef uint64_t uatomic64_t; +typedef int_fast64_t atomic_fast64_t; +typedef uint_fast64_t uatomic_fast64_t; + +typedef intptr_t atomicptr_t; +typedef uintptr_t uatomicptr_t; +typedef intmax_t atomic_max_t; +typedef uintmax_t uatomic_max_t; + +#define __HAVE_64B_ATOMICS 1 +#define USE_ATOMIC_COMPILER_BUILTINS 0 + +#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \ + ({ __typeof (*(mem)) __ret; \ + __asm __volatile ("cas%.b %0,%2,%1" \ + : "=d" (__ret), "+m" (*(mem)) \ + : "d" (newval), "0" (oldval)); \ + __ret; }) + +#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \ + ({ __typeof (*(mem)) __ret; \ + __asm __volatile ("cas%.w %0,%2,%1" \ + : "=d" (__ret), "+m" (*(mem)) \ + : "d" (newval), "0" (oldval)); \ + __ret; }) + +#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \ + ({ __typeof (*(mem)) __ret; \ + __asm __volatile ("cas%.l %0,%2,%1" \ + : "=d" (__ret), "+m" (*(mem)) \ + : "d" (newval), "0" (oldval)); \ + __ret; }) + +# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \ + ({ __typeof (*(mem)) __ret; \ + __typeof (mem) __memp = (mem); \ + __asm __volatile ("cas2%.l %0:%R0,%1:%R1,(%2):(%3)" \ + : "=d" (__ret) \ + : "d" (newval), "r" (__memp), \ + "r" ((char *) __memp + 4), "0" (oldval) \ + : "memory"); \ + __ret; }) + +#define atomic_exchange_acq(mem, newvalue) \ + ({ __typeof (*(mem)) __result = *(mem); \ + if (sizeof (*(mem)) == 1) \ + __asm __volatile ("1: cas%.b %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)) \ + : "d" (newvalue), "0" (__result)); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("1: cas%.w %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)) \ + : "d" (newvalue), "0" (__result)); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("1: cas%.l %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)) \ + : "d" (newvalue), "0" (__result)); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __asm __volatile ("1: cas2%.l %0:%R0,%1:%R1,(%2):(%3);" \ + " jbne 1b" \ + : "=d" (__result) \ + : "d" (newvalue), "r" (__memp), \ + "r" ((char *) __memp + 4), "0" (__result) \ + : "memory"); \ + } \ + __result; }) + +#define atomic_exchange_and_add(mem, value) \ + ({ __typeof (*(mem)) __result = *(mem); \ + __typeof (*(mem)) __temp; \ + if (sizeof (*(mem)) == 1) \ + __asm __volatile ("1: move%.b %0,%2;" \ + " add%.b %3,%2;" \ + " cas%.b %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)), \ + "=&d" (__temp) \ + : "d" (value), "0" (__result)); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("1: move%.w %0,%2;" \ + " add%.w %3,%2;" \ + " cas%.w %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)), \ + "=&d" (__temp) \ + : "d" (value), "0" (__result)); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("1: move%.l %0,%2;" \ + " add%.l %3,%2;" \ + " cas%.l %0,%2,%1;" \ + " jbne 1b" \ + : "=d" (__result), "+m" (*(mem)), \ + "=&d" (__temp) \ + : "d" (value), "0" (__result)); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __asm __volatile ("1: move%.l %0,%1;" \ + " move%.l %R0,%R1;" \ + " add%.l %R2,%R1;" \ + " addx%.l %2,%1;" \ + " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \ + " jbne 1b" \ + : "=d" (__result), "=&d" (__temp) \ + : "d" (value), "r" (__memp), \ + "r" ((char *) __memp + 4), "0" (__result) \ + : "memory"); \ + } \ + __result; }) + +#define atomic_add(mem, value) \ + (void) ({ if (sizeof (*(mem)) == 1) \ + __asm __volatile ("add%.b %1,%0" \ + : "+m" (*(mem)) \ + : "id" (value)); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("add%.w %1,%0" \ + : "+m" (*(mem)) \ + : "id" (value)); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("add%.l %1,%0" \ + : "+m" (*(mem)) \ + : "id" (value)); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __oldval = *__memp; \ + __typeof (*(mem)) __temp; \ + __asm __volatile ("1: move%.l %0,%1;" \ + " move%.l %R0,%R1;" \ + " add%.l %R2,%R1;" \ + " addx%.l %2,%1;" \ + " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \ + " jbne 1b" \ + : "=d" (__oldval), "=&d" (__temp) \ + : "d" (value), "r" (__memp), \ + "r" ((char *) __memp + 4), "0" (__oldval) \ + : "memory"); \ + } \ + }) + +#define atomic_increment_and_test(mem) \ + ({ char __result; \ + if (sizeof (*(mem)) == 1) \ + __asm __volatile ("addq%.b %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("addq%.w %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("addq%.l %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __oldval = *__memp; \ + __typeof (*(mem)) __temp; \ + __asm __volatile ("1: move%.l %1,%2;" \ + " move%.l %R1,%R2;" \ + " addq%.l %#1,%R2;" \ + " addx%.l %5,%2;" \ + " seq %0;" \ + " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \ + " jbne 1b" \ + : "=&dm" (__result), "=d" (__oldval), \ + "=&d" (__temp) \ + : "r" (__memp), "r" ((char *) __memp + 4), \ + "d" (0), "1" (__oldval) \ + : "memory"); \ + } \ + __result; }) + +#define atomic_decrement_and_test(mem) \ + ({ char __result; \ + if (sizeof (*(mem)) == 1) \ + __asm __volatile ("subq%.b %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else if (sizeof (*(mem)) == 2) \ + __asm __volatile ("subq%.w %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else if (sizeof (*(mem)) == 4) \ + __asm __volatile ("subq%.l %#1,%1; seq %0" \ + : "=dm" (__result), "+m" (*(mem))); \ + else \ + { \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __oldval = *__memp; \ + __typeof (*(mem)) __temp; \ + __asm __volatile ("1: move%.l %1,%2;" \ + " move%.l %R1,%R2;" \ + " subq%.l %#1,%R2;" \ + " subx%.l %5,%2;" \ + " seq %0;" \ + " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \ + " jbne 1b" \ + : "=&dm" (__result), "=d" (__oldval), \ + "=&d" (__temp) \ + : "r" (__memp), "r" ((char *) __memp + 4), \ + "d" (0), "1" (__oldval) \ + : "memory"); \ + } \ + __result; }) + +#define atomic_bit_set(mem, bit) \ + __asm __volatile ("bfset %0{%1,#1}" \ + : "+m" (*(mem)) \ + : "di" (sizeof (*(mem)) * 8 - (bit) - 1)) + +#define atomic_bit_test_set(mem, bit) \ + ({ char __result; \ + __asm __volatile ("bfset %1{%2,#1}; sne %0" \ + : "=dm" (__result), "+m" (*(mem)) \ + : "di" (sizeof (*(mem)) * 8 - (bit) - 1)); \ + __result; }) diff --git a/sysdeps/m68k/m680x0/m68020/bits/atomic.h b/sysdeps/m68k/m680x0/m68020/bits/atomic.h deleted file mode 100644 index 9a29022..0000000 --- a/sysdeps/m68k/m680x0/m68020/bits/atomic.h +++ /dev/null @@ -1,256 +0,0 @@ -/* Copyright (C) 2003-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Andreas Schwab , 2003. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int16_t atomic16_t; -typedef uint16_t uatomic16_t; -typedef int_fast16_t atomic_fast16_t; -typedef uint_fast16_t uatomic_fast16_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef int64_t atomic64_t; -typedef uint64_t uatomic64_t; -typedef int_fast64_t atomic_fast64_t; -typedef uint_fast64_t uatomic_fast64_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - -#define __HAVE_64B_ATOMICS 1 -#define USE_ATOMIC_COMPILER_BUILTINS 0 - -#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \ - ({ __typeof (*(mem)) __ret; \ - __asm __volatile ("cas%.b %0,%2,%1" \ - : "=d" (__ret), "+m" (*(mem)) \ - : "d" (newval), "0" (oldval)); \ - __ret; }) - -#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \ - ({ __typeof (*(mem)) __ret; \ - __asm __volatile ("cas%.w %0,%2,%1" \ - : "=d" (__ret), "+m" (*(mem)) \ - : "d" (newval), "0" (oldval)); \ - __ret; }) - -#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \ - ({ __typeof (*(mem)) __ret; \ - __asm __volatile ("cas%.l %0,%2,%1" \ - : "=d" (__ret), "+m" (*(mem)) \ - : "d" (newval), "0" (oldval)); \ - __ret; }) - -# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \ - ({ __typeof (*(mem)) __ret; \ - __typeof (mem) __memp = (mem); \ - __asm __volatile ("cas2%.l %0:%R0,%1:%R1,(%2):(%3)" \ - : "=d" (__ret) \ - : "d" (newval), "r" (__memp), \ - "r" ((char *) __memp + 4), "0" (oldval) \ - : "memory"); \ - __ret; }) - -#define atomic_exchange_acq(mem, newvalue) \ - ({ __typeof (*(mem)) __result = *(mem); \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("1: cas%.b %0,%2,%1;" \ - " jbne 1b" \ - : "=d" (__result), "+m" (*(mem)) \ - : "d" (newvalue), "0" (__result)); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("1: cas%.w %0,%2,%1;" \ - " jbne 1b" \ - : "=d" (__result), "+m" (*(mem)) \ - : "d" (newvalue), "0" (__result)); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("1: cas%.l %0,%2,%1;" \ - " jbne 1b" \ - : "=d" (__result), "+m" (*(mem)) \ - : "d" (newvalue), "0" (__result)); \ - else \ - { \ - __typeof (mem) __memp = (mem); \ - __asm __volatile ("1: cas2%.l %0:%R0,%1:%R1,(%2):(%3);" \ - " jbne 1b" \ - : "=d" (__result) \ - : "d" (newvalue), "r" (__memp), \ - "r" ((char *) __memp + 4), "0" (__result) \ - : "memory"); \ - } \ - __result; }) - -#define atomic_exchange_and_add(mem, value) \ - ({ __typeof (*(mem)) __result = *(mem); \ - __typeof (*(mem)) __temp; \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("1: move%.b %0,%2;" \ - " add%.b %3,%2;" \ - " cas%.b %0,%2,%1;" \ - " jbne 1b" \ - : "=d" (__result), "+m" (*(mem)), \ - "=&d" (__temp) \ - : "d" (value), "0" (__result)); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("1: move%.w %0,%2;" \ - " add%.w %3,%2;" \ - " cas%.w %0,%2,%1;" \ - " jbne 1b" \ - : "=d" (__result), "+m" (*(mem)), \ - "=&d" (__temp) \ - : "d" (value), "0" (__result)); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("1: move%.l %0,%2;" \ - " add%.l %3,%2;" \ - " cas%.l %0,%2,%1;" \ - " jbne 1b" \ - : "=d" (__result), "+m" (*(mem)), \ - "=&d" (__temp) \ - : "d" (value), "0" (__result)); \ - else \ - { \ - __typeof (mem) __memp = (mem); \ - __asm __volatile ("1: move%.l %0,%1;" \ - " move%.l %R0,%R1;" \ - " add%.l %R2,%R1;" \ - " addx%.l %2,%1;" \ - " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \ - " jbne 1b" \ - : "=d" (__result), "=&d" (__temp) \ - : "d" (value), "r" (__memp), \ - "r" ((char *) __memp + 4), "0" (__result) \ - : "memory"); \ - } \ - __result; }) - -#define atomic_add(mem, value) \ - (void) ({ if (sizeof (*(mem)) == 1) \ - __asm __volatile ("add%.b %1,%0" \ - : "+m" (*(mem)) \ - : "id" (value)); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("add%.w %1,%0" \ - : "+m" (*(mem)) \ - : "id" (value)); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("add%.l %1,%0" \ - : "+m" (*(mem)) \ - : "id" (value)); \ - else \ - { \ - __typeof (mem) __memp = (mem); \ - __typeof (*(mem)) __oldval = *__memp; \ - __typeof (*(mem)) __temp; \ - __asm __volatile ("1: move%.l %0,%1;" \ - " move%.l %R0,%R1;" \ - " add%.l %R2,%R1;" \ - " addx%.l %2,%1;" \ - " cas2%.l %0:%R0,%1:%R1,(%3):(%4);" \ - " jbne 1b" \ - : "=d" (__oldval), "=&d" (__temp) \ - : "d" (value), "r" (__memp), \ - "r" ((char *) __memp + 4), "0" (__oldval) \ - : "memory"); \ - } \ - }) - -#define atomic_increment_and_test(mem) \ - ({ char __result; \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("addq%.b %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("addq%.w %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("addq%.l %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else \ - { \ - __typeof (mem) __memp = (mem); \ - __typeof (*(mem)) __oldval = *__memp; \ - __typeof (*(mem)) __temp; \ - __asm __volatile ("1: move%.l %1,%2;" \ - " move%.l %R1,%R2;" \ - " addq%.l %#1,%R2;" \ - " addx%.l %5,%2;" \ - " seq %0;" \ - " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \ - " jbne 1b" \ - : "=&dm" (__result), "=d" (__oldval), \ - "=&d" (__temp) \ - : "r" (__memp), "r" ((char *) __memp + 4), \ - "d" (0), "1" (__oldval) \ - : "memory"); \ - } \ - __result; }) - -#define atomic_decrement_and_test(mem) \ - ({ char __result; \ - if (sizeof (*(mem)) == 1) \ - __asm __volatile ("subq%.b %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else if (sizeof (*(mem)) == 2) \ - __asm __volatile ("subq%.w %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else if (sizeof (*(mem)) == 4) \ - __asm __volatile ("subq%.l %#1,%1; seq %0" \ - : "=dm" (__result), "+m" (*(mem))); \ - else \ - { \ - __typeof (mem) __memp = (mem); \ - __typeof (*(mem)) __oldval = *__memp; \ - __typeof (*(mem)) __temp; \ - __asm __volatile ("1: move%.l %1,%2;" \ - " move%.l %R1,%R2;" \ - " subq%.l %#1,%R2;" \ - " subx%.l %5,%2;" \ - " seq %0;" \ - " cas2%.l %1:%R1,%2:%R2,(%3):(%4);" \ - " jbne 1b" \ - : "=&dm" (__result), "=d" (__oldval), \ - "=&d" (__temp) \ - : "r" (__memp), "r" ((char *) __memp + 4), \ - "d" (0), "1" (__oldval) \ - : "memory"); \ - } \ - __result; }) - -#define atomic_bit_set(mem, bit) \ - __asm __volatile ("bfset %0{%1,#1}" \ - : "+m" (*(mem)) \ - : "di" (sizeof (*(mem)) * 8 - (bit) - 1)) - -#define atomic_bit_test_set(mem, bit) \ - ({ char __result; \ - __asm __volatile ("bfset %1{%2,#1}; sne %0" \ - : "=dm" (__result), "+m" (*(mem)) \ - : "di" (sizeof (*(mem)) * 8 - (bit) - 1)); \ - __result; }) -- cgit v1.1