Add support for clock syscalls

This commit is contained in:
2025-04-30 12:52:49 -04:00
parent 74cfa5f949
commit ab5dd8d9fb
6 changed files with 214 additions and 0 deletions

13
sys.h
View File

@@ -128,9 +128,22 @@ typedef unsigned short sa_family_t;
#define SO_PASSCRED 17
#define SO_PEERCRED 18
// Time management
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 1
#define CLOCK_PROCESS_CPUTIME_ID 2
#define CLOCK_THREAD_CPUTIME_ID 3
#define TIMER_ABSTIME 0x01
int clock_settime(clockid_t clockid, const struct timespec *tp);
int clock_gettime(clockid_t clockid, struct timespec *tp);
int clock_getres(clockid_t clockid, struct timespec *res);
int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *t, struct timespec* remain);
#define nanosleep(t, remain) clock_nanosleep(CLOCK_MONOTONIC, 0, t, remain)
uint32_t fork();
// Provide memset for clang
// TODO: move this (and start code?) to separate .c file
void *memset(void* s, int c, unsigned long n) {
int8_t* mem = s;
for(long int i = 0; i < n; ++i) mem[i] = c;