Is there a compiler memory barrier for a single variable?

后端 未结 4 1619
长情又很酷
长情又很酷 2021-01-02 08:45

Compiler memory barriers has the effect among other things to force the compiler to make sure all stack variables that are cached in registers are written t

4条回答
  •  醉话见心
    2021-01-02 09:00

    Recollecting one of the threads on lkml, one of the methods for single variable compiler-only barrier is:

    #define forget(x) __asm__ __volatile__("":"=m"(x):"m"(x))
    

提交回复
热议问题