aboutsummaryrefslogtreecommitdiffstats
path: root/src/support.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/support.h')
-rw-r--r--src/support.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/support.h b/src/support.h
index 5256e62..99cd518 100644
--- a/src/support.h
+++ b/src/support.h
@@ -82,4 +82,25 @@ sogetsockaddr(struct socket *so, struct sockaddr **nam)
return (error);
}
+/* These are defined in sys/compat/linuxkpi/common/include/linux/compiler.h,
+ * however I don't really want to include all that. */
+#define barrier() __asm__ __volatile__("": : :"memory")
+
+#define ACCESS_ONCE(x) (*(volatile __typeof(x) *)&(x))
+
+#define WRITE_ONCE(x,v) do { \
+ barrier(); \
+ ACCESS_ONCE(x) = (v); \
+ barrier(); \
+} while (0)
+
+#define READ_ONCE(x) ({ \
+ __typeof(x) __var = ({ \
+ barrier(); \
+ ACCESS_ONCE(x); \
+ }); \
+ barrier(); \
+ __var; \
+})
+
#endif