cosmopolitan/libc/linux/futex.h
Justine Tunney a988896048 Add atomics to chibicc
This change also fixes #434 and makes the chibicc assembler better.
2022-06-20 03:08:00 -07:00

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_ */