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 2020-11-28 12:01:51 -08:00
parent a9ea949df8
commit 3e4fd4b0ad
271 changed files with 5706 additions and 1365 deletions

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_AcquireSRWLockExclusive,AcquireSRWLockExclusive,683
.text.windows
AcquireSRWLockExclusive:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_AcquireSRWLockExclusive(%rip)
leave
ret
.endfn AcquireSRWLockExclusive,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_AcquireSRWLockShared,AcquireSRWLockShared,684
.text.windows
AcquireSRWLockShared:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_AcquireSRWLockShared(%rip)
leave
ret
.endfn AcquireSRWLockShared,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_DeleteCriticalSection,DeleteCriticalSection,0
.text.windows
DeleteCriticalSection:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_DeleteCriticalSection(%rip)
leave
ret
.endfn DeleteCriticalSection,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_EnterCriticalSection,EnterCriticalSection,0
.text.windows
EnterCriticalSection:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_EnterCriticalSection(%rip)
leave
ret
.endfn EnterCriticalSection,globl
.previous

View file

@ -1,2 +1,14 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_GetTickCount64,GetTickCount64,780
.text.windows
GetTickCount64:
push %rbp
mov %rsp,%rbp
.profilable
sub $32,%rsp
call *__imp_GetTickCount64(%rip)
leave
ret
.endfn GetTickCount64,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_InitializeCriticalSection,InitializeCriticalSection,0
.text.windows
InitializeCriticalSection:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_InitializeCriticalSection(%rip)
leave
ret
.endfn InitializeCriticalSection,globl
.previous

View file

@ -1,5 +1,5 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_InitializeCriticalSectionAndSpinCount,InitializeCriticalSectionAndSpinCount,856
.imp KernelBase,__imp_InitializeCriticalSectionAndSpinCount,InitializeCriticalSectionAndSpinCount,0
.text.windows
InitializeCriticalSectionAndSpinCount:

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_InitializeSRWLock,InitializeSRWLock,1128
.text.windows
InitializeSRWLock:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_InitializeSRWLock(%rip)
leave
ret
.endfn InitializeSRWLock,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_LeaveCriticalSection,LeaveCriticalSection,0
.text.windows
LeaveCriticalSection:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_LeaveCriticalSection(%rip)
leave
ret
.endfn LeaveCriticalSection,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_ReleaseSRWLockExclusive,ReleaseSRWLockExclusive,1341
.text.windows
ReleaseSRWLockExclusive:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_ReleaseSRWLockExclusive(%rip)
leave
ret
.endfn ReleaseSRWLockExclusive,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_ReleaseSRWLockShared,ReleaseSRWLockShared,1342
.text.windows
ReleaseSRWLockShared:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_ReleaseSRWLockShared(%rip)
leave
ret
.endfn ReleaseSRWLockShared,globl
.previous

View file

@ -0,0 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_SetCriticalSectionSpinCount,SetCriticalSectionSpinCount,0
.text.windows
SetCriticalSectionSpinCount:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_SetCriticalSectionSpinCount(%rip),%rax
jmp __sysv2nt
.endfn SetCriticalSectionSpinCount,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_TryAcquireSRWLockExclusive,TryAcquireSRWLockExclusive,1467
.text.windows
TryAcquireSRWLockExclusive:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_TryAcquireSRWLockExclusive(%rip)
leave
ret
.endfn TryAcquireSRWLockExclusive,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_TryAcquireSRWLockShared,TryAcquireSRWLockShared,1468
.text.windows
TryAcquireSRWLockShared:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_TryAcquireSRWLockShared(%rip)
leave
ret
.endfn TryAcquireSRWLockShared,globl
.previous

View file

@ -0,0 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp KernelBase,__imp_TryEnterCriticalSection,TryEnterCriticalSection,0
.text.windows
TryEnterCriticalSection:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_TryEnterCriticalSection(%rip)
leave
ret
.endfn TryEnterCriticalSection,globl
.previous

13
libc/nt/enum/afd.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_AFD_H_
#define COSMOPOLITAN_LIBC_NT_ENUM_AFD_H_
#define kNtAfdPollReceive 0x0001
#define kNtAfdPollReceiveExpedited 0x0002
#define kNtAfdPollSend 0x0004
#define kNtAfdPollDisconnect 0x0008
#define kNtAfdPollAbort 0x0010
#define kNtAfdPollLocalClose 0x0020
#define kNtAfdPollAccept 0x0080
#define kNtAfdPollConnectFail 0x0100
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_AFD_H_ */

View file

@ -1,13 +1,12 @@
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_FILEMAPFLAGS_H_
#define COSMOPOLITAN_LIBC_NT_ENUM_FILEMAPFLAGS_H_
/* Choose subset of NtPageFlags passed earlier. */
#define kNtFileMapCopy 0x00000001u
#define kNtFileMapWrite 0x00000002u
#define kNtFileMapRead 0x00000004u
#define kNtFileMapExecute 0x00000020u
#define kNtFileMapReserve 0x80000000u
#define kNtFileMapCopy 0x00000001u
#define kNtFileMapWrite 0x00000002u
#define kNtFileMapRead 0x00000004u
#define kNtFileMapExecute 0x00000020u
#define kNtFileMapReserve 0x80000000u
#define kNtFileMapTargetsInvalid 0x40000000u
#define kNtFileMapLargePages 0x20000000u
#define kNtFileMapLargePages 0x20000000u
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_FILEMAPFLAGS_H_ */

View file

@ -2,5 +2,6 @@
#define COSMOPOLITAN_LIBC_NT_ENUM_IOCTL_H_
#define kNtIoctlDiskGetDriveGeometry 0x00070000u
#define kNtIoctlAfdPoll 0x00012024u
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_IOCTL_H_ */

