2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_NT_RUNTIME_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_NT_RUNTIME_H_
|
2020-11-25 16:19:00 +00:00
|
|
|
#include "libc/nt/struct/overlapped.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/nt/thunk/msabi.h"
|
|
|
|
#include "libc/nt/typedef/handlerroutine.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fileoverview NT Obligatory Runtime Functions.
|
|
|
|
*
|
|
|
|
* These functions are placed in their own file because they're (a)
|
|
|
|
* abstracted by the Cosmopolitan runtime; and (b) it helps GCC avoid
|
|
|
|
* bloating binaries with debug information the user doesn't need.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define kNtCpUtf8 65001
|
|
|
|
#define kNtInvalidHandleValue -1L
|
2023-08-08 11:00:29 +00:00
|
|
|
#define kNtStdInputHandle -10u
|
|
|
|
#define kNtStdOutputHandle -11u
|
|
|
|
#define kNtStdErrorHandle -12u
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
|
|
|
char16_t *GetCommandLine(void) nosideeffect;
|
2023-09-06 10:54:42 +00:00
|
|
|
char16_t *GetEnvironmentStrings(void) __wur;
|
2020-06-15 14:18:57 +00:00
|
|
|
bool32 FreeEnvironmentStrings(char16_t *) paramsnonnull();
|
|
|
|
bool32 ReadFile(int64_t hFile, void *lpBuffer, uint32_t nNumberOfBytesToRead,
|
|
|
|
uint32_t *lpNumberOfBytesRead,
|
|
|
|
struct NtOverlapped *opt_lpOverlapped);
|
|
|
|
bool32 WriteFile(int64_t hFile, const void *lpBuffer,
|
|
|
|
uint32_t nNumberOfBytesToWrite,
|
|
|
|
uint32_t *lpNumberOfBytesWritten,
|
|
|
|
struct NtOverlapped *opt_lpOverlapped);
|
|
|
|
bool32 TerminateProcess(int64_t hProcess, uint32_t uExitCode);
|
|
|
|
int64_t GetCurrentProcess(void) pureconst;
|
2020-12-05 20:20:41 +00:00
|
|
|
void ExitProcess(uint32_t uExitCode) wontreturn;
|
2020-06-15 14:18:57 +00:00
|
|
|
uint32_t GetLastError(void) nosideeffect;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
bool32 CloseHandle(int64_t hObject) dontthrow nocallback;
|
2023-08-08 11:00:29 +00:00
|
|
|
intptr_t GetStdHandle(uint32_t nStdHandle) nosideeffect;
|
|
|
|
bool32 SetStdHandle(uint32_t nStdHandle, int64_t hHandle);
|
2020-06-15 14:18:57 +00:00
|
|
|
bool32 SetDefaultDllDirectories(unsigned dirflags);
|
2021-06-24 19:31:26 +00:00
|
|
|
bool32 RtlGenRandom(void *RandomBuffer, uint32_t RandomBufferLength);
|
2021-09-28 05:58:51 +00:00
|
|
|
uint32_t GetModuleFileName(int64_t hModule, char16_t *lpFilename,
|
|
|
|
uint32_t nSize);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
#if ShouldUseMsabiAttribute()
|
|
|
|
#include "libc/nt/thunk/runtime.inc"
|
|
|
|
#endif /* ShouldUseMsabiAttribute() */
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_NT_RUNTIME_H_ */
|