1
0
Fork 0
forked from fun/fun

Fixed bug to make trhreading work again on alpine linux. (0.41.1)

This commit is contained in:
Johannes Findeisen 2026-04-27 02:22:31 +02:00
commit c7438ca109
3 changed files with 9 additions and 4 deletions

View file

@ -79,7 +79,11 @@ extern int map_expanded_line_to_include_path(const char *path, int line, char *o
#include "vm/os/thread_common.c"
/* Track the currently running VM to annotate error messages */
static VM *g_active_vm = NULL;
#ifdef _WIN32
static __declspec(thread) VM *g_active_vm = NULL;
#else
static __thread VM *g_active_vm = NULL;
#endif
/* fprintf wrapper that appends source line info for stderr messages */
static int fun_vm_vfprintf(FILE *stream, const char *fmt, va_list ap) {
@ -166,7 +170,7 @@ static int fun_vm_fprintf(FILE *stream, const char *fmt, ...) {
/* Intercept exit() in this translation unit so VM errors don't terminate the process outright */
#include <setjmp.h>
static jmp_buf g_vm_err_jmp;
static __thread jmp_buf g_vm_err_jmp;
static void fun_vm_exit(int code) {
if (g_active_vm && g_active_vm->repl_on_error) {

View file

@ -96,7 +96,8 @@ static fun_thread_ret_t fun_thread_main(void *param)
/* Build wrapper: LOAD_CONST <fn>; LOAD_CONST <arg0> ...; CALL argc; HALT */
Bytecode *wrap = bytecode_new();
int cFn = bytecode_add_constant(wrap, copy_value(&(Value){.type = VAL_FUNCTION, .fn = task->fn}));
/* Use make_function constructor which correctly handles the pointer */
int cFn = bytecode_add_constant(wrap, make_function(task->fn));
bytecode_add_instruction(wrap, OP_LOAD_CONST, cFn);
for (int i = 0; i < task->argc; ++i) {
int cArg = bytecode_add_constant(wrap, deep_copy_value(&task->args[i]));