From 3d03684f1f7b585418eb33ad6b636f747b670184 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 7 Aug 2020 19:45:29 -0400 Subject: [PATCH] Cleanup --- examples/callbacks/sys.c | 51 +++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/examples/callbacks/sys.c b/examples/callbacks/sys.c index 9dc7a232..c31e15e3 100644 --- a/examples/callbacks/sys.c +++ b/examples/callbacks/sys.c @@ -4,11 +4,40 @@ #include /** - * This variable corresponds to the Scheme function (in the generated C file) + * This variable corresponds to the Scheme function in the generated C file * that we wish to call into. */ extern object __glo_signal_91done; +/** + * Code for the C thread. + * + * In our application we just call the trampoline function to setup a call + * into Scheme code. In a real application this thread would probably do + * quite a bit more work in C, only calling into Scheme code as necessary. + */ +void *c_thread(void *arg) +{ + printf("Hello from C thread\n"); + sleep(1); + printf("C calling into SCM\n"); + + object obj = c_trampoline(arg, __glo_signal_91done, boolean_t); + + printf("C received: "); + Cyc_write(NULL, obj, stdout); + printf("\n"); + return NULL; +} + + +/////////////////////////////////////////////////////////////////////////////// +// +// Should not need to customize below here: +// +/////////////////////////////////////////////////////////////////////////////// + + /** * Scheme function calls into this function when it is done. * We store results and longjmp back to where we started, at the @@ -96,26 +125,6 @@ object c_trampoline(gc_thread_data *parent_thd, object fnc, object arg) } } -/** - * C thread. In our application we just call the trampoline function - * to setup a call into Scheme code. In a real application this thread - * could do quite a bit more work in C, occasionally calling into - * Scheme code as necessary. - */ -void *c_thread(void *arg) -{ - printf("Hello from C thread\n"); - sleep(1); - printf("C calling into SCM\n"); - - object obj = c_trampoline(arg, __glo_signal_91done, boolean_t); - - printf("C received: "); - Cyc_write(NULL, obj, stdout); - printf("\n"); - return NULL; -} - /** * Called by Scheme to create the C thread. * This is required by sample app since we start