update
This commit is contained in:
6
core.h
6
core.h
@@ -175,6 +175,12 @@ DefineList(string, String);
|
||||
}
|
||||
#define ListTail(list, start) ListSlice(list, start, (list).length)
|
||||
|
||||
#define ListRemove(list, index)\
|
||||
if ((index) >= 0 && (index) < (list)->length) {\
|
||||
memcpy((list)->data + (index), (list)->data + (index) + 1, (parentNode->children.length - (i + 1))*sizeof(*((list)->data)));\
|
||||
parentNode->children.length -= 1;\
|
||||
}
|
||||
|
||||
// ### Strings ###
|
||||
struct string {
|
||||
char *str;
|
||||
|
||||
8
os.h
8
os.h
@@ -17,4 +17,12 @@ bool os_fileAppend(Arena *arena, string filename, const byte *contents, size_t c
|
||||
// ### Standard IO ###
|
||||
void os_print(StdStream target, const char *fmt, va_list argList);
|
||||
|
||||
// ### Multithreading ###
|
||||
typedef struct OS_Thread OS_Thread;
|
||||
struct OS_Thread {
|
||||
uint64 id;
|
||||
};
|
||||
|
||||
OS_Thread os_createThread(void *(*entry)(void *ctx), void *ctx);
|
||||
|
||||
#endif
|
||||
|
||||
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