diff options
Diffstat (limited to 'lib/libcompiler_rt')
-rw-r--r-- | lib/libcompiler_rt/Makefile | 43 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_add_4.c | 6 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_add_8.c | 6 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_and_4.c | 7 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_and_8.c | 7 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_op_n.h | 47 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_or_4.c | 7 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_or_8.c | 7 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_sub_4.c | 6 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_sub_8.c | 6 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_xor_4.c | 7 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_fetch_and_xor_8.c | 7 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_lock_test_and_set_4.c | 7 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_lock_test_and_set_8.c | 7 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_val_compare_and_swap_4.c | 6 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_val_compare_and_swap_8.c | 6 | ||||
-rw-r--r-- | lib/libcompiler_rt/__sync_val_compare_and_swap_n.h | 45 |
17 files changed, 14 insertions, 213 deletions
diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile index a9daada..8c560d7 100644 --- a/lib/libcompiler_rt/Makefile +++ b/lib/libcompiler_rt/Makefile @@ -28,6 +28,7 @@ SRCF= absvdi2 \ ashlti3 \ ashrdi3 \ ashrti3 \ + clear_cache \ clzdi2 \ clzsi2 \ clzti2 \ @@ -125,11 +126,6 @@ SRCF= absvdi2 \ umoddi3 \ umodti3 -# Don't build clear_cache on ARM with clang as it is a builtin there. -.if ${MACHINE_CPUARCH} != "arm" || ${COMPILER_TYPE} != "clang" -SRCF+= clear_cache -.endif - # These are already shipped by libc.a on arm and mips .if ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" SRCF+= adddf3 \ @@ -156,25 +152,16 @@ SRCF+= divsi3 \ umodsi3 .endif -# FreeBSD-specific atomic intrinsics. Clang provides them as a builtin. -.if (${MACHINE_CPUARCH} == "arm" && ${COMPILER_TYPE} != "clang") || \ - ${MACHINE_CPUARCH} == "mips" -SRCF+= __sync_fetch_and_add_4 \ - __sync_fetch_and_and_4 \ - __sync_fetch_and_or_4 \ - __sync_fetch_and_sub_4 \ - __sync_fetch_and_xor_4 \ - __sync_lock_test_and_set_4 \ - __sync_val_compare_and_swap_4 -.endif -.if ${MACHINE_ARCH:Mmips64*} != "" -SRCF+= __sync_fetch_and_add_8 \ - __sync_fetch_and_and_8 \ - __sync_fetch_and_or_8 \ - __sync_fetch_and_sub_8 \ - __sync_fetch_and_xor_8 \ - __sync_lock_test_and_set_8 \ - __sync_val_compare_and_swap_8 +# FreeBSD-specific atomic intrinsics. +.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "armv6" +.PATH: ${.CURDIR}/../../sys/arm/arm + +SRCF+= stdatomic +CFLAGS+= -DEMIT_SYNC_ATOMICS +.elif ${MACHINE_CPUARCH} == "mips" +.PATH: ${.CURDIR}/../../sys/mips/mips + +SRCF+= stdatomic .endif .for file in ${SRCF} @@ -196,13 +183,11 @@ SRCS+= aeabi_idivmod.S \ aeabi_uldivmod.S .endif -.if ${MACHINE_CPUARCH} != "mips" -. if ${MK_INSTALLLIB} != "no" +.if ${MK_INSTALLLIB} != "no" SYMLINKS+=libcompiler_rt.a ${LIBDIR}/libgcc.a -. endif -. if ${MK_PROFILE} != "no" +.endif +.if ${MK_PROFILE} != "no" SYMLINKS+=libcompiler_rt_p.a ${LIBDIR}/libgcc_p.a -. endif .endif .if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || \ diff --git a/lib/libcompiler_rt/__sync_fetch_and_add_4.c b/lib/libcompiler_rt/__sync_fetch_and_add_4.c deleted file mode 100644 index 3c11a3b..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_add_4.c +++ /dev/null @@ -1,6 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_add_4 -#define TYPE uint32_t -#define FETCHADD(x, y) atomic_fetchadd_32(x, y) - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_add_8.c b/lib/libcompiler_rt/__sync_fetch_and_add_8.c deleted file mode 100644 index 6157c15..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_add_8.c +++ /dev/null @@ -1,6 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_add_8 -#define TYPE uint64_t -#define FETCHADD(x, y) atomic_fetchadd_64(x, y) - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_and_4.c b/lib/libcompiler_rt/__sync_fetch_and_and_4.c deleted file mode 100644 index 1a488ec..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_and_4.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_and_4 -#define TYPE uint32_t -#define CMPSET atomic_cmpset_32 -#define EXPRESSION t & value - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_and_8.c b/lib/libcompiler_rt/__sync_fetch_and_and_8.c deleted file mode 100644 index 9923e31..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_and_8.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_and_8 -#define TYPE uint64_t -#define CMPSET atomic_cmpset_64 -#define EXPRESSION t & value - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_op_n.h b/lib/libcompiler_rt/__sync_fetch_and_op_n.h deleted file mode 100644 index f7f0e06..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_op_n.h +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <machine/atomic.h> - -TYPE -NAME(volatile TYPE *ptr, TYPE value) -{ - TYPE t; - -#ifdef FETCHADD - t = FETCHADD(ptr, value); -#else - do { - t = *ptr; - } while (!CMPSET(ptr, t, EXPRESSION)); -#endif - - return (t); -} diff --git a/lib/libcompiler_rt/__sync_fetch_and_or_4.c b/lib/libcompiler_rt/__sync_fetch_and_or_4.c deleted file mode 100644 index 1feeeb1..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_or_4.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_or_4 -#define TYPE uint32_t -#define CMPSET atomic_cmpset_32 -#define EXPRESSION t | value - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_or_8.c b/lib/libcompiler_rt/__sync_fetch_and_or_8.c deleted file mode 100644 index 7cb9403..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_or_8.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_or_8 -#define TYPE uint64_t -#define CMPSET atomic_cmpset_64 -#define EXPRESSION t | value - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_sub_4.c b/lib/libcompiler_rt/__sync_fetch_and_sub_4.c deleted file mode 100644 index a251add..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_sub_4.c +++ /dev/null @@ -1,6 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_sub_4 -#define TYPE uint32_t -#define FETCHADD(x, y) atomic_fetchadd_32(x, -(y)) - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_sub_8.c b/lib/libcompiler_rt/__sync_fetch_and_sub_8.c deleted file mode 100644 index 5a93f97..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_sub_8.c +++ /dev/null @@ -1,6 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_sub_8 -#define TYPE uint64_t -#define FETCHADD(x, y) atomic_fetchadd_64(x, -(y)) - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_xor_4.c b/lib/libcompiler_rt/__sync_fetch_and_xor_4.c deleted file mode 100644 index d5f732d..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_xor_4.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_xor_4 -#define TYPE uint32_t -#define CMPSET atomic_cmpset_32 -#define EXPRESSION t ^ value - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_fetch_and_xor_8.c b/lib/libcompiler_rt/__sync_fetch_and_xor_8.c deleted file mode 100644 index 610037e..0000000 --- a/lib/libcompiler_rt/__sync_fetch_and_xor_8.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_fetch_and_xor_8 -#define TYPE uint64_t -#define CMPSET atomic_cmpset_64 -#define EXPRESSION t ^ value - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_lock_test_and_set_4.c b/lib/libcompiler_rt/__sync_lock_test_and_set_4.c deleted file mode 100644 index d4965f9..0000000 --- a/lib/libcompiler_rt/__sync_lock_test_and_set_4.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_lock_test_and_set_4 -#define TYPE uint32_t -#define CMPSET atomic_cmpset_32 -#define EXPRESSION value - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_lock_test_and_set_8.c b/lib/libcompiler_rt/__sync_lock_test_and_set_8.c deleted file mode 100644 index 1e02203..0000000 --- a/lib/libcompiler_rt/__sync_lock_test_and_set_8.c +++ /dev/null @@ -1,7 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_lock_test_and_set_8 -#define TYPE uint64_t -#define CMPSET atomic_cmpset_64 -#define EXPRESSION value - -#include "__sync_fetch_and_op_n.h" diff --git a/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c b/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c deleted file mode 100644 index e0ab115..0000000 --- a/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c +++ /dev/null @@ -1,6 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_val_compare_and_swap_4 -#define TYPE uint32_t -#define CMPSET atomic_cmpset_32 - -#include "__sync_val_compare_and_swap_n.h" diff --git a/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c b/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c deleted file mode 100644 index c6f1101..0000000 --- a/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c +++ /dev/null @@ -1,6 +0,0 @@ -/* $FreeBSD$ */ -#define NAME __sync_val_compare_and_swap_8 -#define TYPE uint64_t -#define CMPSET atomic_cmpset_64 - -#include "__sync_val_compare_and_swap_n.h" diff --git a/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h b/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h deleted file mode 100644 index cd4c9a3..0000000 --- a/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/types.h> -#include <machine/atomic.h> - -TYPE -NAME(volatile TYPE *ptr, TYPE oldval, TYPE newval) -{ - TYPE t; - - while (!CMPSET(ptr, oldval, newval)) { - t = *ptr; - if (t != oldval) - return (t); - } - - return (oldval); -} |