akaros/kern/arch/x86/membar.h
<<
>>
Prefs
   1#include <ros/arch/membar.h>
   2
   3/*************************
   4 * From Linux commit 569dbb88e80d ("Linux 4.13")
   5 * arch/x86/include/asm/barrier.h
   6 *
   7 * Note that their barrier() is our cmb(), but we actually have both available.
   8 * barrier() comes from e.g. <linux/compiler-gcc.h>.
   9 */
  10
  11#define __smp_store_release(p, v)                                       \
  12do {                                                                    \
  13        compiletime_assert_atomic_type(*p);                             \
  14        barrier();                                                      \
  15        WRITE_ONCE(*p, v);                                              \
  16} while (0)
  17
  18#define __smp_load_acquire(p)                                           \
  19({                                                                      \
  20        typeof(*p) ___p1 = READ_ONCE(*p);                               \
  21        compiletime_assert_atomic_type(*p);                             \
  22        barrier();                                                      \
  23        ___p1;                                                          \
  24})
  25
  26/* Atomic operations are already serializing on x86 */
  27#define __smp_mb__before_atomic()       barrier()
  28#define __smp_mb__after_atomic()        barrier()
  29
  30/************************* End Linux barrier.h */
  31
  32#define smp_store_release(p, v) __smp_store_release(p, v)
  33#define smp_load_acquire(p) __smp_load_acquire(p)
  34#define smp_mb__before_atomic() __smp_mb__before_atomic()
  35#define smp_mb__after_atomic() __smp_mb__after_atomic()
  36
  37#define smp_read_barrier_depends()
  38