From 538bc2f212b1131500d022415cc95fcc16cccfc3 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 19 Feb 2024 13:58:55 -0500 Subject: [PATCH] Implement side_cpu_relax for x86 Signed-off-by: Mathieu Desnoyers --- src/compiler.h | 8 ++++++++ 1 file changed, 8 insertions(+) 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 */ -- 2.34.1