mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
f531acc8f9
- Invent openatemp() API - Invent O_UNLINK open flag - Introduce getenv_secure() API - Remove `git pull` from cosmocc - Fix utimes() when path is NULL - Fix mktemp() to never return NULL - Fix utimensat() UTIME_OMIT on XNU - Improve utimensat() code for RHEL5 - Turn `argv[0]` C:/ to /C/ on Windows - Introduce tmpnam() and tmpnam_r() APIs - Fix more const issues with internal APIs - Permit utimes() on WIN32 in O_RDONLY mode - Fix fdopendir() to check fd is a directory - Fix recent crash regression in landlock make - Fix futimens(AT_FDCWD, NULL) to return EBADF - Use workaround so `make -j` doesn't fork bomb - Rename dontdiscard to __wur (just like glibc) - Fix st_size for WIN32 symlinks containing UTF-8 - Introduce stdio ext APIs needed by GNU coreutils - Fix lstat() on WIN32 for symlinks to directories - Move some constants from normalize.inc to limits.h - Fix segv with memchr() and memcmp() overlapping page - Implement POSIX fflush() behavior for reader streams - Implement AT_SYMLINK_NOFOLLOW for utimensat() on WIN32 - Don't change read-only status of existing files on WIN32 - Correctly handle `0x[^[:xdigit:]]` case in strtol() functions
97 lines
6.4 KiB
C
97 lines
6.4 KiB
C
#ifndef COSMOPOLITAN_LIBC_NT_MEMORY_H_
|
|
#define COSMOPOLITAN_LIBC_NT_MEMORY_H_
|
|
#include "libc/nt/struct/memorybasicinformation.h"
|
|
#include "libc/nt/struct/memoryrangeentry.h"
|
|
#include "libc/nt/struct/securityattributes.h"
|
|
#include "libc/nt/thunk/msabi.h"
|
|
/* ░░░░
|
|
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
|
|
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
|
|
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
|
|
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
|
|
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
|
|
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
|
|
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
|
|
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
|
|
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
|
|
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
|
|
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
|
|
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
|
|
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
|
|
│ cosmopolitan § new technology » memory ─╬─│┼
|
|
╚────────────────────────────────────────────────────────────────────────────│*/
|
|
|
|
#define kNtNumaNoPreferredNode 0xffffffffu
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
|
|
void *LocalFree(void *hMem);
|
|
|
|
int64_t CreateFileMapping(
|
|
int64_t opt_hFile,
|
|
const struct NtSecurityAttributes *opt_lpFileMappingAttributes,
|
|
uint32_t flProtect, uint32_t dwMaximumSizeHigh, uint32_t dwMaximumSizeLow,
|
|
const char16_t *opt_lpName);
|
|
int64_t CreateFileMappingNuma(
|
|
int64_t opt_hFile,
|
|
const struct NtSecurityAttributes *opt_lpFileMappingAttributes,
|
|
uint32_t flProtect, uint32_t dwMaximumSizeHigh, uint32_t dwMaximumSizeLow,
|
|
const char16_t *opt_lpName, uint32_t nndDesiredNumaNode);
|
|
|
|
void *MapViewOfFileEx(int64_t hFileMappingObject, uint32_t dwDesiredAccess,
|
|
uint32_t dwFileOffsetHigh, uint32_t dwFileOffsetLow,
|
|
size_t dwNumberOfBytesToMap,
|
|
void *opt_lpDesiredBaseAddress);
|
|
void *MapViewOfFileExNuma(int64_t hFileMappingObject, uint32_t dwDesiredAccess,
|
|
uint32_t dwFileOffsetHigh, uint32_t dwFileOffsetLow,
|
|
size_t dwNumberOfBytesToMap,
|
|
void *opt_lpDesiredBaseAddress,
|
|
uint32_t nndDesiredNumaNode);
|
|
|
|
bool32 UnmapViewOfFile(const void *lpBaseAddress);
|
|
bool32 FlushViewOfFile(const void *lpBaseAddress,
|
|
size_t dwNumberOfBytesToFlush);
|
|
|
|
void *VirtualAlloc(void *opt_lpAddress, uint64_t dwSize,
|
|
uint32_t flAllocationType, uint32_t flProtect);
|
|
bool32 VirtualFree(void *lpAddress, uint64_t dwSize, uint32_t dwFreeType);
|
|
bool32 VirtualProtect(void *lpAddress, uint64_t dwSize, uint32_t flNewProtect,
|
|
uint32_t *lpflOldProtect) paramsnonnull();
|
|
bool32 VirtualLock(const void *lpAddress, size_t dwSize);
|
|
bool32 VirtualUnlock(const void *lpAddress, size_t dwSize);
|
|
uint64_t VirtualQuery(const void *lpAddress,
|
|
struct NtMemoryBasicInformation *lpBuffer,
|
|
uint64_t dwLength);
|
|
void *VirtualAllocEx(int64_t hProcess, void *lpAddress, uint64_t dwSize,
|
|
uint32_t flAllocationType, uint32_t flProtect);
|
|
|
|
bool32 PrefetchVirtualMemory(int64_t hProcess, const uint32_t *NumberOfEntries,
|
|
struct NtMemoryRangeEntry *VirtualAddresses,
|
|
uint32_t reserved_Flags);
|
|
bool32 OfferVirtualMemory(void *inout_VirtualAddress, size_t Size,
|
|
int Priority);
|
|
|
|
int64_t GetProcessHeap(void);
|
|
void *HeapAlloc(int64_t hHeap, uint32_t dwFlags, size_t dwBytes) __wur;
|
|
bool32 HeapFree(int64_t hHeap, uint32_t dwFlags, void *opt_lpMem);
|
|
void *HeapReAlloc(int64_t hHeap, uint32_t dwFlags, void *lpMem,
|
|
size_t dwBytes) __wur;
|
|
|
|
void *GlobalAlloc(uint32_t uFlags, uint64_t dwBytes) __wur;
|
|
void *GlobalFree(void *hMem);
|
|
|
|
#if ShouldUseMsabiAttribute()
|
|
#include "libc/nt/thunk/memory.inc"
|
|
#endif /* ShouldUseMsabiAttribute() */
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_NT_MEMORY_H_ */
|