Add epoll and do more release readiness changes

This change also pays off some of the remaining technical debt with
stdio, file descriptors, and memory managemnt polyfills.
This commit is contained in:
Justine Tunney committed 2020-11-28 12:01:51 -08:00
1 parent a9ea949df8
commit 3e4fd4b0ad
271 files changed
+5706 -1365

No files matched your search

+1 -1
View File
@@ -55,7 +55,7 @@ static textwindows int copyfile$nt(const char *src, const char *dst,
}
return 0;
} else {
return winerr();
return __winerr();
}
}
+2 -2
View File
@@ -74,7 +74,7 @@ static textwindows noinline DIR *opendir$nt(const char *name) {
if ((res->fd = FindFirstFile(name16, &res->windata)) != -1) {
return res;
} else {
winerr();
__winerr();
free(res);
return NULL;
}
@@ -220,7 +220,7 @@ int closedir(DIR *dir) {
if (!IsWindows()) {
rc = close(dir->fd);
} else {
rc = FindClose(dir->fd) ? 0 : winerr();
rc = FindClose(dir->fd) ? 0 : __winerr();
}
free(dir);
} else {
+8 -6
View File
@@ -67,7 +67,7 @@ textwindows void WinMainForked(void) {
char16_t *p;
uint64_t size;
char16_t var[21 + 1 + 21 + 1];
uint32_t i, varlen, protect, access;
uint32_t i, varlen, protect, access, oldprot;
varlen = GetEnvironmentVariable(u"_FORK", var, ARRAYLEN(var));
if (!varlen || varlen >= ARRAYLEN(var)) return;
p = var;
@@ -98,11 +98,13 @@ textwindows void WinMainForked(void) {
break;
}
if (_mmi.p[i].flags & MAP_PRIVATE) {
MapViewOfFileExNuma(
(_mmi.p[i].h = CreateFileMappingNuma(-1, NULL, protect, 0, size, NULL,
kNtNumaNoPreferredNode)),
access, 0, 0, size, addr, kNtNumaNoPreferredNode);
MapViewOfFileExNuma((_mmi.p[i].h = CreateFileMappingNuma(
-1, NULL, kNtPageExecuteReadwrite, 0, size, NULL,
kNtNumaNoPreferredNode)),
kNtFileMapRead | kNtFileMapWrite | kNtFileMapExecute,
0, 0, size, addr, kNtNumaNoPreferredNode);
ReadAll(h, addr, size);
VirtualProtect(addr, size, protect, &oldprot);
} else {
MapViewOfFileExNuma(_mmi.p[i].h, access, 0, 0, size, addr,
kNtNumaNoPreferredNode);
@@ -148,7 +150,7 @@ textwindows int fork$nt(void) {
}
unsetenv("_FORK");
} else {
rc = winerr();
rc = __winerr();
}
} else {
rc = 0;
+1 -1
View File
@@ -78,7 +78,7 @@ textwindows int ntspawn(
opt_out_lpProcessInformation)) {
rc = 0;
} else {
rc = winerr();
rc = __winerr();
}
} else {
rc = -1;
+2 -2
View File
@@ -49,14 +49,14 @@ textwindows int spawnve$nt(unsigned flags, int stdiofds[3], const char *program,
sti.cb = sizeof(sti);
sti.dwFlags = kNtStartfUsestdhandles;
if ((pid = createfd()) == -1) return -1;
if ((pid = __getemptyfd()) == -1) return -1;
for (i = 0; i < 3; ++i) {
if (stdiofds[i] == -1) {
x = &h;
y = &sti.stdiofds[i];
if (kIoMotion[i]) xchg(&x, &y);
if ((tubes[i] = createfd()) != -1 &&
if ((tubes[i] = __getemptyfd()) != -1 &&
CreatePipe(x, y, &kNtIsInheritable, 0)) {
g_fds.p[tubes[i]].handle = h;
} else {
+1 -1
View File
@@ -76,7 +76,7 @@ int ttyname_r(int fd, char *buf, size_t size) {
} else if (IsFreebsd()) {
return ttyname$freebsd(fd, buf, size);
} else if (IsWindows()) {
if (isfdkind(fd, kFdFile)) {
if (__isfdkind(fd, kFdFile)) {
return ttyname$nt(fd, buf, size);
} else {
return ebadf();