This commit is contained in:
Justin Ethier 2020-08-07 19:45:29 -04:00
parent 0bd2f85470
commit 3d03684f1f

View file

@ -4,11 +4,40 @@
#include <unistd.h> #include <unistd.h>
/** /**
* 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. * that we wish to call into.
*/ */
extern object __glo_signal_91done; 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. * Scheme function calls into this function when it is done.
* We store results and longjmp back to where we started, at the * 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. * Called by Scheme to create the C thread.
* This is required by sample app since we start * This is required by sample app since we start