Add *NSYNC unit test suite

This change also fixes the clock_nanosleep() api and polyfills futexes
on Windows, Mac, and NetBSD using exponential backoff.
This commit is contained in:
Justine Tunney 2022-10-07 21:29:40 -07:00
parent 3421b9a580
commit 9849b4c7ba
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
51 changed files with 5505 additions and 1060 deletions

View file

@ -74,7 +74,6 @@ kErrnoDocs:
.e ELOOP,"Too many symbolic links encountered"
.e ENOMSG,"No message of desired type"
.e EIDRM,"Identifier removed"
.e ETIME,"Timer expired"
.e EPROTO,"Protocol error"
.e EOVERFLOW,"Value too large for defined data type"
.e EILSEQ,"Illegal byte sequence"
@ -103,6 +102,7 @@ kErrnoDocs:
.e ESHUTDOWN,"Cannot send after transport endpoint shutdown"
.e ETOOMANYREFS,"Too many references: cannot splice"
.e ETIMEDOUT,"Connection timed out"
.e ETIME,"Timer expired"
.e ECONNREFUSED,"Connection refused"
.e EHOSTDOWN,"Host is down"
.e EHOSTUNREACH,"No route to host"

View file

@ -74,7 +74,6 @@ kErrnoNames:
.e ELOOP
.e ENOMSG
.e EIDRM
.e ETIME
.e EPROTO
.e EOVERFLOW
.e EILSEQ
@ -103,6 +102,7 @@ kErrnoNames:
.e ESHUTDOWN
.e ETOOMANYREFS
.e ETIMEDOUT
.e ETIME
.e ECONNREFUSED
.e EHOSTDOWN
.e EHOSTUNREACH

View file

@ -23,6 +23,7 @@
// Normalizes return value to Linux ABI -errno convention.
sys_umtx_op:
mov $0x1c6,%eax
mov %rcx,%r10
syscall
jc 1f
ret

View file

@ -0,0 +1,43 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
Copyright 2022 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/sysv/consts/clock.h"
#include "libc/thread/freebsd.internal.h"
int sys_umtx_timedwait_uint(int *p, int expect, bool pshare,
const struct timespec *abstime) {
int op;
size_t size;
struct _umtx_time *tm_p, timo;
if (!abstime) {
tm_p = 0;
size = 0;
} else {
timo._clockid = CLOCK_REALTIME;
timo._flags = UMTX_ABSTIME;
timo._timeout = *abstime;
tm_p = &timo;
size = sizeof(timo);
}
if (pshare) {
op = UMTX_OP_WAIT_UINT;
} else {
op = UMTX_OP_WAIT_UINT_PRIVATE;
}
return sys_umtx_op(p, op, expect, (void *)size, tm_p);
}