Clean up the clone() code a bit

This commit is contained in:
Justine Tunney 2022-05-17 07:40:00 -07:00
parent ce71677156
commit 2743f3d012
20 changed files with 252 additions and 150 deletions

View file

@ -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;