mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-03 19:26:34 +02:00
Working example
This commit is contained in:
parent
973279e2ff
commit
a28b68c64a
2 changed files with 11 additions and 10 deletions
|
@ -13,16 +13,16 @@
|
||||||
return_closcall1(data, k, boolean_t); ")
|
return_closcall1(data, k, boolean_t); ")
|
||||||
|
|
||||||
(define (signal-done obj)
|
(define (signal-done obj)
|
||||||
(write `(Called from C set *done* to ,obj))
|
;(write `(Called from C set *done* to ,obj))
|
||||||
(newline)
|
;(newline)
|
||||||
(set! *done* obj)
|
(set! *done* obj)
|
||||||
#t)
|
#t)
|
||||||
|
|
||||||
(define (wait)
|
(define (wait)
|
||||||
(start-c-thread)
|
|
||||||
(thread-sleep! 1)
|
(thread-sleep! 1)
|
||||||
(if *done*
|
(if *done*
|
||||||
#t
|
#t
|
||||||
(wait)))
|
(wait)))
|
||||||
|
|
||||||
|
(start-c-thread)
|
||||||
(wait)
|
(wait)
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
extern object __glo_signal_91done;
|
extern object __glo_signal_91done;
|
||||||
void after_call_scm(gc_thread_data *thd, int argc, object k, object result)
|
void after_call_scm(gc_thread_data *thd, int argc, object k, object result)
|
||||||
{
|
{
|
||||||
// TODO: what to do with result?
|
// TODO: need to check this, does NOT work if result is a stack obj!!
|
||||||
|
thd->gc_cont = result;
|
||||||
longjmp(*(thd->jmp_start), 1);
|
longjmp(*(thd->jmp_start), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ void wait_and_signal(gc_thread_data *thd)
|
||||||
|
|
||||||
void *c_thread(void *arg)
|
void *c_thread(void *arg)
|
||||||
{
|
{
|
||||||
int first = 1;
|
|
||||||
long stack_size = 100000;
|
long stack_size = 100000;
|
||||||
char *stack_base = (char *)&stack_size;
|
char *stack_base = (char *)&stack_size;
|
||||||
char *stack_traces[MAX_STACK_TRACES];
|
char *stack_traces[MAX_STACK_TRACES];
|
||||||
|
@ -45,16 +44,18 @@ void *c_thread(void *arg)
|
||||||
thd.stack_traces = stack_traces; //calloc(MAX_STACK_TRACES, sizeof(char *));
|
thd.stack_traces = stack_traces; //calloc(MAX_STACK_TRACES, sizeof(char *));
|
||||||
thd.stack_trace_idx = 0;
|
thd.stack_trace_idx = 0;
|
||||||
thd.stack_prev_frame = NULL;
|
thd.stack_prev_frame = NULL;
|
||||||
|
thd.gc_cont = NULL;
|
||||||
|
|
||||||
// TODO: many more initializations required, need to figure out
|
// TODO: many more initializations required, need to figure out
|
||||||
// minimum set to optimize for micro / short / long calls into Scheme.
|
// minimum set to optimize for micro / short / long calls into Scheme.
|
||||||
// We will make different assumptions in each case
|
// We will make different assumptions in each case
|
||||||
|
|
||||||
setjmp(*(thd.jmp_start));
|
if (!setjmp(*(thd.jmp_start))) {
|
||||||
|
|
||||||
if (first) {
|
|
||||||
first = 0;
|
|
||||||
wait_and_signal(&thd);
|
wait_and_signal(&thd);
|
||||||
|
} else {
|
||||||
|
printf("Received: ");
|
||||||
|
Cyc_write(&thd, thd.gc_cont, stdout);
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue