#include "../cdb_system.h" #include #include struct sys_thread_args { sys_threadProc proc; void *arg; }; typedef struct sys_thread_args sys_thread_args; // Linux only uses System V AMD64 ABI calling convention (source: https://en.wikipedia.org/wiki/X86_calling_conventions) void *uwu_runThread(void *arg) { sys_thread_args *args = (sys_thread_args *) arg; sys_threadProc proc = args->proc; void *arg2 = args->arg; sys_heapFree(args); proc(arg2); return NULL; } sys_Bool sys_threadNew(sys_threadProc proc, void *arg) { sys_thread_args *args = (sys_thread_args *) sys_heapAlloc(sizeof(sys_thread_args)); args->proc = proc; args->arg = arg; pthread_t thread; if(pthread_create(&thread, NULL, uwu_runThread, args)) { sys_heapFree(args); return sys_False; }else { return sys_True; } } void sys_threadSleep(unsigned long seconds) { sleep(seconds); }