mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-29 14:00:29 +00:00
Put more thought into i/o polyfills
wait4() is now solid enough to run `make -j100` on Windows. You can now use MSG_DONTWAIT on Windows. There was a handle leak in accept() that's been fixed. Our WIN32 overlapped i/o code has been simplified. Priority class now inherits into subprocesses, so the verynice command will work and the signal mask will now be inherited by execve() and posix_spawn()
This commit is contained in:
parent
736fdb757a
commit
e961385e55
52 changed files with 679 additions and 487 deletions
|
@ -71,7 +71,7 @@ TryAgain:
|
|||
switch (__imp_GetLastError()) {
|
||||
case kNtErrorPipeBusy:
|
||||
if (micros >= 1024) __imp_Sleep(micros / 1024);
|
||||
if (micros / 1024 < __SIG_IO_INTERVAL_MS) micros <<= 1;
|
||||
if (micros < 1024 * 1024) micros <<= 1;
|
||||
goto TryAgain;
|
||||
case kNtErrorAccessDenied:
|
||||
// GetNtOpenFlags() always greedily requests execute permissions
|
||||
|
|
|
@ -50,7 +50,7 @@ TryAgain:
|
|||
nDefaultTimeOutMs, opt_lpSecurityAttributes);
|
||||
if (hServer == -1 && __imp_GetLastError() == kNtErrorPipeBusy) {
|
||||
if (micros >= 1024) __imp_Sleep(micros / 1024);
|
||||
if (micros / 1024 < __SIG_IO_INTERVAL_MS) micros <<= 1;
|
||||
if (micros < 1024 * 1024) micros <<= 1;
|
||||
goto TryAgain;
|
||||
}
|
||||
if (hServer == -1) __winerr();
|
||||
|
|
|
@ -23,9 +23,7 @@
|
|||
|
||||
static bool _pthread_deref(struct PosixThread *pt) {
|
||||
int refs = atomic_load_explicit(&pt->pt_refs, memory_order_acquire);
|
||||
if (!refs) return true;
|
||||
unassert(refs > 0);
|
||||
return !atomic_fetch_sub(&pt->pt_refs, 1);
|
||||
return !refs || !atomic_fetch_sub(&pt->pt_refs, 1);
|
||||
}
|
||||
|
||||
void _pthread_unref(struct PosixThread *pt) {
|
||||
|
|
|
@ -42,7 +42,7 @@ textwindows int __sig_mask(int how, const sigset_t *neu, sigset_t *old) {
|
|||
if (how == SIG_BLOCK) {
|
||||
oldmask = atomic_fetch_or_explicit(mask, *neu, memory_order_acq_rel);
|
||||
} else if (how == SIG_UNBLOCK) {
|
||||
oldmask = atomic_fetch_and_explicit(mask, *neu, memory_order_acq_rel);
|
||||
oldmask = atomic_fetch_and_explicit(mask, ~*neu, memory_order_acq_rel);
|
||||
} else { // SIG_SETMASK
|
||||
oldmask = atomic_exchange_explicit(mask, *neu, memory_order_acq_rel);
|
||||
}
|
||||
|
|
|
@ -30,9 +30,7 @@ __msabi extern typeof(WSARecv) *const __imp_WSARecv;
|
|||
|
||||
/**
|
||||
* Receives data from Windows socket.
|
||||
*
|
||||
* @return 0 on success, or -1 on failure
|
||||
* @note this wrapper takes care of ABI, STRACE(), and __winerr()
|
||||
*/
|
||||
textwindows int WSARecv(
|
||||
uint64_t s, const struct NtIovec *inout_lpBuffers, uint32_t dwBufferCount,
|
||||
|
@ -57,9 +55,6 @@ textwindows int WSARecv(
|
|||
if (opt_out_lpNumberOfBytesRecvd) {
|
||||
*opt_out_lpNumberOfBytesRecvd = NumberOfBytesRecvd;
|
||||
}
|
||||
if (rc == -1) {
|
||||
__winsockerr();
|
||||
}
|
||||
if (UNLIKELY(__strace > 0) && strace_enabled(0) > 0) {
|
||||
kprintf(STRACE_PROLOGUE "WSARecv(%lu, [", s);
|
||||
DescribeIovNt(inout_lpBuffers, dwBufferCount,
|
||||
|
@ -73,9 +68,6 @@ textwindows int WSARecv(
|
|||
rc = __imp_WSARecv(s, inout_lpBuffers, dwBufferCount,
|
||||
opt_out_lpNumberOfBytesRecvd, inout_lpFlags,
|
||||
opt_inout_lpOverlapped, opt_lpCompletionRoutine);
|
||||
if (rc == -1) {
|
||||
__winsockerr();
|
||||
}
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -29,9 +29,7 @@ __msabi extern typeof(WSARecvFrom) *const __imp_WSARecvFrom;
|
|||
|
||||
/**
|
||||
* Receives data from Windows socket.
|
||||
*
|
||||
* @return 0 on success, or -1 on failure
|
||||
* @note this wrapper takes care of ABI, STRACE(), and __winerr()
|
||||
*/
|
||||
textwindows int WSARecvFrom(
|
||||
uint64_t s, const struct NtIovec *inout_lpBuffers, uint32_t dwBufferCount,
|
||||
|
@ -52,9 +50,6 @@ textwindows int WSARecvFrom(
|
|||
if (opt_out_lpNumberOfBytesRecvd) {
|
||||
*opt_out_lpNumberOfBytesRecvd = NumberOfBytesRecvd;
|
||||
}
|
||||
if (rc == -1) {
|
||||
__winerr();
|
||||
}
|
||||
if (UNLIKELY(__strace > 0) && strace_enabled(0) > 0) {
|
||||
kprintf(STRACE_PROLOGUE "WSARecvFrom(%lu, [", s);
|
||||
DescribeIovNt(inout_lpBuffers, dwBufferCount,
|
||||
|
@ -69,9 +64,6 @@ textwindows int WSARecvFrom(
|
|||
opt_out_lpNumberOfBytesRecvd, inout_lpFlags,
|
||||
opt_out_fromsockaddr, opt_inout_fromsockaddrlen,
|
||||
opt_inout_lpOverlapped, opt_lpCompletionRoutine);
|
||||
if (rc == -1) {
|
||||
__winerr();
|
||||
}
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue