compiler.h: add READ_ONCE/WRITE_ONCE macro

These macros are needed to make sure the compiler does not optimize away
atomic constructs such as "while (!READ_ONCE(foo))" loops that do not
modify foo within the loop

Also move the barrier() define where it belongs while we are here, it is
needed for READ_ONCE/WRITE_ONCE and including ihk/cpu.h here causes
include loops

Change-Id: Ia533a849ed674719ccbc0495be47d22a3c47b8f8
This commit is contained in:
Dominique Martinet
2018-09-21 12:30:52 +09:00
committed by Masamichi Takagi
parent 13e71ac9dc
commit 3e3ccf377c
6 changed files with 65 additions and 13 deletions

View File

@ -6,6 +6,7 @@
#include <ihk/cpu.h>
#include <ihk/atomic.h>
#include <lwk/compiler.h>
//#define DEBUG_SPINLOCK
//#define DEBUG_MCS_RWLOCK