summaryrefslogtreecommitdiffstats
path: root/libffi
diff options
context:
space:
mode:
authorgeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-01 05:28:41 +0000
committergeoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-01 05:28:41 +0000
commitc8dfb8efd61184617d8964d424fd6a9edba95aa6 (patch)
tree74f939bf9675730feae0078a642eb4da864c5ce5 /libffi
parent154db13d9dd66114ec4845308146f4f993b6696c (diff)
downloadppe42-gcc-c8dfb8efd61184617d8964d424fd6a9edba95aa6.tar.gz
ppe42-gcc-c8dfb8efd61184617d8964d424fd6a9edba95aa6.zip
In gcc/:
PR 23067 * c-decl.c (start_struct): Don't create self-containing structures. * config/rs6000/rs6000.c (darwin_rs6000_special_round_type_align): New. * config/rs6000/rs6000-protos.h (darwin_rs6000_special_round_type_align): New. * config/rs6000/darwin.h (ADJUST_FIELD_ALIGN): Rewrite. (ROUND_TYPE_ALIGN): Use darwin_rs6000_special_round_type_align. In gcc/testsuite/: PR 23067 * gcc.target/powerpc/darwin-abi-3.c: Remove XFAIL. * gcc.target/powerpc/darwin-abi-6.c: Remove XFAIL. * gcc.target/powerpc/darwin-abi-7.c: Remove XFAIL. * gcc.target/powerpc/darwin-abi-8.c: Remove XFAIL. * gcc.target/powerpc/darwin-abi-9.c: Remove XFAIL. * gcc.target/powerpc/darwin-abi-10.c: Remove XFAIL. * gcc.target/powerpc/darwin-abi-11.c: Remove XFAIL. In libobjc/: * encoding.c (darwin_rs6000_special_round_type_align): New. In libffi/: * src/powerpc/ffi_darwin.c (darwin_adjust_aggregate_sizes): New. (ffi_prep_cif_machdep): Call darwin_adjust_aggregate_sizes for Darwin. * testsuite/libffi.call/nested_struct4.c: Remove Darwin XFAIL. * testsuite/libffi.call/nested_struct6.c: Remove Darwin XFAIL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118365 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libffi')
-rw-r--r--libffi/ChangeLog8
-rw-r--r--libffi/src/powerpc/ffi_darwin.c61
-rw-r--r--libffi/testsuite/libffi.call/nested_struct4.c2
-rw-r--r--libffi/testsuite/libffi.call/nested_struct6.c2
4 files changed, 66 insertions, 7 deletions
diff --git a/libffi/ChangeLog b/libffi/ChangeLog
index 1ab09027872..a5bdcd27e54 100644
--- a/libffi/ChangeLog
+++ b/libffi/ChangeLog
@@ -1,3 +1,11 @@
+2006-10-16 Geoffrey Keating <geoffk@apple.com>
+
+ * src/powerpc/ffi_darwin.c (darwin_adjust_aggregate_sizes): New.
+ (ffi_prep_cif_machdep): Call darwin_adjust_aggregate_sizes for
+ Darwin.
+ * testsuite/libffi.call/nested_struct4.c: Remove Darwin XFAIL.
+ * testsuite/libffi.call/nested_struct6.c: Remove Darwin XFAIL.
+
2006-10-10 Paolo Bonzini <bonzini@gnu.org>
Sandro Tolaini <tolaini@libero.it>
diff --git a/libffi/src/powerpc/ffi_darwin.c b/libffi/src/powerpc/ffi_darwin.c
index 1d4fb34232a..6bc0474e3db 100644
--- a/libffi/src/powerpc/ffi_darwin.c
+++ b/libffi/src/powerpc/ffi_darwin.c
@@ -1,11 +1,12 @@
/* -----------------------------------------------------------------------
- ffi.c - Copyright (c) 1998 Geoffrey Keating
+ ffi_darwin.c
- PowerPC Foreign Function Interface
-
- Darwin ABI support (c) 2001 John Hornkvist
- AIX ABI support (c) 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998 Geoffrey Keating
+ Copyright (C) 2001 John Hornkvist
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+ FFI support for Darwin and AIX.
+
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
@@ -225,6 +226,48 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
//FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
}
+/* Adjust the size of S to be correct for Darwin.
+ On Darwin, the first field of a structure has natural alignment. */
+
+static void
+darwin_adjust_aggregate_sizes (ffi_type *s)
+{
+ int i;
+
+ if (s->type != FFI_TYPE_STRUCT)
+ return;
+
+ s->size = 0;
+ for (i = 0; s->elements[i] != NULL; i++)
+ {
+ ffi_type *p;
+ int align;
+
+ p = s->elements[i];
+ darwin_adjust_aggregate_sizes (p);
+ if (i == 0
+ && (p->type == FFI_TYPE_UINT64
+ || p->type == FFI_TYPE_SINT64
+ || p->type == FFI_TYPE_DOUBLE
+ || p->alignment == 8))
+ align = 8;
+ else if (p->alignment == 16 || p->alignment < 4)
+ align = p->alignment;
+ else
+ align = 4;
+ s->size = ALIGN(s->size, align) + p->size;
+ }
+
+ s->size = ALIGN(s->size, s->alignment);
+
+ if (s->elements[0]->type == FFI_TYPE_UINT64
+ || s->elements[0]->type == FFI_TYPE_SINT64
+ || s->elements[0]->type == FFI_TYPE_DOUBLE
+ || s->elements[0]->alignment == 8)
+ s->alignment = s->alignment > 8 ? s->alignment : 8;
+ /* Do not add additional tail padding. */
+}
+
/* Perform machine dependent cif processing. */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
@@ -237,8 +280,16 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
unsigned size_al = 0;
/* All the machine-independent calculation of cif->bytes will be wrong.
+ All the calculation of structure sizes will also be wrong.
Redo the calculation for DARWIN. */
+ if (cif->abi == FFI_DARWIN)
+ {
+ darwin_adjust_aggregate_sizes (cif->rtype);
+ for (i = 0; i < cif->nargs; i++)
+ darwin_adjust_aggregate_sizes (cif->arg_types[i]);
+ }
+
/* Space for the frame pointer, callee's LR, CR, etc, and for
the asm's temp regs. */
diff --git a/libffi/testsuite/libffi.call/nested_struct4.c b/libffi/testsuite/libffi.call/nested_struct4.c
index d7abf69c126..f67b6a95874 100644
--- a/libffi/testsuite/libffi.call/nested_struct4.c
+++ b/libffi/testsuite/libffi.call/nested_struct4.c
@@ -6,7 +6,7 @@
PR: PR 25630.
Originator: <andreast@gcc.gnu.org> 20051010 */
-/* { dg-do run { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* powerpc*-*-darwin* } } */
+/* { dg-do run { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
#include "ffitest.h"
typedef struct A {
diff --git a/libffi/testsuite/libffi.call/nested_struct6.c b/libffi/testsuite/libffi.call/nested_struct6.c
index 116254708ad..8bf737b36f8 100644
--- a/libffi/testsuite/libffi.call/nested_struct6.c
+++ b/libffi/testsuite/libffi.call/nested_struct6.c
@@ -6,7 +6,7 @@
PR: PR 25630.
Originator: <andreast@gcc.gnu.org> 20051010 */
-/* { dg-do run { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* powerpc*-*-darwin* } } */
+/* { dg-do run { xfail mips64*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
#include "ffitest.h"
typedef struct A {
OpenPOWER on IntegriCloud