diff options
author | 2020-04-04 22:11:36 +0000 | |
---|---|---|
committer | 2020-04-04 22:11:36 +0000 | |
commit | 004e15d6a27248383965a270534db07a47fde1ae (patch) | |
tree | 9ac0aece8a9ec29e30162dc06a7908457e1bc5eb /lib/libcompiler_rt | |
parent | Tweak the code that wakes up uvm_pmalloc sleepers in the page daemin. (diff) | |
download | wireguard-openbsd-004e15d6a27248383965a270534db07a47fde1ae.tar.xz wireguard-openbsd-004e15d6a27248383965a270534db07a47fde1ae.zip |
Implement __atomic_is_lock_free for powerpc. Needed because the
architecture doesn't implement 64-bit atomic operations. This
implementation is pessimistic and only flags naturally aligned
operations up to and including 32-bit as lock free.
tested by cwen@
ok gkoehler@
Diffstat (limited to 'lib/libcompiler_rt')
-rw-r--r-- | lib/libcompiler_rt/Makefile | 5 | ||||
-rw-r--r-- | lib/libcompiler_rt/ppc/atomic_lock_free.c | 22 |
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/libcompiler_rt/Makefile b/lib/libcompiler_rt/Makefile index 812bef29aea..6c92a870f20 100644 --- a/lib/libcompiler_rt/Makefile +++ b/lib/libcompiler_rt/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.14 2018/12/25 09:20:49 claudio Exp $ +# $OpenBSD: Makefile,v 1.15 2020/04/04 22:11:36 kettenis Exp $ .include <bsd.own.mk> @@ -275,7 +275,8 @@ SRCS+= comparetf2.c \ .endif .if ${RTARCH} == "ppc" -SRCS+= divtc3.c \ +SRCS+= atomic_lock_free.c \ + divtc3.c \ fixtfdi.c \ fixunstfdi.c \ floatditf.c \ diff --git a/lib/libcompiler_rt/ppc/atomic_lock_free.c b/lib/libcompiler_rt/ppc/atomic_lock_free.c new file mode 100644 index 00000000000..6a781a3069b --- /dev/null +++ b/lib/libcompiler_rt/ppc/atomic_lock_free.c @@ -0,0 +1,22 @@ +/* Public domain. */ + +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> + +#pragma redefine_extname __atomic_is_lock_free_c __atomic_is_lock_free + +bool +__atomic_is_lock_free_c(size_t size, void *ptr) +{ + switch (size) { + case 1: + return true; + case 2: + return (((uintptr_t)ptr & 1) == 0); + case 4: + return (((uintptr_t)ptr & 3) == 0); + } + + return false; +} |