mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Support non-blocking i/o across platforms
This change introduces new tests for `O_NONBLOCK` and `SOCK_NONBLOCK` to confirm that non-blocking i/o is now working on all supported platforms, including Windows. For example, you can now say on Windows, MacOS, etc.: socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP); To create a non-blocking IPv4 TCP socket. Or you can enable non-blocking i/o on an existing socket / pipe / etc. file descriptor by calling fcntl fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); This functionality is polyfilled on older Linux kernels too, e.g. RHEL5. Now that fcntl() support is much better the FIOCLEX / FIONCLEX polyfills for ioctl() have been removed since they're ugly non-POSIX diameond APIs This change fixes a weakness in kprintf() that was causing Windows trace tools to frequently crash.
This commit is contained in:
parent
5c9e03e3e0
commit
1d4eb08fa1
102 changed files with 678 additions and 331 deletions
|
@ -11,18 +11,16 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define FD_READ (1 << FD_READ_BIT)
|
||||
#define FD_READ_BIT 0
|
||||
#define FD_WRITE (1 << FD_WRITE_BIT)
|
||||
#define FD_WRITE_BIT 1
|
||||
#define FD_OOB (1 << FD_OOB_BIT)
|
||||
#define FD_OOB_BIT 2
|
||||
#define FD_ACCEPT (1 << FD_ACCEPT_BIT)
|
||||
#define FD_ACCEPT_BIT 3
|
||||
#define FD_CONNECT (1 << FD_CONNECT_BIT)
|
||||
#define FD_CONNECT_BIT 4
|
||||
#define FD_CLOSE (1 << FD_CLOSE_BIT)
|
||||
#define FD_CLOSE_BIT 5
|
||||
#define kNtFdRead 1
|
||||
#define kNtFdWrite 2
|
||||
#define kNtFdOob 4
|
||||
#define kNtFdAccept 8
|
||||
#define kNtFdConnect 16
|
||||
#define kNtFdClose 32
|
||||
#define kNtFdQos 64
|
||||
#define kNtFdGroupQos 128
|
||||
#define kNtFdRoutingInterfaceChange 256
|
||||
#define kNtFdAddressListChange 512
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -34,17 +32,6 @@ struct SockFd {
|
|||
int protocol;
|
||||
uint32_t rcvtimeo;
|
||||
uint32_t sndtimeo;
|
||||
bool32 (*__msabi ConnectEx)(int64_t s, const struct sockaddr *name,
|
||||
int namelen, const void *opt_lpSendBuffer,
|
||||
uint32_t dwSendDataLength,
|
||||
uint32_t *out_lpdwBytesSent,
|
||||
struct NtOverlapped *inout_lpOverlapped);
|
||||
bool32 (*__msabi AcceptEx)(
|
||||
int64_t sListenSocket, int64_t sAcceptSocket,
|
||||
void *out_lpOutputBuffer /*[recvlen+local+remoteaddrlen]*/,
|
||||
uint32_t dwReceiveDataLength, uint32_t dwLocalAddressLength,
|
||||
uint32_t dwRemoteAddressLength, uint32_t *out_lpdwBytesReceived,
|
||||
struct NtOverlapped *inout_lpOverlapped);
|
||||
};
|
||||
|
||||
errno_t __dos2errno(uint32_t) _Hide;
|
||||
|
@ -59,7 +46,6 @@ int32_t __sys_socket(int32_t, int32_t, int32_t) _Hide;
|
|||
int32_t __sys_socketpair(int32_t, int32_t, int32_t, int32_t[2]) _Hide;
|
||||
|
||||
int32_t sys_accept4(int32_t, void *, uint32_t *, int) dontdiscard _Hide;
|
||||
int32_t sys_accept(int32_t, void *, uint32_t *) _Hide;
|
||||
int32_t sys_bind(int32_t, const void *, uint32_t) _Hide;
|
||||
int32_t sys_connect(int32_t, const void *, uint32_t) _Hide;
|
||||
int32_t sys_getsockopt(int32_t, int32_t, int32_t, void *, uint32_t *) _Hide;
|
||||
|
@ -99,8 +85,6 @@ size_t __iovec2nt(struct NtIovec[hasatleast 16], const struct iovec *,
|
|||
void WinSockInit(void) _Hide;
|
||||
int64_t __winsockerr(void) nocallback _Hide;
|
||||
int __fixupnewsockfd(int, int) _Hide;
|
||||
int __wsablock(int64_t, struct NtOverlapped *, uint32_t *, bool,
|
||||
uint32_t) _Hide;
|
||||
int64_t __winsockblock(int64_t, unsigned, int64_t, uint32_t) _Hide;
|
||||
struct SockFd *_dupsockfd(struct SockFd *) _Hide;
|
||||
int64_t GetNtBaseSocket(int64_t) _Hide;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue