More cygwin fixes

This commit is contained in:
Anthony Green
2012-03-21 08:09:30 -04:00
parent 84d3253f86
commit bd78c9c331
29 changed files with 23571 additions and 34 deletions

0
.pc/aix-fix/.timestamp Normal file
View File

4792
.pc/aix-fix/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1,5 @@
stand-alone stand-alone
aix-fix
mint
win32
win32_tests

0
.pc/mint/.timestamp Normal file
View File

4797
.pc/mint/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

352
.pc/mint/README Normal file
View File

@@ -0,0 +1,352 @@
Status
======
libffi-3.0.11 was released on *****************. Check the libffi web
page for updates: <URL:http://sourceware.org/libffi/>.
What is libffi?
===============
Compilers for high level languages generate code that follow certain
conventions. These conventions are necessary, in part, for separate
compilation to work. One such convention is the "calling
convention". The "calling convention" is essentially a set of
assumptions made by the compiler about where function arguments will
be found on entry to a function. A "calling convention" also specifies
where the return value for a function is found.
Some programs may not know at the time of compilation what arguments
are to be passed to a function. For instance, an interpreter may be
told at run-time about the number and types of arguments used to call
a given function. Libffi can be used in such programs to provide a
bridge from the interpreter program to compiled code.
The libffi library provides a portable, high level programming
interface to various calling conventions. This allows a programmer to
call any function specified by a call interface description at run
time.
FFI stands for Foreign Function Interface. A foreign function
interface is the popular name for the interface that allows code
written in one language to call code written in another language. The
libffi library really only provides the lowest, machine dependent
layer of a fully featured foreign function interface. A layer must
exist above libffi that handles type conversions for values passed
between the two languages.
Supported Platforms
===================
Libffi has been ported to many different platforms.
For specific configuration details and testing status, please
refer to the wiki page here:
http://www.moxielogic.org/wiki/index.php?title=Libffi_3.0.11
At the time of release, the following basic configurations have been
tested:
|--------------+------------------|
| Architecture | Operating System |
|--------------+------------------|
| Alpha | Linux |
| Alpha | Tru64 |
| ARM | Linux |
| ARM | iOS |
| AVR32 | Linux |
| HPPA | HPUX |
| IA-64 | Linux |
| M68K | RTEMS |
| MIPS | IRIX |
| MIPS | Linux |
| MIPS | RTEMS |
| MIPS64 | Linux |
| PowerPC | AMIGA |
| PowerPC | Linux |
| PowerPC | Mac OSX |
| PowerPC | FreeBSD |
| PowerPC64 | Linux |
| S390 | Linux |
| S390X | Linux |
| SPARC | Linux |
| SPARC | Solaris |
| SPARC64 | Linux |
| SPARC64 | FreeBSD |
| X86 | FreeBSD |
| X86 | Interix |
| X86 | kFreeBSD |
| X86 | Linux |
| X86 | Linux/x32 |
| X86 | Mac OSX |
| X86 | OpenBSD |
| X86 | OS/2 |
| X86 | Solaris |
| X86 | Windows/Cygwin |
| X86 | Windows/MingW |
| X86-64 | FreeBSD |
| X86-64 | Linux |
| X86-64 | OpenBSD |
| X86-64 | Windows/MingW |
|--------------+------------------|
Please send additional platform test results to
libffi-discuss@sourceware.org and feel free to update the wiki page
above.
Installing libffi
=================
First you must configure the distribution for your particular
system. Go to the directory you wish to build libffi in and run the
"configure" program found in the root directory of the libffi source
distribution.
You may want to tell configure where to install the libffi library and
header files. To do that, use the --prefix configure switch. Libffi
will install under /usr/local by default.
If you want to enable extra run-time debugging checks use the the
--enable-debug configure switch. This is useful when your program dies
mysteriously while using libffi.
Another useful configure switch is --enable-purify-safety. Using this
will add some extra code which will suppress certain warnings when you
are using Purify with libffi. Only use this switch when using
Purify, as it will slow down the library.
It's also possible to build libffi on Windows platforms with
Microsoft's Visual C++ compiler. In this case, use the msvcc.sh
wrapper script during configuration like so:
path/to/configure CC=path/to/msvcc.sh LD=link CPP=\"cl -nologo -EP\"
For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64".
You may also need to specify --build appropriately. When building with MSVC
under a MingW environment, you may need to remove the line in configure
that sets 'fix_srcfile_path' to a 'cygpath' command. ('cygpath' is not
present in MingW, and is not required when using MingW-style paths.)
For iOS builds, refer to the build-ios.sh script for guidance.
Configure has many other options. Use "configure --help" to see them all.
Once configure has finished, type "make". Note that you must be using
GNU make. You can ftp GNU make from prep.ai.mit.edu:/pub/gnu.
To ensure that libffi is working as advertised, type "make check".
This will require that you have DejaGNU installed.
To install the library and header files, type "make install".
History
=======
See the ChangeLog files for details.
3.0.11 MMM-DD-YY
Lots of build fixes.
Add Amiga newer MacOS support.
Add Linux/x32 support.
Add thiscall and fastcall support on Windows.
Fix Octeon and MC68881 support.
Fix code pessimizations.
3.0.10 Aug-23-11
Add support for Apple's iOS.
Add support for ARM VFP ABI.
Add RTEMS support for MIPS and M68K.
Fix instruction cache clearing problems on
ARM and SPARC.
Fix the N64 build on mips-sgi-irix6.5.
Enable builds with Microsoft's compiler.
Enable x86 builds with Oracle's Solaris compiler.
Fix support for calling code compiled with Oracle's Sparc
Solaris compiler.
Testsuite fixes for Tru64 Unix.
Additional platform support.
3.0.9 Dec-31-09
Add AVR32 and win64 ports. Add ARM softfp support.
Many fixes for AIX, Solaris, HP-UX, *BSD.
Several PowerPC and x86-64 bug fixes.
Build DLL for windows.
3.0.8 Dec-19-08
Add *BSD, BeOS, and PA-Linux support.
3.0.7 Nov-11-08
Fix for ppc FreeBSD.
(thanks to Andreas Tobler)
3.0.6 Jul-17-08
Fix for closures on sh.
Mark the sh/sh64 stack as non-executable.
(both thanks to Kaz Kojima)
3.0.5 Apr-3-08
Fix libffi.pc file.
Fix #define ARM for IcedTea users.
Fix x86 closure bug.
3.0.4 Feb-24-08
Fix x86 OpenBSD configury.
3.0.3 Feb-22-08
Enable x86 OpenBSD thanks to Thomas Heller, and
x86-64 FreeBSD thanks to Björn König and Andreas Tobler.
Clean up test instruction in README.
3.0.2 Feb-21-08
Improved x86 FreeBSD support.
Thanks to Björn König.
3.0.1 Feb-15-08
Fix instruction cache flushing bug on MIPS.
Thanks to David Daney.
3.0.0 Feb-15-08
Many changes, mostly thanks to the GCC project.
Cygnus Solutions is now Red Hat.
[10 years go by...]
1.20 Oct-5-98
Raffaele Sena produces ARM port.
1.19 Oct-5-98
Fixed x86 long double and long long return support.
m68k bug fixes from Andreas Schwab.
Patch for DU assembler compatibility for the Alpha from Richard
Henderson.
1.18 Apr-17-98
Bug fixes and MIPS configuration changes.
1.17 Feb-24-98
Bug fixes and m68k port from Andreas Schwab. PowerPC port from
Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes.
1.16 Feb-11-98
Richard Henderson produces Alpha port.
1.15 Dec-4-97
Fixed an n32 ABI bug. New libtool, auto* support.
1.14 May-13-97
libtool is now used to generate shared and static libraries.
Fixed a minor portability problem reported by Russ McManus
<mcmanr@eq.gs.com>.
1.13 Dec-2-96
Added --enable-purify-safety to keep Purify from complaining
about certain low level code.
Sparc fix for calling functions with < 6 args.
Linux x86 a.out fix.
1.12 Nov-22-96
Added missing ffi_type_void, needed for supporting void return
types. Fixed test case for non MIPS machines. Cygnus Support
is now Cygnus Solutions.
1.11 Oct-30-96
Added notes about GNU make.
1.10 Oct-29-96
Added configuration fix for non GNU compilers.
1.09 Oct-29-96
Added --enable-debug configure switch. Clean-ups based on LCLint
feedback. ffi_mips.h is always installed. Many configuration
fixes. Fixed ffitest.c for sparc builds.
1.08 Oct-15-96
Fixed n32 problem. Many clean-ups.
1.07 Oct-14-96
Gordon Irlam rewrites v8.S again. Bug fixes.
1.06 Oct-14-96
Gordon Irlam improved the sparc port.
1.05 Oct-14-96
Interface changes based on feedback.
1.04 Oct-11-96
Sparc port complete (modulo struct passing bug).
1.03 Oct-10-96
Passing struct args, and returning struct values works for
all architectures/calling conventions. Expanded tests.
1.02 Oct-9-96
Added SGI n32 support. Fixed bugs in both o32 and Linux support.
Added "make test".
1.01 Oct-8-96
Fixed float passing bug in mips version. Restructured some
of the code. Builds cleanly with SGI tools.
1.00 Oct-7-96
First release. No public announcement.
Authors & Credits
=================
libffi was originally written by Anthony Green <green@redhat.com>.
The developers of the GNU Compiler Collection project have made
innumerable valuable contributions. See the ChangeLog file for
details.
Some of the ideas behind libffi were inspired by Gianni Mariani's free
gencall library for Silicon Graphics machines.
The closure mechanism was designed and implemented by Kresten Krab
Thorup.
Major processor architecture ports were contributed by the following
developers:
alpha Richard Henderson
arm Raffaele Sena
cris Simon Posnjak, Hans-Peter Nilsson
frv Anthony Green
ia64 Hans Boehm
m32r Kazuhiro Inaoka
m68k Andreas Schwab
mips Anthony Green, Casey Marshall
mips64 David Daney
pa Randolph Chung, Dave Anglin, Andreas Tobler
powerpc Geoffrey Keating, Andreas Tobler,
David Edelsohn, John Hornkvist
powerpc64 Jakub Jelinek
s390 Gerhard Tonn, Ulrich Weigand
sh Kaz Kojima
sh64 Kaz Kojima
sparc Anthony Green, Gordon Irlam
x86 Anthony Green, Jon Beniston
x86-64 Bo Thorsen
Jesper Skov and Andrew Haley both did more than their fair share of
stepping through the code and tracking down bugs.
Thanks also to Tom Tromey for bug fixes, documentation and
configuration help.
Thanks to Jim Blandy, who provided some useful feedback on the libffi
interface.
Andreas Tobler has done a tremendous amount of work on the testsuite.
Alex Oliva solved the executable page problem for SElinux.
The list above is almost certainly incomplete and inaccurate. I'm
happy to make corrections or additions upon request.
If you have a problem, or have found a bug, please send a note to the
author at green@moxielogic.com, or the project mailing list at
libffi-discuss@sourceware.org.

