~ chicken-core (chicken-5) 41b9d74b1acb1320c2cd757fcc223da248f326a4
commit 41b9d74b1acb1320c2cd757fcc223da248f326a4 Author: felix <felix@call-with-current-continuation.org> AuthorDate: Sun Jul 19 11:32:37 2015 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Sun Jul 19 11:32:37 2015 +0200 bugfixes in C_callback diff --git a/chicken.h b/chicken.h index 5195d485..af365d51 100644 --- a/chicken.h +++ b/chicken.h @@ -495,6 +495,7 @@ static inline int isinf_ld (long double x) #define C_SIZEOF_BUCKET 3 #define C_SIZEOF_LOCATIVE 5 #define C_SIZEOF_PORT 16 +#define C_SIZEOF_CLOSURE(n) ((n)+1) /* Fixed size types have pre-computed header tags */ #define C_PAIR_TAG (C_PAIR_TYPE | (C_SIZEOF_PAIR - 1)) diff --git a/runtime.c b/runtime.c index 3c799ed8..0ffc762e 100644 --- a/runtime.c +++ b/runtime.c @@ -1888,7 +1888,7 @@ C_word C_fcall C_callback(C_word closure, int argc) jmp_buf prev; #endif C_word - *a = C_alloc(3), + *a = C_alloc(C_SIZEOF_CLOSURE(2)), k = C_closure(&a, 2, (C_word)callback_return_continuation, C_SCHEME_FALSE), *av; int old = chicken_is_running; @@ -1903,13 +1903,13 @@ C_word C_fcall C_callback(C_word closure, int argc) av[ 0 ] = closure; av[ 1 ] = k; /*XXX is the order of arguments an issue? */ - C_memcpy(av + 2, C_temporary_stack, (argc - 2) * sizeof(C_word)); + C_memcpy(av + 2, C_temporary_stack, argc * sizeof(C_word)); C_temporary_stack = C_temporary_stack_bottom; #ifdef HAVE_SIGSETJMP - if(!C_sigsetjmp(C_restart, 0)) C_do_apply(argc, av); + if(!C_sigsetjmp(C_restart, 0)) C_do_apply(argc + 2, av); #else - if(!C_setjmp(C_restart)) C_do_apply(argc, av); + if(!C_setjmp(C_restart)) C_do_apply(argc + 2, av); #endif serious_signal_occurred = 0;Trap