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 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 ###
|
// ### Strings ###
|
||||||
struct string {
|
struct string {
|
||||||
char *str;
|
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 ###
|
// ### Standard IO ###
|
||||||
void os_print(StdStream target, const char *fmt, va_list argList);
|
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
|
#endif
|
||||||
|
|||||||
10
os_linux.c
10
os_linux.c
@@ -7,6 +7,7 @@
|
|||||||
#include "sys/stat.h"
|
#include "sys/stat.h"
|
||||||
#include "unistd.h" // POSIX Standard
|
#include "unistd.h" // POSIX Standard
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
#include "pthread.h"
|
||||||
|
|
||||||
void *os_alloc(size_t capacity) {
|
void *os_alloc(size_t capacity) {
|
||||||
return mmap(0, capacity, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
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);
|
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
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user