mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-12 09:17:53 +00:00
This more accurately reflects how the kernels actually implement this function and it most importantly avoids incurring startup latency.
16 lines
466 B
C
16 lines
466 B
C
#ifndef COSMOPOLITAN_LIBC_YIELD_H_
|
|
#define COSMOPOLITAN_LIBC_YIELD_H_
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
#ifdef _COSMO_SOURCE
|
|
|
|
static inline void spin_yield(void) {
|
|
#if defined(__GNUC__) && defined(__aarch64__)
|
|
__asm__ volatile("yield");
|
|
#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
|
|
__asm__ volatile("pause");
|
|
#endif
|
|
}
|
|
|
|
#endif /* _COSMO_SOURCE */
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_YIELD_H_ */
|