lkml.org 
[lkml]   [2020]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH v4 22/27] compiler: Simple READ/WRITE_ONCE() implementations
Because I need WRITE_ONCE_NOCHECK() and in anticipation of Will's
READ_ONCE rewrite, provide __{READ,WRITE}_ONCE_SCALAR().

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/compiler.h | 8 ++++++++
1 file changed, 8 insertions(+)

--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -289,6 +289,14 @@ unsigned long read_word_at_a_time(const
__u.__val; \
})

+#define __READ_ONCE_SCALAR(x) \
+ (*(const volatile typeof(x) *)&(x))
+
+#define __WRITE_ONCE_SCALAR(x, val) \
+do { \
+ *(volatile typeof(x) *)&(x) = val; \
+} while (0)
+
#endif /* __KERNEL__ */

/*

\
 
 \ /
  Last update: 2020-02-21 14:51    [W:3.287 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site