Add WSL to test fleet

All tests pass now under WSL2. They should pass under WSL1 too, but only
WSL2 is integrated into the test fleet right now. This change also fills
in some gaps in the error numbers.

Fixes #665
This commit is contained in:
Justine Tunney 2022-11-02 06:49:42 -07:00
parent fae0c0286f
commit 14d036b68d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
43 changed files with 2867 additions and 214 deletions

View file

@ -60,7 +60,7 @@
# build/config.mk
SHELL = build/bootstrap/cocmd.com
HOSTS ?= freebsd openbsd netbsd rhel7 rhel5 xnu win10 win10:31338
HOSTS ?= freebsd openbsd netbsd rhel7 rhel5 xnu win10 win10:31336
MAKEFLAGS += -j --no-builtin-rules
.SUFFIXES:

View file

@ -246,12 +246,16 @@ gdb foo.com -ex 'add-symbol-file foo.com.dbg 0x401000'
| AMD | K8 Venus | 2005 |
| Intel | Core | 2006 |
| Linux | 2.6.18 | 2007 |
| Windows | 8 | 2012 |
| Windows | 8 [1] | 2012 |
| Mac OS X | 15.6 | 2018 |
| OpenBSD | 6.4 | 2018 |
| FreeBSD | 13 | 2020 |
| NetBSD | 9.2 | 2021 |
[1] See our [vista branch](https://github.com/jart/cosmopolitan/tree/vista)
for a community supported version of Cosmopolitan that works on Windows
Vista and Windows 7.
## Special Thanks
Funding for this project is crowdsourced using

View file

@ -108,7 +108,6 @@ static bool __sig_deliver(bool restartable, int sig, int si_code,
STRACE("delivering %G", sig);
// enter the signal
__sig_lock();
rva = __sighandrvas[sig];
flags = __sighandflags[sig];
if ((~flags & SA_NODEFER) || (flags & SA_RESETHAND)) {
@ -119,7 +118,6 @@ static bool __sig_deliver(bool restartable, int sig, int si_code,
// signal handler. in that case you must use SA_NODEFER.
__sighandrvas[sig] = (int32_t)(intptr_t)SIG_DFL;
}
__sig_unlock();
// setup the somewhat expensive information args
// only if they're requested by the user in sigaction()
@ -141,11 +139,9 @@ static bool __sig_deliver(bool restartable, int sig, int si_code,
// since sigaction() is @asyncsignalsafe we only restore it if the
// user didn't change it during the signal handler. we also don't
// need to do anything if this was a oneshot signal or nodefer.
__sig_lock();
if (__sighandrvas[sig] == (int32_t)(intptr_t)SIG_DFL) {
__sighandrvas[sig] = rva;
}
__sig_unlock();
}
if (!restartable) {
@ -228,12 +224,12 @@ textwindows int __sig_add(int tid, int sig, int si_code) {
int rc;
struct Signal *mem;
if (1 <= sig && sig <= 64) {
__sig_lock();
if (__sighandrvas[sig] == (unsigned)(intptr_t)SIG_IGN) {
STRACE("ignoring %G", sig);
rc = 0;
} else {
STRACE("enqueuing %G", sig);
__sig_lock();
++__sig_count;
if ((mem = __sig_alloc())) {
mem->tid = tid;
@ -245,8 +241,8 @@ textwindows int __sig_add(int tid, int sig, int si_code) {
} else {
rc = enomem();
}
__sig_unlock();
}
__sig_unlock();
} else {
rc = einval();
}

File diff suppressed because it is too large Load diff

View file

@ -85,9 +85,11 @@ union metasigaction {
struct sigaction_xnu_out xnu_out;
};
void __sigenter_netbsd(int, void *, void *) hidden;
void __sigenter_freebsd(int, void *, void *) hidden;
void __sigenter_openbsd(int, void *, void *) hidden;
void __sigenter_xnu(int, struct siginfo *, void *) hidden;
void __sigenter_linux(int, struct siginfo *, void *) hidden;
void __sigenter_netbsd(int, struct siginfo *, void *) hidden;
void __sigenter_freebsd(int, struct siginfo *, void *) hidden;
void __sigenter_openbsd(int, struct siginfo *, void *) hidden;
static void sigaction_cosmo2native(union metasigaction *sa) {
if (!sa) return;
@ -156,6 +158,7 @@ static int __sigaction(int sig, const struct sigaction *act,
"sigaction cosmo abi needs tuning");
int64_t arg4, arg5;
int rc, rva, oldrva;
sigaction_f sigenter;
struct sigaction *ap, copy;
if (IsMetal()) return enosys(); /* TODO: Signals on Metal */
if (!(0 < sig && sig < NSIG)) return einval();
@ -183,11 +186,7 @@ static int __sigaction(int sig, const struct sigaction *act,
ap = &copy;
if (IsXnu()) {
ap->sa_restorer = (void *)&__sigenter_xnu;
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = (void *)&__sigenter_xnu;
}
sigenter = __sigenter_xnu;
// mitigate Rosetta signal handling strangeness
// https://github.com/jart/cosmopolitan/issues/455
ap->sa_flags |= SA_SIGINFO;
@ -196,27 +195,21 @@ static int __sigaction(int sig, const struct sigaction *act,
ap->sa_flags |= SA_RESTORER;
ap->sa_restorer = &__restore_rt;
}
sigenter = __sigenter_linux;
} else if (IsNetbsd()) {
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = (sigaction_f)__sigenter_netbsd;
}
sigenter = __sigenter_netbsd;
} else if (IsFreebsd()) {
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = (sigaction_f)__sigenter_freebsd;
}
sigenter = __sigenter_freebsd;
} else if (IsOpenbsd()) {
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = (sigaction_f)__sigenter_openbsd;
}
sigenter = __sigenter_openbsd;
} else {
return enosys();
}
if (rva < kSigactionMinRva) {
ap->sa_sigaction = (void *)(intptr_t)rva;
} else {
ap->sa_sigaction = sigenter;
}
sigaction_cosmo2native((union metasigaction *)ap);
} else {
ap = NULL;
@ -468,7 +461,6 @@ static int __sigaction(int sig, const struct sigaction *act,
* @return 0 on success or -1 w/ errno
* @see xsigaction() for a much better api
* @asyncsignalsafe
* @threadsafe
* @vforksafe
*/
int sigaction(int sig, const struct sigaction *act, struct sigaction *oldact) {
@ -476,11 +468,7 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oldact) {
if (sig == SIGKILL || sig == SIGSTOP) {
rc = einval();
} else {
BLOCK_SIGNALS;
__sig_lock();
rc = __sigaction(sig, act, oldact);
__sig_unlock();
ALLOW_SIGNALS;
}
STRACE("sigaction(%G, %s, [%s]) → %d% m", sig, DescribeSigaction(0, act),
DescribeSigaction(rc, oldact), rc);

View file

@ -49,16 +49,16 @@ void _check_sigchld(void) {
i = WaitForMultipleObjects(n, handles, false, 0);
if (i == kNtWaitTimeout) return;
if (i == kNtWaitFailed) {
STRACE("%s failed %u", "WaitForMultipleObjects", GetLastError());
NTTRACE("%s failed %u", "WaitForMultipleObjects", GetLastError());
return;
}
if (__sighandrvas[SIGCHLD] == (intptr_t)SIG_IGN ||
__sighandrvas[SIGCHLD] == (intptr_t)SIG_DFL) {
STRACE("new zombie fd=%d handle=%ld", pids[i], handles[i]);
NTTRACE("new zombie fd=%d handle=%ld", pids[i], handles[i]);
return;
}
if (__sighandflags[SIGCHLD] & SA_NOCLDWAIT) {
STRACE("SIGCHILD SA_NOCLDWAIT fd=%d handle=%ld", pids[i], handles[i]);
NTTRACE("SIGCHILD SA_NOCLDWAIT fd=%d handle=%ld", pids[i], handles[i]);
CloseHandle(handles[i]);
__releasefd(pids[i]);
}

View file

@ -0,0 +1,48 @@
/*-*- 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 "ape/sections.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/state.internal.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/siginfo.h"
#include "libc/calls/ucontext.h"
#include "libc/intrin/likely.h"
#include "libc/math.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/sa.h"
privileged void __sigenter_linux(int sig, struct siginfo *info,
ucontext_t *ctx) {
int i, rva, flags;
rva = __sighandrvas[sig & (NSIG - 1)];
if (rva >= kSigactionMinRva) {
flags = __sighandflags[sig & (NSIG - 1)];
// WSL1 doesn't set the fpregs field.
// https://github.com/microsoft/WSL/issues/2555
if ((flags & SA_SIGINFO) && UNLIKELY(!ctx->uc_mcontext.fpregs)) {
ctx->uc_mcontext.fpregs = &ctx->__fpustate;
for (i = 0; i < 8; ++i) {
long double nan = NAN;
memcpy(ctx->__fpustate.st + i, &nan, 16);
}
}
((sigaction_f)(_base + rva))(sig, info, ctx);
}
}

View file

@ -8,8 +8,6 @@
COSMOPOLITAN_C_START_
int sys_sigqueueinfo(int, const siginfo_t *) hidden;
void __sigenter_xnu(void *, int, int, struct siginfo_xnu *,
struct __darwin_ucontext *) hidden;
const char *DescribeSiginfo(char[300], int, const siginfo_t *);
#define DescribeSiginfo(x, y) DescribeSiginfo(alloca(300), x, y)

View file

@ -75,9 +75,11 @@
#define SupportsFreebsd() ((SUPPORT_VECTOR & _HOSTFREEBSD) == _HOSTFREEBSD)
#define SupportsOpenbsd() ((SUPPORT_VECTOR & _HOSTOPENBSD) == _HOSTOPENBSD)
#define SupportsNetbsd() ((SUPPORT_VECTOR & _HOSTNETBSD) == _HOSTNETBSD)
#define SupportsBsd() (!!(SUPPORT_VECTOR & (_HOSTXNU | _HOSTFREEBSD | _HOSTOPENBSD | _HOSTNETBSD)))
#define SupportsBsd() \
(!!(SUPPORT_VECTOR & (_HOSTXNU | _HOSTFREEBSD | _HOSTOPENBSD | _HOSTNETBSD)))
#define SupportsSystemv() \
(!!(SUPPORT_VECTOR & (_HOSTLINUX | _HOSTXNU | _HOSTOPENBSD | _HOSTFREEBSD | _HOSTNETBSD)))
(!!(SUPPORT_VECTOR & \
(_HOSTLINUX | _HOSTXNU | _HOSTOPENBSD | _HOSTFREEBSD | _HOSTNETBSD)))
#ifndef __ASSEMBLER__
#define IsLinux() (SupportsLinux() && (__hostos & _HOSTLINUX))
@ -106,6 +108,8 @@ COSMOPOLITAN_C_START_
extern const int __hostos;
bool IsWsl1(void);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_DCE_H_ */

View file

@ -16,34 +16,31 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/assert.h"
#include "libc/calls/calls.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/runtime/internal.h"
#include "libc/intrin/likely.h"
#include "libc/sysv/consts/map.h"
#include "libc/sysv/consts/prot.h"
#define MAP_GROWSDOWN_linux 0x00000100
#define MAP_ANONYMOUS_linux 0x00000020
#define GROWSDOWN 0x00000100
#define ANONYMOUS 0x00000020
/**
* Returns true if host platform is WSL.
* Returns true if host platform is WSL 1.0.
*/
bool __is_wsl(void) {
int e;
void *p;
bool res;
if (!IsLinux()) return false;
e = errno;
p = __sys_mmap(0, 4096, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS_linux | MAP_GROWSDOWN_linux, -1, 0,
0);
if (p != MAP_FAILED) {
__sys_munmap(p, 4096);
return false;
}
res = errno == ENOTSUP;
bool IsWsl1(void) {
static char res;
if (res) return res & 1;
if (!IsLinux()) return res = 2, false;
int e = errno;
_unassert(__sys_mmap((void *)1, 4096, PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | ANONYMOUS | GROWSDOWN, -1, 0,
0) == MAP_FAILED);
bool tmp = errno == ENOTSUP;
errno = e;
return res;
res = 2 | tmp;
return tmp;
}

View file

@ -41,8 +41,10 @@
#include "libc/runtime/internal.h"
#include "libc/runtime/pc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/thread/tls.h"
#include "third_party/libcxx/math.h"
/**
* @fileoverview Abnormal termination handling & GUI debugging.
@ -135,16 +137,24 @@ relegated static char *ShowGeneralRegisters(char *p, ucontext_t *ctx) {
j = 0;
if (ctx->uc_mcontext.fpregs) {
memcpy(&st, (char *)&ctx->uc_mcontext.fpregs->st[k], sizeof(st));
} else {
bzero(&st, sizeof(st));
p = stpcpy(p, " ST(");
p = FormatUint64(p, k++);
p = stpcpy(p, ") ");
if (signbit(st)) {
st = -st;
*p++ = '-';
}
if (isnan(st)) {
p = stpcpy(p, "nan");
} else if (isinf(st)) {
p = stpcpy(p, "inf");
} else {
if (st > 999.999) st = 999.999;
x = st * 1000;
p = FormatUint64(p, x / 1000), *p++ = '.';
p = FormatUint64(p, x % 1000);
}
}
p = stpcpy(p, " ST(");
p = FormatUint64(p, k++);
p = stpcpy(p, ") ");
x = st * 1000;
if (x < 0) x = -x, *p++ = '-';
p = FormatUint64(p, x / 1000), *p++ = '.';
p = FormatUint64(p, x % 1000);
*p++ = '\n';
}
}

View file

@ -90,7 +90,7 @@
#define kNtErrorDiskFull 112 /* ENOSPC */
#define kNtErrorNoMoreSearchHandles 113
#define kNtErrorInvalidTargetHandle 114 /* EBADF */
#define kNtErrorInvalidCategory 117
#define kNtErrorInvalidCategory 117 /* ENOATTR */
#define kNtErrorInvalidVerifySwitch 118
#define kNtErrorBadDriverLevel 119
#define kNtErrorCallNotImplemented 120
@ -151,7 +151,7 @@
#define kNtErrorInvalidStackseg 189
#define kNtErrorInvalidModuletype 190
#define kNtErrorInvalidExeSignature 191
#define kNtErrorExeMarkedInvalid 192
#define kNtErrorExeMarkedInvalid 192 /* EBADEXEC */
#define kNtErrorBadExeFormat 193 /* ENOEXEC */
#define kNtErrorIteratedDataExceeds_64k 194
#define kNtErrorInvalidMinallocsize 195
@ -172,14 +172,14 @@
#define kNtErrorLocked 212
#define kNtErrorTooManyModules 214
#define kNtErrorNestingNotAllowed 215
#define kNtErrorExeMachineTypeMismatch 216
#define kNtErrorExeMachineTypeMismatch 216 /* EBADARCH */
#define kNtErrorExeCannotModifySignedBinary 217
#define kNtErrorExeCannotModifyStrongSignedBinary 218
#define kNtErrorFileCheckedOut 220
#define kNtErrorCheckoutRequired 221
#define kNtErrorBadFileType 222
#define kNtErrorBadFileType 222 /* EFTYPE */
#define kNtErrorFileTooLarge 223 /* EFBIG */
#define kNtErrorFormsAuthRequired 224
#define kNtErrorFormsAuthRequired 224 /* ENEEDAUTH */
#define kNtErrorVirusInfected 225
#define kNtErrorVirusDeleted 226
#define kNtErrorPipeLocal 229
@ -231,7 +231,7 @@
#define kNtErrorFileLevelTrimNotSupported 326
#define kNtErrorOffsetAlignmentViolation 327
#define kNtErrorInvalidFieldInParameterList 328
#define kNtErrorOperationInProgress 329
#define kNtErrorOperationInProgress 329 /* EPROGUNAVAIL */
#define kNtErrorBadDevicePath 330
#define kNtErrorTooManyDescriptors 331 /* ENFILE */
#define kNtErrorScrubDataDisabled 332
@ -331,7 +331,7 @@
#define kNtErrorPnpQueryRemoveDeviceTimeout 480
#define kNtErrorPnpQueryRemoveRelatedDeviceTimeout 481
#define kNtErrorPnpQueryRemoveUnrelatedDeviceTimeout 482
#define kNtErrorDeviceHardwareError 483
#define kNtErrorDeviceHardwareError 483 /* EDEVERR */
#define kNtErrorInvalidAddress 487 /* EFAULT */
#define kNtErrorVrfCfgEnabled 1183
#define kNtErrorPartitionTerminating 1184
@ -396,7 +396,7 @@
#define kNtErrorDataNotAccepted 592
#define kNtErrorVdmHardError 593
#define kNtErrorDriverCancelTimeout 594
#define kNtErrorReplyMessageMismatch 595
#define kNtErrorReplyMessageMismatch 595 /* EPROGMISMATCH */
#define kNtErrorLostWritebehindData 596
#define kNtErrorClientServerParametersInvalid 597
#define kNtErrorNotTinyStream 598
@ -440,7 +440,7 @@
#define kNtErrorPnpRestartEnumeration 636
#define kNtErrorSystemImageBadSignature 637
#define kNtErrorPnpRebootRequired 638
#define kNtErrorInsufficientPower 639
#define kNtErrorInsufficientPower 639 /* EPWROFF */
#define kNtErrorMultipleFaultViolation 640
#define kNtErrorSystemShutdown 641
#define kNtErrorPortNotSet 642
@ -771,7 +771,7 @@
#define kNtErrorConnectionActive 1230
#define kNtErrorNetworkUnreachable 1231
#define kNtErrorHostUnreachable 1232
#define kNtErrorProtocolUnreachable 1233
#define kNtErrorProtocolUnreachable 1233 /* multimapped to ENETUNREACH */
#define kNtErrorPortUnreachable 1234
#define kNtErrorRequestAborted 1235
#define kNtErrorConnectionAborted 1236
@ -782,7 +782,7 @@
#define kNtErrorIncorrectAddress 1241
#define kNtErrorAlreadyRegistered 1242
#define kNtErrorServiceNotFound 1243
#define kNtErrorNotAuthenticated 1244
#define kNtErrorNotAuthenticated 1244 /* EAUTH */
#define kNtErrorNotLoggedOn 1245
#define kNtErrorContinue 1246
#define kNtErrorAlreadyInitialized 1247
@ -820,7 +820,7 @@
#define kNtErrorDebuggerInactive 1284
#define kNtErrorDelayLoadFailed 1285
#define kNtErrorVdmDisallowed 1286
#define kNtErrorUnidentifiedError 1287
#define kNtErrorUnidentifiedError 1287 /* EIDRM */
#define kNtErrorInvalidCruntimeParameter 1288
#define kNtErrorBeyondVdl 1289
#define kNtErrorIncompatibleServiceSidType 1290
@ -1038,8 +1038,8 @@
#define kNtErrorInstallLanguageUnsupported 1623
#define kNtErrorInstallTransformFailure 1624
#define kNtErrorInstallPackageRejected 1625
#define kNtErrorFunctionNotCalled 1626
#define kNtErrorFunctionFailed 1627
#define kNtErrorFunctionNotCalled 1626 /* EBADRPC */
#define kNtErrorFunctionFailed 1627 /* ERPCMISMATCH */
#define kNtErrorInvalidTable 1628
#define kNtErrorDatatypeMismatch 1629
#define kNtErrorUnsupportedType 1630
@ -1707,7 +1707,7 @@
#define kNtErrorCtxSessionInUse 7062
#define kNtErrorCtxNoForceLogoff 7063
#define kNtErrorCtxAccountRestriction 7064
#define kNtErrorRdpProtocolError 7065
#define kNtErrorRdpProtocolError 7065 /* EPROTO */
#define kNtErrorCtxCdmConnect 7066
#define kNtErrorCtxCdmDisconnect 7067
#define kNtErrorCtxSecurityLayerError 7068
@ -2566,7 +2566,7 @@
#define kNtErrorStateSettingValueSizeLimitExceeded 15816
#define kNtErrorStateSettingNameSizeLimitExceeded 15817
#define kNtErrorStateContainerNameSizeLimitExceeded 15818
#define kNtErrorApiUnavailable 15841
#define kNtErrorApiUnavailable 15841 /* EPROCUNAVAIL */
#define kNtWaitIoCompletion 0xc0

View file

@ -29,7 +29,6 @@ extern unsigned char _tls_size[];
extern unsigned char _tls_content[];
void _init(void) hidden;
bool __is_wsl(void);
void __morph_tls(void);
void __enable_tls(void);
void __enable_threads(void) hidden;

View file

@ -51,6 +51,6 @@ int connect(int fd, const struct sockaddr *addr, uint32_t addrsize) {
} else {
rc = efault();
}
STRACE("connect(%d, %s) -> %d% lm", fd, DescribeSockaddr(addr, addrsize), rc);
STRACE("connect(%d, %s) %d% lm", fd, DescribeSockaddr(addr, addrsize), rc);
return rc;
}

View file

@ -65,8 +65,8 @@ syscon errno ENOLCK 37 77 77 77 77 158 # no locks available; kNt
syscon errno ENOTEMPTY 39 66 66 66 66 145 # directory not empty; bsd consensus; kNtErrorDirNotEmpty (TODO: What is WSAENOTEMPTY? 10066); raised by rmdir(2)
syscon errno ELOOP 40 62 62 62 62 1921 # too many levels of symbolic links; bsd consensus; kNtErrorCantResolveFilename; raised by access(2), acct(2), bind(2), chdir(2), chmod(2), chown(2), chroot(2), epoll_ctl(2), execve(2), execveat(2), keyctl(2), link(2), mkdir(2), mknod(2), mount(2), open(2), open_by_handle_at(2), openat2(2), readlink(2), rename(2), rmdir(2), spu_create(2), stat(2), statfs(2), statx(2), symlink(2), truncate(2), unlink(2), utimensat(2)
syscon errno ENOMSG 42 91 83 90 83 4306 # kNtErrorEmpty; raised by msgop(2)
syscon errno EIDRM 43 90 82 89 82 0 # identifier removed; raised by msgctl(2), msgget(2), msgop(2), semctl(2), semop(2), shmctl(2), shmget(2), shmop(2)
syscon errno EPROTO 71 100 92 95 96 0 # raised by accept(2), connect(2), socket(2), socketpair(2)
syscon errno EIDRM 43 90 82 89 82 1287 # identifier removed; kNtErrorUnidentifiedError; raised by msgctl(2), msgget(2), msgop(2), semctl(2), semop(2), shmctl(2), shmget(2), shmop(2)
syscon errno EPROTO 71 100 92 95 96 7065 # Protocol error; kNtErrorRdpProtocolError; raised by accept(2), connect(2), socket(2), socketpair(2)
syscon errno EOVERFLOW 75 84 84 87 84 534 # kNtErrorArithmeticOverflow; raised by aio_read(2), copy_file_range(2), ctime(2), fanotify_init(2), lseek(2), mmap(2), open(2), open_by_handle_at(2), sem_post(2), sendfile(2), shmctl(2), stat(2), statfs(2), statvfs(2), time(2), timegm(2)
syscon errno EILSEQ 84 92 86 84 85 582 # kNtErrorIllegalCharacter; returned by fgetwc(3), fputwc(3), getwchar(3), putwchar(3), scanf(3), ungetwc(3)
syscon errno EUSERS 87 68 68 68 68 10068 # too many users; bsd consensus; WSAEUSERS; raised by acct(2)
@ -102,28 +102,28 @@ syscon errno EALREADY 114 37 37 37 37 10037 # connection already
syscon errno EINPROGRESS 115 36 36 36 36 10036 # bsd consensus; WSAEINPROGRESS; raised by connect(2) w/ O_NONBLOCK
syscon errno ESTALE 116 70 70 70 70 10070 # bsd consensus; WSAESTALE; raised by open_by_handle_at(2)
syscon errno EREMOTE 66 71 71 71 71 10071 # bsd consensus
syscon errno EBADRPC 0 72 72 72 72 0 # bsd consensus
syscon errno ERPCMISMATCH 0 73 73 73 73 0 # bsd consensus
syscon errno EPROGUNAVAIL 0 74 74 74 74 0 # bsd consensus
syscon errno EPROGMISMATCH 0 75 75 75 75 0 # bsd consensus
syscon errno EPROCUNAVAIL 0 76 76 76 76 0 # bsd consensus
syscon errno EFTYPE 0 79 79 79 79 0 # bsd consensus
syscon errno EAUTH 0 80 80 80 80 0 # bsd consensus
syscon errno ENEEDAUTH 0 81 81 81 81 0 # bsd consensus
syscon errno EPROCLIM 0 67 67 67 67 10067 # bsd consensus
syscon errno ENOATTR 0 93 87 83 93 0 #
syscon errno EPWROFF 0 82 0 0 0 0 #
syscon errno EDEVERR 0 83 0 0 0 0 #
syscon errno EBADEXEC 0 85 0 0 0 0 #
syscon errno EBADARCH 0 86 0 0 0 0 #
syscon errno ESHLIBVERS 0 87 0 0 0 0 # shiver me timbers
syscon errno EBADMACHO 0 88 0 0 0 0 #
syscon errno ENOPOLICY 0 103 0 0 0 0 #
syscon errno EBADRPC 300 72 72 72 72 1626 # kNtErrorFunctionNotCalled; bsd consensus; made up on linux
syscon errno ERPCMISMATCH 301 73 73 73 73 1627 # kNtErrorFunctionFailed; bsd consensus; made up on linux
syscon errno EPROGUNAVAIL 302 74 74 74 74 329 # kNtErrorOperationInProgress; bsd consensus; made up on linux
syscon errno EPROGMISMATCH 303 75 75 75 75 595 # kNtErrorReplyMessageMismatch; bsd consensus; made up on linux
syscon errno EPROCUNAVAIL 304 76 76 76 76 15841 # kNtErrorApiUnavailable; bsd consensus; made up on linux
syscon errno EFTYPE 305 79 79 79 79 222 # Inappropriate file type or format; kNtErrorBadFileType; bsd consensus; made up on linux
syscon errno EAUTH 306 80 80 80 80 1244 # Authentication error; kNtErrorNotAuthenticated; bsd consensus; made up on linux
syscon errno ENEEDAUTH 307 81 81 81 81 224 # Need authenticator; kNtErrorFormsAuthRequired; bsd consensus; made up on linux
syscon errno EPROCLIM 308 67 67 67 67 10067 # bsd consensus; made up on linux
syscon errno ENOATTR 309 93 87 83 93 117 # Attribute not found; kNtErrorInvalidCategory; made up on linux
syscon errno EPWROFF 310 82 310 310 310 639 # Intelligent device errors. Device power is off; kNtErrorInsufficientPower; made up on non-xnu
syscon errno EDEVERR 311 83 311 311 311 483 # kNtErrorDeviceHardwareError; made up on non-xnu
syscon errno EBADEXEC 312 85 312 312 312 192 # kNtErrorExeMarkedInvalid; made up on non-xnu
syscon errno EBADARCH 313 86 313 313 313 216 # kNtErrorExeMachineTypeMismatch; made up on non-xnu
syscon errno ESHLIBVERS 314 87 314 314 314 0 # shiver me timbers; made up on non-xnu
syscon errno EBADMACHO 315 88 315 315 315 0 # made up on non-xnu
syscon errno ENOPOLICY 316 103 316 316 316 0 # made up on non-xnu
syscon errno EBADMSG 74 94 89 92 88 0 # raised by ioctl_getfsmap(2)
syscon errno ECANCELED 125 89 85 88 87 1223 # kNtErrorCancelled; raised by timerfd_create(2)
syscon errno EOWNERDEAD 130 105 96 94 97 105 # kNtErrorSemOwnerDied; raised by pthread_cond_timedwait(3), pthread_mutex_consistent(3), pthread_mutex_getprioceiling(3), pthread_mutex_lock(3), pthread_mutex_timedlock(3), pthread_mutexattr_getrobust(3), pthread_mutexattr_setrobust(3)
syscon errno ENOTRECOVERABLE 131 104 95 93 98 0 # raised by pthread_cond_timedwait(3), pthread_mutex_consistent(3), pthread_mutex_getprioceiling(3), pthread_mutex_lock(3), pthread_mutex_timedlock(3), pthread_mutexattr_getrobust(3), pthread_mutexattr_setrobust(3)
syscon errno ENONET 64 0 0 0 0 0 # unilateral; raised by accept(2)
syscon errno ENONET 64 317 317 317 317 0 # made up on BSDs; raised by accept(2)
syscon errno ERESTART 85 -1 -1 -1 -3 0 # should only be seen in ptrace()
syscon errno ENODATA 61 96 0 0 89 232 # no message is available in xsi stream or named pipe is being closed; no data available; barely in posix; returned by ioctl; very close in spirit to EPIPE?
syscon errno ENOSR 63 98 0 90 90 0 # out of streams resources; something like EAGAIN; it's in POSIX; maybe some commercial UNIX returns it with openat, putmsg, putpmsg, posix_openpt, ioctl, open

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EAUTH,0,80,80,80,80,0
.syscon errno,EAUTH,306,80,80,80,80,1244

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EBADARCH,0,86,0,0,0,0
.syscon errno,EBADARCH,313,86,313,313,313,216

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EBADEXEC,0,85,0,0,0,0
.syscon errno,EBADEXEC,312,85,312,312,312,192

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EBADMACHO,0,88,0,0,0,0
.syscon errno,EBADMACHO,315,88,315,315,315,0

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EBADRPC,0,72,72,72,72,0
.syscon errno,EBADRPC,300,72,72,72,72,1626

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EDEVERR,0,83,0,0,0,0
.syscon errno,EDEVERR,311,83,311,311,311,0

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EFTYPE,0,79,79,79,79,0
.syscon errno,EFTYPE,305,79,79,79,79,222

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EIDRM,43,90,82,89,82,0
.syscon errno,EIDRM,43,90,82,89,82,1287

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENEEDAUTH,0,81,81,81,81,0
.syscon errno,ENEEDAUTH,307,81,81,81,81,224

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENOATTR,0,93,87,83,93,0
.syscon errno,ENOATTR,309,93,87,83,93,117

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENONET,64,0,0,0,0,0
.syscon errno,ENONET,64,317,317,317,317,0

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENOPOLICY,0,103,0,0,0,0
.syscon errno,ENOPOLICY,316,103,316,316,316,0

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EPROCLIM,0,67,67,67,67,10067
.syscon errno,EPROCLIM,308,67,67,67,67,10067

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EPROCUNAVAIL,0,76,76,76,76,0
.syscon errno,EPROCUNAVAIL,304,76,76,76,76,15841

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EPROGMISMATCH,0,75,75,75,75,0
.syscon errno,EPROGMISMATCH,303,75,75,75,75,595

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EPROGUNAVAIL,0,74,74,74,74,0
.syscon errno,EPROGUNAVAIL,302,74,74,74,74,329

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EPROTO,71,100,92,95,96,0
.syscon errno,EPROTO,71,100,92,95,96,7065

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EPWROFF,0,82,0,0,0,0
.syscon errno,EPWROFF,310,82,310,310,310,639

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ERPCMISMATCH,0,73,73,73,73,0
.syscon errno,ERPCMISMATCH,301,73,73,73,73,1627

View file

@ -1,2 +1,2 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ESHLIBVERS,0,87,0,0,0,0
.syscon errno,ESHLIBVERS,314,87,314,314,314,0

View file

@ -19,80 +19,6 @@
dir=libc/sysv/dos2errno
. libc/sysv/gen.sh
# # DOS ERRNO CANONICAL MAPPINGS
# #
# # These are defined by consts.sh.
# # They're here too as a reminder.
# #
# dos kNtErrorInvalidFunction ENOSYS # in consts.sh
# dos kNtErrorFileNotFound ENOENT # in consts.sh
# dos kNtErrorPathNotFound ENOTDIR # in consts.sh
# dos kNtErrorTooManyOpenFiles EMFILE # in consts.sh
# dos kNtErrorTooManyDescriptors ENFILE # in consts.sh
# dos kNtErrorTooManyLinks EMLINK # in consts.sh
# dos kNtErrorAccessDenied EACCES # in consts.sh
# dos kNtErrorInvalidHandle EBADF # in consts.sh
# dos kNtErrorInvalidAccess EPERM # in consts.sh
# dos kNtErrorNotEnoughQuota EDQUOT # in consts.sh
# dos kNtErrorSeek ESPIPE # in consts.sh
# dos kNtErrorNotDosDisk ENOTBLK # in consts.sh
# dos kNtErrorFileExists EEXIST # in consts.sh
# dos kNtErrorInvalidParameter EINVAL # in consts.sh
# dos kNtErrorOutofmemory ENOMEM # in consts.sh
# dos kNtErrorBrokenPipe EPIPE # in consts.sh
# dos kNtErrorWaitNoChildren ECHILD # in consts.sh
# dos kNtErrorPathBusy ETXTBSY # in consts.sh
# dos kNtErrorBusy EBUSY # in consts.sh
# dos kNtErrorAlreadyExists EEXIST # in consts.sh
# dos kNtErrorBadExeFormat ENOEXEC # in consts.sh
# dos kNtErrorFileTooLarge EFBIG # in consts.sh
# dos kNtErrorDirectoryNotSupported EISDIR # in consts.sh
# dos kNtErrorInvalidAddress EFAULT # in consts.sh
# dos kNtErrorThreadNotInProcess ESRCH # in consts.sh
# dos kNtErrorNoMediaInDrive ENXIO # in consts.sh
# dos kNtErrorIoDevice EIO # in consts.sh
# dos kNtErrorSerialNoDevice ENOTTY # in consts.sh
# dos kNtErrorPossibleDeadlock EDEADLK # in consts.sh
# dos kNtErrorBadDevice ENODEV # in consts.sh
# dos kNtErrorInvalidCommandLine E2BIG # in consts.sh
# dos kNtErrorFileReadOnly EROFS # in consts.sh
# dos kNtErrorNoData ENODATA # in consts.sh
# dos WSAEPROCLIM EPROCLIM # in consts.sh
# dos WSAESHUTDOWN ESHUTDOWN # in consts.sh
# dos WSAEINPROGRESS EINPROGRESS # in consts.sh
# dos WSAENETDOWN ENETDOWN # in consts.sh
# dos WSAENETUNREACH ENETUNREACH # in consts.sh
# dos WSAENETRESET ENETRESET # in consts.sh
# dos WSAEUSERS EUSERS # in consts.sh
# dos WSAENOTSOCK ENOTSOCK # in consts.sh
# dos WSAEDESTADDRREQ EDESTADDRREQ # in consts.sh
# dos WSAEMSGSIZE EMSGSIZE # in consts.sh
# dos WSAEPROTOTYPE EPROTOTYPE # in consts.sh
# dos WSAENOPROTOOPT ENOPROTOOPT # in consts.sh
# dos WSAEPROTONOSUPPORT EPROTONOSUPPORT # in consts.sh
# dos WSAESOCKTNOSUPPORT ESOCKTNOSUPPORT # in consts.sh
# dos WSAEOPNOTSUPP ENOTSUP # in consts.sh
# dos WSAEOPNOTSUPP EOPNOTSUPP # in consts.sh
# dos WSAEPFNOSUPPORT EPFNOSUPPORT # in consts.sh
# dos WSAEAFNOSUPPORT EAFNOSUPPORT # in consts.sh
# dos WSAEADDRINUSE EADDRINUSE # in consts.sh
# dos WSAEADDRNOTAVAIL EADDRNOTAVAIL # in consts.sh
# dos WSAECONNABORTED ECONNABORTED # in consts.sh
# dos WSAECONNRESET ECONNRESET # in consts.sh
# dos WSAENOBUFS ENOBUFS # in consts.sh
# dos WSAEISCONN EISCONN # in consts.sh
# dos WSAENOTCONN ENOTCONN # in consts.sh
# dos WSAESHUTDOWN ESHUTDOWN # in consts.sh
# dos WSAETOOMANYREFS ETOOMANYREFS # in consts.sh
# dos kNtErrorTimeout ETIMEDOUT # in consts.sh
# dos WSAECONNREFUSED ECONNREFUSED # in consts.sh
# dos WSAEHOSTDOWN EHOSTDOWN # in consts.sh
# dos WSAEHOSTUNREACH EHOSTUNREACH # in consts.sh
# dos WSAEALREADY EALREADY # in consts.sh
# dos WSAESTALE ESTALE # in consts.sh
# dos WSAEREMOTE EREMOTE # in consts.sh
# dos WSAEINTR EINTR # in consts.sh
# DOS ERRNO MULTIMAPPINGS
#
# These mappings are defined in a decentralized section which are

View file

@ -102,6 +102,9 @@ TEST(diagnose_syscall, getpid) {
// netbsd puts parent pid in edx
// xnu seems to just clobber it!
ASSERT_STREQ("rax rdx rcx r11", _gc(DiffContexts(&x, &y)));
} else if (IsWsl1()) {
// XXX: WSL1 must be emulating SYSCALL instructions.
ASSERT_STREQ("rax rcx", _gc(DiffContexts(&x, &y)));
} else {
ASSERT_STREQ("rax rcx r11", _gc(DiffContexts(&x, &y)));
}
@ -112,6 +115,9 @@ TEST(diagnose_syscall, testWriteSuccess) {
diagnose_syscall(__NR_write, 2, Z, 0, Z, Z, Z, Z, &x, &y);
if (IsFreebsd()) {
ASSERT_STREQ("rax rcx r8 r9 r10 r11", _gc(DiffContexts(&x, &y)));
} else if (IsWsl1()) {
// XXX: WSL1 must be emulating SYSCALL instructions.
ASSERT_STREQ("rax rcx", _gc(DiffContexts(&x, &y)));
} else {
ASSERT_STREQ("rax rcx r11", _gc(DiffContexts(&x, &y)));
}
@ -124,6 +130,9 @@ TEST(diagnose_syscall, testWriteFailed) {
ASSERT_STREQ("rax rcx r8 r9 r10 r11 cf", _gc(DiffContexts(&x, &y)));
} else if (IsBsd()) {
ASSERT_STREQ("rax rcx r11 cf", _gc(DiffContexts(&x, &y)));
} else if (IsWsl1()) {
// XXX: WSL1 must be emulating SYSCALL instructions.
ASSERT_STREQ("rax rcx", _gc(DiffContexts(&x, &y)));
} else {
ASSERT_STREQ("rax rcx r11", _gc(DiffContexts(&x, &y)));
}

View file

@ -199,7 +199,7 @@ TEST(sigaction, autoZombieSlayer) {
ASSERT_NE(-1, (pid = fork()));
if (!pid) _Exit(0);
// XXX: WSL does the wrong thing here.
if (__is_wsl()) usleep(10);
if (IsWsl1()) usleep(10);
ASSERT_SYS(ECHILD, -1, wait(0));
// clean up
ASSERT_SYS(0, 0, sigaction(SIGCHLD, &sa, 0));

View file

@ -326,7 +326,7 @@ TEST(ShowCrashReports, testDivideByZero) {
__die();
}
// XXX: WSL doesn't save and restore x87 registers to ucontext_t
if (!__is_wsl()) {
if (!IsWsl1()) {
if (!strstr(output, "3.141")) {
fprintf(stderr, "ERROR: crash report didn't have fpu register\n%s\n",
_gc(IndentLines(output, -1, 0, 4)));

View file

@ -53,7 +53,8 @@ TEST(sbrk, underflowsEnd_returnsEinval) {
}
TEST(sbrk, giantDelta_returnsEnomem) {
if (IsXnu()) return; // mmap polyfills this but brk doesn't right now
if (IsXnu()) return; // mmap polyfills this but brk doesn't right now
if (IsWsl1()) return; // WSL1 setrlimit() is busted
SPAWN(fork);
struct rlimit rl = {1024 * 1024, 1024 * 1024};
ASSERT_SYS(0, 0, setrlimit(RLIMIT_AS, &rl));

View file

@ -126,8 +126,8 @@ TEST(sendfile, testPositioning) {
ASSERT_EQ(-1, sendfile(4, 5, 0, 6));
ASSERT_TRUE(errno == EINVAL || errno == EPIPE);
errno = 0;
// XXX: WSL clobbers file offset on failure!
if (!__is_wsl()) {
// XXX: WSL1 clobbers file offset on failure!
if (!IsWsl1()) {
ASSERT_EQ(12, GetFileOffset(5));
}
_Exit(0);

View file

@ -22,6 +22,7 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/nt/version.h"
#include "libc/runtime/internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/sock/struct/sockaddr.h"
@ -165,7 +166,8 @@ TEST(unix, serverGoesDown_usingSendTo_unlink) { // much easier
ASSERT_SYS(0, 5, sendto(4, "hello", 5, 0, (void *)&addr, len));
ASSERT_SYS(0, 5, read(3, buf, 8));
ASSERT_SYS(0, 0, close(3));
ASSERT_SYS(ECONNREFUSED, -1, sendto(4, "hello", 5, 0, (void *)&addr, len));
ASSERT_SYS(IsWsl1() ? ENOTCONN : ECONNREFUSED, -1,
sendto(4, "hello", 5, 0, (void *)&addr, len));
ASSERT_SYS(0, 0, unlink(addr.sun_path));
ASSERT_SYS(ENOENT, -1, sendto(4, "hello", 5, 0, (void *)&addr, len));
ASSERT_SYS(0, 3, socket(AF_UNIX, SOCK_DGRAM, 0));

View file

@ -118,7 +118,6 @@ uint16_t g_sshport;
char g_hostname[128];
uint16_t g_runitdport;
volatile bool alarmed;
char g_ssh[PATH_MAX];
int __sys_execve(const char *, char *const[], char *const[]) hidden;
@ -473,8 +472,6 @@ int main(int argc, char *argv[]) {
}
CheckExists((g_runitd = argv[1]));
CheckExists((g_prog = argv[2]));
CHECK_NOTNULL(
commandv(firstnonnull(getenv("SSH"), "ssh"), g_ssh, sizeof(g_ssh)));
if (argc == 3) {
/* hosts list empty */
return 0;