diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-12 09:47:06 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-12 09:47:06 +0000 |
commit | 1e938daad5b062afa6ea5b0819f344265737e910 (patch) | |
tree | 5d59376a7129a9bec100ce2c80bf18c62f336994 /sys/arch/vax | |
parent | 0a59b23ff03ff9720643b502ab5d926401fa1446 (diff) |
Pull in more atomic functions to avoid <sys/atomic.h> trying to use gcc4
built-ins which aren't available on vax. (A similar diff for m88k is in the
pipeline as well)
Diffstat (limited to 'sys/arch/vax')
-rw-r--r-- | sys/arch/vax/include/atomic.h | 92 |
1 files changed, 88 insertions, 4 deletions
diff --git a/sys/arch/vax/include/atomic.h b/sys/arch/vax/include/atomic.h index 4b7f1a9288d..701c31d2aac 100644 --- a/sys/arch/vax/include/atomic.h +++ b/sys/arch/vax/include/atomic.h @@ -1,9 +1,9 @@ -/* $OpenBSD: atomic.h,v 1.6 2014/03/29 18:09:30 guenther Exp $ */ +/* $OpenBSD: atomic.h,v 1.7 2014/07/12 09:47:05 miod Exp $ */ /* Public Domain */ -#ifndef _MACHINE_ATOMIC_H_ -#define _MACHINE_ATOMIC_H_ +#ifndef _VAX_ATOMIC_H_ +#define _VAX_ATOMIC_H_ #if defined(_KERNEL) @@ -30,5 +30,89 @@ atomic_clearbits_int(volatile unsigned int *uip, unsigned int v) splx(s); } +static __inline unsigned int +atomic_add_int_nv_sp(volatile unsigned int *uip, unsigned int v) +{ + int s; + unsigned int nv; + + s = splhigh(); + *uip += v; + nv = *uip; + splx(s); + + return nv; +} + +static __inline unsigned int +atomic_sub_int_nv_sp(volatile unsigned int *uip, unsigned int v) +{ + int s; + unsigned int nv; + + s = splhigh(); + *uip -= v; + nv = *uip; + splx(s); + + return nv; +} + +static inline unsigned int +atomic_cas_uint_sp(unsigned int *p, unsigned int o, unsigned int n) +{ + int s; + unsigned int ov; + + s = splhigh(); + ov = *p; + if (ov == o) + *p = n; + splx(s); + + return ov; +} + +static inline unsigned int +atomic_swap_uint_sp(unsigned int *p, unsigned int v) +{ + int s; + unsigned int ov; + + s = splhigh(); + ov = *p; + *p = v; + splx(s); + + return ov; +} + +#define atomic_add_int_nv atomic_add_int_nv_sp +#define atomic_sub_int_nv atomic_sub_int_nv_sp +#define atomic_cas_uint atomic_cas_uint_sp +#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)) +#define atomic_sub_long_nv(p,v) \ + ((unsigned long)atomic_sub_int_nv((unsigned int *)p, (unsigned int)v)) + +#define atomic_cas_ulong(p,o,n) \ + ((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)) + +#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)) + +static inline void +__sync_synchronize(void) +{ + __asm__ volatile ("" ::: "memory"); +} + #endif /* defined(_KERNEL) */ -#endif /* _MACHINE_ATOMIC_H_ */ +#endif /* _VAX_ATOMIC_H_ */ |