mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 23:13:34 +00:00
e466dd0553
This change hardens the code for opening /zip/ files using the system call interface. Thread safety and signal safety has been improved for file descriptors in general. We now document fixed addresses that are needed for low level allocations.
27 lines
830 B
C
27 lines
830 B
C
#ifndef COSMOPOLITAN_LIBC_LINUX_FUTEX_H_
|
|
#define COSMOPOLITAN_LIBC_LINUX_FUTEX_H_
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
#include "libc/calls/struct/timespec.h"
|
|
|
|
forceinline int LinuxFutexWait(void *addr, int expect,
|
|
struct timespec *timeout) {
|
|
int ax;
|
|
register void *r10 asm("r10") = timeout;
|
|
asm volatile("syscall"
|
|
: "=a"(ax)
|
|
: "0"(202), "D"(addr), "S"(0), "d"(expect), "r"(r10)
|
|
: "rcx", "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_ */
|