289
.pc/mint/src/m68k/ffi.c Normal file
View File

@@ -0,0 +1,289 @@
/* -----------------------------------------------------------------------
ffi.c
m68k Foreign Function Interface
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef __rtems__
void rtems_cache_flush_multiple_data_lines( const void *, size_t );
#else
#include <sys/syscall.h>
#include <asm/cachectl.h>
#endif
void ffi_call_SYSV (extended_cif *,
unsigned, unsigned,
void *, void (*fn) ());
void *ffi_prep_args (void *stack, extended_cif *ecif);
void ffi_closure_SYSV (ffi_closure *);
void ffi_closure_struct_SYSV (ffi_closure *);
unsigned int ffi_closure_SYSV_inner (ffi_closure *closure,
void *resp, void *args);
/* ffi_prep_args is called by the assembly routine once stack space has
been allocated for the function's arguments. */
void *
ffi_prep_args (void *stack, extended_cif *ecif)
{
unsigned int i;
void **p_argv;
char *argp;
ffi_type **p_arg;
void *struct_value_ptr;
argp = stack;
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
&& !ecif->cif->flags)
struct_value_ptr = ecif->rvalue;
else
struct_value_ptr = NULL;
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
i != 0;
i--, p_arg++)
{
size_t z;
z = (*p_arg)->size;
if (z < sizeof (int))
{
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int) *(SINT8 *) *p_argv;
break;
case FFI_TYPE_UINT8:
*(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv;
break;
case FFI_TYPE_SINT16:
*(signed int *) argp = (signed int) *(SINT16 *) *p_argv;
break;
case FFI_TYPE_UINT16:
*(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv;
break;
case FFI_TYPE_STRUCT:
memcpy (argp + sizeof (int) - z, *p_argv, z);
break;
default:
FFI_ASSERT (0);
}
z = sizeof (int);
}
else
{
memcpy (argp, *p_argv, z);
/* Align if necessary. */
if ((sizeof(int) - 1) & z)
z = ALIGN(z, sizeof(int));
}
p_argv++;
argp += z;
}
return struct_value_ptr;
}
#define CIF_FLAGS_INT 1
#define CIF_FLAGS_DINT 2
#define CIF_FLAGS_FLOAT 4
#define CIF_FLAGS_DOUBLE 8
#define CIF_FLAGS_LDOUBLE 16
#define CIF_FLAGS_POINTER 32
#define CIF_FLAGS_STRUCT1 64
#define CIF_FLAGS_STRUCT2 128
/* Perform machine dependent cif processing */
ffi_status
ffi_prep_cif_machdep (ffi_cif *cif)
{
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
cif->flags = 0;
break;
case FFI_TYPE_STRUCT:
switch (cif->rtype->size)
{
case 1:
cif->flags = CIF_FLAGS_STRUCT1;
break;
case 2:
cif->flags = CIF_FLAGS_STRUCT2;
break;
case 4:
cif->flags = CIF_FLAGS_INT;
break;
case 8:
cif->flags = CIF_FLAGS_DINT;
break;
default:
cif->flags = 0;
break;
}
break;
case FFI_TYPE_FLOAT:
cif->flags = CIF_FLAGS_FLOAT;
break;
case FFI_TYPE_DOUBLE:
cif->flags = CIF_FLAGS_DOUBLE;
break;
#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE)
case FFI_TYPE_LONGDOUBLE:
cif->flags = CIF_FLAGS_LDOUBLE;
break;
#endif
case FFI_TYPE_POINTER:
cif->flags = CIF_FLAGS_POINTER;
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
cif->flags = CIF_FLAGS_DINT;
break;
default:
cif->flags = CIF_FLAGS_INT;
break;
}
return FFI_OK;
}
void
ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return value
address then we need to make one. */
if (rvalue == NULL
&& cif->rtype->type == FFI_TYPE_STRUCT
&& cif->rtype->size > 8)
ecif.rvalue = alloca (cif->rtype->size);
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_SYSV:
ffi_call_SYSV (&ecif, cif->bytes, cif->flags,
ecif.rvalue, fn);
break;
default:
FFI_ASSERT (0);
break;
}
}
static void
ffi_prep_incoming_args_SYSV (char *stack, void **avalue, ffi_cif *cif)
{
unsigned int i;
void **p_argv;
char *argp;
ffi_type **p_arg;
argp = stack;
p_argv = avalue;
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
{
size_t z;
z = (*p_arg)->size;
if (z <= 4)
{
*p_argv = (void *) (argp + 4 - z);
z = 4;
}
else
{
*p_argv = (void *) argp;
/* Align if necessary */
if ((sizeof(int) - 1) & z)
z = ALIGN(z, sizeof(int));
}
p_argv++;
argp += z;
}
}
unsigned int
ffi_closure_SYSV_inner (ffi_closure *closure, void *resp, void *args)
{
ffi_cif *cif;
void **arg_area;
cif = closure->cif;
arg_area = (void**) alloca (cif->nargs * sizeof (void *));
ffi_prep_incoming_args_SYSV(args, arg_area, cif);
(closure->fun) (cif, resp, arg_area, closure->user_data);
return cif->flags;
}
ffi_status
ffi_prep_closure_loc (ffi_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data,
void *codeloc)
{
if (cif->abi != FFI_SYSV)
return FFI_BAD_ABI;
*(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)
*(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 );
#else
syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE,
FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE);
#endif
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
return FFI_OK;
}

