From owner-svn-src-head@FreeBSD.ORG Sat Apr 27 04:56:06 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5C009F79; Sat, 27 Apr 2013 04:56:06 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3C6F91E1D; Sat, 27 Apr 2013 04:56:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3R4u6nJ016213; Sat, 27 Apr 2013 04:56:06 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3R4u2XN016191; Sat, 27 Apr 2013 04:56:02 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201304270456.r3R4u2XN016191@svn.freebsd.org> From: Ed Schouten Date: Sat, 27 Apr 2013 04:56:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249968 - head/lib/libcompiler_rt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Apr 2013 04:56:06 -0000 Author: ed Date: Sat Apr 27 04:56:02 2013 New Revision: 249968 URL: http://svnweb.freebsd.org/changeset/base/249968 Log: Unbreak on ARM + Clang. Clang only supports atomic operations for ARMv6. For non-ARMv6, we still need to emit these functions. Clang's prototype for these functions slightly differs, as it is truly based on GCC's documentation. It requires the use of signed types, but also requires varargs. Still, we are not allowed to simply implement this function directly. Cleverly work around this by implementing it under a different name and using __strong_reference(). Modified: head/lib/libcompiler_rt/Makefile head/lib/libcompiler_rt/__sync_fetch_and_add_4.c head/lib/libcompiler_rt/__sync_fetch_and_add_8.c head/lib/libcompiler_rt/__sync_fetch_and_and_4.c head/lib/libcompiler_rt/__sync_fetch_and_and_8.c head/lib/libcompiler_rt/__sync_fetch_and_op_n.h head/lib/libcompiler_rt/__sync_fetch_and_or_4.c head/lib/libcompiler_rt/__sync_fetch_and_or_8.c head/lib/libcompiler_rt/__sync_fetch_and_sub_4.c head/lib/libcompiler_rt/__sync_fetch_and_sub_8.c head/lib/libcompiler_rt/__sync_fetch_and_xor_4.c head/lib/libcompiler_rt/__sync_fetch_and_xor_8.c head/lib/libcompiler_rt/__sync_lock_test_and_set_4.c head/lib/libcompiler_rt/__sync_lock_test_and_set_8.c head/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c head/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c head/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h Modified: head/lib/libcompiler_rt/Makefile ============================================================================== --- head/lib/libcompiler_rt/Makefile Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/Makefile Sat Apr 27 04:56:02 2013 (r249968) @@ -156,9 +156,8 @@ SRCF+= divsi3 \ umodsi3 .endif -# FreeBSD-specific atomic intrinsics. Clang provides them as a builtin. -.if (${MACHINE_CPUARCH} == "arm" && ${COMPILER_TYPE} != "clang") || \ - ${MACHINE_CPUARCH} == "mips" +# FreeBSD-specific atomic intrinsics. +.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" SRCF+= __sync_fetch_and_add_4 \ __sync_fetch_and_and_4 \ __sync_fetch_and_or_4 \ Modified: head/lib/libcompiler_rt/__sync_fetch_and_add_4.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_add_4.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_add_4.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_add_4 -#define TYPE uint32_t +#define TYPE int32_t #define FETCHADD(x, y) atomic_fetchadd_32(x, y) #include "__sync_fetch_and_op_n.h" Modified: head/lib/libcompiler_rt/__sync_fetch_and_add_8.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_add_8.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_add_8.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_add_8 -#define TYPE uint64_t +#define TYPE int64_t #define FETCHADD(x, y) atomic_fetchadd_64(x, y) #include "__sync_fetch_and_op_n.h" Modified: head/lib/libcompiler_rt/__sync_fetch_and_and_4.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_and_4.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_and_4.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_and_4 -#define TYPE uint32_t +#define TYPE int32_t #define CMPSET atomic_cmpset_32 #define EXPRESSION t & value Modified: head/lib/libcompiler_rt/__sync_fetch_and_and_8.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_and_8.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_and_8.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_and_8 -#define TYPE uint64_t +#define TYPE int64_t #define CMPSET atomic_cmpset_64 #define EXPRESSION t & value Modified: head/lib/libcompiler_rt/__sync_fetch_and_op_n.h ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_op_n.h Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_op_n.h Sat Apr 27 04:56:02 2013 (r249968) @@ -30,8 +30,13 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined __clang__ +static TYPE +atomic_func(volatile TYPE *ptr, TYPE value, ...) +#else TYPE NAME(volatile TYPE *ptr, TYPE value) +#endif { TYPE t; @@ -45,3 +50,7 @@ NAME(volatile TYPE *ptr, TYPE value) return (t); } + +#ifdef __clang__ +__strong_reference(atomic_func, NAME); +#endif Modified: head/lib/libcompiler_rt/__sync_fetch_and_or_4.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_or_4.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_or_4.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_or_4 -#define TYPE uint32_t +#define TYPE int32_t #define CMPSET atomic_cmpset_32 #define EXPRESSION t | value Modified: head/lib/libcompiler_rt/__sync_fetch_and_or_8.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_or_8.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_or_8.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_or_8 -#define TYPE uint64_t +#define TYPE int64_t #define CMPSET atomic_cmpset_64 #define EXPRESSION t | value Modified: head/lib/libcompiler_rt/__sync_fetch_and_sub_4.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_sub_4.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_sub_4.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_sub_4 -#define TYPE uint32_t +#define TYPE int32_t #define FETCHADD(x, y) atomic_fetchadd_32(x, -(y)) #include "__sync_fetch_and_op_n.h" Modified: head/lib/libcompiler_rt/__sync_fetch_and_sub_8.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_sub_8.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_sub_8.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_sub_8 -#define TYPE uint64_t +#define TYPE int64_t #define FETCHADD(x, y) atomic_fetchadd_64(x, -(y)) #include "__sync_fetch_and_op_n.h" Modified: head/lib/libcompiler_rt/__sync_fetch_and_xor_4.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_xor_4.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_xor_4.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_xor_4 -#define TYPE uint32_t +#define TYPE int32_t #define CMPSET atomic_cmpset_32 #define EXPRESSION t ^ value Modified: head/lib/libcompiler_rt/__sync_fetch_and_xor_8.c ============================================================================== --- head/lib/libcompiler_rt/__sync_fetch_and_xor_8.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_fetch_and_xor_8.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_fetch_and_xor_8 -#define TYPE uint64_t +#define TYPE int64_t #define CMPSET atomic_cmpset_64 #define EXPRESSION t ^ value Modified: head/lib/libcompiler_rt/__sync_lock_test_and_set_4.c ============================================================================== --- head/lib/libcompiler_rt/__sync_lock_test_and_set_4.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_lock_test_and_set_4.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_lock_test_and_set_4 -#define TYPE uint32_t +#define TYPE int32_t #define CMPSET atomic_cmpset_32 #define EXPRESSION value Modified: head/lib/libcompiler_rt/__sync_lock_test_and_set_8.c ============================================================================== --- head/lib/libcompiler_rt/__sync_lock_test_and_set_8.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_lock_test_and_set_8.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_lock_test_and_set_8 -#define TYPE uint64_t +#define TYPE int64_t #define CMPSET atomic_cmpset_64 #define EXPRESSION value Modified: head/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c ============================================================================== --- head/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_val_compare_and_swap_4.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_val_compare_and_swap_4 -#define TYPE uint32_t +#define TYPE int32_t #define CMPSET atomic_cmpset_32 #include "__sync_val_compare_and_swap_n.h" Modified: head/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c ============================================================================== --- head/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_val_compare_and_swap_8.c Sat Apr 27 04:56:02 2013 (r249968) @@ -1,6 +1,6 @@ /* $FreeBSD$ */ #define NAME __sync_val_compare_and_swap_8 -#define TYPE uint64_t +#define TYPE int64_t #define CMPSET atomic_cmpset_64 #include "__sync_val_compare_and_swap_n.h" Modified: head/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h ============================================================================== --- head/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h Sat Apr 27 04:49:51 2013 (r249967) +++ head/lib/libcompiler_rt/__sync_val_compare_and_swap_n.h Sat Apr 27 04:56:02 2013 (r249968) @@ -30,8 +30,13 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined __clang__ +static TYPE +atomic_func(volatile TYPE *ptr, TYPE oldval, TYPE newval, ...) +#else TYPE NAME(volatile TYPE *ptr, TYPE oldval, TYPE newval) +#endif { TYPE t; @@ -43,3 +48,7 @@ NAME(volatile TYPE *ptr, TYPE oldval, TY return (oldval); } + +#ifdef __clang__ +__strong_reference(atomic_func, NAME); +#endif