Convert C function calls

This commit is contained in:
Justin Ethier 2021-02-21 11:24:08 -05:00
parent d06dbcb64a
commit 93310be845
3 changed files with 7 additions and 4 deletions

6
ffi.c
View file

@ -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);
}
/**

View file

@ -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);
/**@}*/

View file

@ -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);