270
.pc/mint/src/m68k/sysv.S Normal file
View File

@@ -0,0 +1,270 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 1998, 2012 Andreas Schwab
Copyright (c) 2008 Red Hat, Inc.
m68k Foreign Function Interface
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
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
#ifdef HAVE_AS_CFI_PSEUDO_OP
#define CFI_STARTPROC() .cfi_startproc
#define CFI_OFFSET(reg,off) .cfi_offset reg,off
#define CFI_DEF_CFA(reg,off) .cfi_def_cfa reg,off
#define CFI_ENDPROC() .cfi_endproc
#else
#define CFI_STARTPROC()
#define CFI_OFFSET(reg,off)
#define CFI_DEF_CFA(reg,off)
#define CFI_ENDPROC()
#endif
.text
.globl ffi_call_SYSV
.type ffi_call_SYSV,@function
.align 4
ffi_call_SYSV:
CFI_STARTPROC()
link %fp,#0
CFI_OFFSET(14,-8)
CFI_DEF_CFA(14,8)
move.l %d2,-(%sp)
CFI_OFFSET(2,-12)
| Make room for all of the new args.
sub.l 12(%fp),%sp
| Call ffi_prep_args
move.l 8(%fp),-(%sp)
pea 4(%sp)
#if !defined __PIC__
jsr ffi_prep_args
#else
bsr.l ffi_prep_args@PLTPC
#endif
addq.l #8,%sp
| Pass pointer to struct value, if any
move.l %a0,%a1
| Call the function
move.l 24(%fp),%a0
jsr (%a0)
| Remove the space we pushed for the args
add.l 12(%fp),%sp
| Load the pointer to storage for the return value
move.l 20(%fp),%a1
| Load the return type code
move.l 16(%fp),%d2
| If the return value pointer is NULL, assume no return value.
| NOTE: On the mc68000, tst on an address register is not supported.
#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
cmp.w #0, %a1
#else
tst.l %a1
#endif
jbeq noretval
btst #0,%d2
jbeq retlongint
move.l %d0,(%a1)
jbra epilogue
retlongint:
btst #1,%d2
jbeq retfloat
move.l %d0,(%a1)
move.l %d1,4(%a1)
jbra epilogue
retfloat:
btst #2,%d2
jbeq retdouble
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.s %fp0,(%a1)
#else
move.l %d0,(%a1)
#endif
jbra epilogue
retdouble:
btst #3,%d2
jbeq retlongdouble
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d %fp0,(%a1)
#else
move.l %d0,(%a1)+
move.l %d1,(%a1)
#endif
jbra epilogue
retlongdouble:
btst #4,%d2
jbeq retpointer
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.x %fp0,(%a1)
#else
move.l %d0,(%a1)+
move.l %d1,(%a1)+
move.l %d2,(%a1)
#endif
jbra epilogue
retpointer:
btst #5,%d2
jbeq retstruct1
move.l %a0,(%a1)
jbra epilogue
retstruct1:
btst #6,%d2
jbeq retstruct2
move.b %d0,(%a1)
jbra epilogue
retstruct2:
btst #7,%d2
jbeq noretval
move.w %d0,(%a1)
noretval:
epilogue:
move.l (%sp)+,%d2
unlk %fp
rts
CFI_ENDPROC()
.size ffi_call_SYSV,.-ffi_call_SYSV
.globl ffi_closure_SYSV
.type ffi_closure_SYSV, @function
.align 4
ffi_closure_SYSV:
CFI_STARTPROC()
link %fp,#-12
CFI_OFFSET(14,-8)
CFI_DEF_CFA(14,8)
move.l %sp,-12(%fp)
pea 8(%fp)
pea -12(%fp)
move.l %a0,-(%sp)
#if !defined __PIC__
jsr ffi_closure_SYSV_inner
#else
bsr.l ffi_closure_SYSV_inner@PLTPC
#endif
lsr.l #1,%d0
jne 1f
jcc .Lcls_epilogue
move.l -12(%fp),%d0
.Lcls_epilogue:
unlk %fp
rts
1:
lea -12(%fp),%a0
lsr.l #2,%d0
jne 1f
jcs .Lcls_ret_float
move.l (%a0)+,%d0
move.l (%a0),%d1
jra .Lcls_epilogue
.Lcls_ret_float:
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.s (%a0),%fp0
#else
move.l (%a0),%d0
#endif
jra .Lcls_epilogue
1:
lsr.l #2,%d0
jne 1f
jcs .Lcls_ret_ldouble
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d (%a0),%fp0
#else
move.l (%a0)+,%d0
move.l (%a0),%d1
#endif
jra .Lcls_epilogue
.Lcls_ret_ldouble:
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.x (%a0),%fp0
#else
move.l (%a0)+,%d0
move.l (%a0)+,%d1
move.l (%a0),%d2
#endif
jra .Lcls_epilogue
1:
lsr.l #2,%d0
jne .Lcls_ret_struct2
jcs .Lcls_ret_struct1
move.l (%a0),%a0
move.l %a0,%d0
jra .Lcls_epilogue
.Lcls_ret_struct1:
move.b (%a0),%d0
jra .Lcls_epilogue
.Lcls_ret_struct2:
move.w (%a0),%d0
jra .Lcls_epilogue
CFI_ENDPROC()
.size ffi_closure_SYSV,.-ffi_closure_SYSV
.globl ffi_closure_struct_SYSV
.type ffi_closure_struct_SYSV, @function
.align 4
ffi_closure_struct_SYSV:
CFI_STARTPROC()
link %fp,#0
CFI_OFFSET(14,-8)
CFI_DEF_CFA(14,8)
move.l %sp,-12(%fp)
pea 8(%fp)
move.l %a1,-(%sp)
move.l %a0,-(%sp)
#if !defined __PIC__
jsr ffi_closure_SYSV_inner
#else
bsr.l ffi_closure_SYSV_inner@PLTPC
#endif
unlk %fp
rts
CFI_ENDPROC()
.size ffi_closure_struct_SYSV,.-ffi_closure_struct_SYSV
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits
#endif

