Provide _atomic_cas_{16,8}_up

This commit is contained in:
martin 2014-01-29 13:06:36 +00:00
parent 69d52dbe21
commit 0c99b2643b
2 changed files with 28 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.15 2012/11/28 21:39:59 martin Exp $
# $NetBSD: Makefile.inc,v 1.16 2014/01/29 13:06:36 martin Exp $
.include <bsd.own.mk>
@ -29,7 +29,8 @@ SRCS+= atomic_cas.S
. endif
. if (${LIB} == "c" || ${LIB} == "pthread")
CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP
CPPFLAGS+= -D__HAVE_ASM_ATOMIC_CAS_UP -D__HAVE_ASM_ATOMIC_CAS_16_UP \
-D__HAVE_ASM_ATOMIC_CAS_8_UP
SRCS+= atomic_init_testset.c atomic_cas_up.S
. endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: atomic_cas_up.S,v 1.1 2012/11/28 21:39:59 martin Exp $ */
/* $NetBSD: atomic_cas_up.S,v 1.2 2014/01/29 13:06:36 martin Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -43,3 +43,27 @@ RAS_END_ASM_HIDDEN(_atomic_cas)
retl
mov %o3, %o0 ! return old value
ENTRY(_atomic_cas_16_up)
.hidden _C_LABEL(_atomic_cas_16_up)
RAS_START_ASM_HIDDEN(_atomic_cas_16)
lduh [%o0], %o3 ! get old value
cmp %o1, %o3 ! old == new?
beq,a 1f ! yes, do the store
sth %o2, [%o0] ! (in the delay slot)
RAS_END_ASM_HIDDEN(_atomic_cas_16)
1:
retl
mov %o3, %o0 ! return old value
ENTRY(_atomic_cas_8_up)
.hidden _C_LABEL(_atomic_cas_8_up)
RAS_START_ASM_HIDDEN(_atomic_cas_8)
ldub [%o0], %o3 ! get old value
cmp %o1, %o3 ! old == new?
beq,a 1f ! yes, do the store
stb %o2, [%o0] ! (in the delay slot)
RAS_END_ASM_HIDDEN(_atomic_cas_8)
1:
retl
mov %o3, %o0 ! return old value