Skip to content
Browse files

Use C_stack_pointer instead of C_alloc(0) when generating foreign cal…

…lback stubs

alloca(0) returns NULL in LLVM instead of returning the stack pointer,
so generate a call to C_stack_pointer instead.  This is only necessary
when adjusting the callback stack, as all other calls to C_alloc are
omitted when their size is 0.
  • Loading branch information...
1 parent 55bce3a commit 38bca304f928aaf4172a89e0a5b893e1efb2e1e3 @ursetto committed Jan 13, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 c-backend.scm
3 c-backend.scm
@@ -1116,7 +1116,8 @@
(when rname
(gen #t "/* from " (cleanup rname) " */") )
(generate-foreign-callback-header "" stub)
- (gen #\{ #t "C_word x,s=" sizestr ",*a=C_alloc(s);")
+ (gen #\{ #t "C_word x,s=" sizestr ",*a="
+ (if (string=? "0" sizestr) "C_stack_pointer;" "C_alloc(s);"))
(gen #t "C_callback_adjust_stack(a,s);") ; make sure content is below stack_bottom as well
(lambda (v t)

0 comments on commit 38bca30

Please sign in to comment.
Something went wrong with that request. Please try again.