mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 11:48:30 +00:00
Improve synchronization
- Fix bugs in kDos2Errno definition - malloc() should now be thread safe - Fix bug in rollup.com header generator - Fix open(O_APPEND) on the New Technology - Fix select() on the New Technology and test it - Work towards refactoring i/o for thread safety - Socket reads and writes on NT now poll for signals - Work towards i/o completion ports on the New Technology - Make read() and write() intermittently check for signals - Blinkenlights keyboard i/o so much better on NT w/ poll() - You can now poll() files and sockets at the same time on NT - Fix bug in appendr() that manifests with dlmalloc footers off
This commit is contained in:
parent
233144b19d
commit
933411ba99
266 changed files with 8761 additions and 4344 deletions
|
@ -18,6 +18,9 @@ int64_t CreateFileA(
|
|||
uint32_t dwFlagsAndAttributes, /* libc/nt/enum/fileflagandattributes.h */
|
||||
int64_t opt_hTemplateFile) paramsnonnull((1));
|
||||
|
||||
int GetNtOpenFlags(int flags, int mode, uint32_t *out_perm, uint32_t *out_share,
|
||||
uint32_t *out_disp, uint32_t *out_attr);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_CREATEFILE_H_ */
|
||||
|
|
|
@ -1,7 +1,68 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_SIO_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_ENUM_SIO_H_
|
||||
|
||||
#define kNtSioBspHandlePoll 0x4800001D
|
||||
#define kNtSioBaseHandle 0x48000022
|
||||
#define kNtSioAbsorbRtralert 0x98000005u
|
||||
#define kNtSioAcquirePortReservation 0x98000064u
|
||||
#define kNtSioAddressListChange 0x28000017u
|
||||
#define kNtSioAddressListQuery 0x48000016u
|
||||
#define kNtSioAddressListSort 0xc8000019u
|
||||
#define kNtSioApplyTransportSetting 0x98000013u
|
||||
#define kNtSioAssociateHandle 0x88000001u
|
||||
#define kNtSioAssociatePortReservation 0x98000066u
|
||||
#define kNtSioBaseHandle 0x48000022u
|
||||
#define kNtSioBspHandlePoll 0x4800001Du
|
||||
#define kNtSioDeletePeerTargetName 0x980000cbu
|
||||
#define kNtSioEnableCircularQueueing 0x28000002u
|
||||
#define kNtSioFindRoute 0x48000003u
|
||||
#define kNtSioFlush 0x28000004u
|
||||
#define kNtSioGetBroadcastAddress 0x48000005u
|
||||
#define kNtSioGetExtensionFunctionPointer 0xc8000006u
|
||||
#define kNtSioGetGroupQos 0xc8000008u
|
||||
#define kNtSioGetInterfaceList 0x4008747fu
|
||||
#define kNtSioGetMultipleExtensionFunctionPointer 0xc8000024u
|
||||
#define kNtSioGetQos 0xc8000007u
|
||||
#define kNtSioIndexAddMcast 0x9800000au
|
||||
#define kNtSioIndexBind 0x98000008u
|
||||
#define kNtSioIndexDelMcast 0x9800000bu
|
||||
#define kNtSioIndexMcastif 0x98000009u
|
||||
#define kNtSioKeepaliveVals 0x98000004u
|
||||
#define kNtSioLimitBroadcasts 0x98000007u
|
||||
#define kNtSioLoopbackFastPath 0x98000010u
|
||||
#define kNtSioMulticastScope 0x8800000au
|
||||
#define kNtSioMultipointLoopback 0x88000009u
|
||||
#define kNtSioQueryRssProcessorInfo 0x48000025u
|
||||
#define kNtSioQueryRssScalabilityInfo 0x580000d2u
|
||||
#define kNtSioQuerySecurity 0xd80000c9u
|
||||
#define kNtSioQueryTargetPnpHandle 0x48000018u
|
||||
#define kNtSioQueryTransportSetting 0x98000014u
|
||||
#define kNtSioQueryWfpAleEndpointHandle 0x580000cdu
|
||||
#define kNtSioQueryWfpConnectionRedirectContext 0x980000ddu
|
||||
#define kNtSioQueryWfpConnectionRedirectRecords 0x980000dcu
|
||||
#define kNtSioRcvall 0x98000001u
|
||||
#define kNtSioRcvallIf 0x9800000eu
|
||||
#define kNtSioRcvallIgmpmcast 0x98000003u
|
||||
#define kNtSioRcvallMcast 0x98000002u
|
||||
#define kNtSioRcvallMcastIf 0x9800000du
|
||||
#define kNtSioReleasePortReservation 0x98000065u
|
||||
#define kNtSioReserved1 0x8800001au
|
||||
#define kNtSioReserved2 0x88000021u
|
||||
#define kNtSioRoutingInterfaceChange 0x88000015u
|
||||
#define kNtSioRoutingInterfaceQuery 0xc8000014u
|
||||
#define kNtSioSetGroupQos 0x8800000cu
|
||||
#define kNtSioSetPeerTargetName 0x980000cau
|
||||
#define kNtSioSetPriorityHint 0x98000018u
|
||||
#define kNtSioSetQos 0x8800000bu
|
||||
#define kNtSioSetSecurity 0x980000c8u
|
||||
#define kNtSioSetWfpConnectionRedirectRecords 0x980000deu
|
||||
#define kNtSioSocketCloseNotify 0x9800000du
|
||||
#define kNtSioSocketUsageNotification 0x980000ccu
|
||||
#define kNtSioTcpInfo 0xd8000027u
|
||||
#define kNtSioTcpInitialRto 0x98000011u
|
||||
#define kNtSioTcpSetAckFrequency 0x98000017u
|
||||
#define kNtSioTcpSetIcw 0x98000016u
|
||||
#define kNtSioTranslateHandle 0xc800000du
|
||||
#define kNtSioUcastIf 0x98000006u
|
||||
#define kNtSioUdpConnreset 0x9800000cu
|
||||
#define kNtSioUdpNetreset 0x9800000fu
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_SIO_H_ */
|
||||
|
|
12
libc/nt/enum/wsa.h
Normal file
12
libc/nt/enum/wsa.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_WSA_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_ENUM_WSA_H_
|
||||
#include "libc/nt/errors.h"
|
||||
|
||||
#define kNtWsaInvalidHandle kNtErrorInvalidHandle
|
||||
#define kNtWsaNotEnoughMemory kNtErrorNotEnoughMemory
|
||||
#define kNtWsaInvalidParameter kNtErrorInvalidParameter
|
||||
#define kNtWsaIoPending kNtErrorIoPending
|
||||
#define kNtWsaIoIncomplete kNtErrorIoIncomplete
|
||||
#define kNtWsaOperationAborted kNtErrorOperationAborted
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_WSA_H_ */
|
71
libc/nt/enum/wsaid.h
Normal file
71
libc/nt/enum/wsaid.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_WSAID_H_
|
||||
#define COSMOPOLITAN_LIBC_NT_ENUM_WSAID_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define WSAID_WSAPOLL \
|
||||
{ \
|
||||
0x18C76F85, 0xDC66, 0x4964, { \
|
||||
0x97, 0x2E, 0x23, 0xC2, 0x72, 0x38, 0x31, 0x2B \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WSAID_WSARECVMSG \
|
||||
{ \
|
||||
0xf689d7c8, 0x6f1f, 0x436b, { \
|
||||
0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WSAID_WSASENDMSG \
|
||||
{ \
|
||||
0xa441e712, 0x754f, 0x43ca, { \
|
||||
0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WSAID_CONNECTEX \
|
||||
{ \
|
||||
0x25a207b9, 0xddf3, 0x4660, { \
|
||||
0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WSAID_ACCEPTEX \
|
||||
{ \
|
||||
0xb5367df1, 0xcbac, 0x11cf, { \
|
||||
0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WSAID_GETACCEPTEXSOCKADDRS \
|
||||
{ \
|
||||
0xb5367df2, 0xcbac, 0x11cf, { \
|
||||
0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WSAID_TRANSMITFILE \
|
||||
{ \
|
||||
0xb5367df0, 0xcbac, 0x11cf, { \
|
||||
0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WSAID_TRANSMITPACKETS \
|
||||
{ \
|
||||
0xd9689da0, 0x1f90, 0x11d3, { \
|
||||
0x99, 0x71, 0x00, 0xc0, 0x4f, 0x68, 0xc8, 0x76 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WSAID_DISCONNECTEX \
|
||||
{ \
|
||||
0x7fda2e11, 0x8630, 0x436f, { \
|
||||
0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57 \
|
||||
} \
|
||||
}
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_WSAID_H_ */
|
|
@ -179,7 +179,7 @@ int64_t FindFirstFileEx(const char16_t *lpFileName, int fInfoLevelId,
|
|||
uint32_t dwAdditionalFlags);
|
||||
bool32 FindNextFile(int64_t hFindFile,
|
||||
struct NtWin32FindData *out_lpFindFileData);
|
||||
bool32 FindClose(int64_t inout_hFindFile);
|
||||
bool32 FindClose(int64_t hFindFile);
|
||||
|
||||
int64_t FindFirstVolume(char16_t *out_lpszVolumeName, uint32_t cchBufferLength);
|
||||
bool32 FindNextVolume(int64_t inout_hFindVolume, char16_t *out_lpszVolumeName,
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
#define kNtPipeRejectRemoteClients 0x00000008
|
||||
|
||||
/* CreateNamedPipe::nMaxInstances */
|
||||
#define NT_PIPE_UNLIMITED_INSTANCES 255
|
||||
#define kNtPipeUnlimitedInstances 255
|
||||
|
||||
/* CreateNamedPipeInfo */
|
||||
#define PIPE_CLIENT_END 0x00000000
|
||||
#define PIPE_SERVER_END 0x00000001
|
||||
/* GetNamedPipeInfo */
|
||||
#define kNtPipeClientEnd 0x00000000
|
||||
#define kNtPipeServerEnd 0x00000001
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
.imp kernel32,__imp_FindClose,FindClose,0
|
||||
|
||||
.text.windows
|
||||
FindClose:
|
||||
__FindClose:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
|
@ -11,5 +11,5 @@ FindClose:
|
|||
call *__imp_FindClose(%rip)
|
||||
leave
|
||||
ret
|
||||
.endfn FindClose,globl
|
||||
.endfn __FindClose,globl
|
||||
.previous
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
.imp kernel32,__imp_ReOpenFile,ReOpenFile,0
|
||||
|
||||
.text.windows
|
||||
ReOpenFile:
|
||||
__ReOpenFile:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_ReOpenFile(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn ReOpenFile,globl
|
||||
.endfn __ReOpenFile,globl
|
||||
.previous
|
||||
|
|
|
@ -323,7 +323,6 @@ imp 'FindActCtxSectionStringA' FindActCtxSectionStringA kernel32 373
|
|||
imp 'FindActCtxSectionStringWWorker' FindActCtxSectionStringWWorker kernel32 375
|
||||
imp 'FindAtom' FindAtomW kernel32 377
|
||||
imp 'FindAtomA' FindAtomA kernel32 376
|
||||
imp 'FindClose' FindClose kernel32 0 1
|
||||
imp 'FindCloseChangeNotification' FindCloseChangeNotification kernel32 0
|
||||
imp 'FindFirstChangeNotification' FindFirstChangeNotificationW kernel32 0
|
||||
imp 'FindFirstChangeNotificationA' FindFirstChangeNotificationA kernel32 0
|
||||
|
@ -993,7 +992,6 @@ imp 'QuirkIsEnabledWorker' QuirkIsEnabledWorker kernel32 1119
|
|||
imp 'RaiseException' RaiseException kernel32 0
|
||||
imp 'RaiseFailFastException' RaiseFailFastException kernel32 0
|
||||
imp 'RaiseInvalid16BitExeError' RaiseInvalid16BitExeError kernel32 1122
|
||||
imp 'ReOpenFile' ReOpenFile kernel32 0 4 # TODO(jart): 6.2 and higher
|
||||
imp 'ReadConsole' ReadConsoleW kernel32 0 5
|
||||
imp 'ReadConsoleA' ReadConsoleA kernel32 0 5
|
||||
imp 'ReadConsoleInput' ReadConsoleInputW kernel32 0 4
|
||||
|
@ -1357,6 +1355,7 @@ imp '__CreateProcess' CreateProcessW kernel32 0 10
|
|||
imp '__CreateThread' CreateThread kernel32 0 6
|
||||
imp '__DeleteFile' DeleteFileW kernel32 0 1
|
||||
imp '__DeviceIoControl' DeviceIoControl kernel32 0 8
|
||||
imp '__FindClose' FindClose kernel32 0 1
|
||||
imp '__FindFirstFile' FindFirstFileW kernel32 0 2
|
||||
imp '__FindNextFile' FindNextFileW kernel32 0 2
|
||||
imp '__FlushFileBuffers' FlushFileBuffers kernel32 0 1
|
||||
|
@ -1366,6 +1365,7 @@ imp '__GetFileAttributes' GetFileAttributesW kernel32 0 1
|
|||
imp '__MapViewOfFileEx' MapViewOfFileEx kernel32 0 6
|
||||
imp '__MapViewOfFileExNuma' MapViewOfFileExNuma kernel32 0 7
|
||||
imp '__OpenProcess' OpenProcess kernel32 0 3
|
||||
imp '__ReOpenFile' ReOpenFile kernel32 0 4 # TODO(jart): 6.2 and higher
|
||||
imp '__RemoveDirectory' RemoveDirectoryW kernel32 0 1
|
||||
imp '__SetCurrentDirectory' SetCurrentDirectoryW kernel32 0 1
|
||||
imp '__TerminateProcess' TerminateProcess kernel32 0 2
|
||||
|
@ -3956,8 +3956,8 @@ imp 'sys_getprotobyname_nt' getprotobyname ws2_32 53
|
|||
imp 'sys_getprotobynumber_nt' getprotobynumber ws2_32 54
|
||||
imp 'sys_getservbyname_nt' getservbyname ws2_32 55
|
||||
imp 'sys_getservbyport_nt' getservbyport ws2_32 56
|
||||
imp 'sys_recv_nt' recv ws2_32 16 4 # we're using WSARecvFrom()
|
||||
imp 'sys_send_nt' send ws2_32 19 4 # we're using WSASendTo()
|
||||
imp '__sys_recv_nt' recv ws2_32 16 4 # we're using WSARecvFrom()
|
||||
imp '__sys_send_nt' send ws2_32 19 4 # we're using WSASendTo()
|
||||
|
||||
# IPHLPAPI.DLL
|
||||
#
|
||||
|
|
|
@ -43,12 +43,12 @@
|
|||
│ cosmopolitan § new technology » winsock ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
#define kNtCompEqual 0
|
||||
#define kNtCompNotless 1
|
||||
|
||||
#define kNtWsaFlagOverlapped 0x01
|
||||
#define kNtWsaFlagNoHandleInherit 0x80
|
||||
|
||||
#define kNtCompEqual 0
|
||||
#define kNtCompNotless 1
|
||||
|
||||
#define kNtTfDisconnect 0x01
|
||||
#define kNtTfReuseSocket 0x02
|
||||
#define kNtTfWriteBehind 0x04
|
||||
|
@ -60,33 +60,6 @@
|
|||
#define kNtSoUpdateAcceptContext 0x700B
|
||||
#define kNtSoUpdateConnectContext 0x7010
|
||||
|
||||
#define kNtSioAddressListChange 0x28000017u
|
||||
#define kNtSioAddressListQuery 0x48000016u
|
||||
#define kNtSioAddressListSort 0xC8000019u
|
||||
#define kNtSioAssociateHandle 0x88000001u
|
||||
#define kNtSioEnableCircularQueueing 0x28000002u
|
||||
#define kNtSioFindRoute 0x48000003u
|
||||
#define kNtSioFlush 0x28000004u
|
||||
#define kNtSioGetBroadcastAddress 0x48000005u
|
||||
#define kNtSioGetExtensionFunctionPointer 0xC8000006u
|
||||
#define kNtSioGetGroupQos 0xC8000008u
|
||||
#define kNtSioGetQos 0xC8000007u
|
||||
#define kNtSioMulticastScope 0x8800000Au
|
||||
#define kNtSioMultipointLoopback 0x88000009u
|
||||
#define kNtSioQueryRssProcessorInfo 0x48000025u
|
||||
#define kNtSioQueryTargetPnpHandle 0x48000018u
|
||||
#define kNtSioReserved1 0x8800001Au
|
||||
#define kNtSioReserved2 0x88000021u
|
||||
#define kNtSioRoutingInterfaceChange 0x88000015u
|
||||
#define kNtSioRoutingInterfaceQuery 0xC8000014u
|
||||
#define kNtSioSetGroupQos 0x8800000Cu
|
||||
#define kNtSioSetQos 0x8800000Bu
|
||||
#define kNtSioSocketCloseNotify 0x9800000Du
|
||||
#define kNtSioTranslateHandle 0xC800000Du
|
||||
#define kNtSioUdpConnreset 0x9800000Cu
|
||||
#define kNtSioUdpNetreset 0x9800000Fu
|
||||
#define kNtSioGetInterfaceList 0x4008747fu /* _IOR('t', 127, ULONG) */
|
||||
|
||||
#define kNtNspNotifyImmediately 0
|
||||
#define kNtNspNotifyHwnd 1
|
||||
#define kNtNspNotifyEvent 2
|
||||
|
@ -548,11 +521,6 @@ void GetAcceptExSockaddrs(
|
|||
struct sockaddr **out_RemoteSockaddr /*[*RemoteSockaddrLength]*/,
|
||||
int *out_RemoteSockaddrLength);
|
||||
|
||||
bool32 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 DisconnectEx(int64_t s, struct NtOverlapped *inout_opt_lpOverlapped,
|
||||
uint32_t dwFlags, uint32_t dwReserved);
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
.imp ws2_32,__imp_recv,recv,16
|
||||
|
||||
.text.windows
|
||||
sys_recv_nt:
|
||||
__sys_recv_nt:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_recv(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn sys_recv_nt,globl
|
||||
.endfn __sys_recv_nt,globl
|
||||
.previous
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
.imp ws2_32,__imp_send,send,19
|
||||
|
||||
.text.windows
|
||||
sys_send_nt:
|
||||
__sys_send_nt:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_send(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn sys_send_nt,globl
|
||||
.endfn __sys_send_nt,globl
|
||||
.previous
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue