mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-24 14:22:28 +00:00
Clean up the clone() code a bit
This commit is contained in:
parent
ce71677156
commit
2743f3d012
20 changed files with 252 additions and 150 deletions
|
@ -34,13 +34,15 @@ int cthread_join(cthread_t td, int* rc) {
|
|||
: "cc");
|
||||
|
||||
if (!(state & cthread_finished)) {
|
||||
int ax;
|
||||
int flags = FUTEX_WAIT; // PRIVATE makes it hang
|
||||
register struct timespec* timeout asm("r10") = NULL;
|
||||
asm volatile("syscall"
|
||||
: /* no outputs */
|
||||
: "a"(__NR_futex), "D"(&td->tid), "S"(flags), "d"(tid),
|
||||
"r"(timeout)
|
||||
: "rcx", "r11", "cc", "memory");
|
||||
struct timespec* timeout = NULL;
|
||||
asm volatile("mov\t%5,%%r10\n\t" // timeout
|
||||
"syscall"
|
||||
: "=a"(ax)
|
||||
: "0"(__NR_futex), "D"(&td->tid), "S"(flags), "d"(tid),
|
||||
"g"(timeout)
|
||||
: "rcx", "r10", "r11", "cc", "memory");
|
||||
}
|
||||
|
||||
*rc = td->rc;
|
||||
|
|
|
@ -25,12 +25,12 @@ int cthread_memory_wait32(uint32_t* addr, uint32_t val,
|
|||
if (__NR_futex != 0xfff) {
|
||||
int flags = FUTEX_WAIT;
|
||||
int rc;
|
||||
register struct timespec* timeout_ asm("r10") = timeout;
|
||||
asm volatile("syscall"
|
||||
asm volatile("mov\t%5,%%r10\n\t" // timeout
|
||||
"syscall"
|
||||
: "=a"(rc)
|
||||
: "0"(__NR_futex), "D"(addr), "S"(flags), "d"(val),
|
||||
"r"(timeout_)
|
||||
: "rcx", "r11", "cc", "memory");
|
||||
"g"(timeout)
|
||||
: "rcx", "r10", "r11", "cc", "memory");
|
||||
return rc;
|
||||
}
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue