Fix for closures with sunpro compiler
authorAnthony Green <green@moxielogic.com>
Thu, 10 Jan 2013 02:14:54 +0000 (21:14 -0500)
committerAnthony Green <green@moxielogic.com>
Thu, 10 Jan 2013 02:14:54 +0000 (21:14 -0500)
ChangeLog
configure
configure.ac
src/x86/ffi.c
src/x86/sysv.S

index 289d195..ff76645 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-10  Anthony Green  <green@moxielogic.com>
+
+       * configure.ac: Put local.exp in the right place.
+       * configure: Rebuilt.
+
+       * src/x86/ffi.c: Update comment about regparm function attributes.
+       * src/x86/sysv.S (ffi_closure_SYSV): The SUNPRO compiler requires
+       that all function arguments be passed on the stack (no regparm
+       support).
+
 2013-01-08  Anthony Green  <green@moxielogic.com>
 
        * configure.ac: Generate local.exp.  This sets CC_FOR_TARGET
index 5876eb7..4a12b96 100755 (executable)
--- a/configure
+++ b/configure
@@ -13068,10 +13068,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 if test "x$GCC" = "xyes"; then
   CFLAGS="$CFLAGS -fexceptions"
-  touch testsuite/local.exp
+  touch local.exp
 else
   cat > local.exp <<EOF
-set CC_FOR_TARGET $CC
+set CC_FOR_TARGET "$CC"
 EOF
 fi
 
index 7ffb36c..13d5bc2 100644 (file)
@@ -40,10 +40,10 @@ AX_CC_MAXOPT
 AX_CFLAGS_WARN_ALL
 if test "x$GCC" = "xyes"; then
   CFLAGS="$CFLAGS -fexceptions"
-  touch testsuite/local.exp
+  touch local.exp
 else
   cat > local.exp <<EOF
-set CC_FOR_TARGET $CC  
+set CC_FOR_TARGET "$CC"
 EOF
 fi
 
index 611e221..3f46693 100644 (file)
@@ -424,7 +424,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 /** private members **/
 
 /* The following __attribute__((regparm(1))) decorations will have no effect
-   on MSVC - standard cdecl convention applies. */
+   on MSVC or SUNPRO_C -- standard conventions apply. */
 static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
                                          void** args, ffi_cif* cif);
 void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *)
index 69e7e8d..71502bb 100644 (file)
@@ -182,9 +182,19 @@ ffi_closure_SYSV:
        leal    -24(%ebp), %edx
        movl    %edx, -12(%ebp) /* resp */
        leal    8(%ebp), %edx
+#ifdef __SUNPRO_C
+       /* The SUNPRO compiler doesn't support GCC's regparm function
+          attribute, so we have to pass all three arguments to
+          ffi_closure_SYSV_inner on the stack.  */
+       movl    %edx, 8(%esp)   /* args = __builtin_dwarf_cfa () */
+       leal    -12(%ebp), %edx
+       movl    %edx, 4(%esp)   /* &resp */
+       movl    %eax, (%esp)    /* closure */
+#else
        movl    %edx, 4(%esp)   /* args = __builtin_dwarf_cfa () */
        leal    -12(%ebp), %edx
        movl    %edx, (%esp)    /* &resp */
+#endif
 #if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__
        call    ffi_closure_SYSV_inner
 #else