ref: 38ab710df8704dc44dc3274ce4e7d5037cd6c7ef
parent: 15306c74c7f0101c4c367a220f83911a25ff3e2e
author: Sigrid Solveig Haflínudóttir <[email protected]>
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