diff --git a/src/arena.c b/src/arena.c index b11991a..a35af3b 100644 --- a/src/arena.c +++ b/src/arena.c @@ -4,7 +4,7 @@ typedef enum { arena__alloc, arena__reset, arena__save, arena__restore, arena__release } arena__action; -typedef closure(void*, arena__action, ureg, ureg, void*, const char*, sreg) Arena; +typedef closure(void*, arena__action, uregister, uregister, void*, const char*, sregister) Arena; #define arena_new(A, T) cast(T*, A(arena__alloc, sizeof(T), alignof(T), 0, __FILE__, __LINE__)) #define arena_make(A, C, T) cast(T*, A(arena__alloc, sizeof(T) * (C), alignof(T), 0, __FILE__, __LINE__)) @@ -14,13 +14,13 @@ typedef closure(void*, arena__action, ureg, ureg, void*, const char*, sreg) Aren #define arena_restore(A, SP) A(arena__restore, 0, 0, (SP), __FILE__, __LINE__) // tiny macro to make arenas easier to declare -#define $(a1, a2, a3, a4, a5, a6) ^void* (arena__action a1, ureg a2, ureg a3, void* a4, const char* a5, sreg a6) +#define $(a1, a2, a3, a4, a5, a6) ^void* (arena__action a1, uregister a2, uregister a3, void* a4, const char* a5, sregister a6) static Arena -Static(u8* data, ureg count) { +Static(uint8* data, uregister count) { memset(data, 0, count); - capture ureg offset = 0; + capture uregister offset = 0; return persist($(action, size, align, savepoint, _2, _3) { switch (action) { default: { @@ -43,12 +43,12 @@ Static(u8* data, ureg count) { case arena__save: { assert(savepoint != NULL && "Static: savepoint was null"); - *cast(ureg*, savepoint) = offset; + *cast(uregister*, savepoint) = offset; } break; case arena__restore: { assert(savepoint != NULL && "Static: savepoint was null"); - offset = *cast(ureg*, savepoint); + offset = *cast(uregister*, savepoint); } break; } @@ -57,7 +57,7 @@ Static(u8* data, ureg count) { } static Arena -Linear(ureg max_memory) { +Linear(uregister max_memory) { void* ptr = malloc(max_memory); Arena backing = Static(ptr, max_memory); return persist($(action, size, align, savepoint, file, line) { @@ -89,7 +89,7 @@ Logger(Arena arena) { static Arena Region(Arena arena) { - capture ureg savepoint = 0; + capture uregister savepoint = 0; arena_save(arena, &savepoint); return persist($(action, size, align, _, file, line) { diff --git a/src/base.c b/src/base.c index 2b5b1b6..699292e 100644 --- a/src/base.c +++ b/src/base.c @@ -1,23 +1,23 @@ #include -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; +typedef uint8_t uint8; +typedef uint16_t uint16; +typedef uint32_t uint32; +typedef uint64_t uint64; -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef int64_t s64; +typedef int8_t sint8; +typedef int16_t sint16; +typedef int32_t sint32; +typedef int64_t sint64; -typedef float f32; -typedef double f64; +typedef float float32; +typedef double float64; -typedef uintptr_t uptr; -typedef intptr_t sptr; +typedef uintptr_t upointer; +typedef intptr_t spointer; -typedef uptr ureg; -typedef sptr sreg; +typedef upointer uregister; +typedef spointer sregister; #define auto __auto_type @@ -32,8 +32,8 @@ typedef sptr sreg; #include -#define capture __block // allows a variable to be mutably captured by a closure (will be moved to the heap if needed) -#define persist Block_copy // moves a closure to the heap (reference counted) so it can persist outside of its local stack frame +#define capture __block // allows a variable to be mutably captured by a closure (will be moved to the heap if needed) +#define persist Block_copy // moves a closure to the heap (reference counted) so it can persist outside of its local stack frame #define unpersist Block_release // frees a closure (or decrements its reference count) typedef closure(void, void) __scope_exit; diff --git a/src/main.c b/src/main.c index 733ce6c..5d89489 100644 --- a/src/main.c +++ b/src/main.c @@ -59,7 +59,7 @@ init(void) { }); printf("x = %d (before)\n", x); - for (ureg i = 0; i < 10; i += 1) { + for (uregister i = 0; i < 10; i += 1) { inc(); } printf("x = %d (after)\n", x); @@ -67,19 +67,19 @@ init(void) { auto arena = Logger(Linear(1024 * 1024)); scope_exit { arena_release(arena); }; - sreg* a = arena_new(arena, sreg); - sreg* b = arena_new(arena, sreg); + sregister* a = arena_new(arena, sregister); + sregister* b = arena_new(arena, sregister); { auto region = Region(arena); scope_exit { arena_reset(region); }; - arena_make(region, 10, sreg); - arena_make(region, 10, f32); + arena_make(region, 10, sregister); + arena_make(region, 10, float32); arena_make(region, 10, bool); } - sreg* c = arena_new(arena, sreg); + sregister* c = arena_new(arena, sregister); *a = 1024; *b = 2048; @@ -91,9 +91,9 @@ init(void) { arena_reset(arena); - c = arena_new(arena, sreg); - b = arena_new(arena, sreg); - a = arena_new(arena, sreg); + c = arena_new(arena, sregister); + b = arena_new(arena, sregister); + a = arena_new(arena, sregister); printf("%zu (%p)\n", *a, a); printf("%zu (%p)\n", *b, b);