mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
a988896048
This change also fixes #434 and makes the chibicc assembler better.
27 lines
833 B
C
27 lines
833 B
C
#ifndef COSMOPOLITAN_LIBC_LINUX_FUTEX_H_
|
|
#define COSMOPOLITAN_LIBC_LINUX_FUTEX_H_
|
|
#include "libc/calls/struct/timespec.h"
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
forceinline int LinuxFutexWait(void *addr, int expect,
|
|
struct timespec *timeout) {
|
|
int ax;
|
|
asm volatile("mov\t%5,%%r10\n\t"
|
|
"syscall"
|
|
: "=a"(ax)
|
|
: "0"(202), "D"(addr), "S"(0), "d"(expect), "g"(timeout)
|
|
: "rcx", "r10", "r11", "memory");
|
|
return ax;
|
|
}
|
|
|
|
forceinline int LinuxFutexWake(void *addr, int count) {
|
|
int ax;
|
|
asm volatile("syscall"
|
|
: "=a"(ax)
|
|
: "0"(202), "D"(addr), "S"(1), "d"(count)
|
|
: "rcx", "r11", "memory");
|
|
return ax;
|
|
}
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_LINUX_FUTEX_H_ */
|