|
PatchworkOS
19e446b
A non-POSIX operating system.
|
#include <stdatomic.h>#include <stdint.h>#include <stdio.h>#include "_libstd/ERR.h"#include "_libstd/NULL.h"#include "_libstd/PAGE_SIZE.h"#include "_libstd/clock_t.h"#include "_libstd/config.h"#include "_libstd/fd_t.h"#include "_libstd/pid_t.h"#include "_libstd/tid_t.h"Go to the source code of this file.
Data Structures | |
| struct | sync_t |
| Synchronization object. More... | |
Macros | |
| #define | PRIORITY_MAX 63 |
| The maximum priority value, inclusive. | |
| #define | PRIORITY_MAX_USER 31 |
| The maximum priority user space is allowed to specify, inclusive. | |
| #define | PRIORITY_MIN 0 |
| The minimum priority value. | |
| #define | BYTES_TO_PAGES(amount) (((amount) + PAGE_SIZE - 1) / PAGE_SIZE) |
| Convert a size in bytes to pages. | |
| #define | PAGE_SIZE_OF(object) BYTES_TO_PAGES(sizeof(object)) |
| Size of an object in pages. | |
| #define | FUTEX_ALL UINT64_MAX |
| Futex wake all constant. | |
Typedefs | |
| typedef uint8_t | priority_t |
| Priority type. | |
| typedef void(* | note_func_t) (char *note) |
| Note handler function type. | |
| typedef uint64_t(* | atnotify_func_t) (char *note) |
User space atnotify() handler function type. | |
Enumerations | |
| enum | spawn_flags_t { SPAWN_DEFAULT = 0 , SPAWN_SUSPEND = 1 << 0 , SPAWN_EMPTY_FDS = 1 << 1 , SPAWN_STDIO_FDS = 1 << 2 , SPAWN_EMPTY_ENV = 1 << 3 , SPAWN_EMPTY_CWD = 1 << 4 , SPAWN_EMPTY_GROUP = 1 << 5 , SPAWN_COPY_NS = 1 << 6 , SPAWN_EMPTY_NS , SPAWN_EMPTY_ALL } |
| Spawn behaviour flags. More... | |
| enum | prot_t { PROT_NONE = 0 , PROT_READ = (1 << 0) , PROT_WRITE = (1 << 1) , PROT_EXECUTE = (1 << 2) } |
| Memory protection flags. More... | |
| enum | futex_op_t { FUTEX_WAIT , FUTEX_WAKE } |
| Futex operation enum. More... | |
| enum | atnotify_t { ATNOTIFY_ADD = 0 , ATNOTIFY_REMOVE = 1 } |
| Action type for atnotify(). More... | |
| enum | arch_prctl_t { ARCH_GET_FS = 0 , ARCH_SET_FS = 1 } |
| Architecture specific thread data codes. More... | |
Functions | |
| pid_t | spawn (const char **argv, spawn_flags_t flags) |
| System call for spawning new processes. | |
| pid_t | getpid (void) |
| System call to retrieve the current pid. | |
| tid_t | gettid (void) |
| System call to retrieve the current tid. | |
| void * | mmap (fd_t fd, void *address, size_t length, prot_t prot) |
| System call to map memory from a file. | |
| void * | munmap (void *address, size_t length) |
| System call to unmap mapped memory. | |
| void * | mprotect (void *address, size_t length, prot_t prot) |
| System call to change the protection flags of memory. | |
| uint64_t | futex (atomic_uint64_t *addr, uint64_t val, futex_op_t op, clock_t timeout) |
| System call for fast user space mutual exclusion. | |
| clock_t | uptime (void) |
| System call for retreving the time since boot. | |
| uint64_t | nanosleep (clock_t timeout) |
| System call for sleeping. | |
| uint64_t | notify (note_func_t handler) |
| System call that sets the handler to be called when a note is received. | |
| _NORETURN void | noted (void) |
| System call that notifies the kernel that the current note has been handled. | |
| int64_t | wordcmp (const char *string, const char *word) |
| Helper for comparing the first word of a string. | |
| uint64_t | atnotify (atnotify_func_t handler, atnotify_t action) |
| Adds or removes a handler to be called in user space when a note is received. | |
| _NORETURN void | exits (const char *status) |
| System call that handles pending notes for the current thread. | |
| uint64_t | kill (pid_t pid) |
| Helper for sending the "kill" command to a process. | |
| uint64_t | arch_prctl (arch_prctl_t op, uintptr_t addr) |
| System call for setting architecture specific thread data. | |