summaryrefslogtreecommitdiff
path: root/sys/arch/m88k
diff options
context:
space:
mode:
authorKenji Aoyama <aoyama@cvs.openbsd.org>2018-08-22 11:25:59 +0000
committerKenji Aoyama <aoyama@cvs.openbsd.org>2018-08-22 11:25:59 +0000
commit79c8afe488b572b9709e3f483f0281ed23a88a7d (patch)
treef5c559fc85c31052a5864287820409132bdb3cac /sys/arch/m88k
parentaf8c550b52963e151df1503f5a70e1e0d2b23d32 (diff)
Adding membar_xxx defines to userland.
The src/lib/libc/thread/rthread.c 1.8 change adds #include <sys/atomic.h> 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@
Diffstat (limited to 'sys/arch/m88k')
-rw-r--r--sys/arch/m88k/include/atomic.h50
1 files changed, 49 insertions, 1 deletions
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
+ * <sys/atomic.h> 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_ */