Implement ACCESS_ONCE(), WRITE_ONCE() and READ_ONCE().
MFC after: 1 week Sponsored by: Mellanox Technologies
This commit is contained in:
parent
5a95a154ec
commit
cee21041cf
@ -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_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user