Implement side_cpu_relax for x86
[libside.git] / src / compiler.h
1 // SPDX-License-Identifier: MIT
2 /*
3 * Copyright (C) 2024 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 */
5
6 #ifndef _SIDE_COMPILER_H
7 #define _SIDE_COMPILER_H
8
9 #if defined(__x86_64__) || defined(__i386__)
10 static inline
11 void side_cpu_relax(void)
12 {
13 asm volatile ("rep; nop" : : : "memory");
14 }
15 #else
16 //TODO: implement per-architecture busy loop "pause"/"rep; nop;" instruction.
17 static inline
18 void side_cpu_relax(void)
19 {
20 asm volatile ("" : : : "memory");
21 }
22 #endif
23
24 #endif /* _SIDE_COMPILER_H */
This page took 0.190029 seconds and 5 git commands to generate.