Implement ACCESS_ONCE(), WRITE_ONCE() and READ_ONCE().

MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2015-12-21 10:56:38 +00:00
parent 5a95a154ec
commit cee21041cf

View File

@ -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_ */