X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=arch_x86.h;h=8a5732536c9d3106af919b5467dab1f58c5f9313;hp=9e0079d6a5a7fc8fee6e81e0ea26d80995446450;hb=ba59a0c7b244a0939a2298fc76a9002436ef9674;hpb=ca9a18e1de82400d47549d01621a637a0b8765b7 diff --git a/arch_x86.h b/arch_x86.h index 9e0079d..8a57325 100644 --- a/arch_x86.h +++ b/arch_x86.h @@ -84,11 +84,36 @@ /* Nop everywhere except on alpha. */ #define smp_read_barrier_depends() +static inline void rep_nop(void) +{ + asm volatile("rep; nop" : : : "memory"); +} + static inline void cpu_relax(void) { rep_nop(); } +/* + * Serialize core instruction execution. Also acts as a compiler barrier. + */ +#ifdef __PIC__ +/* + * Cannot use cpuid because it clobbers the ebx register and clashes + * with -fPIC : + * error: PIC register 'ebx' clobbered in 'asm' + */ +static inline void sync_core(void) +{ + mb(); +} +#else +static inline void sync_core(void) +{ + asm volatile("cpuid" : : : "memory", "eax", "ebx", "ecx", "edx"); +} +#endif + #define rdtscll(val) \ do { \ unsigned int __a, __d; \