10
libc/nt/enum/keyedevent.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_KEYEDEVENT_H_
#define COSMOPOLITAN_LIBC_NT_ENUM_KEYEDEVENT_H_
#include "libc/nt/enum/accessmask.h"
#define kNtKeyedeventWait 0x00000001u
#define kNtKeyedeventWake 0x00000002u
#define kNtKeyedeventAllAccess \
(kNtStandardRightsRequired | kNtKeyedeventWait | kNtKeyedeventWake)
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_KEYEDEVENT_H_ */

7
libc/nt/enum/sio.h Normal file
View file

@ -0,0 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_NT_ENUM_SIO_H_
#define COSMOPOLITAN_LIBC_NT_ENUM_SIO_H_
#define kNtSioBspHandlePoll 0x4800001D
#define kNtSioBaseHandle 0x48000022
#endif /* COSMOPOLITAN_LIBC_NT_ENUM_SIO_H_ */

View file

@ -2,79 +2,82 @@
#define COSMOPOLITAN_LIBC_NT_STATUS_H_
/* high two bits = {success,informational,warning,error} */
#define kNtStatusWait0 0x00000000 /* success statuses */
#define kNtStatusAbandonedWait0 0x00000080
#define kNtStatusUserApc 0x000000C0
#define kNtStatusTimeout 0x00000102
#define kNtStatusPending 0x00000103
#define kNtStatusGuardPageViolation 0x80000001 /* warning statuses */
#define kNtStatusDatatypeMisalignment 0x80000002
#define kNtStatusBreakpoint 0x80000003
#define kNtStatusSingleStep 0x80000004
#define kNtStatusLongjump 0x80000026
#define kNtStatusUnwindConsolidate 0x80000029
#define kNtStatusAccessViolation 0xC0000005 /* error statuses */
#define kNtStatusInPageError 0xC0000006
#define kNtStatusInvalidHandle 0xC0000008
#define kNtStatusInvalidParameter 0xC000000D
#define kNtStatusNoMemory 0xC0000017
#define kNtStatusIllegalInstruction 0xC000001D
#define kNtStatusNoncontinuableException 0xC0000025
#define kNtStatusInvalidDisposition 0xC0000026
#define kNtStatusArrayBoundsExceeded 0xC000008C
#define kNtStatusFloatDenormalOperand 0xC000008D
#define kNtStatusFloatDivideByZero 0xC000008E
#define kNtStatusFloatInexactResult 0xC000008F
#define kNtStatusFloatInvalidOperation 0xC0000090
#define kNtStatusFloatOverflow 0xC0000091
#define kNtStatusFloatStackCheck 0xC0000092
#define kNtStatusFloatUnderflow 0xC0000093
#define kNtStatusIntegerDivideBYZero 0xC0000094
#define kNtStatusIntegerOverflow 0xC0000095
#define kNtStatusPrivilegedInstruction 0xC0000096
#define kNtStatusStackOverflow 0xC00000FD
#define kNtStatusDllNotFound 0xC0000135
#define kNtStatusOrdinalNotFound 0xC0000138
#define kNtStatusEntrypointNotFound 0xC0000139
#define kNtStatusControlCExit 0xC000013A
#define kNtStatusDllInitFailed 0xC0000142
#define kNtStatusFloatMultipleFaults 0xC00002B4
#define kNtStatusFloatMultipleTraps 0xC00002B5
#define kNtStatusRegNatConsumption 0xC00002C9
#define kNtStatusHeapCorruption 0xC0000374
#define kNtStatusStackBufferOverrun 0xC0000409
#define kNtStatusInvalidCruntimeParameter 0xC0000417
#define kNtStatusAssertionFailure 0xC0000420
#define kNtStatusEnclaveViolation 0xC00004A2
#define kNtStatusSegmentNotification 0x40000005
#define kNtStatusFatalAppExit 0x40000015
/* statuses for the debugger facility */
#define kNtDbgExceptionHandled 0x00010001
#define kNtDbgContinue 0x00010002
#define kNtDbgReplyLater 0x40010001
#define kNtDbgTerminateThread 0x40010003
#define kNtDbgTerminateProcess 0x40010004
#define kNtDbgControlC 0x40010005
#define kNtDbgPrintexceptionC 0x40010006
#define kNtDbgRipexception 0x40010007
#define kNtDbgControlBreak 0x40010008
#define kNtDbgCommandException 0x40010009
#define kNtDbgPrintexceptionWideC 0x4001000A
#define kNtDbgExceptionNotHandled 0x80010001
#define kNtStillActive kNtStatusPending
#define kNtStatusSuccess 0x00000000u /* success statuses */
#define kNtStatusWait0 0x00000000u
#define kNtStatusAbandonedWait0 0x00000080u
#define kNtStatusUserApc 0x000000C0u
#define kNtStatusTimeout 0x00000102u
#define kNtStatusPending 0x00000103u
#define kNtStatusGuardPageViolation 0x80000001u /* warning statuses */
#define kNtStatusDatatypeMisalignment 0x80000002u
#define kNtStatusBreakpoint 0x80000003u
#define kNtStatusSingleStep 0x80000004u
#define kNtStatusLongjump 0x80000026u
#define kNtStatusUnwindConsolidate 0x80000029u
#define kNtStatusAccessViolation 0xC0000005u /* error statuses */
#define kNtStatusInPageError 0xC0000006u
#define kNtStatusInvalidHandle 0xC0000008u
#define kNtStatusInvalidParameter 0xC000000Du
#define kNtStatusNoMemory 0xC0000017u
#define kNtStatusIllegalInstruction 0xC000001Du
#define kNtStatusNoncontinuableException 0xC0000025u
#define kNtStatusInvalidDisposition 0xC0000026u
#define kNtStatusArrayBoundsExceeded 0xC000008Cu
#define kNtStatusFloatDenormalOperand 0xC000008Du
#define kNtStatusFloatDivideByZero 0xC000008Eu
#define kNtStatusFloatInexactResult 0xC000008Fu
#define kNtStatusFloatInvalidOperation 0xC0000090u
#define kNtStatusFloatOverflow 0xC0000091u
#define kNtStatusFloatStackCheck 0xC0000092u
#define kNtStatusFloatUnderflow 0xC0000093u
#define kNtStatusIntegerDivideBYZero 0xC0000094u
#define kNtStatusIntegerOverflow 0xC0000095u
#define kNtStatusPrivilegedInstruction 0xC0000096u
#define kNtStatusStackOverflow 0xC00000FDu
#define kNtStatusDllNotFound 0xC0000135u
#define kNtStatusOrdinalNotFound 0xC0000138u
#define kNtStatusEntrypointNotFound 0xC0000139u
#define kNtStatusControlCExit 0xC000013Au
#define kNtStatusDllInitFailed 0xC0000142u
#define kNtStatusFloatMultipleFaults 0xC00002B4u
#define kNtStatusFloatMultipleTraps 0xC00002B5u
#define kNtStatusRegNatConsumption 0xC00002C9u
#define kNtStatusHeapCorruption 0xC0000374u
#define kNtStatusStackBufferOverrun 0xC0000409u
#define kNtStatusInvalidCruntimeParameter 0xC0000417u
#define kNtStatusAssertionFailure 0xC0000420u
#define kNtStatusEnclaveViolation 0xC00004A2u
#define kNtStatusSegmentNotification 0x40000005u
#define kNtStatusFatalAppExit 0x40000015u
#define kNtStatusNotFound 0xC0000225u
#define kNtStatusCancelled 0xC0000120u
#define kNtDbgExceptionHandled 0x00010001u
#define kNtDbgContinue 0x00010002u
#define kNtDbgReplyLater 0x40010001u
#define kNtDbgTerminateThread 0x40010003u
#define kNtDbgTerminateProcess 0x40010004u
#define kNtDbgControlC 0x40010005u
#define kNtDbgPrintexceptionC 0x40010006u
#define kNtDbgRipexception 0x40010007u
#define kNtDbgControlBreak 0x40010008u
#define kNtDbgCommandException 0x40010009u
#define kNtDbgPrintexceptionWideC 0x4001000Au
#define kNtDbgExceptionNotHandled 0x80010001u
#define kNtStillActive kNtStatusPending
#if !(__ASSEMBLER__ + __LINKER__ + 0)
typedef uint32_t NtStatus;
forceinline int NtSeverity(NtStatus s) { return (unsigned)s >> 30; }
forceinline bool32 NtSuccess(NtStatus s) { return NtSeverity(s) == 0; }
forceinline bool32 NtInformation(NtStatus s) { return NtSeverity(s) == 1; }
forceinline bool32 NtWarning(NtStatus s) { return NtSeverity(s) == 2; }
forceinline bool32 NtError(NtStatus s) { return NtSeverity(s) == 3; }
forceinline int NtCode(NtStatus s) { return s & 0xffff; }
forceinline int NtFacility(NtStatus s) { return (s >> 16) & 0xfff; }
forceinline int NtFacilityCode(NtStatus s) { return s & 0x0FFFFFFF; }
#define NtSuccess(s) ((NtStatus)(s) >= 0)
#define NtInformation(s) (NtSeverity(s) == 1)
#define NtWarning(s) (NtSeverity(s) == 2)
#define NtError(s) (NtSeverity(s) == 3)
#define NtCode(s) ((NtStatus)(s)&0xffff)
#define NtSeverity(s) ((NtStatus)(s) >> 30)
#define NtFacility(s) (((NtStatus)(s) >> 16) & 0xfff)
#define NtFacilityCode(s) ((NtStatus)(s)&0x0FFFFFFF)
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NT_STATUS_H_ */

