From: aoyama Date: Wed, 22 Aug 2018 11:25:58 +0000 (+0000) Subject: Adding membar_xxx defines to userland. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fc343cf934d04b41f9abaa99e672a3beee955880;p=openbsd Adding membar_xxx defines to userland. The src/lib/libc/thread/rthread.c 1.8 change adds #include in userland code. Current m88k atomic.h contents are inside of #if defined(_KERNEL) guard, then, nothing is defined for userland program. So we need adding some defines to compile it on m88k. The original diff is suggested from Miod Vallat, modified by the advice from mpi@ and kettenis@. ok kettenis@ --- diff --git a/sys/arch/m88k/include/atomic.h b/sys/arch/m88k/include/atomic.h index cafbada29b2..6ce3c0902d5 100644 --- a/sys/arch/m88k/include/atomic.h +++ b/sys/arch/m88k/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.13 2015/07/03 12:47:30 miod Exp $ */ +/* $OpenBSD: atomic.h,v 1.14 2018/08/22 11:25:58 aoyama Exp $ */ /* Public Domain */ @@ -151,5 +151,53 @@ __sync_synchronize(void) __asm__ volatile ("tb1 0, %%r0, 0" ::: "memory"); } +#else /* _KERNEL */ + +#if !defined(__GNUC__) || (__GNUC__ < 4) + +/* + * Atomic routines are not available to userland, but we need to prevent + * from declaring them as inline wrappers of __sync_* functions, + * which are not available with gcc 3. + */ + +#define atomic_cas_uint UNIMPLEMENTED +#define atomic_cas_ulong UNIMPLEMENTED +#define atomic_cas_ptr UNIMPLEMENTED + +#define atomic_swap_uint UNIMPLEMENTED +#define atomic_swap_ulong UNIMPLEMENTED +#define atomic_swap_ptr UNIMPLEMENTED + +#define atomic_add_int_nv UNIMPLEMENTED +#define atomic_add_long_nv UNIMPLEMENTED +#define atomic_add_int UNIMPLEMENTED +#define atomic_add_long UNIMPLEMENTED + +#define atomic_inc_int UNIMPLEMENTED +#define atomic_inc_long UNIMPLEMENTED + +#define atomic_sub_int_nv UNIMPLEMENTED +#define atomic_sub_long_nv UNIMPLEMENTED +#define atomic_sub_int UNIMPLEMENTED +#define atomic_sub_long UNIMPLEMENTED + +#define atomic_dec_int UNIMPLEMENTED +#define atomic_dec_long UNIMPLEMENTED + +/* trap numbers below 128 would cause a privileged instruction fault */ +#define __membar() do { \ + __asm __volatile("tb1 0, %%r0, 128" ::: "memory"); \ +} while (0) + +#endif /* gcc < 4 */ + +#define membar_enter() __membar() +#define membar_exit() __membar() +#define membar_producer() __membar() +#define membar_consumer() __membar() +#define membar_sync() __membar() + #endif /* defined(_KERNEL) */ + #endif /* _M88K_ATOMIC_H_ */