Ticket #771: 0002-Use-C_stack_pointer-instead-of-C_alloc-0-when-genera.patch

File 0002-Use-C_stack_pointer-instead-of-C_alloc-0-when-genera.patch, 1.1 KB (added by Jim Ursetto, 13 years ago)
  • c-backend.scm

    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  
    11161116         (when rname
    11171117           (gen #t "/* from " (cleanup rname) " */") )
    11181118         (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);"))
    11201121         (gen #t "C_callback_adjust_stack(a,s);") ; make sure content is below stack_bottom as well
    11211122         (for-each
    11221123          (lambda (v t)