summaryrefslogtreecommitdiff
path: root/libffi/src/powerpc/ffi_darwin.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-12-04 20:36:35 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2009-12-04 20:36:35 +0000
commit4dc2c60a897ef762e6ddbd6c52774bc37bd56fd3 (patch)
tree88a7abfd78b2c2c60c7ad216cd53ff0145afa88e /libffi/src/powerpc/ffi_darwin.c
parente715205f2655663612e993567369dd71e16b1b29 (diff)
downloadgcc-4dc2c60a897ef762e6ddbd6c52774bc37bd56fd3.tar.gz
2009-12-04 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 154988 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@154994 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libffi/src/powerpc/ffi_darwin.c')
-rw-r--r--libffi/src/powerpc/ffi_darwin.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/libffi/src/powerpc/ffi_darwin.c b/libffi/src/powerpc/ffi_darwin.c
index 53dbdb2b244..def92a56376 100644
--- a/libffi/src/powerpc/ffi_darwin.c
+++ b/libffi/src/powerpc/ffi_darwin.c
@@ -90,13 +90,12 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
/* 'fpr_base' points at the space for fpr1, and grows upwards as
we use FPR registers. */
- double *fpr_base = (double *) ((stacktop - ASM_NEEDS_REGISTERS)
- - NUM_FPR_ARG_REGISTERS);
+ double *fpr_base = (double *) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS;
int fparg_count = 0;
/* 'next_arg' grows up as we put parameters in it. */
- unsigned long *next_arg = (unsigned long *) stack + 6; /* 6 reserved positions. */
+ unsigned long *next_arg = stack + 6; /* 6 reserved positions. */
int i;
double double_tmp;
@@ -107,8 +106,8 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
unsigned size_al = 0;
/* Check that everything starts aligned properly. */
- FFI_ASSERT(((unsigned)(char *)stack & 0xF) == 0);
- FFI_ASSERT(((unsigned)(char *)stacktop & 0xF) == 0);
+ FFI_ASSERT(((unsigned) (char *) stack & 0xF) == 0);
+ FFI_ASSERT(((unsigned) (char *) stacktop & 0xF) == 0);
FFI_ASSERT((bytes & 0xF) == 0);
/* Deal with return values that are actually pass-by-reference.
@@ -116,7 +115,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
Return values are referenced by r3, so r4 is the first parameter. */
if (flags & FLAG_RETVAL_REFERENCE)
- *next_arg++ = (unsigned long)(char *)ecif->rvalue;
+ *next_arg++ = (unsigned long) (char *) ecif->rvalue;
/* Now for the arguments. */
for (i = ecif->cif->nargs; i > 0; i--, ptr++, p_argv++)
@@ -127,7 +126,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
purpose registers are filled, the corresponding GPRs that match
the size of the floating-point parameter are skipped. */
case FFI_TYPE_FLOAT:
- double_tmp = *(float *)*p_argv;
+ double_tmp = *(float *) *p_argv;
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
*(double *)next_arg = double_tmp;
else
@@ -138,7 +137,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
break;
case FFI_TYPE_DOUBLE:
- double_tmp = *(double *)*p_argv;
+ double_tmp = *(double *) *p_argv;
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
*(double *)next_arg = double_tmp;
else
@@ -163,11 +162,13 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
next_arg += 2;
fparg_count += 2;
#else
- double_tmp = *((double *) *p_argv);
+ double_tmp = ((double *) *p_argv)[0];
if (fparg_count < NUM_FPR_ARG_REGISTERS)
*fpr_base++ = double_tmp;
else
*(double *) next_arg = double_tmp;
+ next_arg += 2;
+ fparg_count++;
double_tmp = ((double *) *p_argv)[1];
if (fparg_count < NUM_FPR_ARG_REGISTERS)
@@ -183,11 +184,11 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
#ifdef POWERPC64
- gprvalue = *(long long *) p_argv;
+ gprvalue = *(long long *) *p_argv;
goto putgpr;
#else
*(long long *) next_arg = *(long long *) *p_argv;
- next_arg+=2;
+ next_arg += 2;
#endif
break;
case FFI_TYPE_POINTER:
@@ -225,14 +226,13 @@ void ffi_prep_args(extended_cif *ecif, unsigned long *const stack)
Structures with 3 byte in size are padded upwards. */
size_al = (*ptr)->size;
/* If the first member of the struct is a double, then align
- the struct to double-word.
- Type 3 is defined in include/ffi.h. #define FFI_TYPE_DOUBLE 3. */
- if ((*ptr)->elements[0]->type == 3)
+ 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)
dest_cpy += 4 - size_al;
- memcpy((char *)dest_cpy, (char *)*p_argv, size_al);
+ memcpy((char *) dest_cpy, (char *) *p_argv, size_al);
next_arg += (size_al + 3) / 4;
#endif
break;
@@ -690,7 +690,7 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
ffi_type ** arg_types;
long i, avn;
ffi_cif * cif;
- ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS;
+ ffi_dblfl * end_pfr = pfr + NUM_FPR_ARG_REGISTERS;
unsigned size_al;
cif = closure->cif;
@@ -856,6 +856,7 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
memcpy (&temp_ld.lb[0], pfr, sizeof(ldbits));
memcpy (&temp_ld.lb[1], pgr + 2, sizeof(ldbits));
avalue[i] = &temp_ld.ld;
+ pfr++;
}
else
{