0
.pc/win32/.timestamp Normal file
View File

4802
.pc/win32/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

1119
.pc/win32/src/x86/win32.S Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,45 @@
/* Area: ffi_call
Purpose: Check fastcall strlen call on X86_WIN32 systems.
Limitations: none.
PR: none.
Originator: From the original ffitest.c */
/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
#include "ffitest.h"
static size_t __attribute__((fastcall)) my_fastcall_strlen(char *s)
{
return (strlen(s));
}
int d
int main (void)
{
ffi_cif cif;
ffi_type *args[MAX_ARGS];
void *values[MAX_ARGS];
ffi_arg rint;
char *s;
args[0] = &ffi_type_pointer;
values[0] = (void*) &s;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_FASTCALL, 1,
&ffi_type_sint, args) == FFI_OK);
s = "a";
ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
CHECK(rint == 1);
s = "1234567";
ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
CHECK(rint == 7);
s = "1234567890123456789012345";
ffi_call(&cif, FFI_FN(my_fastcall_strlen), &rint, values);
CHECK(rint == 25);
printf("fastcall strlen tests passed\n");
exit(0);
}

View File

4808
.pc/win32_tests/ChangeLog Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,263 @@
# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# This file was contributed by John David Anglin (dave.anglin@nrc-cnrc.gc.ca)
set orig_environment_saved 0
set orig_ld_library_path_saved 0
set orig_ld_run_path_saved 0
set orig_shlib_path_saved 0
set orig_ld_libraryn32_path_saved 0
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
#######################################
# proc set_ld_library_path_env_vars { }
#######################################
proc set_ld_library_path_env_vars { } {
global ld_library_path
global orig_environment_saved
global orig_ld_library_path_saved
global orig_ld_run_path_saved
global orig_shlib_path_saved
global orig_ld_libraryn32_path_saved
global orig_ld_library64_path_saved
global orig_ld_library_path_32_saved
global orig_ld_library_path_64_saved
global orig_dyld_library_path_saved
global orig_ld_library_path
global orig_ld_run_path
global orig_shlib_path
global orig_ld_libraryn32_path
global orig_ld_library64_path
global orig_ld_library_path_32
global orig_ld_library_path_64
global orig_dyld_library_path
global GCC_EXEC_PREFIX
# Set the relocated compiler prefix, but only if the user hasn't specified one.
if { [info exists GCC_EXEC_PREFIX] && ![info exists env(GCC_EXEC_PREFIX)] } {
setenv GCC_EXEC_PREFIX "$GCC_EXEC_PREFIX"
}
# Setting the ld library path causes trouble when testing cross-compilers.
if { [is_remote target] } {
return
}
if { $orig_environment_saved == 0 } {
global env
set orig_environment_saved 1
# Save the original environment.
if [info exists env(LD_LIBRARY_PATH)] {
set orig_ld_library_path "$env(LD_LIBRARY_PATH)"
set orig_ld_library_path_saved 1
}
if [info exists env(LD_RUN_PATH)] {
set orig_ld_run_path "$env(LD_RUN_PATH)"
set orig_ld_run_path_saved 1
}
if [info exists env(SHLIB_PATH)] {
set orig_shlib_path "$env(SHLIB_PATH)"
set orig_shlib_path_saved 1
}
if [info exists env(LD_LIBRARYN32_PATH)] {
set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)"
set orig_ld_libraryn32_path_saved 1
}
if [info exists env(LD_LIBRARY64_PATH)] {
set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)"
set orig_ld_library64_path_saved 1
}
if [info exists env(LD_LIBRARY_PATH_32)] {
set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)"
set orig_ld_library_path_32_saved 1
}
if [info exists env(LD_LIBRARY_PATH_64)] {
set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)"
set orig_ld_library_path_64_saved 1
}
if [info exists env(DYLD_LIBRARY_PATH)] {
set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)"
set orig_dyld_library_path_saved 1
}
}
# We need to set ld library path in the environment. Currently,
# unix.exp doesn't set the environment correctly for all systems.
# It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a
# program. We also need the environment set for compilations, etc.
#
# On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
# called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
# (for the 64-bit ABI). The same applies to Darwin (DYLD_LIBRARY_PATH),
# Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64),
# and HP-UX (SHLIB_PATH). In some cases, the variables are independent
# of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the
# variable is not defined.
#
# Doing this is somewhat of a hack as ld_library_path gets repeated in
# SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
if { $orig_ld_library_path_saved } {
setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
} else {
setenv LD_LIBRARY_PATH "$ld_library_path"
}
if { $orig_ld_run_path_saved } {
setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path"
} else {
setenv LD_RUN_PATH "$ld_library_path"
}
# The default shared library dynamic path search for 64-bit
# HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH.
# LD_LIBRARY_PATH isn't used for 32-bit executables. Thus, we
# set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent.
if { $orig_shlib_path_saved } {
setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path"
} else {
setenv SHLIB_PATH "$ld_library_path"
}
if { $orig_ld_libraryn32_path_saved } {
setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path"
} elseif { $orig_ld_library_path_saved } {
setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path"
} else {
setenv LD_LIBRARYN32_PATH "$ld_library_path"
}
if { $orig_ld_library64_path_saved } {
setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path"
} elseif { $orig_ld_library_path_saved } {
setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path"
} else {
setenv LD_LIBRARY64_PATH "$ld_library_path"
}
if { $orig_ld_library_path_32_saved } {
setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32"
} elseif { $orig_ld_library_path_saved } {
setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path"
} else {
setenv LD_LIBRARY_PATH_32 "$ld_library_path"
}
if { $orig_ld_library_path_64_saved } {
setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64"
} elseif { $orig_ld_library_path_saved } {
setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path"
} else {
setenv LD_LIBRARY_PATH_64 "$ld_library_path"
}
if { $orig_dyld_library_path_saved } {
setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
} else {
setenv DYLD_LIBRARY_PATH "$ld_library_path"
}
verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
}
#######################################
# proc restore_ld_library_path_env_vars { }
#######################################
proc restore_ld_library_path_env_vars { } {
global orig_environment_saved
global orig_ld_library_path_saved
global orig_ld_run_path_saved
global orig_shlib_path_saved
global orig_ld_libraryn32_path_saved
global orig_ld_library64_path_saved
global orig_ld_library_path_32_saved
global orig_ld_library_path_64_saved
global orig_dyld_library_path_saved
global orig_ld_library_path
global orig_ld_run_path
global orig_shlib_path
global orig_ld_libraryn32_path
global orig_ld_library64_path
global orig_ld_library_path_32
global orig_ld_library_path_64
global orig_dyld_library_path
if { $orig_environment_saved == 0 } {
return
}
if { $orig_ld_library_path_saved } {
setenv LD_LIBRARY_PATH "$orig_ld_library_path"
} elseif [info exists env(LD_LIBRARY_PATH)] {
unsetenv LD_LIBRARY_PATH
}
if { $orig_ld_run_path_saved } {
setenv LD_RUN_PATH "$orig_ld_run_path"
} elseif [info exists env(LD_RUN_PATH)] {
unsetenv LD_RUN_PATH
}
if { $orig_shlib_path_saved } {
setenv SHLIB_PATH "$orig_shlib_path"
} elseif [info exists env(SHLIB_PATH)] {
unsetenv SHLIB_PATH
}
if { $orig_ld_libraryn32_path_saved } {
setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path"
} elseif [info exists env(LD_LIBRARYN32_PATH)] {
unsetenv LD_LIBRARYN32_PATH
}
if { $orig_ld_library64_path_saved } {
setenv LD_LIBRARY64_PATH "$orig_ld_library64_path"
} elseif [info exists env(LD_LIBRARY64_PATH)] {
unsetenv LD_LIBRARY64_PATH
}
if { $orig_ld_library_path_32_saved } {
setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32"
} elseif [info exists env(LD_LIBRARY_PATH_32)] {
unsetenv LD_LIBRARY_PATH_32
}
if { $orig_ld_library_path_64_saved } {
setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64"
} elseif [info exists env(LD_LIBRARY_PATH_64)] {
unsetenv LD_LIBRARY_PATH_64
}
if { $orig_dyld_library_path_saved } {
setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path"
} elseif [info exists env(DYLD_LIBRARY_PATH)] {
unsetenv DYLD_LIBRARY_PATH
}
}
#######################################
# proc get_shlib_extension { }
#######################################
proc get_shlib_extension { } {
global shlib_ext
if { [ istarget *-*-darwin* ] } {
set shlib_ext "dylib"
} elseif { [ istarget *-*-cygwin* ] || [ istarget *-*-mingw* ] } {
set shlib_ext "dll"
} elseif { [ istarget hppa*-*-hpux* ] } {
set shlib_ext "sl"
} else {
set shlib_ext "so"
}
return $shlib_ext
}

View File

@@ -1,3 +1,26 @@
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.
* 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.
* src/m68k/sysv.S: Ditto.
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> 2012-03-13 Kaz Kojima <kkojima@gcc.gnu.org>
* src/sh/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test, * src/sh/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,

2
README
View File

@@ -58,6 +58,7 @@ tested:
| AVR32 | Linux | | AVR32 | Linux |
| HPPA | HPUX | | HPPA | HPUX |
| IA-64 | Linux | | IA-64 | Linux |
| M68K | FreeMiNT |
| M68K | RTEMS | | M68K | RTEMS |
| MIPS | IRIX | | MIPS | IRIX |
| MIPS | Linux | | MIPS | Linux |
@@ -150,6 +151,7 @@ See the ChangeLog files for details.
Lots of build fixes. Lots of build fixes.
Add Amiga newer MacOS support. Add Amiga newer MacOS support.
Add Linux/x32 support. Add Linux/x32 support.
Add m68k FreeMiNT support.
Add thiscall and fastcall support on Windows. Add thiscall and fastcall support on Windows.
Fix Octeon and MC68881 support. Fix Octeon and MC68881 support.
Fix code pessimizations. Fix code pessimizations.

30
patches/aix-fix Normal file
View 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
View 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.

View File

@@ -1,2 +1,6 @@
stand-alone stand-alone
aix-fix
mint
win32
win32_tests

