From 93310be845ee8dee14fb19cab97ffcd0612a589f Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Sun, 21 Feb 2021 11:24:08 -0500 Subject: [PATCH] Convert C function calls --- ffi.c | 6 ++++-- include/cyclone/runtime.h | 2 +- runtime.c | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ffi.c b/ffi.c index 37553adb..fa356331 100644 --- a/ffi.c +++ b/ffi.c @@ -101,8 +101,9 @@ object Cyc_scm_call(gc_thread_data *parent_thd, object fnc, int argc, object *ar * We store results and longjmp back to where we started, at the * bottom of the trampoline (we only jump once). */ -static void no_gc_after_call_scm(gc_thread_data *thd, int argc, object k, object result) +static void no_gc_after_call_scm(gc_thread_data *thd, object _, int argc, object *args) { + object result = args[0]; thd->gc_cont = result; longjmp(*(thd->jmp_start), 1); } @@ -113,7 +114,8 @@ static void no_gc_after_call_scm(gc_thread_data *thd, int argc, object k, object static void no_gc_call_scm(gc_thread_data *thd, object fnc, object obj) { mclosure0(after, (function_type)no_gc_after_call_scm); - ((closure)fnc)->fn(thd, 2, fnc, &after, obj); + object buf[2] = {&after, obj}; + ((closure)fnc)->fn(thd, fnc, 2, buf); } /** diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index 5f67e73e..f3f4f251 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -569,7 +569,7 @@ time_t Cyc_file_last_modified_time(char *path); object Cyc_spawn_thread(object thunk); void Cyc_start_trampoline(gc_thread_data * thd); void Cyc_end_thread(gc_thread_data * thd); -void Cyc_exit_thread(gc_thread_data * thd); +void Cyc_exit_thread(void *data, object _, int argc, object *args); object Cyc_thread_sleep(void *data, object timeout); /**@}*/ diff --git a/runtime.c b/runtime.c index 124e153f..987e924c 100644 --- a/runtime.c +++ b/runtime.c @@ -6633,7 +6633,7 @@ void Cyc_end_thread(gc_thread_data * thd) GC(thd, &clo, thd->gc_args, 0); } -void Cyc_exit_thread(gc_thread_data * thd) +void Cyc_exit_thread(void *data, object _, int argc, object *args) { // alternatively could call longjmp with a null continuation, but that seems // more complicated than necessary. or does it... see next comment: @@ -6644,6 +6644,7 @@ void Cyc_exit_thread(gc_thread_data * thd) //printf("DEBUG - exiting thread\n"); // Remove thread from the list of mutators, and mark its data to be freed + gc_thread_data *thd = data; gc_remove_mutator(thd); ck_pr_cas_int((int *)&(thd->thread_state), CYC_THREAD_STATE_RUNNABLE, CYC_THREAD_STATE_TERMINATED);