diff options
| author | 2026-05-10 14:51:46 +0100 | |
|---|---|---|
| committer | 2026-10-10 04:23:05 +0100 | |
| commit | e66dbc42d523ec6d1a4e1b4fec21fb211eb660bb (patch) | |
| tree | 4e6a4b88ff960b552fd77a43ba8902fe1295188b /src/os.h | |
| parent | c219ee378c374ceaf576ac477ccbe34a73e65d94 (diff) | |
| download | sst-e66dbc42d523ec6d1a4e1b4fec21fb211eb660bb.tar.gz sst-e66dbc42d523ec6d1a4e1b4fec21fb211eb660bb.zip | |
Abstract page allocation and locking in os.c
Simplifies ac.c just a little bit.
Diffstat (limited to 'src/os.h')
| -rw-r--r-- | src/os.h | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -228,6 +228,18 @@ int os_dlfile(void *lib, os_char *buf, int sz); #endif /* + * Allocates some memory from the operating system. Rounds the size up to the + * page size (4096). Returns an address on success, or null on failure. + */ +void *os_pagealloc(int sz, int prot); + +/* + * Frees a page range allocated using os_pagealloc(). Rounds the address and + * size to page boundaries (4096). + */ +void os_pagefree(void *addr, int sz); + +/* * Changes memory protection for the address range given by addr and len, using * one of the Win32-style PAGE_* flags specified above. Returns true on success * and false on failure. @@ -235,6 +247,13 @@ int os_dlfile(void *lib, os_char *buf, int sz); bool os_mprot(void *addr, int len, int mode); /* + * Locks a page range in physical memory; prevents paging to disk. The address + * and size *must* be page-aligned, otherwise behaviour is undefined. + * Returns true on success, false on failure. + */ +bool os_mlock(void *addr, int sz); + +/* * Fills buf with up to sz cryptographically random bytes. sz has an OS-specific * upper limit - a safe value across all major operating systems is 256. */ |
