Polyfill sched_yield() on XNU

We were using the Mach system call swtch() earlier. It's possible Apple
removed this system call in their recent 12.4 upgrade. We're better off
using x86 PAUSE here, since Mach is less public than the UNIX syscalls.

See #426
This commit is contained in:
Justine Tunney 2022-06-17 03:43:20 -07:00
parent 34e39ad027
commit a0ddb889da
2 changed files with 8 additions and 1 deletions

View file

@ -26,6 +26,13 @@
// @return 0 on success, or -1 w/ errno
sched_yield:
#if SupportsXnu()
testb IsXnu()
jz 1f
pause
ret
#endif
#if SupportsWindows()
// Windows Support
//

View file

@ -60,7 +60,7 @@ scall __sys_pipe 0x02a10721e202a016 globl hidden # NOTE: pipe2() on FreeBSD; XN
scall sys_select 0x1a104705d205d017 globl hidden
scall pselect 0x1b406e20a218afff globl
scall pselect6 0xfffffffffffff10e globl
scall sys_sched_yield 0x15e12a14b103c018 globl hidden # swtch() on xnu
scall sys_sched_yield 0x15e12a14bffff018 globl hidden # swtch on xnu? possibly removed in 12.4
scall __sys_mremap 0x19bffffffffff019 globl hidden
scall sys_mincore 0x04e04e04e204e01b globl hidden
scall sys_madvise 0x04b04b04b204b01c globl hidden