summaryrefslogtreecommitdiff
path: root/kern/macros.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-03-15 21:43:41 +0100
committerRichard Braun <rbraun@sceen.net>2017-03-15 21:56:42 +0100
commit196eae0d9ee0d2d8ca42e96e49d6988313d39f6d (patch)
tree81d20378edede1e02d8f8f578331848715667877 /kern/macros.h
parent0f8c14517212dfd03c5cafcab56ffc7dead18209 (diff)
kern/syscnt: replace the evcnt module
The syscnt module supports more generic counters, in addition to atomic access from any context on any architecture.
Diffstat (limited to 'kern/macros.h')
-rw-r--r--kern/macros.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/kern/macros.h b/kern/macros.h
index a5b7b032..f3eb1075 100644
--- a/kern/macros.h
+++ b/kern/macros.h
@@ -55,6 +55,9 @@
#define structof(ptr, type, member) \
((type *)((char *)(ptr) - offsetof(type, member)))
+#define read_once(x) (*(volatile typeof(x) *)&(x))
+#define write_once(x, v) (read_once(x) = (v))
+
#define alignof(x) __alignof__(x)
#define likely(expr) __builtin_expect(!!(expr), 1)