View file

@ -2682,7 +2682,7 @@ imp 'GetThreadTimes' GetThreadTimes KernelBase 777 5
imp 'GetThreadUILanguage' GetThreadUILanguage KernelBase 778
imp 'GetThreadWaitChain' GetThreadWaitChain advapi32 1369
imp 'GetTickCount' GetTickCount KernelBase 779
imp 'GetTickCount64' GetTickCount64 KernelBase 780
imp 'GetTickCount64' GetTickCount64 KernelBase 780 0
imp 'GetTimeFormatA' GetTimeFormatA KernelBase 781
imp 'GetTimeFormatAWorker' GetTimeFormatAWorker kernel32 782
imp 'GetTimeFormatEx' GetTimeFormatEx KernelBase 782
@ -3587,7 +3587,7 @@ imp 'NtAssociateWaitCompletionPacket' NtAssociateWaitCompletionPacket ntdll
imp 'NtCallEnclave' NtCallEnclave ntdll 249
imp 'NtCallbackReturn' NtCallbackReturn ntdll 250 3
imp 'NtCancelIoFile' NtCancelIoFile ntdll 251 2
imp 'NtCancelIoFileEx' NtCancelIoFileEx ntdll 252
imp 'NtCancelIoFileEx' NtCancelIoFileEx ntdll 252 3
imp 'NtCancelSynchronousIoFile' NtCancelSynchronousIoFile ntdll 253
imp 'NtCancelTimer' NtCancelTimer ntdll 254
imp 'NtCancelTimer2' NtCancelTimer2 ntdll 255
@ -3622,7 +3622,7 @@ imp 'NtCreateJobObject' NtCreateJobObject ntdll 283
imp 'NtCreateJobSet' NtCreateJobSet ntdll 284
imp 'NtCreateKey' NtCreateKey ntdll 285 7
imp 'NtCreateKeyTransacted' NtCreateKeyTransacted ntdll 286
imp 'NtCreateKeyedEvent' NtCreateKeyedEvent ntdll 287
imp 'NtCreateKeyedEvent' NtCreateKeyedEvent ntdll 287 4
imp 'NtCreateLowBoxToken' NtCreateLowBoxToken ntdll 288
imp 'NtCreateMailslotFile' NtCreateMailslotFile ntdll 289
imp 'NtCreateMutant' NtCreateMutant ntdll 290
@ -3862,7 +3862,7 @@ imp 'NtRecoverResourceManager' NtRecoverResourceManager ntdll 523
imp 'NtRecoverTransactionManager' NtRecoverTransactionManager ntdll 524
imp 'NtRegisterProtocolAddressInformation' NtRegisterProtocolAddressInformation ntdll 525
imp 'NtRegisterThreadTerminatePort' NtRegisterThreadTerminatePort ntdll 526
imp 'NtReleaseKeyedEvent' NtReleaseKeyedEvent ntdll 527
imp 'NtReleaseKeyedEvent' NtReleaseKeyedEvent ntdll 527 4
imp 'NtReleaseMutant' NtReleaseMutant ntdll 528
imp 'NtReleaseSemaphore' NtReleaseSemaphore ntdll 529
imp 'NtReleaseWorkerFactoryWorker' NtReleaseWorkerFactoryWorker ntdll 530
@ -3983,7 +3983,7 @@ imp 'NtVdm64CreateProcessInternal' NtVdm64CreateProcessInternalW kernel32
imp 'NtVdmControl' NtVdmControl ntdll 644
imp 'NtWaitForAlertByThreadId' NtWaitForAlertByThreadId ntdll 645
imp 'NtWaitForDebugEvent' NtWaitForDebugEvent ntdll 646
imp 'NtWaitForKeyedEvent' NtWaitForKeyedEvent ntdll 647
imp 'NtWaitForKeyedEvent' NtWaitForKeyedEvent ntdll 647 4
imp 'NtWaitForMultipleObjects' NtWaitForMultipleObjects ntdll 648
imp 'NtWaitForMultipleObjects32' NtWaitForMultipleObjects32 ntdll 649
imp 'NtWaitForSingleObject' NtWaitForSingleObject ntdll 650 3
@ -5338,7 +5338,7 @@ imp 'RtlNewSecurityObjectWithMultipleInheritance' RtlNewSecurityObjectWithMulti
imp 'RtlNormalizeProcessParams' RtlNormalizeProcessParams ntdll 1244
imp 'RtlNormalizeString' RtlNormalizeString ntdll 1245
imp 'RtlNtPathNameToDosPathName' RtlNtPathNameToDosPathName ntdll 1246
imp 'RtlNtStatusToDosError' RtlNtStatusToDosError ntdll 1247
imp 'RtlNtStatusToDosError' RtlNtStatusToDosError ntdll 1247 1
imp 'RtlNtStatusToDosErrorNoTeb' RtlNtStatusToDosErrorNoTeb ntdll 1248
imp 'RtlNtdllName' RtlNtdllName ntdll 1249
imp 'RtlNumberGenericTableElements' RtlNumberGenericTableElements ntdll 1250
@ -7881,7 +7881,7 @@ imp 'qsort$nt' qsort ntdll 2294
imp 'qsort_s$nt' qsort_s ntdll 2295
imp 'recv$nt' recv ws2_32 16
imp '__recvfrom$nt' recvfrom ws2_32 17
imp 'select$nt' select ws2_32 18
imp '__select$nt' select ws2_32 18 5
imp 'semDxTrimNotification' semDxTrimNotification gdi32 1965
imp 'send$nt' send ws2_32 19
imp '__sendto$nt' sendto ws2_32 20
@ -7970,3 +7970,19 @@ imp 'wsprintfA' wsprintfA user32 2596
imp 'wsprintf' wsprintfW user32 2601
imp 'wvsprintfA' wvsprintfA user32 2602
imp 'wvsprintf' wvsprintfW user32 2603
imp 'InitializeCriticalSection' InitializeCriticalSection KernelBase 0 1
imp 'EnterCriticalSection' EnterCriticalSection KernelBase 0 1
imp 'LeaveCriticalSection' LeaveCriticalSection KernelBase 0 1
imp 'TryEnterCriticalSection' TryEnterCriticalSection KernelBase 0 1
imp 'DeleteCriticalSection' DeleteCriticalSection KernelBase 0 1
imp 'InitializeCriticalSectionAndSpinCount' InitializeCriticalSectionAndSpinCount KernelBase 0 2
imp 'SetCriticalSectionSpinCount' SetCriticalSectionSpinCount KernelBase 0 2
imp 'InitializeSRWLock' InitializeSRWLock KernelBase 1128 1
imp 'AcquireSRWLockExclusive' AcquireSRWLockExclusive KernelBase 683 1
imp 'AcquireSRWLockShared' AcquireSRWLockShared KernelBase 684 1
imp 'ReleaseSRWLockExclusive' ReleaseSRWLockExclusive KernelBase 1341 1
imp 'ReleaseSRWLockShared' ReleaseSRWLockShared KernelBase 1342 1
imp 'TryAcquireSRWLockExclusive' TryAcquireSRWLockExclusive KernelBase 1467 1
imp 'TryAcquireSRWLockShared' TryAcquireSRWLockShared KernelBase 1468 1

