mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-28 13:30:29 +00:00
Use CLK_TCK for clock_nanosleep() spin threshold
This more accurately reflects how the kernels actually implement this function and it most importantly avoids incurring startup latency.
This commit is contained in:
parent
11c18fa644
commit
695f74035d
4 changed files with 108 additions and 55 deletions
16
libc/nexgen32e/yield.h
Normal file
16
libc/nexgen32e/yield.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#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_ */
|
Loading…
Add table
Add a link
Reference in a new issue