From: Mathieu Desnoyers Date: Mon, 19 Feb 2024 18:58:55 +0000 (-0500) Subject: Implement side_cpu_relax for x86 X-Git-Url: http://git.efficios.com/?p=libside.git;a=commitdiff_plain;h=538bc2f212b1131500d022415cc95fcc16cccfc3 Implement side_cpu_relax for x86 Signed-off-by: Mathieu Desnoyers --- diff --git a/src/compiler.h b/src/compiler.h index 5287813..bf76b26 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -6,11 +6,19 @@ #ifndef _SIDE_COMPILER_H #define _SIDE_COMPILER_H +#if defined(__x86_64__) || defined(__i386__) +static inline +void side_cpu_relax(void) +{ + asm volatile ("rep; nop" : : : "memory"); +} +#else //TODO: implement per-architecture busy loop "pause"/"rep; nop;" instruction. static inline void side_cpu_relax(void) { asm volatile ("" : : : "memory"); } +#endif #endif /* _SIDE_COMPILER_H */