My code is simple as below.I found rmb and wmb for read and write,but found no general one.lwsync is available on PowerPC,but what is the replacement for x86?Thanks in advance.
#define barrier() __asm__ volatile ("lwsync")
...
lock()
if(!pInst);
{
T* temp=new T;
barrier();
pInst=temp;
}
unlock();
rmb()
and wmb() are the Linux kernel functions. There is also mb()
.
The x86 instructions are lfence
, sfence
, and mfence
, IIRC.