39
patches/win32 Normal file
View 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
View 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
+ }
}
#######################################

View File

@@ -13,8 +13,13 @@
void rtems_cache_flush_multiple_data_lines( const void *, size_t ); void rtems_cache_flush_multiple_data_lines( const void *, size_t );
#else #else
#include <sys/syscall.h> #include <sys/syscall.h>
#ifdef __MINT__
#include <mint/mintbind.h>
#include <mint/ssystem.h>
#else
#include <asm/cachectl.h> #include <asm/cachectl.h>
#endif #endif
#endif
void ffi_call_SYSV (extended_cif *, void ffi_call_SYSV (extended_cif *,
unsigned, unsigned, unsigned, unsigned,
@@ -39,8 +44,12 @@ ffi_prep_args (void *stack, extended_cif *ecif)
argp = stack; argp = stack;
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT if (
&& !ecif->cif->flags) #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; struct_value_ptr = ecif->rvalue;
else else
struct_value_ptr = NULL; struct_value_ptr = NULL;
@@ -51,12 +60,12 @@ ffi_prep_args (void *stack, extended_cif *ecif)
i != 0; i != 0;
i--, p_arg++) 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)) if (z < sizeof (int))
{ {
switch ((*p_arg)->type) switch (type)
{ {
case FFI_TYPE_SINT8: case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int) *(SINT8 *) *p_argv; *(signed int *) argp = (signed int) *(SINT8 *) *p_argv;
@@ -75,7 +84,14 @@ ffi_prep_args (void *stack, extended_cif *ecif)
break; break;
case FFI_TYPE_STRUCT: 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); memcpy (argp + sizeof (int) - z, *p_argv, z);
#endif
break; break;
default: default:
@@ -120,17 +136,34 @@ ffi_prep_cif_machdep (ffi_cif *cif)
break; break;
case FFI_TYPE_STRUCT: 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) switch (cif->rtype->size)
{ {
case 1: case 1:
#ifdef __MINT__
cif->flags = CIF_FLAGS_STRUCT2;
#else
cif->flags = CIF_FLAGS_STRUCT1; cif->flags = CIF_FLAGS_STRUCT1;
#endif
break; break;
case 2: case 2:
cif->flags = CIF_FLAGS_STRUCT2; cif->flags = CIF_FLAGS_STRUCT2;
break; break;
#ifdef __MINT__
case 3:
#endif
case 4: case 4:
cif->flags = CIF_FLAGS_INT; cif->flags = CIF_FLAGS_INT;
break; break;
#ifdef __MINT__
case 7:
#endif
case 8: case 8:
cif->flags = CIF_FLAGS_DINT; cif->flags = CIF_FLAGS_DINT;
break; break;
@@ -150,7 +183,11 @@ ffi_prep_cif_machdep (ffi_cif *cif)
#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE) #if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE)
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
#ifdef __MINT__
cif->flags = 0;
#else
cif->flags = CIF_FLAGS_LDOUBLE; cif->flags = CIF_FLAGS_LDOUBLE;
#endif
break; break;
#endif #endif
@@ -218,6 +255,26 @@ ffi_prep_incoming_args_SYSV (char *stack, void **avalue, ffi_cif *cif)
size_t z; size_t z;
z = (*p_arg)->size; 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) if (z <= 4)
{ {
*p_argv = (void *) (argp + 4 - z); *p_argv = (void *) (argp + 4 - z);
@@ -267,14 +324,21 @@ ffi_prep_closure_loc (ffi_closure* closure,
*(unsigned short *)closure->tramp = 0x207c; *(unsigned short *)closure->tramp = 0x207c;
*(void **)(closure->tramp + 2) = codeloc; *(void **)(closure->tramp + 2) = codeloc;
*(unsigned short *)(closure->tramp + 6) = 0x4ef9; *(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; *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV;
else else
*(void **)(closure->tramp + 8) = ffi_closure_SYSV; *(void **)(closure->tramp + 8) = ffi_closure_SYSV;
#ifdef __rtems__ #ifdef __rtems__
rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE ); rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE );
#elif defined(__MINT__)
Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE);
#else #else
syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE, syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE,
FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE); FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE);
@@ -286,4 +350,3 @@ ffi_prep_closure_loc (ffi_closure* closure,
return FFI_OK; return FFI_OK;
} }

