1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-24 22:26:03 +00:00

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@
This commit is contained in:
kettenis
2020-04-04 22:11:36 +00:00
parent 4ed81bdbc7
commit 004e15d6a2
2 changed files with 25 additions and 2 deletions

View File

@@ -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 \

View File

@@ -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;
}