More cygwin fixes
This commit is contained in:
30
patches/aix-fix
Normal file
30
patches/aix-fix
Normal file
@@ -0,0 +1,30 @@
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,8 @@
|
||||
+2012-03-19 chennam <csit@axway.com>
|
||||
+
|
||||
+ * src/powerpc/ffi_darwin.c (ffi_prep_closure_loc): Fix AIX closure
|
||||
+ support.
|
||||
+
|
||||
2012-03-13 Kaz Kojima <kkojima@gcc.gnu.org>
|
||||
|
||||
* src/sh/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,
|
||||
Index: libffi/src/powerpc/ffi_darwin.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/powerpc/ffi_darwin.c
|
||||
+++ libffi/src/powerpc/ffi_darwin.c
|
||||
@@ -1065,10 +1065,10 @@ ffi_prep_closure_loc (ffi_closure* closu
|
||||
closure->cif = cif;
|
||||
closure->fun = fun;
|
||||
closure->user_data = user_data;
|
||||
+ break;
|
||||
|
||||
default:
|
||||
-
|
||||
- FFI_ASSERT(0);
|
||||
+ return FFI_BAD_ABI;
|
||||
break;
|
||||
}
|
||||
return FFI_OK;
|
||||
345
patches/mint
Normal file
345
patches/mint
Normal file
@@ -0,0 +1,345 @@
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,8 @@
|
||||
+2012-03-19 Alan Hourihane <alanh@fairlite.co.uk>
|
||||
+
|
||||
+ * src/m68k/ffi.c: Add MINT support.
|
||||
+ * src/m68k/sysv.S: Ditto.
|
||||
+
|
||||
2012-03-19 chennam <csit@axway.com>
|
||||
|
||||
* src/powerpc/ffi_darwin.c (ffi_prep_closure_loc): Fix AIX closure
|
||||
Index: libffi/src/m68k/ffi.c
|
||||
===================================================================
|
||||
--- libffi.orig/src/m68k/ffi.c
|
||||
+++ libffi/src/m68k/ffi.c
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
ffi.c
|
||||
-
|
||||
- m68k Foreign Function Interface
|
||||
+
|
||||
+ m68k Foreign Function Interface
|
||||
----------------------------------------------------------------------- */
|
||||
|
||||
#include <ffi.h>
|
||||
@@ -13,8 +13,13 @@
|
||||
void rtems_cache_flush_multiple_data_lines( const void *, size_t );
|
||||
#else
|
||||
#include <sys/syscall.h>
|
||||
+#ifdef __MINT__
|
||||
+#include <mint/mintbind.h>
|
||||
+#include <mint/ssystem.h>
|
||||
+#else
|
||||
#include <asm/cachectl.h>
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
void ffi_call_SYSV (extended_cif *,
|
||||
unsigned, unsigned,
|
||||
@@ -39,8 +44,12 @@ ffi_prep_args (void *stack, extended_cif
|
||||
|
||||
argp = stack;
|
||||
|
||||
- if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
|
||||
- && !ecif->cif->flags)
|
||||
+ if (
|
||||
+#ifdef __MINT__
|
||||
+ (ecif->cif->rtype->type == FFI_TYPE_LONGDOUBLE) ||
|
||||
+#endif
|
||||
+ (((ecif->cif->rtype->type == FFI_TYPE_STRUCT)
|
||||
+ && !ecif->cif->flags)))
|
||||
struct_value_ptr = ecif->rvalue;
|
||||
else
|
||||
struct_value_ptr = NULL;
|
||||
@@ -51,12 +60,12 @@ ffi_prep_args (void *stack, extended_cif
|
||||
i != 0;
|
||||
i--, p_arg++)
|
||||
{
|
||||
- size_t z;
|
||||
+ size_t z = (*p_arg)->size;
|
||||
+ int type = (*p_arg)->type;
|
||||
|
||||
- z = (*p_arg)->size;
|
||||
if (z < sizeof (int))
|
||||
{
|
||||
- switch ((*p_arg)->type)
|
||||
+ switch (type)
|
||||
{
|
||||
case FFI_TYPE_SINT8:
|
||||
*(signed int *) argp = (signed int) *(SINT8 *) *p_argv;
|
||||
@@ -75,7 +84,14 @@ ffi_prep_args (void *stack, extended_cif
|
||||
break;
|
||||
|
||||
case FFI_TYPE_STRUCT:
|
||||
+#ifdef __MINT__
|
||||
+ if (z == 1 || z == 2)
|
||||
+ memcpy (argp + 2, *p_argv, z);
|
||||
+ else
|
||||
+ memcpy (argp, *p_argv, z);
|
||||
+#else
|
||||
memcpy (argp + sizeof (int) - z, *p_argv, z);
|
||||
+#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -120,17 +136,34 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
||||
break;
|
||||
|
||||
case FFI_TYPE_STRUCT:
|
||||
+ if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT &&
|
||||
+ cif->rtype->elements[1])
|
||||
+ {
|
||||
+ cif->flags = 0;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
switch (cif->rtype->size)
|
||||
{
|
||||
case 1:
|
||||
+#ifdef __MINT__
|
||||
+ cif->flags = CIF_FLAGS_STRUCT2;
|
||||
+#else
|
||||
cif->flags = CIF_FLAGS_STRUCT1;
|
||||
+#endif
|
||||
break;
|
||||
case 2:
|
||||
cif->flags = CIF_FLAGS_STRUCT2;
|
||||
break;
|
||||
+#ifdef __MINT__
|
||||
+ case 3:
|
||||
+#endif
|
||||
case 4:
|
||||
cif->flags = CIF_FLAGS_INT;
|
||||
break;
|
||||
+#ifdef __MINT__
|
||||
+ case 7:
|
||||
+#endif
|
||||
case 8:
|
||||
cif->flags = CIF_FLAGS_DINT;
|
||||
break;
|
||||
@@ -150,7 +183,11 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
||||
|
||||
#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE)
|
||||
case FFI_TYPE_LONGDOUBLE:
|
||||
+#ifdef __MINT__
|
||||
+ cif->flags = 0;
|
||||
+#else
|
||||
cif->flags = CIF_FLAGS_LDOUBLE;
|
||||
+#endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -218,6 +255,26 @@ ffi_prep_incoming_args_SYSV (char *stack
|
||||
size_t z;
|
||||
|
||||
z = (*p_arg)->size;
|
||||
+#ifdef __MINT__
|
||||
+ if (cif->flags &&
|
||||
+ cif->rtype->type == FFI_TYPE_STRUCT &&
|
||||
+ (z == 1 || z == 2))
|
||||
+ {
|
||||
+ *p_argv = (void *) (argp + 2);
|
||||
+
|
||||
+ z = 4;
|
||||
+ }
|
||||
+ else
|
||||
+ if (cif->flags &&
|
||||
+ cif->rtype->type == FFI_TYPE_STRUCT &&
|
||||
+ (z == 3 || z == 4))
|
||||
+ {
|
||||
+ *p_argv = (void *) (argp);
|
||||
+
|
||||
+ z = 4;
|
||||
+ }
|
||||
+ else
|
||||
+#endif
|
||||
if (z <= 4)
|
||||
{
|
||||
*p_argv = (void *) (argp + 4 - z);
|
||||
@@ -267,14 +324,21 @@ ffi_prep_closure_loc (ffi_closure* closu
|
||||
*(unsigned short *)closure->tramp = 0x207c;
|
||||
*(void **)(closure->tramp + 2) = codeloc;
|
||||
*(unsigned short *)(closure->tramp + 6) = 0x4ef9;
|
||||
- if (cif->rtype->type == FFI_TYPE_STRUCT
|
||||
- && !cif->flags)
|
||||
+
|
||||
+ if (
|
||||
+#ifdef __MINT__
|
||||
+ (cif->rtype->type == FFI_TYPE_LONGDOUBLE) ||
|
||||
+#endif
|
||||
+ (((cif->rtype->type == FFI_TYPE_STRUCT)
|
||||
+ && !cif->flags)))
|
||||
*(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV;
|
||||
else
|
||||
*(void **)(closure->tramp + 8) = ffi_closure_SYSV;
|
||||
|
||||
#ifdef __rtems__
|
||||
rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE );
|
||||
+#elif defined(__MINT__)
|
||||
+ Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE);
|
||||
#else
|
||||
syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE,
|
||||
FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE);
|
||||
@@ -286,4 +350,3 @@ ffi_prep_closure_loc (ffi_closure* closu
|
||||
|
||||
return FFI_OK;
|
||||
}
|
||||
-
|
||||
Index: libffi/src/m68k/sysv.S
|
||||
===================================================================
|
||||
--- libffi.orig/src/m68k/sysv.S
|
||||
+++ libffi/src/m68k/sysv.S
|
||||
@@ -1,6 +1,7 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
|
||||
- sysv.S - Copyright (c) 1998, 2012 Andreas Schwab
|
||||
+ sysv.S - Copyright (c) 2012 Alan Hourihane
|
||||
+ Copyright (c) 1998, 2012 Andreas Schwab
|
||||
Copyright (c) 2008 Red Hat, Inc.
|
||||
|
||||
m68k Foreign Function Interface
|
||||
@@ -42,13 +43,19 @@
|
||||
#define CFI_ENDPROC()
|
||||
#endif
|
||||
|
||||
+#ifdef __MINT__
|
||||
+#define CALLFUNC(funcname) _ ## funcname
|
||||
+#else
|
||||
+#define CALLFUNC(funcname) funcname
|
||||
+#endif
|
||||
+
|
||||
.text
|
||||
|
||||
- .globl ffi_call_SYSV
|
||||
- .type ffi_call_SYSV,@function
|
||||
+ .globl CALLFUNC(ffi_call_SYSV)
|
||||
+ .type CALLFUNC(ffi_call_SYSV),@function
|
||||
.align 4
|
||||
|
||||
-ffi_call_SYSV:
|
||||
+CALLFUNC(ffi_call_SYSV):
|
||||
CFI_STARTPROC()
|
||||
link %fp,#0
|
||||
CFI_OFFSET(14,-8)
|
||||
@@ -63,14 +70,18 @@ ffi_call_SYSV:
|
||||
move.l 8(%fp),-(%sp)
|
||||
pea 4(%sp)
|
||||
#if !defined __PIC__
|
||||
- jsr ffi_prep_args
|
||||
+ jsr CALLFUNC(ffi_prep_args)
|
||||
#else
|
||||
- bsr.l ffi_prep_args@PLTPC
|
||||
+ bsr.l CALLFUNC(ffi_prep_args@PLTPC)
|
||||
#endif
|
||||
addq.l #8,%sp
|
||||
|
||||
| Pass pointer to struct value, if any
|
||||
+#ifdef __MINT__
|
||||
+ move.l %d0,%a1
|
||||
+#else
|
||||
move.l %a0,%a1
|
||||
+#endif
|
||||
|
||||
| Call the function
|
||||
move.l 24(%fp),%a0
|
||||
@@ -142,7 +153,11 @@ retlongdouble:
|
||||
retpointer:
|
||||
btst #5,%d2
|
||||
jbeq retstruct1
|
||||
+#ifdef __MINT__
|
||||
+ move.l %d0,(%a1)
|
||||
+#else
|
||||
move.l %a0,(%a1)
|
||||
+#endif
|
||||
jbra epilogue
|
||||
|
||||
retstruct1:
|
||||
@@ -162,13 +177,13 @@ epilogue:
|
||||
unlk %fp
|
||||
rts
|
||||
CFI_ENDPROC()
|
||||
- .size ffi_call_SYSV,.-ffi_call_SYSV
|
||||
+ .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV)
|
||||
|
||||
- .globl ffi_closure_SYSV
|
||||
- .type ffi_closure_SYSV, @function
|
||||
+ .globl CALLFUNC(ffi_closure_SYSV)
|
||||
+ .type CALLFUNC(ffi_closure_SYSV), @function
|
||||
.align 4
|
||||
|
||||
-ffi_closure_SYSV:
|
||||
+CALLFUNC(ffi_closure_SYSV):
|
||||
CFI_STARTPROC()
|
||||
link %fp,#-12
|
||||
CFI_OFFSET(14,-8)
|
||||
@@ -178,9 +193,9 @@ ffi_closure_SYSV:
|
||||
pea -12(%fp)
|
||||
move.l %a0,-(%sp)
|
||||
#if !defined __PIC__
|
||||
- jsr ffi_closure_SYSV_inner
|
||||
+ jsr CALLFUNC(ffi_closure_SYSV_inner)
|
||||
#else
|
||||
- bsr.l ffi_closure_SYSV_inner@PLTPC
|
||||
+ bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
|
||||
#endif
|
||||
|
||||
lsr.l #1,%d0
|
||||
@@ -240,13 +255,13 @@ ffi_closure_SYSV:
|
||||
jra .Lcls_epilogue
|
||||
CFI_ENDPROC()
|
||||
|
||||
- .size ffi_closure_SYSV,.-ffi_closure_SYSV
|
||||
+ .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
|
||||
|
||||
- .globl ffi_closure_struct_SYSV
|
||||
- .type ffi_closure_struct_SYSV, @function
|
||||
+ .globl CALLFUNC(ffi_closure_struct_SYSV)
|
||||
+ .type CALLFUNC(ffi_closure_struct_SYSV), @function
|
||||
.align 4
|
||||
|
||||
-ffi_closure_struct_SYSV:
|
||||
+CALLFUNC(ffi_closure_struct_SYSV):
|
||||
CFI_STARTPROC()
|
||||
link %fp,#0
|
||||
CFI_OFFSET(14,-8)
|
||||
@@ -256,14 +271,14 @@ ffi_closure_struct_SYSV:
|
||||
move.l %a1,-(%sp)
|
||||
move.l %a0,-(%sp)
|
||||
#if !defined __PIC__
|
||||
- jsr ffi_closure_SYSV_inner
|
||||
+ jsr CALLFUNC(ffi_closure_SYSV_inner)
|
||||
#else
|
||||
- bsr.l ffi_closure_SYSV_inner@PLTPC
|
||||
+ bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
|
||||
#endif
|
||||
unlk %fp
|
||||
rts
|
||||
CFI_ENDPROC()
|
||||
- .size ffi_closure_struct_SYSV,.-ffi_closure_struct_SYSV
|
||||
+ .size CALLFUNC(ffi_closure_struct_SYSV),.-CALLFUNC(ffi_closure_struct_SYSV)
|
||||
|
||||
#if defined __ELF__ && defined __linux__
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
Index: libffi/README
|
||||
===================================================================
|
||||
--- libffi.orig/README
|
||||
+++ libffi/README
|
||||
@@ -58,6 +58,7 @@ tested:
|
||||
| AVR32 | Linux |
|
||||
| HPPA | HPUX |
|
||||
| IA-64 | Linux |
|
||||
+| M68K | FreeMiNT |
|
||||
| M68K | RTEMS |
|
||||
| MIPS | IRIX |
|
||||
| MIPS | Linux |
|
||||
@@ -150,6 +151,7 @@ See the ChangeLog files for details.
|
||||
Lots of build fixes.
|
||||
Add Amiga newer MacOS support.
|
||||
Add Linux/x32 support.
|
||||
+ Add m68k FreeMiNT support.
|
||||
Add thiscall and fastcall support on Windows.
|
||||
Fix Octeon and MC68881 support.
|
||||
Fix code pessimizations.
|
||||
@@ -1,2 +1,6 @@
|
||||
|
||||
stand-alone
|
||||
aix-fix
|
||||
mint
|
||||
win32
|
||||
win32_tests
|
||||
|
||||
39
patches/win32
Normal file
39
patches/win32
Normal file
@@ -0,0 +1,39 @@
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,9 @@
|
||||
+2012-03-20 Peter Rosin <peda@lysator.liu.se>
|
||||
+
|
||||
+ * testsuite/libffi.call/strlen2_win32.c (main): Remove bug.
|
||||
+ * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label
|
||||
+ visible outside the PROC, so that ffi_closure_THISCALL can see it.
|
||||
+
|
||||
2012-03-19 Alan Hourihane <alanh@fairlite.co.uk>
|
||||
|
||||
* src/m68k/ffi.c: Add MINT support.
|
||||
Index: libffi/testsuite/libffi.call/strlen2_win32.c
|
||||
===================================================================
|
||||
--- libffi.orig/testsuite/libffi.call/strlen2_win32.c
|
||||
+++ libffi/testsuite/libffi.call/strlen2_win32.c
|
||||
@@ -13,7 +13,6 @@ static size_t __attribute__((fastcall))
|
||||
return (strlen(s));
|
||||
}
|
||||
|
||||
-int d
|
||||
int main (void)
|
||||
{
|
||||
ffi_cif cif;
|
||||
Index: libffi/src/x86/win32.S
|
||||
===================================================================
|
||||
--- libffi.orig/src/x86/win32.S
|
||||
+++ libffi/src/x86/win32.S
|
||||
@@ -187,7 +187,7 @@ ffi_closure_SYSV PROC NEAR FORCEFRAME
|
||||
lea edx, [ebp - 24]
|
||||
mov [ebp - 12], edx ;; resp
|
||||
lea edx, [ebp + 8]
|
||||
-stub:
|
||||
+stub::
|
||||
mov [esp + 8], edx ;; args
|
||||
lea edx, [ebp - 12]
|
||||
mov [esp + 4], edx ;; &resp
|
||||
97
patches/win32_tests
Normal file
97
patches/win32_tests
Normal file
@@ -0,0 +1,97 @@
|
||||
Index: libffi/ChangeLog
|
||||
===================================================================
|
||||
--- libffi.orig/ChangeLog
|
||||
+++ libffi/ChangeLog
|
||||
@@ -1,3 +1,10 @@
|
||||
+2012-03-21 Peter Rosin <peda@lysator.liu.se>
|
||||
+
|
||||
+ * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*]
|
||||
+ (set_ld_library_path_env_vars): Add the library search dir to PATH
|
||||
+ (and save PATH for later).
|
||||
+ (restore_ld_library_path_env_vars): Restore PATH.
|
||||
+
|
||||
2012-03-20 Peter Rosin <peda@lysator.liu.se>
|
||||
|
||||
* testsuite/libffi.call/strlen2_win32.c (main): Remove bug.
|
||||
Index: libffi/testsuite/lib/target-libpath.exp
|
||||
===================================================================
|
||||
--- libffi.orig/testsuite/lib/target-libpath.exp
|
||||
+++ libffi/testsuite/lib/target-libpath.exp
|
||||
@@ -25,7 +25,7 @@ set orig_ld_library64_path_saved 0
|
||||
set orig_ld_library_path_32_saved 0
|
||||
set orig_ld_library_path_64_saved 0
|
||||
set orig_dyld_library_path_saved 0
|
||||
-
|
||||
+set orig_path_saved 0
|
||||
|
||||
#######################################
|
||||
# proc set_ld_library_path_env_vars { }
|
||||
@@ -42,6 +42,7 @@ proc set_ld_library_path_env_vars { } {
|
||||
global orig_ld_library_path_32_saved
|
||||
global orig_ld_library_path_64_saved
|
||||
global orig_dyld_library_path_saved
|
||||
+ global orig_path_saved
|
||||
global orig_ld_library_path
|
||||
global orig_ld_run_path
|
||||
global orig_shlib_path
|
||||
@@ -50,6 +51,7 @@ proc set_ld_library_path_env_vars { } {
|
||||
global orig_ld_library_path_32
|
||||
global orig_ld_library_path_64
|
||||
global orig_dyld_library_path
|
||||
+ global orig_path
|
||||
global GCC_EXEC_PREFIX
|
||||
|
||||
# Set the relocated compiler prefix, but only if the user hasn't specified one.
|
||||
@@ -100,6 +102,10 @@ proc set_ld_library_path_env_vars { } {
|
||||
set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)"
|
||||
set orig_dyld_library_path_saved 1
|
||||
}
|
||||
+ if [info exists env(PATH)] {
|
||||
+ set orig_path "$env(PATH)"
|
||||
+ set orig_path_saved 1
|
||||
+ }
|
||||
}
|
||||
|
||||
# We need to set ld library path in the environment. Currently,
|
||||
@@ -169,6 +175,13 @@ proc set_ld_library_path_env_vars { } {
|
||||
} else {
|
||||
setenv DYLD_LIBRARY_PATH "$ld_library_path"
|
||||
}
|
||||
+ if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
|
||||
+ if { $orig_path_saved } {
|
||||
+ setenv PATH "$ld_library_path:$orig_path"
|
||||
+ } else {
|
||||
+ setenv PATH "$ld_library_path"
|
||||
+ }
|
||||
+ }
|
||||
|
||||
verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
|
||||
}
|
||||
@@ -187,6 +200,7 @@ proc restore_ld_library_path_env_vars {
|
||||
global orig_ld_library_path_32_saved
|
||||
global orig_ld_library_path_64_saved
|
||||
global orig_dyld_library_path_saved
|
||||
+ global orig_path_saved
|
||||
global orig_ld_library_path
|
||||
global orig_ld_run_path
|
||||
global orig_shlib_path
|
||||
@@ -195,6 +209,7 @@ proc restore_ld_library_path_env_vars {
|
||||
global orig_ld_library_path_32
|
||||
global orig_ld_library_path_64
|
||||
global orig_dyld_library_path
|
||||
+ global orig_path
|
||||
|
||||
if { $orig_environment_saved == 0 } {
|
||||
return
|
||||
@@ -240,6 +255,11 @@ proc restore_ld_library_path_env_vars {
|
||||
} elseif [info exists env(DYLD_LIBRARY_PATH)] {
|
||||
unsetenv DYLD_LIBRARY_PATH
|
||||
}
|
||||
+ if { $orig_path_saved } {
|
||||
+ setenv PATH "$orig_path"
|
||||
+ } elseif [info exists env(PATH)] {
|
||||
+ unsetenv PATH
|
||||
+ }
|
||||
}
|
||||
|
||||
#######################################
|
||||
Reference in New Issue
Block a user