From b6a8cdec0644848be2c33a0b98958bac4cee0f95 Mon Sep 17 00:00:00 2001 From: dlg Date: Fri, 18 Jul 2014 10:40:14 +0000 Subject: [PATCH] pass atomic_{cas,swap}_uint a volatile void * instead of a volatile void **. the latter is really hard to cast for, and not what what solaris does. ok kettenis@ --- share/man/man9/atomic_cas_uint.9 | 6 +++--- share/man/man9/atomic_swap_uint.9 | 6 +++--- sys/arch/amd64/include/atomic.h | 8 ++++---- sys/arch/m88k/include/atomic.h | 6 +++--- sys/arch/sparc64/include/atomic.h | 8 ++++---- sys/arch/vax/include/atomic.h | 16 ++++++++-------- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/share/man/man9/atomic_cas_uint.9 b/share/man/man9/atomic_cas_uint.9 index a8e5370486a..a4840fb0443 100644 --- a/share/man/man9/atomic_cas_uint.9 +++ b/share/man/man9/atomic_cas_uint.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: atomic_cas_uint.9,v 1.5 2014/02/13 12:03:47 dlg Exp $ +.\" $OpenBSD: atomic_cas_uint.9,v 1.6 2014/07/18 10:40:14 dlg Exp $ .\" .\" Copyright (c) 2014 David Gwynne .\" All rights reserved. @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 13 2014 $ +.Dd $Mdocdate: July 18 2014 $ .Dt ATOMIC_CAS_UINT 9 .Os .Sh NAME @@ -30,7 +30,7 @@ .Ft unsigned long .Fn atomic_cas_ulong "volatile unsigned long *p" "unsigned long expected" "unsigned long new" .Ft void * -.Fn atomic_cas_ptr "volatile void **p" "void *expected" "void *new" +.Fn atomic_cas_ptr "volatile void *p" "void *expected" "void *new" .Sh DESCRIPTION The atomic_cas set of functions provide an interface for atomically performing compare-and-swap operations with respect to interrupts diff --git a/share/man/man9/atomic_swap_uint.9 b/share/man/man9/atomic_swap_uint.9 index c60dfbc302f..64c6b9e60f8 100644 --- a/share/man/man9/atomic_swap_uint.9 +++ b/share/man/man9/atomic_swap_uint.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: atomic_swap_uint.9,v 1.5 2014/02/13 12:03:47 dlg Exp $ +.\" $OpenBSD: atomic_swap_uint.9,v 1.6 2014/07/18 10:40:14 dlg Exp $ .\" .\" Copyright (c) 2014 David Gwynne .\" All rights reserved. @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 13 2014 $ +.Dd $Mdocdate: July 18 2014 $ .Dt ATOMIC_SWAP_UINT 9 .Os .Sh NAME @@ -30,7 +30,7 @@ .Ft unsigned long .Fn atomic_swap_ulong "volatile unsigned long *p" "unsigned long new" .Ft void * -.Fn atomic_swap_ptr "volatile void **p" "void *new" +.Fn atomic_swap_ptr "volatile void *p" "void *new" .Sh DESCRIPTION The atomic_swap set of functions provide an interface for atomically performing swap operations with respect to interrupts and multiple diff --git a/sys/arch/amd64/include/atomic.h b/sys/arch/amd64/include/atomic.h index d25ec726796..e371c438d32 100644 --- a/sys/arch/amd64/include/atomic.h +++ b/sys/arch/amd64/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.12 2014/03/29 18:09:28 guenther Exp $ */ +/* $OpenBSD: atomic.h,v 1.13 2014/07/18 10:40:14 dlg Exp $ */ /* $NetBSD: atomic.h,v 1.1 2003/04/26 18:39:37 fvdl Exp $ */ /* @@ -80,11 +80,11 @@ _atomic_cas_ulong(volatile unsigned long *p, unsigned long e, unsigned long n) #define atomic_cas_ulong(_p, _e, _n) _atomic_cas_ulong((_p), (_e), (_n)) static inline void * -_atomic_cas_ptr(volatile void **p, void *e, void *n) +_atomic_cas_ptr(volatile void *p, void *e, void *n) { __asm volatile(LOCK " cmpxchgq %2, %1" - : "=a" (n), "=m" (*p) - : "r" (n), "a" (e), "m" (*p) + : "=a" (n), "=m" (*(unsigned long *)p) + : "r" (n), "a" (e), "m" (*(unsigned long *)p) : "memory"); return (n); diff --git a/sys/arch/m88k/include/atomic.h b/sys/arch/m88k/include/atomic.h index 73e89a532fc..7a0f8d34c88 100644 --- a/sys/arch/m88k/include/atomic.h +++ b/sys/arch/m88k/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.11 2014/07/13 08:13:07 miod Exp $ */ +/* $OpenBSD: atomic.h,v 1.12 2014/07/18 10:40:14 dlg Exp $ */ /* Public Domain */ @@ -137,12 +137,12 @@ atomic_clear_int(volatile unsigned int *uip) ((unsigned long)atomic_cas_uint((unsigned int *)p, (unsigned int)o, \ (unsigned int)n)) #define atomic_cas_ptr(p,o,n) \ - ((void *)atomic_cas_uint((void **)p, (void *)o, (void *)n)) + ((void *)atomic_cas_uint((void *)p, (void *)o, (void *)n)) #define atomic_swap_ulong(p,o) \ ((unsigned long)atomic_swap_uint((unsigned int *)p, (unsigned int)o) #define atomic_swap_ptr(p,o) \ - ((void *)atomic_swap_uint((void **)p, (void *)o)) + ((void *)atomic_swap_uint((void *)p, (void *)o)) static inline void __sync_synchronize(void) diff --git a/sys/arch/sparc64/include/atomic.h b/sys/arch/sparc64/include/atomic.h index 29d05829631..bcf412ee6b3 100644 --- a/sys/arch/sparc64/include/atomic.h +++ b/sys/arch/sparc64/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.11 2014/03/29 18:09:30 guenther Exp $ */ +/* $OpenBSD: atomic.h,v 1.12 2014/07/18 10:40:14 dlg Exp $ */ /* * Copyright (c) 2007 Artur Grabowski * @@ -43,11 +43,11 @@ _atomic_cas_ulong(volatile unsigned long *p, unsigned long e, unsigned long n) #define atomic_cas_ulong(_p, _e, _n) _atomic_cas_ulong((_p), (_e), (_n)) static inline void * -_atomic_cas_ptr(volatile void **p, void *e, void *n) +_atomic_cas_ptr(volatile void *p, void *e, void *n) { __asm volatile("casx [%2], %3, %0" - : "+r" (n), "=m" (*p) - : "r" (p), "r" (e), "m" (*p)); + : "+r" (n), "=m" (*(volatile unsigned long *)p) + : "r" (p), "r" (e), "m" (*(volatile unsigned long *)p)); return (n); } diff --git a/sys/arch/vax/include/atomic.h b/sys/arch/vax/include/atomic.h index 701c31d2aac..6a35b0f8146 100644 --- a/sys/arch/vax/include/atomic.h +++ b/sys/arch/vax/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.7 2014/07/12 09:47:05 miod Exp $ */ +/* $OpenBSD: atomic.h,v 1.8 2014/07/18 10:40:14 dlg Exp $ */ /* Public Domain */ @@ -93,20 +93,20 @@ atomic_swap_uint_sp(unsigned int *p, unsigned int v) #define atomic_swap_uint atomic_swap_uint_sp #define atomic_add_long_nv(p,v) \ - ((unsigned long)atomic_add_int_nv((unsigned int *)p, (unsigned int)v)) + ((unsigned long)atomic_add_int_nv((unsigned long *)p, (unsigned long)v)) #define atomic_sub_long_nv(p,v) \ - ((unsigned long)atomic_sub_int_nv((unsigned int *)p, (unsigned int)v)) + ((unsigned long)atomic_sub_int_nv((unsigned long *)p, (unsigned long)v)) #define atomic_cas_ulong(p,o,n) \ - ((unsigned long)atomic_cas_uint((unsigned int *)p, (unsigned int)o, \ - (unsigned int)n)) + ((unsigned long)atomic_cas_uint((unsigned long *)p, (unsigned long)o, \ + (unsigned long)n)) #define atomic_cas_ptr(p,o,n) \ - ((void *)atomic_cas_uint((void **)p, (void *)o, (void *)n)) + ((void *)atomic_cas_uint((void *)p, (void *)o, (void *)n)) #define atomic_swap_ulong(p,o) \ - ((unsigned long)atomic_swap_uint((unsigned int *)p, (unsigned int)o) + ((unsigned long)atomic_swap_uint((unsigned long *)p, (unsigned long)o) #define atomic_swap_ptr(p,o) \ - ((void *)atomic_swap_uint((void **)p, (void *)o)) + ((void *)atomic_swap_uint((void *)p, (void *)o)) static inline void __sync_synchronize(void) -- 2.20.1