update
This commit is contained in:
10
os_linux.c
10
os_linux.c
@@ -7,6 +7,7 @@
|
||||
#include "sys/stat.h"
|
||||
#include "unistd.h" // POSIX Standard
|
||||
#include "stdio.h"
|
||||
#include "pthread.h"
|
||||
|
||||
void *os_alloc(size_t capacity) {
|
||||
return mmap(0, capacity, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
@@ -96,4 +97,13 @@ void os_print(StdStream target, const char *fmt, va_list argList) {
|
||||
scratchEnd(temp);
|
||||
}
|
||||
|
||||
OS_Thread os_createThread(void *(*entry)(void *), void *ctx) {
|
||||
pthread_t handle;
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_create(&handle, &attr, entry, ctx);
|
||||
pthread_attr_destroy(&attr);
|
||||
return (OS_Thread){ .id=handle };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user