From efe34282b5db31999bbee266e87eb07fe78b814c Mon Sep 17 00:00:00 2001
From: Jim Ursetto <zbigniewsz@gmail.com>
Date: Fri, 13 Jan 2012 00:00:22 -0600
Subject: [PATCH 2/2] Use C_stack_pointer instead of C_alloc(0) when
generating foreign callback 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.
---
c-backend.scm | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/c-backend.scm b/c-backend.scm
index 1d04f01..a90b864 100644
a
|
b
|
|
1116 | 1116 | (when rname |
1117 | 1117 | (gen #t "/* from " (cleanup rname) " */") ) |
1118 | 1118 | (generate-foreign-callback-header "" stub) |
1119 | | (gen #\{ #t "C_word x,s=" sizestr ",*a=C_alloc(s);") |
| 1119 | (gen #\{ #t "C_word x,s=" sizestr ",*a=" |
| 1120 | (if (string=? "0" sizestr) "C_stack_pointer;" "C_alloc(s);")) |
1120 | 1121 | (gen #t "C_callback_adjust_stack(a,s);") ; make sure content is below stack_bottom as well |
1121 | 1122 | (for-each |
1122 | 1123 | (lambda (v t) |