ref: 08cacb3e4642186cbcee1b5da64d4921a7e8feaf
parent: 053f9ab110a55a24150c8cae285176fda8831fad
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Nov 21 18:36:03 EST 2024
computed gotos: use direct label addresses instead of offsets
--- a/flisp.c
+++ b/flisp.c
@@ -895,9 +895,9 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#define OP(x) op_##x:
-#define NEXT_OP goto *((uint8_t*)&&op_OP_LOADA0 + ops[op = *ip++])
-#define GOTO_OP_OFFSET(op) [op] = (int)((uint8_t*)&&op_##op - (uint8_t*)&&op_OP_LOADA0)
- static const int ops[] = {+#define NEXT_OP goto *ops[op = *ip++]
+#define GOTO_OP_OFFSET(op) [op] = &&op_##op
+ static const void *ops[] = {GOTO_OP_OFFSET(OP_LOADA0),
GOTO_OP_OFFSET(OP_LOADA1),
GOTO_OP_OFFSET(OP_LOADV),
@@ -1074,7 +1074,7 @@
default:
op = i;
#if defined(COMPUTED_GOTO)
- goto *((uint8_t*)&&op_OP_LOADA0 + ops[i]);
+ goto *ops[i];
#else
continue;
#endif
--
⑨