View File

@@ -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. Copyright (c) 2008 Red Hat, Inc.
m68k Foreign Function Interface m68k Foreign Function Interface
@@ -40,15 +41,21 @@
#define CFI_OFFSET(reg,off) #define CFI_OFFSET(reg,off)
#define CFI_DEF_CFA(reg,off) #define CFI_DEF_CFA(reg,off)
#define CFI_ENDPROC() #define CFI_ENDPROC()
#endif
#ifdef __MINT__
#define CALLFUNC(funcname) _ ## funcname
#else
#define CALLFUNC(funcname) funcname
#endif #endif
.text .text
.globl ffi_call_SYSV .globl CALLFUNC(ffi_call_SYSV)
.type ffi_call_SYSV,@function .type CALLFUNC(ffi_call_SYSV),@function
.align 4 .align 4
ffi_call_SYSV: CALLFUNC(ffi_call_SYSV):
CFI_STARTPROC() CFI_STARTPROC()
link %fp,#0 link %fp,#0
CFI_OFFSET(14,-8) CFI_OFFSET(14,-8)
@@ -63,14 +70,18 @@ ffi_call_SYSV:
move.l 8(%fp),-(%sp) move.l 8(%fp),-(%sp)
pea 4(%sp) pea 4(%sp)
#if !defined __PIC__ #if !defined __PIC__
jsr ffi_prep_args jsr CALLFUNC(ffi_prep_args)
#else #else
bsr.l ffi_prep_args@PLTPC bsr.l CALLFUNC(ffi_prep_args@PLTPC)
#endif #endif
addq.l #8,%sp addq.l #8,%sp
| Pass pointer to struct value, if any | Pass pointer to struct value, if any
#ifdef __MINT__
move.l %d0,%a1
#else
move.l %a0,%a1 move.l %a0,%a1
#endif
| Call the function | Call the function
move.l 24(%fp),%a0 move.l 24(%fp),%a0
@@ -142,7 +153,11 @@ retlongdouble:
retpointer: retpointer:
btst #5,%d2 btst #5,%d2
jbeq retstruct1 jbeq retstruct1
#ifdef __MINT__
move.l %d0,(%a1)
#else
move.l %a0,(%a1) move.l %a0,(%a1)
#endif
jbra epilogue jbra epilogue
retstruct1: retstruct1:
@@ -162,13 +177,13 @@ epilogue:
unlk %fp unlk %fp
rts rts
CFI_ENDPROC() CFI_ENDPROC()
.size ffi_call_SYSV,.-ffi_call_SYSV .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV)
.globl ffi_closure_SYSV .globl CALLFUNC(ffi_closure_SYSV)
.type ffi_closure_SYSV, @function .type CALLFUNC(ffi_closure_SYSV), @function
.align 4 .align 4
ffi_closure_SYSV: CALLFUNC(ffi_closure_SYSV):
CFI_STARTPROC() CFI_STARTPROC()
link %fp,#-12 link %fp,#-12
CFI_OFFSET(14,-8) CFI_OFFSET(14,-8)
@@ -178,9 +193,9 @@ ffi_closure_SYSV:
pea -12(%fp) pea -12(%fp)
move.l %a0,-(%sp) move.l %a0,-(%sp)
#if !defined __PIC__ #if !defined __PIC__
jsr ffi_closure_SYSV_inner jsr CALLFUNC(ffi_closure_SYSV_inner)
#else #else
bsr.l ffi_closure_SYSV_inner@PLTPC bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
#endif #endif
lsr.l #1,%d0 lsr.l #1,%d0
@@ -240,13 +255,13 @@ ffi_closure_SYSV:
jra .Lcls_epilogue jra .Lcls_epilogue
CFI_ENDPROC() CFI_ENDPROC()
.size ffi_closure_SYSV,.-ffi_closure_SYSV .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
.globl ffi_closure_struct_SYSV .globl CALLFUNC(ffi_closure_struct_SYSV)
.type ffi_closure_struct_SYSV, @function .type CALLFUNC(ffi_closure_struct_SYSV), @function
.align 4 .align 4
ffi_closure_struct_SYSV: CALLFUNC(ffi_closure_struct_SYSV):
CFI_STARTPROC() CFI_STARTPROC()
link %fp,#0 link %fp,#0
CFI_OFFSET(14,-8) CFI_OFFSET(14,-8)
@@ -256,14 +271,14 @@ ffi_closure_struct_SYSV:
move.l %a1,-(%sp) move.l %a1,-(%sp)
move.l %a0,-(%sp) move.l %a0,-(%sp)
#if !defined __PIC__ #if !defined __PIC__
jsr ffi_closure_SYSV_inner jsr CALLFUNC(ffi_closure_SYSV_inner)
#else #else
bsr.l ffi_closure_SYSV_inner@PLTPC bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
#endif #endif
unlk %fp unlk %fp
rts rts
CFI_ENDPROC() 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__ #if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits .section .note.GNU-stack,"",@progbits

