prep_cif.c (initialize_aggregate): Include tail padding in structure size.
authorAlan Modra <amodra@bigpond.net.au>
Thu, 11 Sep 2003 23:54:40 +0000 (23:54 +0000)
committerAlan Modra <amodra@gcc.gnu.org>
Thu, 11 Sep 2003 23:54:40 +0000 (09:24 +0930)
* src/prep_cif.c (initialize_aggregate): Include tail padding in
structure size.
* src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Correct
placement of float result.
* testsuite/libffi.special/unwindtest.cc (closure_test_fn1): Correct
cast of "resp" for big-endian 64 bit machines.

From-SVN: r71323

libffi/ChangeLog
libffi/src/powerpc/linux64_closure.S
libffi/src/prep_cif.c
libffi/testsuite/libffi.special/unwindtest.cc

index 2efe64b..15f9c6d 100644 (file)
@@ -1,3 +1,12 @@
+2003-09-12  Alan Modra  <amodra@bigpond.net.au>
+
+       * src/prep_cif.c (initialize_aggregate): Include tail padding in
+       structure size.
+       * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Correct
+       placement of float result.
+       * testsuite/libffi.special/unwindtest.cc (closure_test_fn1): Correct
+       cast of "resp" for big-endian 64 bit machines.
+
 2003-09-11  Alan Modra  <amodra@bigpond.net.au>
 
        * src/types.c (double, longdouble): Merge identical SH and ARM
index 6cad16a..2d44d67 100644 (file)
@@ -97,7 +97,7 @@ ffi_closure_LINUX64:
        addi %r1, %r1, 224
        blr
 # case FFI_TYPE_FLOAT
-       lfs %f1, 112+4(%r1)
+       lfs %f1, 112+0(%r1)
        mtlr %r0
        addi %r1, %r1, 224
        blr
index d3c89c3..d60d98e 100644 (file)
@@ -64,6 +64,15 @@ static ffi_status initialize_aggregate(/*@out@*/ ffi_type *arg)
       ptr++;
     }
 
+  /* Structure size includes tail padding.  This is important for
+     structures that fit in one register on ABIs like the PowerPC64
+     Linux ABI that right justify small structs in a register.
+     It's also needed for nested structure layout, for example
+     struct A { long a; char b; }; struct B { struct A x; char y; };
+     should find y at an offset of 2*sizeof(long) and result in a
+     total size of 3*sizeof(long).  */
+  arg->size = ALIGN (arg->size, arg->alignment);
+
   if (arg->size == 0)
     return FFI_BAD_TYPEDEF;
   else
index 97b1536..b6be367 100644 (file)
@@ -37,9 +37,9 @@ void closure_test_fn1(ffi_cif* cif,void* resp,void** args,
           (int)(*(int *)args[10]), (int)(*(float *)args[11]),
           (int)*(int *)args[12], (int)(*(int *)args[13]),
           (int)(*(int *)args[14]), *(int *)args[15],
-          (int)(long)userdata, *(int*)resp);
+          (int)(long)userdata, (int)*(ffi_arg*)resp);
     
-    throw *(int*)resp;
+    throw (int)*(ffi_arg*)resp;
 }
 
 typedef int (*closure_test_type1)(float, float, float, float, signed short,