From: cassowarii <2374677+cassowarii@users.noreply.github.com> Date: Sun, 19 Jul 2026 05:18:25 +0000 (-0700) Subject: a couple random c tweaks X-Git-Url: https://www.git.cassowary.me/gitweb.cgi?a=commitdiff_plain;h=0bc798b033d72b283fa70131bddb324f00b2d928;p=sarabande.git a couple random c tweaks --- diff --git a/src/global.h b/src/global.h index 4f7c920..b4adf4b 100644 --- a/src/global.h +++ b/src/global.h @@ -3,10 +3,10 @@ #ifdef DEBUG #define PANIC(...) do { fprintf(stderr, "PANIC: " __VA_ARGS__); fprintf(stderr, "\n at " __FILE__ ":%d\n", __LINE__); abort(); } while (0) -#define CHECK(...) do { fprintf(stderr, "PANIC: " __VA_ARGS__); fprintf(stderr, "\n at " __FILE__ ":%d\n", __LINE__); abort(); } while (0) +#define CHECK(...) do { fprintf(stderr, "BUGCHECK: " __VA_ARGS__); fprintf(stderr, "\n at " __FILE__ ":%d\n", __LINE__); abort(); } while (0) #define debug(...) printf(__VA_ARGS__) #else -#define PANIC(...) do { fprintf(stderr, "BUGCHECK: " __VA_ARGS__); fprintf(stderr, "\n"); abort(); } while (0) +#define PANIC(...) do { fprintf(stderr, "PANIC: " __VA_ARGS__); fprintf(stderr, "\n"); abort(); } while (0) #define CHECK(...) ((void)0) #define debug(...) ((void)0) #endif diff --git a/src/vm/exec.c b/src/vm/exec.c index 6b1dad0..84568ba 100644 --- a/src/vm/exec.c +++ b/src/vm/exec.c @@ -20,13 +20,15 @@ void swap_stack_top(hVm vm); void print_stack(hVm vm); void sbVm_initialize(hVm vm, usize stacksize, usize rstacksize, flag debugmode) { - *vm = (sbVm) {0}; - vm->vstack = malloc(stacksize); - vm->stacksize = stacksize; - vm->rstack = malloc(rstacksize); - vm->rstacksize = rstacksize; + *vm = (sbVm) { + .stacksize = stacksize, + .rstacksize = rstacksize, + .debugmode = debugmode, + }; + vm->vstack = malloc(stacksize); vm->vsp = vm->vstack; + vm->rstack = malloc(rstacksize); vm->rsp = vm->rstack; vm->fp = (sbVmStackFrame*)vm->rstack;