Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Dec 2015 10:56:38 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r292537 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201512211056.tBLAucMt014267@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Dec 21 10:56:38 2015
New Revision: 292537
URL: https://svnweb.freebsd.org/changeset/base/292537

Log:
  Implement ACCESS_ONCE(), WRITE_ONCE() and READ_ONCE().
  
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/compiler.h

Modified: head/sys/compat/linuxkpi/common/include/linux/compiler.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/compiler.h	Mon Dec 21 09:38:45 2015	(r292536)
+++ head/sys/compat/linuxkpi/common/include/linux/compiler.h	Mon Dec 21 10:56:38 2015	(r292537)
@@ -72,4 +72,20 @@
 
 #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();			\
+	__var = ACCESS_ONCE(x);		\
+	barrier();			\
+	__var;				\
+})
+  
 #endif	/* _LINUX_COMPILER_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512211056.tBLAucMt014267>