View file

@ -1,6 +1,7 @@
#ifndef COSMOPOLITAN_LIBC_NT_NT_DEBUG_H_
#define COSMOPOLITAN_LIBC_NT_NT_DEBUG_H_
#include "libc/nt/enum/status.h"
#include "libc/nt/struct/context.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/* ░░░░
@ -32,8 +33,6 @@ COSMOPOLITAN_C_START_
Windows to the next, and possibly even between service packs for
each release. Quoth MSDN */
struct NtContext;
NtStatus NtContinue(struct NtContext *Context, int32_t TestAlert);
COSMOPOLITAN_C_END_

View file

@ -2,6 +2,7 @@
#define COSMOPOLITAN_LIBC_NT_NT_FILE_H_
#include "libc/nt/enum/fileinformationclass.h"
#include "libc/nt/enum/status.h"
#include "libc/nt/struct/iostatusblock.h"
#include "libc/nt/thunk/msabi.h"
#include "libc/nt/typedef/ioapcroutine.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
@ -38,6 +39,8 @@ COSMOPOLITAN_C_START_
struct NtIoStatusBlock;
struct NtObjectAttributes;
NtStatus NtClose(int64_t handle);
NtStatus NtCreateFile(int64_t *out_FileHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
struct NtIoStatusBlock *out_IoStatusBlock,
@ -45,32 +48,48 @@ NtStatus NtCreateFile(int64_t *out_FileHandle, uint32_t DesiredAccess,
uint32_t ShareAccess, uint32_t CreateDisposition,
uint32_t CreateOptions, void *opt_EaBuffer,
uint32_t EaLength);
NtStatus NtReadFile(int64_t FileHandle, void *opt_Event,
NtIoApcRoutine opt_ApcRoutine, void *opt_ApcContext,
struct NtIoStatusBlock *out_IoStatusBlock, void *out_Buffer,
uint32_t Length, int64_t *opt_ByteOffset,
uint32_t *opt_Key);
NtStatus NtWriteFile(int64_t FileHandle, void *opt_Event,
NtIoApcRoutine opt_ApcRoutine, void *opt_ApcContext,
struct NtIoStatusBlock *out_IoStatusBlock,
const void *Buffer, uint32_t Length,
int64_t *opt_ByteOffset, uint32_t *opt_Key);
NtStatus NtClose(int64_t handle);
NtStatus NtDuplicateObject(int64_t SourceProcessHandle, void *SourceHandle,
void *TargetProcessHandle,
void **opt_out_TargetHandle, uint32_t DesiredAcess,
uint32_t Atrributes, uint32_t options_t);
NtStatus NtQueryInformationFile(int64_t FileHandle,
struct NtIoStatusBlock *out_IoStatusBlock,
void *out_FileInformation,
uint32_t FileInformationLength,
uint32_t FileInformationClass);
NtStatus NtSetInformationFile(int64_t FileHandle,
struct NtIoStatusBlock *out_IoStatusBlock,
void *FileInformation,
uint32_t FileInformationLength,
uint32_t FileInformationClass);
NtStatus NtDeviceIoControlFile(
int64_t FileHandle, int64_t opt_Event, NtIoApcRoutine opt_ApcRoutine,
void *opt_ApcContext, struct NtIoStatusBlock *out_IoStatusBlock,
uint32_t IoControlCode, void *opt_InputBuffer, uint32_t InputBufferLength,
void *opt_out_OutputBuffer, uint32_t OutputBufferLength);
NtStatus NtCancelIoFileEx(int64_t FileHandle,
struct NtIoStatusBlock *IoRequestToCancel,
struct NtIoStatusBlock *IoStatusBlock);
NtStatus RtlNtStatusToDosError(NtStatus Status);
#if ShouldUseMsabiAttribute()
#include "libc/nt/thunk/ntfile.inc"
#endif /* ShouldUseMsabiAttribute() */

48
libc/nt/nt/key.h Normal file
View file

@ -0,0 +1,48 @@
#ifndef COSMOPOLITAN_LIBC_NT_NT_EVENT_H_
#define COSMOPOLITAN_LIBC_NT_NT_EVENT_H_
#include "libc/nt/enum/status.h"
#include "libc/nt/struct/objectattributes.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
/* ░░░░
cosmopolitan § new technology » beyond the pale » files
The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release. Quoth MSDN */
NtStatus NtCreateKeyedEvent(int64_t *KeyedEventHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
uint32_t Flags);
NtStatus NtReleaseKeyedEvent(int64_t KeyedEventHandle, void *KeyValue,
bool32 Alertable, int64_t *Timeout);
NtStatus NtWaitForKeyedEvent(int64_t KeyedEventHandle, void *KeyValue,
bool32 Alertable, int64_t *Timeout);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NT_NT_EVENT_H_ */

View file

@ -180,11 +180,6 @@ NtStatus NtFlushInstructionCache(int64_t ProcessHandle, void *opt_BaseAddress,
size_t FlushSize);
NtStatus NtQueryAttributesFile(const struct NtObjectAttributes *object,
struct NtFileBasicInformation *file_information);
NtStatus NtDeviceIoControlFile(
int64_t FileHandle, void *opt_Event, NtIoApcRoutine opt_ApcRoutine,
void *opt_ApcContext, struct NtIoStatusBlock *out_IoStatusBlock,
uint32_t IoControlCode, void *opt_InputBuffer, uint32_t InputBufferLength,
void *opt_out_OutputBuffer, uint32_t OutputBufferLength);
NtStatus NtQueryDirectoryFile(
int64_t FileHandle, void *opt_Event, NtIoApcRoutine opt_ApcRoutine,
void *opt_ApcContext, struct NtIoStatusBlock *out_IoStatusBlock,

View file

@ -1,2 +1,12 @@
.include "o/libc/nt/ntdllimport.inc"
.ntimp NtCancelIoFileEx
.text.windows
NtCancelIoFileEx:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_NtCancelIoFileEx(%rip),%rax
jmp __sysv2nt
.endfn NtCancelIoFileEx,globl
.previous

View file

@ -1,2 +1,12 @@
.include "o/libc/nt/ntdllimport.inc"
.ntimp NtCreateKeyedEvent
.text.windows
NtCreateKeyedEvent:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_NtCreateKeyedEvent(%rip),%rax
jmp __sysv2nt
.endfn NtCreateKeyedEvent,globl
.previous

View file

@ -1,2 +1,12 @@
.include "o/libc/nt/ntdllimport.inc"
.ntimp NtReleaseKeyedEvent
.text.windows
NtReleaseKeyedEvent:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_NtReleaseKeyedEvent(%rip),%rax
jmp __sysv2nt
.endfn NtReleaseKeyedEvent,globl
.previous

View file

@ -1,2 +1,12 @@
.include "o/libc/nt/ntdllimport.inc"
.ntimp NtWaitForKeyedEvent
.text.windows
NtWaitForKeyedEvent:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_NtWaitForKeyedEvent(%rip),%rax
jmp __sysv2nt
.endfn NtWaitForKeyedEvent,globl
.previous

View file

@ -1,2 +1,15 @@
.include "o/libc/nt/ntdllimport.inc"
.ntimp RtlNtStatusToDosError
.text.windows
RtlNtStatusToDosError:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_RtlNtStatusToDosError(%rip)
leave
ret
.endfn RtlNtStatusToDosError,globl
.previous

22
libc/nt/struct/afd.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_AFD_H_
#define COSMOPOLITAN_LIBC_NT_STRUCT_AFD_H_
#include "libc/nt/enum/status.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct NtAfdPollHandleInfo {
int64_t Handle;
uint32_t Events;
NtStatus Status;
};
struct NtAfdPollInfo {
int64_t Timeout;
uint32_t NumberOfHandles;
uint32_t Exclusive;
struct NtAfdPollHandleInfo Handles[1];
};
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NT_STRUCT_AFD_H_ */

View file

@ -1,9 +1,8 @@
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_CRITICALSECTION_H_
#define COSMOPOLITAN_LIBC_NT_STRUCT_CRITICALSECTION_H_
#include "libc/nt/struct/criticalsectiondebug.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct NtCriticalSectionDebug;
struct NtCriticalSection {
struct NtCriticalSectionDebug *DebugInfo;
int32_t LockCount;

View file

@ -1,10 +1,9 @@
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_CRITICALSECTIONDEBUG_H_
#define COSMOPOLITAN_LIBC_NT_STRUCT_CRITICALSECTIONDEBUG_H_
#include "libc/nt/struct/criticalsection.h"
#include "libc/nt/struct/linkedlist.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct NtCriticalSection;
struct NtCriticalSectionDebug {
uint16_t Type;
uint16_t CreatorBackTraceIndex;

View file

@ -1,13 +1,12 @@
#ifndef COSMOPOLITAN_LIBC_NT_I_OBJECTATTRIBUTES_H_
#define COSMOPOLITAN_LIBC_NT_I_OBJECTATTRIBUTES_H_
#include "libc/nt/struct/rtluserprocessparameters.h"
#include "libc/nt/struct/securityattributes.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct NtUnicodeString;
struct NtSecurityDescriptor;
struct NtObjectAttributes {
uint32_t Length;
void *RootDirectory;
int64_t RootDirectory;
struct NtUnicodeString *ObjectName;
uint32_t Attributes; /* OBJ_INHERIT, etc. */
struct NtSecurityDescriptor *SecurityDescriptor;

View file

@ -1,9 +1,8 @@
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_RTLUSERPROCESSPARAMETERS_H_
#define COSMOPOLITAN_LIBC_NT_STRUCT_RTLUSERPROCESSPARAMETERS_H_
#include "libc/nt/struct/unicodestring.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct NtUnicodeString;
struct NtRtlUserProcessParameters {
uint32_t MaximumLength;
uint32_t Length;

View file

@ -1,9 +1,8 @@
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_SECURITYATTRIBUTES_H_
#define COSMOPOLITAN_LIBC_NT_STRUCT_SECURITYATTRIBUTES_H_
#include "libc/nt/struct/securitydescriptor.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct NtSecurityDescriptor;
struct NtSecurityAttributes {
uint32_t nLength;
struct NtSecurityDescriptor *lpSecurityDescriptor;

View file

@ -1,9 +1,8 @@
#ifndef COSMOPOLITAN_LIBC_NT_STRUCT_SECURITYDESCRIPTOR_H_
#define COSMOPOLITAN_LIBC_NT_STRUCT_SECURITYDESCRIPTOR_H_
#include "libc/nt/struct/acl.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct NtAcl;
struct NtSecurityDescriptor {
uint8_t Revision;
uint8_t Sbz1;

View file

@ -32,6 +32,21 @@ COSMOPOLITAN_C_START_
cosmopolitan § new technology » synchronization
*/
#define InterlockedAdd(PTR, VAL) \
({ \
typeof(*(PTR)) Res; \
typeof(Res) Val = (VAL); \
asm volatile("xadd\t%0,%1" : "=r"(Res), "+m"(*(PTR)) : "0"(Val)); \
Res + Val; \
})
#define InterlockedExchange(PTR, VAL) \
({ \
typeof(*(PTR)) Res = (VAL); \
asm volatile("xchg\t%0,%1" : "+r"(Res), "+m"(*(PTR))); \
Res; \
})
typedef void (*NtTimerapcroutine)(void *lpArgToCompletionRoutine,
uint32_t dwTimerLowValue,
uint32_t dwTimerHighValue);
@ -78,6 +93,16 @@ int32_t InitializeCriticalSectionAndSpinCount(
uint32_t SetCriticalSectionSpinCount(
struct NtCriticalSection *lpCriticalSection, uint32_t dwSpinCount);
void InitializeSRWLock(intptr_t *);
void AcquireSRWLockExclusive(intptr_t *);
void AcquireSRWLockShared(intptr_t *);
void ReleaseSRWLockExclusive(intptr_t *);
void ReleaseSRWLockShared(intptr_t *);
void TryAcquireSRWLockExclusive(intptr_t *);
void TryAcquireSRWLockShared(intptr_t *);
uint64_t GetTickCount64(void);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NT_SYNCHRONIZATION_H_ */

View file

@ -1,12 +1,11 @@
#ifndef COSMOPOLITAN_LIBC_NT_TYPEDEF_EXCEPTIONHANDLER_H_
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_EXCEPTIONHANDLER_H_
#include "libc/nt/struct/context.h"
#include "libc/nt/struct/exceptionframe.h"
#include "libc/nt/struct/ntexceptionrecord.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct NtExceptionFrame;
struct NtExceptionRecord;
struct NtContext;
typedef unsigned (*NtExceptionHandler)(struct NtExceptionRecord *,
struct NtExceptionFrame *,
struct NtContext *, void *);

View file

@ -1,9 +1,8 @@
#ifndef COSMOPOLITAN_LIBC_NT_TYPEDEF_IOAPCROUTINE_H_
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_IOAPCROUTINE_H_
#include "libc/nt/struct/iostatusblock.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
struct NtIoStatusBlock;
typedef void (*NtIoApcRoutine)(void *ApcContext,
struct NtIoStatusBlock *IoStatusBlock,
uint32_t Reserved);

View file

@ -43,6 +43,9 @@
cosmopolitan § new technology » winsock
*/
#define kNtCompEqual 0
#define kNtCompNotless 1
#define kNtWsaFlagOverlapped 0x01
#define kNtWsaFlagNoHandleInherit 0x80
@ -83,63 +86,31 @@
#define kNtSioUdpConnreset 0x9800000Cu
#define kNtSioUdpNetreset 0x9800000Fu
#define kNtNspNotifyImmediately 0
#define kNtNspNotifyHwnd 1
#define kNtNspNotifyEvent 2
#define kNtNspNotifyPort 3
#define kNtNspNotifyApc 4
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
#define kNtWsaidAcceptex \
{ \
0xB5367DF1, 0xCBAC, 0x11CF, { \
0x95, 0xCA, 0x00, 0x80, 0x5F, 0x48, 0xA1, 0x92 \
} \
}
#define kNtWsaidConnectex \
{ \
0x25A207B9, 0xDDF3, 0x4660, { \
0x8E, 0xE9, 0x76, 0xE5, 0x8C, 0x74, 0x06, 0x3E \
} \
}
#define kNtWsaidDisconnectex \
{ \
0x7FDA2E11, 0x8630, 0x436F, { \
0xA0, 0x31, 0xF5, 0x36, 0xA6, 0xEE, 0xC1, 0x57 \
} \
}
#define kNtWsaidTransmitfile \
{ \
0xB5367DF0, 0xCBAC, 0x11CF, { \
0x95, 0xCA, 0x00, 0x80, 0x5F, 0x48, 0xA1, 0x92 \
} \
}
enum NtWsaEComparator { COMP_EQUAL, COMP_NOTLESS };
enum NtWsaCompletionType {
kNtNspNotifyImmediately = 0,
kNtNspNotifyHwnd,
kNtNspNotifyEvent,
kNtNspNotifyPort,
kNtNspNotifyApc,
};
struct timeval$nt {
struct NtTimeval {
int32_t tv_sec; /* [sic] */
int32_t tv_usec;
};
struct iovec$nt {
struct NtIovec {
uint32_t len;
char *buf;
};
struct msghdr$nt {
struct NtMsgHdr {
struct sockaddr *name;
int32_t namelen;
struct iovec$nt *lpBuffers;
struct NtIovec *lpBuffers;
uint32_t dwBufferCount;
struct iovec$nt Control;
struct NtIovec Control;
uint32_t dwFlags;
};
@ -223,12 +194,12 @@ struct NtFlowSpec {
struct NtQos {
struct NtFlowSpec SendingFlowspec;
struct NtFlowSpec ReceivingFlowspec;
struct iovec$nt ProviderSpecific;
struct NtIovec ProviderSpecific;
};
struct NtWsaVersion {
uint32_t dwVersion;
enum NtWsaEComparator ecHow;
int ecHow;
};
struct NtAfProtocols {
@ -303,9 +274,9 @@ struct NtTransmitFileBuffers {
};
typedef int (*NtConditionProc)(
const struct iovec$nt *lpCallerId, const struct iovec$nt *lpCallerData,
const struct NtIovec *lpCallerId, const struct NtIovec *lpCallerData,
struct NtQos *inout_lpSQOS, struct NtQos *inout_lpGQOS,
const struct iovec$nt *lpCalleeId, const struct iovec$nt *lpCalleeData,
const struct NtIovec *lpCalleeId, const struct NtIovec *lpCalleeData,
uint32_t *out_group, const uint32_t *dwCallbackData);
typedef void (*NtWsaOverlappedCompletionRoutine)(
@ -313,7 +284,7 @@ typedef void (*NtWsaOverlappedCompletionRoutine)(
const struct NtOverlapped *lpOverlapped, uint32_t dwFlags);
struct NtWsaCompletion {
enum NtWsaCompletionType Type;
int Type;
union {
struct {
int64_t hWnd;
@ -335,6 +306,11 @@ struct NtWsaCompletion {
} Parameters;
};
struct NtFdSet {
uint32_t fd_count;
int64_t fd_array[64];
};
/**
* Winsock2 prototypes.
*
@ -359,14 +335,16 @@ int __ioctlsocket$nt(uint64_t, int32_t, uint32_t *);
int __listen$nt(uint64_t, int);
int __setsockopt$nt(uint64_t, int, int, const void *, int);
int __shutdown$nt(uint64_t, int);
int __select$nt(int, struct NtFdSet *, struct NtFdSet *, struct NtFdSet *,
struct NtTimeval *);
uint64_t WSASocket(int af, int type, int protocol,
const struct NtWsaProtocolInfo *opt_lpProtocolInfo,
const uint32_t opt_group, uint32_t dwFlags) nodiscard;
int WSAConnect(uint64_t s, const struct sockaddr *name, const int namelen,
const struct iovec$nt *opt_lpCallerData,
struct iovec$nt *opt_out_lpCalleeData,
const struct NtIovec *opt_lpCallerData,
struct NtIovec *opt_out_lpCalleeData,
const struct NtQos *opt_lpSQOS, const struct NtQos *opt_lpGQOS)
paramsnonnull((2));
@ -376,7 +354,7 @@ bool32 WSAConnectByName(uint64_t s, const char16_t *nodename,
struct sockaddr *out_LocalAddress,
uint32_t *opt_inout_RemoteAddressLength,
struct sockaddr *out_RemoteAddress,
const struct timeval$nt *opt_timeout,
const struct NtTimeval *opt_timeout,
struct NtOverlapped *__Reserved) paramsnonnull((2, 3));
bool32 WSAConnectByList(uint64_t s,
@ -385,7 +363,7 @@ bool32 WSAConnectByList(uint64_t s,
struct sockaddr *out_LocalAddress,
uint32_t *opt_inout_RemoteAddressLength,
struct sockaddr *out_RemoteAddress,
const struct timeval$nt *opt_timeout,
const struct NtTimeval *opt_timeout,
struct NtOverlapped *__Reserved) paramsnonnull((2));
int64_t WSAAccept(uint64_t s, struct sockaddr *out_addr,
@ -394,19 +372,19 @@ int64_t WSAAccept(uint64_t s, struct sockaddr *out_addr,
const uint32_t *opt_dwCallbackData)
paramsnonnull((2)) nodiscard;
int WSASend(uint64_t s, const struct iovec$nt *lpBuffers,
uint32_t dwBufferCount, uint32_t *opt_out_lpNumberOfBytesSent,
uint32_t dwFlags, struct NtOverlapped *opt_inout_lpOverlapped,
int WSASend(uint64_t s, const struct NtIovec *lpBuffers, uint32_t dwBufferCount,
uint32_t *opt_out_lpNumberOfBytesSent, uint32_t dwFlags,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((2));
int WSASendMsg(int64_t Handle, const struct msghdr$nt *lpMsg, uint32_t dwFlags,
int WSASendMsg(int64_t Handle, const struct NtMsgHdr *lpMsg, uint32_t dwFlags,
uint32_t *opt_out_lpNumberOfBytesSent,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((2));
int WSASendTo(uint64_t s, const struct iovec$nt *lpBuffers,
int WSASendTo(uint64_t s, const struct NtIovec *lpBuffers,
uint32_t dwBufferCount,
uint32_t *opt_out_lpNumberOfBytesSent /* opt if !overlapped */,
uint32_t dwFlags, const void *opt_tosockaddr,
@ -418,14 +396,14 @@ int WSASendTo(uint64_t s, const struct iovec$nt *lpBuffers,
int WSAPoll(struct pollfd$nt *inout_fdArray, uint32_t nfds, signed timeout_ms)
paramsnonnull();
int WSARecv(uint64_t s, const struct iovec$nt *out_lpBuffers,
int WSARecv(uint64_t s, const struct NtIovec *out_lpBuffers,
uint32_t dwBufferCount, uint32_t *opt_out_lpNumberOfBytesRecvd,
uint32_t *inout_lpFlags,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((2, 5));
int WSARecvFrom(uint64_t s, const struct iovec$nt *out_lpBuffers,
int WSARecvFrom(uint64_t s, const struct NtIovec *out_lpBuffers,
uint32_t dwBufferCount, uint32_t *opt_out_lpNumberOfBytesRecvd,
uint32_t *inout_lpFlags, void *out_fromsockaddr,
uint32_t *inout_fromsockaddrlen,
@ -434,7 +412,7 @@ int WSARecvFrom(uint64_t s, const struct iovec$nt *out_lpBuffers,
paramsnonnull((2, 5, 6, 7));
int WSARecvDisconnect(uint64_t s,
const struct iovec$nt *opt_lpInboundDisconnectData);
const struct NtIovec *opt_lpInboundDisconnectData);
int WSADuplicateSocket(uint64_t s, uint32_t dwProcessId,
struct NtWsaProtocolInfo *out_lpProtocolInfo)
@ -445,7 +423,7 @@ int WSAIoctl(uint64_t s, uint32_t dwIoControlCode, const void *lpvInBuffer,
uint32_t *out_lpcbBytesReturned,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((3, 5, 7));
paramsnonnull((5, 7));
int WSANSPIoctl(int64_t hLookup, uint32_t dwControlCode,
const void *lpvInBuffer, uint32_t cbInBuffer,
@ -479,12 +457,12 @@ int WSAEnumProtocols(const int32_t *opt_lpiProtocols,
struct NtWsaProtocolInfo *out_lpProtocolBuffer,
uint32_t *inout_lpdwBufferLength) paramsnonnull();
bool32 WSAGetQOSByName(uint64_t s, const struct iovec$nt *lpQOSName,
bool32 WSAGetQOSByName(uint64_t s, const struct NtIovec *lpQOSName,
struct NtQos *out_lpQOS) paramsnonnull();
uint64_t WSAJoinLeaf(uint64_t s, const struct sockaddr *name, const int namelen,
const struct iovec$nt *opt_lpCallerData,
struct iovec$nt *opt_out_lpCalleeData,
const struct NtIovec *opt_lpCallerData,
struct NtIovec *opt_out_lpCalleeData,
const struct NtQos *opt_lpSQOS,
const struct NtQos *opt_lpGQOS, uint32_t dwFlags)
paramsnonnull((2, 4));

View file

@ -1,2 +1,12 @@
.include "o/libc/nt/codegen.inc"
.imp ws2_32,__imp_select,select,18
.text.windows
__select$nt:
push %rbp
mov %rsp,%rbp
.profilable
mov __imp_select(%rip),%rax
jmp __sysv2nt6
.endfn __select$nt,globl
.previous