Let ARM use the custom tailored atomic intrinsics.

This commit is contained in:
Ed Schouten 2013-06-15 09:04:10 +00:00
parent eaa3b76d1a
commit 2d5add2ae6
11 changed files with 3 additions and 211 deletions

View File

@ -158,14 +158,9 @@ SRCF+= divsi3 \
# FreeBSD-specific atomic intrinsics.
.if ${MACHINE_CPUARCH} == "arm"
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_synchronize \
__sync_val_compare_and_swap_4
.PATH: ${.CURDIR}/../../sys/arm/arm
SRCF+= stdatomic
.elif ${MACHINE_CPUARCH} == "mips"
.PATH: ${.CURDIR}/../../sys/mips/mips

View File

@ -1,6 +0,0 @@
/* $FreeBSD$ */
#define NAME __sync_fetch_and_add_4
#define TYPE int32_t
#define FETCHADD(x, y) atomic_fetchadd_32(x, y)
#include "__sync_fetch_and_op_n.h"

View File

@ -1,7 +0,0 @@
/* $FreeBSD$ */
#define NAME __sync_fetch_and_and_4
#define TYPE int32_t
#define CMPSET atomic_cmpset_32
#define EXPRESSION t & value
#include "__sync_fetch_and_op_n.h"

View File

@ -1,56 +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>
#ifdef __clang__
static TYPE
atomic_func(volatile TYPE *ptr, TYPE value, ...)
#else
TYPE
NAME(volatile TYPE *ptr, TYPE value)
#endif
{
TYPE t;
#ifdef FETCHADD
t = FETCHADD(ptr, value);
#else
do {
t = *ptr;
} while (!CMPSET(ptr, t, EXPRESSION));
#endif
return (t);
}
#ifdef __clang__
__strong_reference(atomic_func, NAME);
#endif

View File

@ -1,7 +0,0 @@
/* $FreeBSD$ */
#define NAME __sync_fetch_and_or_4
#define TYPE int32_t
#define CMPSET atomic_cmpset_32
#define EXPRESSION t | value
#include "__sync_fetch_and_op_n.h"

View File

@ -1,6 +0,0 @@
/* $FreeBSD$ */
#define NAME __sync_fetch_and_sub_4
#define TYPE int32_t
#define FETCHADD(x, y) atomic_fetchadd_32(x, -(y))
#include "__sync_fetch_and_op_n.h"

View File

@ -1,7 +0,0 @@
/* $FreeBSD$ */
#define NAME __sync_fetch_and_xor_4
#define TYPE int32_t
#define CMPSET atomic_cmpset_32
#define EXPRESSION t ^ value
#include "__sync_fetch_and_op_n.h"

View File

@ -1,7 +0,0 @@
/* $FreeBSD$ */
#define NAME __sync_lock_test_and_set_4
#define TYPE int32_t
#define CMPSET atomic_cmpset_32
#define EXPRESSION value
#include "__sync_fetch_and_op_n.h"

View File

@ -1,47 +0,0 @@
/*-
* Copyright (c) 2013 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>
#ifdef __clang__
static void
atomic_func(void)
#else
void
__sync_synchronize(void)
#endif
{
mb();
}
#ifdef __clang__
__strong_reference(atomic_func, __sync_synchronize);
#endif

View File

@ -1,6 +0,0 @@
/* $FreeBSD$ */
#define NAME __sync_val_compare_and_swap_4
#define TYPE int32_t
#define CMPSET atomic_cmpset_32
#include "__sync_val_compare_and_swap_n.h"

View File

@ -1,54 +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>
#ifdef __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;
while (!CMPSET(ptr, oldval, newval)) {
t = *ptr;
if (t != oldval)
return (t);
}
return (oldval);
}
#ifdef __clang__
__strong_reference(atomic_func, NAME);
#endif