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

@@ -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_ */