aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>2003-03-21 14:43:20 +0100
committerZdenek Dvorak <rakdver@gcc.gnu.org>2003-03-21 13:43:20 +0000
commitcd41c847e78ec5063fbc47a8ddfebc9e53451fff (patch)
tree6dea143dc96cfc4e89d2a91d39d6ea3e47cf03e1
parent731458a46df64853cfea759eecdb3f704752dcbd (diff)
downloadgcc-cd41c847e78ec5063fbc47a8ddfebc9e53451fff.zip
gcc-cd41c847e78ec5063fbc47a8ddfebc9e53451fff.tar.gz
gcc-cd41c847e78ec5063fbc47a8ddfebc9e53451fff.tar.bz2
ffi.h.in: Define X86 instead of X86_64 in 32 bit mode.
* libffi/include/ffi.h.in: Define X86 instead of X86_64 in 32 bit mode. * libffi/src/x86/ffi.c (ffi_closure_SYSV, ffi_closure_raw_SYSV): Receive closure pointer through parameter, read args using __builtin_dwarf_cfa. (FFI_INIT_TRAMPOLINE): Send closure reference through eax. From-SVN: r64663
-rw-r--r--libffi/ChangeLog9
-rw-r--r--libffi/include/ffi.h.in7
-rw-r--r--libffi/src/x86/ffi.c45
3 files changed, 32 insertions, 29 deletions
diff --git a/libffi/ChangeLog b/libffi/ChangeLog
index 89dded9..01517c1 100644
--- a/libffi/ChangeLog
+++ b/libffi/ChangeLog
@@ -1,3 +1,12 @@
+2003-03-21 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
+
+ * libffi/include/ffi.h.in: Define X86 instead of X86_64 in 32
+ bit mode.
+ * libffi/src/x86/ffi.c (ffi_closure_SYSV, ffi_closure_raw_SYSV):
+ Receive closure pointer through parameter, read args using
+ __builtin_dwarf_cfa.
+ (FFI_INIT_TRAMPOLINE): Send closure reference through eax.
+
2003-03-03 Andreas Tobler <a.tobler@schweiz.ch>
* src/powerpc/darwin_closure.S: Recode to fit dynamic libraries.
diff --git a/libffi/include/ffi.h.in b/libffi/include/ffi.h.in
index 0285384..fe91ecd 100644
--- a/libffi/include/ffi.h.in
+++ b/libffi/include/ffi.h.in
@@ -170,6 +170,13 @@ extern "C" {
#endif
#endif
+#ifdef X86_64
+#if defined (__i386__)
+#undef X86_64
+#define X86
+#endif
+#endif
+
#ifndef LIBFFI_ASM
/* ---- Generic type definitions ----------------------------------------- */
diff --git a/libffi/src/x86/ffi.c b/libffi/src/x86/ffi.c
index 68135f9..bd0874f 100644
--- a/libffi/src/x86/ffi.c
+++ b/libffi/src/x86/ffi.c
@@ -214,35 +214,29 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif,
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
void** args, ffi_cif* cif);
-static void ffi_closure_SYSV ();
-static void ffi_closure_raw_SYSV ();
+static void ffi_closure_SYSV (ffi_closure *)
+ __attribute__ ((regparm(1)));
+static void ffi_closure_raw_SYSV (ffi_raw_closure *)
+ __attribute__ ((regparm(1)));
-/* This function is jumped to by the trampoline, on entry, %ecx (a
- * caller-save register) holds the address of the closure.
- * Clearly, this requires __GNUC__, so perhaps we should translate this
- * into an assembly file if this is to be distributed with ffi.
- */
+/* This function is jumped to by the trampoline */
static void
-ffi_closure_SYSV ()
+ffi_closure_SYSV (closure)
+ ffi_closure *closure;
{
// this is our return value storage
long double res;
// our various things...
- void *args;
ffi_cif *cif;
void **arg_area;
- ffi_closure *closure;
unsigned short rtype;
void *resp = (void*)&res;
+ void *args = __builtin_dwarf_cfa ();
- /* grab the trampoline context pointer */
- asm ("movl %%ecx,%0" : "=r" (closure));
-
cif = closure->cif;
arg_area = (void**) alloca (cif->nargs * sizeof (void*));
- asm ("leal 8(%%ebp),%0" : "=q" (args));
/* this call will initialize ARG_AREA, such that each
* element in that array points to the corresponding
@@ -330,11 +324,11 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \
- unsigned int __dis = __fun - ((unsigned int) __tramp + 10); \
- *(unsigned char*) &__tramp[0] = 0xb9; \
- *(unsigned int*) &__tramp[1] = __ctx; \
- *(unsigned char*) &__tramp[5] = 0xe9; \
- *(unsigned int*) &__tramp[6] = __dis; \
+ unsigned int __dis = __fun - ((unsigned int) __tramp + FFI_TRAMPOLINE_SIZE); \
+ *(unsigned char*) &__tramp[0] = 0xb8; \
+ *(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
+ *(unsigned char *) &__tramp[5] = 0xe9; \
+ *(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \
})
@@ -364,30 +358,23 @@ ffi_prep_closure (ffi_closure* closure,
#if !FFI_NO_RAW_API
static void
-ffi_closure_raw_SYSV ()
+ffi_closure_raw_SYSV (closure)
+ ffi_raw_closure *closure;
{
// this is our return value storage
long double res;
// our various things...
- void *args;
ffi_raw *raw_args;
ffi_cif *cif;
- ffi_raw_closure *closure;
unsigned short rtype;
void *resp = (void*)&res;
- /* grab the trampoline context pointer */
- asm ("movl %%ecx,%0" : "=r" (closure));
-
- /* take the argument pointer */
- asm ("leal 8(%%ebp),%0" : "=q" (args));
-
/* get the cif */
cif = closure->cif;
/* the SYSV/X86 abi matches the RAW API exactly, well.. almost */
- raw_args = (ffi_raw*) args;
+ raw_args = (ffi_raw*) __builtin_dwarf_cfa ();
(closure->fun) (cif, resp, raw_args, closure->user_data);