summaryrefslogtreecommitdiff
path: root/src/powerpc
diff options
context:
space:
mode:
authorAnthony Green <green@gmachine.(none)>2009-12-29 10:06:04 -0500
committerAnthony Green <green@gmachine.(none)>2009-12-29 10:06:04 -0500
commit0cfe60e9d13f132b88995cfee41f2156344f6fa2 (patch)
tree9f67a6804965d5543fe130e6d6dbac2efa97a578 /src/powerpc
parent14e2e92e8645804b6940b3e96c98e9f7f384a6b2 (diff)
downloadlibffi-0cfe60e9d13f132b88995cfee41f2156344f6fa2.tar.gz
3.0.9rc12
Diffstat (limited to 'src/powerpc')
-rw-r--r--src/powerpc/.svn/entries28
-rw-r--r--src/powerpc/.svn/text-base/ffi.c.svn-base3
-rw-r--r--src/powerpc/.svn/text-base/ffi_darwin.c.svn-base75
-rw-r--r--src/powerpc/ffi.c1
-rw-r--r--src/powerpc/ffi.c.rej18
-rw-r--r--src/powerpc/ffi_darwin.c75
6 files changed, 160 insertions, 40 deletions
diff --git a/src/powerpc/.svn/entries b/src/powerpc/.svn/entries
index 1f52202..d10b5a2 100644
--- a/src/powerpc/.svn/entries
+++ b/src/powerpc/.svn/entries
@@ -1,14 +1,14 @@
10
dir
-155472
+155499
svn+ssh://green@gcc.gnu.org/svn/gcc/trunk/libffi/src/powerpc
svn+ssh://green@gcc.gnu.org/svn/gcc
-2009-12-08T00:41:10.883117Z
-155070
+2009-12-28T18:19:18.861565Z
+155492
dje
@@ -202,11 +202,11 @@ file
-2009-12-20T06:01:53.730558Z
-5e33e72fe5ecabf0a89cf4d5227cb1ca
-2009-06-16T17:55:39.375944Z
-148543
-andreast
+2009-12-29T03:43:00.498236Z
+817f588a25206791e6c66eac1d0053ef
+2009-12-26T12:40:27.505316Z
+155473
+schwab
@@ -228,7 +228,7 @@ andreast
-39006
+39056
sysv.S
file
@@ -338,10 +338,10 @@ file
-2009-12-20T06:01:53.730558Z
-060e5d94c60a73470ae84eefddd59be0
-2009-12-04T15:36:50.057287Z
-154983
+2009-12-29T03:43:00.515985Z
+16f90a13659a11e0db8871d655b430f8
+2009-12-28T18:19:18.861565Z
+155492
dje
@@ -364,7 +364,7 @@ dje
-24973
+26077
linux64.S
file
diff --git a/src/powerpc/.svn/text-base/ffi.c.svn-base b/src/powerpc/.svn/text-base/ffi.c.svn-base
index fbbfbe2..75784a9 100644
--- a/src/powerpc/.svn/text-base/ffi.c.svn-base
+++ b/src/powerpc/.svn/text-base/ffi.c.svn-base
@@ -185,6 +185,7 @@ ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
{
*next_arg.f = (float) double_tmp;
next_arg.u += 1;
+ intarg_count++;
}
else
*fpr_base.d++ = double_tmp;
@@ -1149,6 +1150,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
pst++;
avalue[i] = pst;
pst += 2;
+ ng = 8;
}
break;
@@ -1222,6 +1224,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
{
avalue[i] = pst;
pst += 4;
+ ng = 8;
}
break;
}
diff --git a/src/powerpc/.svn/text-base/ffi_darwin.c.svn-base b/src/powerpc/.svn/text-base/ffi_darwin.c.svn-base
index def92a5..d84f1c3 100644
--- a/src/powerpc/.svn/text-base/ffi_darwin.c.svn-base
+++ b/src/powerpc/.svn/text-base/ffi_darwin.c.svn-base
@@ -32,7 +32,7 @@
#include <stdlib.h>
-extern void ffi_closure_ASM(void);
+extern void ffi_closure_ASM (void);
enum {
/* The assembly depends on these exact flags. */
@@ -80,10 +80,13 @@ enum { ASM_NEEDS_REGISTERS = 4 };
*/
-void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
+void
+ffi_prep_args (extended_cif *ecif, unsigned long *const stack)
{
const unsigned bytes = ecif->cif->bytes;
const unsigned flags = ecif->cif->flags;
+ const unsigned nargs = ecif->cif->nargs;
+ const ffi_abi abi = ecif->cif->abi;
/* 'stacktop' points at the previous backchain pointer. */
unsigned long *const stacktop = stack + (bytes / sizeof(unsigned long));
@@ -118,7 +121,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
*next_arg++ = (unsigned long) (char *) ecif->rvalue;
/* Now for the arguments. */
- for (i = ecif->cif->nargs; i > 0; i--, ptr++, p_argv++)
+ for (i = nargs; i > 0; i--, ptr++, p_argv++)
{
switch ((*ptr)->type)
{
@@ -213,7 +216,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
size_al = (*ptr)->size;
if ((*ptr)->elements[0]->type == 3)
size_al = ALIGN((*ptr)->size, 8);
- if (size_al < 3 && ecif->cif->abi == FFI_DARWIN)
+ if (size_al < 3 && abi == FFI_DARWIN)
dest_cpy += 4 - size_al;
memcpy ((char *) dest_cpy, (char *) *p_argv, size_al);
@@ -229,7 +232,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
the struct to double-word. */
if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE)
size_al = ALIGN((*ptr)->size, 8);
- if (size_al < 3 && ecif->cif->abi == FFI_DARWIN)
+ if (size_al < 3 && abi == FFI_DARWIN)
dest_cpy += 4 - size_al;
memcpy((char *) dest_cpy, (char *) *p_argv, size_al);
@@ -301,8 +304,44 @@ darwin_adjust_aggregate_sizes (ffi_type *s)
/* Do not add additional tail padding. */
}
+/* Adjust the size of S to be correct for AIX.
+ Word-align double unless it is the first member of a structure. */
+
+static void
+aix_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];
+ aix_adjust_aggregate_sizes (p);
+ align = p->alignment;
+ if (i != 0 && p->type == FFI_TYPE_DOUBLE)
+ 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)
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
{
/* All this is for the DARWIN ABI. */
int i;
@@ -323,6 +362,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
darwin_adjust_aggregate_sizes (cif->arg_types[i]);
}
+ if (cif->abi == FFI_AIX)
+ {
+ aix_adjust_aggregate_sizes (cif->rtype);
+ for (i = 0; i < cif->nargs; i++)
+ aix_adjust_aggregate_sizes (cif->arg_types[i]);
+ }
+
/* Space for the frame pointer, callee's LR, CR, etc, and for
the asm's temp regs. */
@@ -473,7 +519,8 @@ extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *,
extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *,
void (*fn)(void), void (*fn2)(void));
-void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+void
+ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
extended_cif ecif;
@@ -486,7 +533,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
- ecif.rvalue = alloca(cif->rtype->size);
+ ecif.rvalue = alloca (cif->rtype->size);
}
else
ecif.rvalue = rvalue;
@@ -661,8 +708,9 @@ typedef union
double d;
} ffi_dblfl;
-int ffi_closure_helper_DARWIN (ffi_closure*, void*,
- unsigned long*, ffi_dblfl*);
+int
+ffi_closure_helper_DARWIN (ffi_closure *, void *,
+ unsigned long *, ffi_dblfl *);
/* Basically the trampoline invokes ffi_closure_ASM, and on
entry, r11 holds the address of the closure.
@@ -671,8 +719,9 @@ int ffi_closure_helper_DARWIN (ffi_closure*, void*,
up space for a return value, ffi_closure_ASM invokes the
following helper function to do most of the work. */
-int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
- unsigned long * pgr, ffi_dblfl * pfr)
+int
+ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
+ unsigned long *pgr, ffi_dblfl *pfr)
{
/* rvalue is the pointer to space for return value in closure assembly
pgr is the pointer to where r3-r10 are stored in ffi_closure_ASM
@@ -694,7 +743,7 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
unsigned size_al;
cif = closure->cif;
- avalue = alloca(cif->nargs * sizeof(void *));
+ avalue = alloca (cif->nargs * sizeof(void *));
/* Copy the caller's structure return value address so that the closure
returns the data directly to the caller. */
diff --git a/src/powerpc/ffi.c b/src/powerpc/ffi.c
index 7f27c3c..957a5d5 100644
--- a/src/powerpc/ffi.c
+++ b/src/powerpc/ffi.c
@@ -1205,6 +1205,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
pst++;
avalue[i] = pst;
pst += 2;
+ ng = 8;
}
break;
diff --git a/src/powerpc/ffi.c.rej b/src/powerpc/ffi.c.rej
new file mode 100644
index 0000000..20d3c3a
--- /dev/null
+++ b/src/powerpc/ffi.c.rej
@@ -0,0 +1,18 @@
+--- src/powerpc/ffi.c
++++ src/powerpc/ffi.c
+@@ -186,6 +187,7 @@
+ {
+ *next_arg.f = (float) double_tmp;
+ next_arg.u += 1;
++ intarg_count++;
+ }
+ else
+ *fpr_base.d++ = double_tmp;
+@@ -1224,6 +1227,7 @@
+ {
+ avalue[i] = pst;
+ pst += 4;
++ ng = 8;
+ }
+ break;
+ }
diff --git a/src/powerpc/ffi_darwin.c b/src/powerpc/ffi_darwin.c
index def92a5..d84f1c3 100644
--- a/src/powerpc/ffi_darwin.c
+++ b/src/powerpc/ffi_darwin.c
@@ -32,7 +32,7 @@
#include <stdlib.h>
-extern void ffi_closure_ASM(void);
+extern void ffi_closure_ASM (void);
enum {
/* The assembly depends on these exact flags. */
@@ -80,10 +80,13 @@ enum { ASM_NEEDS_REGISTERS = 4 };
*/
-void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
+void
+ffi_prep_args (extended_cif *ecif, unsigned long *const stack)
{
const unsigned bytes = ecif->cif->bytes;
const unsigned flags = ecif->cif->flags;
+ const unsigned nargs = ecif->cif->nargs;
+ const ffi_abi abi = ecif->cif->abi;
/* 'stacktop' points at the previous backchain pointer. */
unsigned long *const stacktop = stack + (bytes / sizeof(unsigned long));
@@ -118,7 +121,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
*next_arg++ = (unsigned long) (char *) ecif->rvalue;
/* Now for the arguments. */
- for (i = ecif->cif->nargs; i > 0; i--, ptr++, p_argv++)
+ for (i = nargs; i > 0; i--, ptr++, p_argv++)
{
switch ((*ptr)->type)
{
@@ -213,7 +216,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
size_al = (*ptr)->size;
if ((*ptr)->elements[0]->type == 3)
size_al = ALIGN((*ptr)->size, 8);
- if (size_al < 3 && ecif->cif->abi == FFI_DARWIN)
+ if (size_al < 3 && abi == FFI_DARWIN)
dest_cpy += 4 - size_al;
memcpy ((char *) dest_cpy, (char *) *p_argv, size_al);
@@ -229,7 +232,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
the struct to double-word. */
if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE)
size_al = ALIGN((*ptr)->size, 8);
- if (size_al < 3 && ecif->cif->abi == FFI_DARWIN)
+ if (size_al < 3 && abi == FFI_DARWIN)
dest_cpy += 4 - size_al;
memcpy((char *) dest_cpy, (char *) *p_argv, size_al);
@@ -301,8 +304,44 @@ darwin_adjust_aggregate_sizes (ffi_type *s)
/* Do not add additional tail padding. */
}
+/* Adjust the size of S to be correct for AIX.
+ Word-align double unless it is the first member of a structure. */
+
+static void
+aix_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];
+ aix_adjust_aggregate_sizes (p);
+ align = p->alignment;
+ if (i != 0 && p->type == FFI_TYPE_DOUBLE)
+ 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)
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
{
/* All this is for the DARWIN ABI. */
int i;
@@ -323,6 +362,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
darwin_adjust_aggregate_sizes (cif->arg_types[i]);
}
+ if (cif->abi == FFI_AIX)
+ {
+ aix_adjust_aggregate_sizes (cif->rtype);
+ for (i = 0; i < cif->nargs; i++)
+ aix_adjust_aggregate_sizes (cif->arg_types[i]);
+ }
+
/* Space for the frame pointer, callee's LR, CR, etc, and for
the asm's temp regs. */
@@ -473,7 +519,8 @@ extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *,
extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *,
void (*fn)(void), void (*fn2)(void));
-void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+void
+ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
extended_cif ecif;
@@ -486,7 +533,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
- ecif.rvalue = alloca(cif->rtype->size);
+ ecif.rvalue = alloca (cif->rtype->size);
}
else
ecif.rvalue = rvalue;
@@ -661,8 +708,9 @@ typedef union
double d;
} ffi_dblfl;
-int ffi_closure_helper_DARWIN (ffi_closure*, void*,
- unsigned long*, ffi_dblfl*);
+int
+ffi_closure_helper_DARWIN (ffi_closure *, void *,
+ unsigned long *, ffi_dblfl *);
/* Basically the trampoline invokes ffi_closure_ASM, and on
entry, r11 holds the address of the closure.
@@ -671,8 +719,9 @@ int ffi_closure_helper_DARWIN (ffi_closure*, void*,
up space for a return value, ffi_closure_ASM invokes the
following helper function to do most of the work. */
-int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
- unsigned long * pgr, ffi_dblfl * pfr)
+int
+ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
+ unsigned long *pgr, ffi_dblfl *pfr)
{
/* rvalue is the pointer to space for return value in closure assembly
pgr is the pointer to where r3-r10 are stored in ffi_closure_ASM
@@ -694,7 +743,7 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
unsigned size_al;
cif = closure->cif;
- avalue = alloca(cif->nargs * sizeof(void *));
+ avalue = alloca (cif->nargs * sizeof(void *));
/* Copy the caller's structure return value address so that the closure
returns the data directly to the caller. */