View File

@@ -1065,10 +1065,10 @@ ffi_prep_closure_loc (ffi_closure* closure,
closure->cif = cif; closure->cif = cif;
closure->fun = fun; closure->fun = fun;
closure->user_data = user_data; closure->user_data = user_data;
break;
default: default:
return FFI_BAD_ABI;
FFI_ASSERT(0);
break; break;
} }
return FFI_OK; return FFI_OK;

View File

@@ -187,7 +187,7 @@ ffi_closure_SYSV PROC NEAR FORCEFRAME
lea edx, [ebp - 24] lea edx, [ebp - 24]
mov [ebp - 12], edx ;; resp mov [ebp - 12], edx ;; resp
lea edx, [ebp + 8] lea edx, [ebp + 8]
stub: stub::
mov [esp + 8], edx ;; args mov [esp + 8], edx ;; args
lea edx, [ebp - 12] lea edx, [ebp - 12]
mov [esp + 4], edx ;; &resp mov [esp + 4], edx ;; &resp

View File

@@ -25,7 +25,7 @@ set orig_ld_library64_path_saved 0
set orig_ld_library_path_32_saved 0 set orig_ld_library_path_32_saved 0
set orig_ld_library_path_64_saved 0 set orig_ld_library_path_64_saved 0
set orig_dyld_library_path_saved 0 set orig_dyld_library_path_saved 0
set orig_path_saved 0
####################################### #######################################
# proc set_ld_library_path_env_vars { } # 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_32_saved
global orig_ld_library_path_64_saved global orig_ld_library_path_64_saved
global orig_dyld_library_path_saved global orig_dyld_library_path_saved
global orig_path_saved
global orig_ld_library_path global orig_ld_library_path
global orig_ld_run_path global orig_ld_run_path
global orig_shlib_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_32
global orig_ld_library_path_64 global orig_ld_library_path_64
global orig_dyld_library_path global orig_dyld_library_path
global orig_path
global GCC_EXEC_PREFIX global GCC_EXEC_PREFIX
# Set the relocated compiler prefix, but only if the user hasn't specified one. # 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 "$env(DYLD_LIBRARY_PATH)"
set orig_dyld_library_path_saved 1 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, # We need to set ld library path in the environment. Currently,
@@ -169,6 +175,13 @@ proc set_ld_library_path_env_vars { } {
} else { } else {
setenv DYLD_LIBRARY_PATH "$ld_library_path" 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" 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_32_saved
global orig_ld_library_path_64_saved global orig_ld_library_path_64_saved
global orig_dyld_library_path_saved global orig_dyld_library_path_saved
global orig_path_saved
global orig_ld_library_path global orig_ld_library_path
global orig_ld_run_path global orig_ld_run_path
global orig_shlib_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_32
global orig_ld_library_path_64 global orig_ld_library_path_64
global orig_dyld_library_path global orig_dyld_library_path
global orig_path
if { $orig_environment_saved == 0 } { if { $orig_environment_saved == 0 } {
return return
@@ -240,6 +255,11 @@ proc restore_ld_library_path_env_vars { } {
} elseif [info exists env(DYLD_LIBRARY_PATH)] { } elseif [info exists env(DYLD_LIBRARY_PATH)] {
unsetenv DYLD_LIBRARY_PATH unsetenv DYLD_LIBRARY_PATH
} }
if { $orig_path_saved } {
setenv PATH "$orig_path"
} elseif [info exists env(PATH)] {
unsetenv PATH
}
} }
####################################### #######################################

View File

@@ -13,7 +13,6 @@ static size_t __attribute__((fastcall)) my_fastcall_strlen(char *s)
return (strlen(s)); return (strlen(s));
} }
int d
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;