From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Zijlstra Subject: [PATCH v3 19/22] compiler: Simple READ/WRITE_ONCE() implementations Date: Wed, 19 Feb 2020 15:47:43 +0100 Message-ID: <20200219150745.474563308@infradead.org> References: <20200219144724.800607165@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from merlin.infradead.org ([205.233.59.134]:52038 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbgBSPOh (ORCPT ); Wed, 19 Feb 2020 10:14:37 -0500 Sender: linux-arch-owner@vger.kernel.org List-ID: To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, rostedt@goodmis.org Cc: peterz@infradead.org, mingo@kernel.org, joel@joelfernandes.org, gregkh@linuxfoundation.org, gustavo@embeddedor.com, tglx@linutronix.de, paulmck@kernel.org, josh@joshtriplett.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, luto@kernel.org, tony.luck@intel.com, frederic@kernel.org, dan.carpenter@oracle.com, mhiramat@kernel.org 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) --- 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__ */ /*