Add Interix support
This commit is contained in:
@@ -14,3 +14,4 @@ hpux-mallinfo
|
|||||||
copyright-updates
|
copyright-updates
|
||||||
ios
|
ios
|
||||||
fix-xfails
|
fix-xfails
|
||||||
|
interix
|
||||||
|
|||||||
0
.pc/interix/.timestamp
Normal file
0
.pc/interix/.timestamp
Normal file
4483
.pc/interix/ChangeLog
Normal file
4483
.pc/interix/ChangeLog
Normal file
File diff suppressed because it is too large
Load Diff
337
.pc/interix/README
Normal file
337
.pc/interix/README
Normal file
@@ -0,0 +1,337 @@
|
|||||||
|
Status
|
||||||
|
======
|
||||||
|
|
||||||
|
libffi-3.0.10 was released on XXXXXXXXXX, 2011. 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.10
|
||||||
|
|
||||||
|
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 | Linux |
|
||||||
|
| PowerPC | Mac OSX |
|
||||||
|
| PowerPC | FreeBSD |
|
||||||
|
| PowerPC64 | Linux |
|
||||||
|
| S390 | Linux |
|
||||||
|
| S390X | Linux |
|
||||||
|
| SPARC | Linux |
|
||||||
|
| SPARC | Solaris |
|
||||||
|
| SPARC64 | Linux |
|
||||||
|
| SPARC64 | FreeBSD |
|
||||||
|
| X86 | FreeBSD |
|
||||||
|
| X86 | kFreeBSD |
|
||||||
|
| X86 | Linux |
|
||||||
|
| 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.10 ???-??-??
|
||||||
|
Add support for Apple's iOS.
|
||||||
|
Add RTEMS support for MIPS and M68K.
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
17573
.pc/interix/configure
vendored
Executable file
17573
.pc/interix/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
482
.pc/interix/configure.ac
Normal file
482
.pc/interix/configure.ac
Normal file
@@ -0,0 +1,482 @@
|
|||||||
|
dnl Process this with autoconf to create configure
|
||||||
|
|
||||||
|
AC_PREREQ(2.63)
|
||||||
|
|
||||||
|
AC_INIT([libffi], [3.0.10rc2], [http://gcc.gnu.org/bugs.html])
|
||||||
|
AC_CONFIG_HEADERS([fficonfig.h])
|
||||||
|
|
||||||
|
AC_CANONICAL_SYSTEM
|
||||||
|
target_alias=${target_alias-$host_alias}
|
||||||
|
|
||||||
|
. ${srcdir}/configure.host
|
||||||
|
|
||||||
|
AM_INIT_AUTOMAKE
|
||||||
|
|
||||||
|
# The same as in boehm-gc and libstdc++. Have to borrow it from there.
|
||||||
|
# We must force CC to /not/ be precious variables; otherwise
|
||||||
|
# the wrong, non-multilib-adjusted value will be used in multilibs.
|
||||||
|
# As a side effect, we have to subst CFLAGS ourselves.
|
||||||
|
# Also save and restore CFLAGS, since AC_PROG_CC will come up with
|
||||||
|
# defaults of its own if none are provided.
|
||||||
|
|
||||||
|
m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
|
||||||
|
m4_define([_AC_ARG_VAR_PRECIOUS],[])
|
||||||
|
save_CFLAGS=$CFLAGS
|
||||||
|
AC_PROG_CC
|
||||||
|
CFLAGS=$save_CFLAGS
|
||||||
|
m4_undefine([_AC_ARG_VAR_PRECIOUS])
|
||||||
|
m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
|
||||||
|
|
||||||
|
AC_SUBST(CFLAGS)
|
||||||
|
|
||||||
|
AM_PROG_AS
|
||||||
|
AM_PROG_CC_C_O
|
||||||
|
AC_PROG_LIBTOOL
|
||||||
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
|
AM_MAINTAINER_MODE
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS(sys/mman.h)
|
||||||
|
AC_CHECK_FUNCS(mmap)
|
||||||
|
AC_FUNC_MMAP_BLACKLIST
|
||||||
|
|
||||||
|
dnl The -no-testsuite modules omit the test subdir.
|
||||||
|
AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
|
||||||
|
|
||||||
|
TARGETDIR="unknown"
|
||||||
|
case "$host" in
|
||||||
|
alpha*-*-*)
|
||||||
|
TARGET=ALPHA; TARGETDIR=alpha;
|
||||||
|
# Support 128-bit long double, changeable via command-line switch.
|
||||||
|
HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
|
||||||
|
;;
|
||||||
|
|
||||||
|
arm*-*-*)
|
||||||
|
TARGET=ARM; TARGETDIR=arm
|
||||||
|
;;
|
||||||
|
|
||||||
|
amd64-*-freebsd* | amd64-*-openbsd*)
|
||||||
|
TARGET=X86_64; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
|
||||||
|
amd64-*-freebsd*)
|
||||||
|
TARGET=X86_64; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
|
||||||
|
avr32*-*-*)
|
||||||
|
TARGET=AVR32; TARGETDIR=avr32
|
||||||
|
;;
|
||||||
|
|
||||||
|
cris-*-*)
|
||||||
|
TARGET=LIBFFI_CRIS; TARGETDIR=cris
|
||||||
|
;;
|
||||||
|
|
||||||
|
frv-*-*)
|
||||||
|
TARGET=FRV; TARGETDIR=frv
|
||||||
|
;;
|
||||||
|
|
||||||
|
hppa*-*-linux* | parisc*-*-linux*)
|
||||||
|
TARGET=PA_LINUX; TARGETDIR=pa
|
||||||
|
;;
|
||||||
|
hppa*64-*-hpux*)
|
||||||
|
TARGET=PA64_HPUX; TARGETDIR=pa
|
||||||
|
;;
|
||||||
|
hppa*-*-hpux*)
|
||||||
|
TARGET=PA_HPUX; TARGETDIR=pa
|
||||||
|
;;
|
||||||
|
|
||||||
|
i?86-*-freebsd* | i?86-*-openbsd*)
|
||||||
|
TARGET=X86_FREEBSD; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
|
||||||
|
TARGET=X86_WIN32; TARGETDIR=x86
|
||||||
|
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||||
|
# We must also check with_cross_host to decide if this is a native
|
||||||
|
# or cross-build and select where to install dlls appropriately.
|
||||||
|
if test -n "$with_cross_host" &&
|
||||||
|
test x"$with_cross_host" != x"no"; then
|
||||||
|
AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
|
||||||
|
else
|
||||||
|
AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
i?86-*-darwin*)
|
||||||
|
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
i?86-*-solaris2.1[[0-9]]*)
|
||||||
|
TARGET=X86_64; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
i?86-*-*)
|
||||||
|
TARGET=X86; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
|
||||||
|
ia64*-*-*)
|
||||||
|
TARGET=IA64; TARGETDIR=ia64
|
||||||
|
;;
|
||||||
|
|
||||||
|
m32r*-*-*)
|
||||||
|
TARGET=M32R; TARGETDIR=m32r
|
||||||
|
;;
|
||||||
|
|
||||||
|
m68k-*-*)
|
||||||
|
TARGET=M68K; TARGETDIR=m68k
|
||||||
|
;;
|
||||||
|
|
||||||
|
mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
|
||||||
|
TARGET=MIPS; TARGETDIR=mips
|
||||||
|
;;
|
||||||
|
mips*-*-linux*)
|
||||||
|
# Support 128-bit long double for NewABI.
|
||||||
|
HAVE_LONG_DOUBLE='defined(__mips64)'
|
||||||
|
TARGET=MIPS; TARGETDIR=mips
|
||||||
|
;;
|
||||||
|
|
||||||
|
powerpc*-*-linux* | powerpc-*-sysv*)
|
||||||
|
TARGET=POWERPC; TARGETDIR=powerpc
|
||||||
|
;;
|
||||||
|
powerpc-*-beos*)
|
||||||
|
TARGET=POWERPC; TARGETDIR=powerpc
|
||||||
|
;;
|
||||||
|
powerpc-*-darwin*)
|
||||||
|
TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
|
||||||
|
;;
|
||||||
|
powerpc-*-aix* | rs6000-*-aix*)
|
||||||
|
TARGET=POWERPC_AIX; TARGETDIR=powerpc
|
||||||
|
;;
|
||||||
|
powerpc-*-freebsd*)
|
||||||
|
TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
|
||||||
|
;;
|
||||||
|
powerpc64-*-freebsd*)
|
||||||
|
TARGET=POWERPC; TARGETDIR=powerpc
|
||||||
|
;;
|
||||||
|
powerpc*-*-rtems*)
|
||||||
|
TARGET=POWERPC; TARGETDIR=powerpc
|
||||||
|
;;
|
||||||
|
|
||||||
|
s390-*-* | s390x-*-*)
|
||||||
|
TARGET=S390; TARGETDIR=s390
|
||||||
|
;;
|
||||||
|
|
||||||
|
sh-*-* | sh[[34]]*-*-*)
|
||||||
|
TARGET=SH; TARGETDIR=sh
|
||||||
|
;;
|
||||||
|
sh64-*-* | sh5*-*-*)
|
||||||
|
TARGET=SH64; TARGETDIR=sh64
|
||||||
|
;;
|
||||||
|
|
||||||
|
sparc*-*-*)
|
||||||
|
TARGET=SPARC; TARGETDIR=sparc
|
||||||
|
;;
|
||||||
|
|
||||||
|
x86_64-*-darwin*)
|
||||||
|
TARGET=X86_DARWIN; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
|
||||||
|
x86_64-*-cygwin* | x86_64-*-mingw*)
|
||||||
|
TARGET=X86_WIN64; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
|
||||||
|
x86_64-*-*)
|
||||||
|
TARGET=X86_64; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
AC_SUBST(AM_RUNTESTFLAGS)
|
||||||
|
AC_SUBST(AM_LTLDFLAGS)
|
||||||
|
|
||||||
|
if test $TARGETDIR = unknown; then
|
||||||
|
AC_MSG_ERROR(["libffi has not been ported to $host."])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
|
||||||
|
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
|
||||||
|
AM_CONDITIONAL(X86, test x$TARGET = xX86)
|
||||||
|
AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
|
||||||
|
AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
|
||||||
|
AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
|
||||||
|
AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
|
||||||
|
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
|
||||||
|
AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
|
||||||
|
AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
|
||||||
|
AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
|
||||||
|
AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE)
|
||||||
|
AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
|
||||||
|
AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
|
||||||
|
AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
|
||||||
|
AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
|
||||||
|
AM_CONDITIONAL(ARM, test x$TARGET = xARM)
|
||||||
|
AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
|
||||||
|
AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
|
||||||
|
AM_CONDITIONAL(FRV, test x$TARGET = xFRV)
|
||||||
|
AM_CONDITIONAL(S390, test x$TARGET = xS390)
|
||||||
|
AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
|
||||||
|
AM_CONDITIONAL(SH, test x$TARGET = xSH)
|
||||||
|
AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
|
||||||
|
AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
|
||||||
|
AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
|
||||||
|
AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
|
||||||
|
|
||||||
|
AC_HEADER_STDC
|
||||||
|
AC_CHECK_FUNCS(memcpy)
|
||||||
|
AC_FUNC_ALLOCA
|
||||||
|
|
||||||
|
AC_CHECK_SIZEOF(double)
|
||||||
|
AC_CHECK_SIZEOF(long double)
|
||||||
|
|
||||||
|
# Also AC_SUBST this variable for ffi.h.
|
||||||
|
if test -z "$HAVE_LONG_DOUBLE"; then
|
||||||
|
HAVE_LONG_DOUBLE=0
|
||||||
|
if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
|
||||||
|
if test $ac_cv_sizeof_long_double != 0; then
|
||||||
|
HAVE_LONG_DOUBLE=1
|
||||||
|
AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
AC_SUBST(HAVE_LONG_DOUBLE)
|
||||||
|
|
||||||
|
AC_C_BIGENDIAN
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([assembler .cfi pseudo-op support],
|
||||||
|
libffi_cv_as_cfi_pseudo_op, [
|
||||||
|
libffi_cv_as_cfi_pseudo_op=unknown
|
||||||
|
AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],,
|
||||||
|
[libffi_cv_as_cfi_pseudo_op=yes],
|
||||||
|
[libffi_cv_as_cfi_pseudo_op=no])
|
||||||
|
])
|
||||||
|
if test "x$libffi_cv_as_cfi_pseudo_op" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1,
|
||||||
|
[Define if your assembler supports .cfi_* directives.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test x$TARGET = xSPARC; then
|
||||||
|
AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
|
||||||
|
libffi_cv_as_sparc_ua_pcrel, [
|
||||||
|
save_CFLAGS="$CFLAGS"
|
||||||
|
save_LDFLAGS="$LDFLAGS"
|
||||||
|
CFLAGS="$CFLAGS -fpic"
|
||||||
|
LDFLAGS="$LDFLAGS -shared"
|
||||||
|
AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
|
||||||
|
[libffi_cv_as_sparc_ua_pcrel=yes],
|
||||||
|
[libffi_cv_as_sparc_ua_pcrel=no])
|
||||||
|
CFLAGS="$save_CFLAGS"
|
||||||
|
LDFLAGS="$save_LDFLAGS"])
|
||||||
|
if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
|
||||||
|
[Define if your assembler and linker support unaligned PC relative relocs.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([assembler .register pseudo-op support],
|
||||||
|
libffi_cv_as_register_pseudo_op, [
|
||||||
|
libffi_cv_as_register_pseudo_op=unknown
|
||||||
|
# Check if we have .register
|
||||||
|
AC_TRY_COMPILE([asm (".register %g2, #scratch");],,
|
||||||
|
[libffi_cv_as_register_pseudo_op=yes],
|
||||||
|
[libffi_cv_as_register_pseudo_op=no])
|
||||||
|
])
|
||||||
|
if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
|
||||||
|
[Define if your assembler supports .register.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
|
||||||
|
AC_CACHE_CHECK([assembler supports pc related relocs],
|
||||||
|
libffi_cv_as_x86_pcrel, [
|
||||||
|
libffi_cv_as_x86_pcrel=no
|
||||||
|
echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
|
||||||
|
if $CC $CFLAGS -c conftest.s > /dev/null; then
|
||||||
|
libffi_cv_as_x86_pcrel=yes
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
if test "x$libffi_cv_as_x86_pcrel" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_AS_X86_PCREL, 1,
|
||||||
|
[Define if your assembler supports PC relative relocs.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([assembler .ascii pseudo-op support],
|
||||||
|
libffi_cv_as_ascii_pseudo_op, [
|
||||||
|
libffi_cv_as_ascii_pseudo_op=unknown
|
||||||
|
# Check if we have .ascii
|
||||||
|
AC_TRY_COMPILE([asm (".ascii \\"string\\"");],,
|
||||||
|
[libffi_cv_as_ascii_pseudo_op=yes],
|
||||||
|
[libffi_cv_as_ascii_pseudo_op=no])
|
||||||
|
])
|
||||||
|
if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_AS_ASCII_PSEUDO_OP, 1,
|
||||||
|
[Define if your assembler supports .ascii.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([assembler .string pseudo-op support],
|
||||||
|
libffi_cv_as_string_pseudo_op, [
|
||||||
|
libffi_cv_as_string_pseudo_op=unknown
|
||||||
|
# Check if we have .string
|
||||||
|
AC_TRY_COMPILE([asm (".string \\"string\\"");],,
|
||||||
|
[libffi_cv_as_string_pseudo_op=yes],
|
||||||
|
[libffi_cv_as_string_pseudo_op=no])
|
||||||
|
])
|
||||||
|
if test "x$libffi_cv_as_string_pseudo_op" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_AS_STRING_PSEUDO_OP, 1,
|
||||||
|
[Define if your assembler supports .string.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test x$TARGET = xX86_WIN64; then
|
||||||
|
LT_SYS_SYMBOL_USCORE
|
||||||
|
if test "x$sys_symbol_underscore" = xyes; then
|
||||||
|
AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
FFI_EXEC_TRAMPOLINE_TABLE=0
|
||||||
|
case "$target" in
|
||||||
|
*arm*-apple-darwin*)
|
||||||
|
FFI_EXEC_TRAMPOLINE_TABLE=1
|
||||||
|
AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
|
||||||
|
[Cannot use PROT_EXEC on this target, so, we revert to
|
||||||
|
alternative means])
|
||||||
|
;;
|
||||||
|
*-apple-darwin10* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*)
|
||||||
|
AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
|
||||||
|
[Cannot use malloc on this target, so, we revert to
|
||||||
|
alternative means])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
|
||||||
|
AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
|
||||||
|
|
||||||
|
if test x$TARGET = xX86_64; then
|
||||||
|
AC_CACHE_CHECK([assembler supports unwind section type],
|
||||||
|
libffi_cv_as_x86_64_unwind_section_type, [
|
||||||
|
libffi_cv_as_x86_64_unwind_section_type=yes
|
||||||
|
echo '.section .eh_frame,"a",@unwind' > conftest.s
|
||||||
|
if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
|
||||||
|
libffi_cv_as_x86_64_unwind_section_type=no
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
|
||||||
|
[Define if your assembler supports unwind section type.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([whether .eh_frame section should be read-only],
|
||||||
|
libffi_cv_ro_eh_frame, [
|
||||||
|
libffi_cv_ro_eh_frame=no
|
||||||
|
echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
|
||||||
|
if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then
|
||||||
|
if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then
|
||||||
|
libffi_cv_ro_eh_frame=yes
|
||||||
|
elif grep '.section.*eh_frame.*#alloc' conftest.c \
|
||||||
|
| grep -v '#write' > /dev/null; then
|
||||||
|
libffi_cv_ro_eh_frame=yes
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm -f conftest.*
|
||||||
|
])
|
||||||
|
if test "x$libffi_cv_ro_eh_frame" = xyes; then
|
||||||
|
AC_DEFINE(HAVE_RO_EH_FRAME, 1,
|
||||||
|
[Define if .eh_frame sections should be read-only.])
|
||||||
|
AC_DEFINE(EH_FRAME_FLAGS, "a",
|
||||||
|
[Define to the flags needed for the .section .eh_frame directive.])
|
||||||
|
else
|
||||||
|
AC_DEFINE(EH_FRAME_FLAGS, "aw",
|
||||||
|
[Define to the flags needed for the .section .eh_frame directive.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
|
||||||
|
libffi_cv_hidden_visibility_attribute, [
|
||||||
|
echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > conftest.c
|
||||||
|
libffi_cv_hidden_visibility_attribute=no
|
||||||
|
if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
|
||||||
|
if grep '\.hidden.*foo' conftest.s >/dev/null; then
|
||||||
|
libffi_cv_hidden_visibility_attribute=yes
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm -f conftest.*
|
||||||
|
])
|
||||||
|
if test $libffi_cv_hidden_visibility_attribute = yes; then
|
||||||
|
AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
|
||||||
|
[Define if __attribute__((visibility("hidden"))) is supported.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AH_BOTTOM([
|
||||||
|
#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
|
||||||
|
#ifdef LIBFFI_ASM
|
||||||
|
#define FFI_HIDDEN(name) .hidden name
|
||||||
|
#else
|
||||||
|
#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef LIBFFI_ASM
|
||||||
|
#define FFI_HIDDEN(name)
|
||||||
|
#else
|
||||||
|
#define FFI_HIDDEN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_SUBST(TARGET)
|
||||||
|
AC_SUBST(TARGETDIR)
|
||||||
|
|
||||||
|
AC_SUBST(SHELL)
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(debug,
|
||||||
|
[ --enable-debug debugging mode],
|
||||||
|
if test "$enable_debug" = "yes"; then
|
||||||
|
AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
|
||||||
|
fi)
|
||||||
|
AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(structs,
|
||||||
|
[ --disable-structs omit code for struct support],
|
||||||
|
if test "$enable_structs" = "no"; then
|
||||||
|
AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.])
|
||||||
|
fi)
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(raw-api,
|
||||||
|
[ --disable-raw-api make the raw api unavailable],
|
||||||
|
if test "$enable_raw_api" = "no"; then
|
||||||
|
AC_DEFINE(FFI_NO_RAW_API, 1, [Define this is you do not want support for the raw API.])
|
||||||
|
fi)
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(purify-safety,
|
||||||
|
[ --enable-purify-safety purify-safe mode],
|
||||||
|
if test "$enable_purify_safety" = "yes"; then
|
||||||
|
AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
|
||||||
|
fi)
|
||||||
|
|
||||||
|
if test -n "$with_cross_host" &&
|
||||||
|
test x"$with_cross_host" != x"no"; then
|
||||||
|
toolexecdir='$(exec_prefix)/$(target_alias)'
|
||||||
|
toolexeclibdir='$(toolexecdir)/lib'
|
||||||
|
else
|
||||||
|
toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
|
||||||
|
toolexeclibdir='$(libdir)'
|
||||||
|
fi
|
||||||
|
multi_os_directory=`$CC -print-multi-os-directory`
|
||||||
|
case $multi_os_directory in
|
||||||
|
.) ;; # Avoid trailing /.
|
||||||
|
*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
|
||||||
|
esac
|
||||||
|
AC_SUBST(toolexecdir)
|
||||||
|
AC_SUBST(toolexeclibdir)
|
||||||
|
|
||||||
|
if test "${multilib}" = "yes"; then
|
||||||
|
multilib_arg="--enable-multilib"
|
||||||
|
else
|
||||||
|
multilib_arg=
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
|
||||||
|
AC_CONFIG_COMMANDS(src, [
|
||||||
|
test -d src || mkdir src
|
||||||
|
test -d src/$TARGETDIR || mkdir src/$TARGETDIR
|
||||||
|
], [TARGETDIR="$TARGETDIR"])
|
||||||
|
|
||||||
|
AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
|
||||||
|
|
||||||
|
AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
|
||||||
|
|
||||||
|
AC_OUTPUT
|
||||||
615
.pc/interix/src/closures.c
Normal file
615
.pc/interix/src/closures.c
Normal file
@@ -0,0 +1,615 @@
|
|||||||
|
/* -----------------------------------------------------------------------
|
||||||
|
closures.c - Copyright (c) 2007, 2009, 2010 Red Hat, Inc.
|
||||||
|
Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc
|
||||||
|
Copyright (c) 2011 Plausible Labs Cooperative, Inc.
|
||||||
|
|
||||||
|
Code to allocate and deallocate memory for closures.
|
||||||
|
|
||||||
|
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.
|
||||||
|
----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#if defined __linux__ && !defined _GNU_SOURCE
|
||||||
|
#define _GNU_SOURCE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ffi.h>
|
||||||
|
#include <ffi_common.h>
|
||||||
|
|
||||||
|
#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
|
||||||
|
# if __gnu_linux__
|
||||||
|
/* This macro indicates it may be forbidden to map anonymous memory
|
||||||
|
with both write and execute permission. Code compiled when this
|
||||||
|
option is defined will attempt to map such pages once, but if it
|
||||||
|
fails, it falls back to creating a temporary file in a writable and
|
||||||
|
executable filesystem and mapping pages from it into separate
|
||||||
|
locations in the virtual memory space, one location writable and
|
||||||
|
another executable. */
|
||||||
|
# define FFI_MMAP_EXEC_WRIT 1
|
||||||
|
# define HAVE_MNTENT 1
|
||||||
|
# endif
|
||||||
|
# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)
|
||||||
|
/* Windows systems may have Data Execution Protection (DEP) enabled,
|
||||||
|
which requires the use of VirtualMalloc/VirtualFree to alloc/free
|
||||||
|
executable memory. */
|
||||||
|
# define FFI_MMAP_EXEC_WRIT 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX
|
||||||
|
# ifdef __linux__
|
||||||
|
/* When defined to 1 check for SELinux and if SELinux is active,
|
||||||
|
don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that
|
||||||
|
might cause audit messages. */
|
||||||
|
# define FFI_MMAP_EXEC_SELINUX 1
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if FFI_CLOSURES
|
||||||
|
|
||||||
|
# if FFI_EXEC_TRAMPOLINE_TABLE
|
||||||
|
|
||||||
|
// Per-target implementation; It's unclear what can reasonable be shared between two OS/architecture implementations.
|
||||||
|
|
||||||
|
# elif FFI_MMAP_EXEC_WRIT /* !FFI_EXEC_TRAMPOLINE_TABLE */
|
||||||
|
|
||||||
|
#define USE_LOCKS 1
|
||||||
|
#define USE_DL_PREFIX 1
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#ifndef USE_BUILTIN_FFS
|
||||||
|
#define USE_BUILTIN_FFS 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We need to use mmap, not sbrk. */
|
||||||
|
#define HAVE_MORECORE 0
|
||||||
|
|
||||||
|
/* We could, in theory, support mremap, but it wouldn't buy us anything. */
|
||||||
|
#define HAVE_MREMAP 0
|
||||||
|
|
||||||
|
/* We have no use for this, so save some code and data. */
|
||||||
|
#define NO_MALLINFO 1
|
||||||
|
|
||||||
|
/* We need all allocations to be in regular segments, otherwise we
|
||||||
|
lose track of the corresponding code address. */
|
||||||
|
#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
|
||||||
|
|
||||||
|
/* Don't allocate more than a page unless needed. */
|
||||||
|
#define DEFAULT_GRANULARITY ((size_t)malloc_getpagesize)
|
||||||
|
|
||||||
|
#if FFI_CLOSURE_TEST
|
||||||
|
/* Don't release single pages, to avoid a worst-case scenario of
|
||||||
|
continuously allocating and releasing single pages, but release
|
||||||
|
pairs of pages, which should do just as well given that allocations
|
||||||
|
are likely to be small. */
|
||||||
|
#define DEFAULT_TRIM_THRESHOLD ((size_t)malloc_getpagesize)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#if !defined(X86_WIN32) && !defined(X86_WIN64)
|
||||||
|
#ifdef HAVE_MNTENT
|
||||||
|
#include <mntent.h>
|
||||||
|
#endif /* HAVE_MNTENT */
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
/* We don't want sys/mman.h to be included after we redefine mmap and
|
||||||
|
dlmunmap. */
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#define LACKS_SYS_MMAN_H 1
|
||||||
|
|
||||||
|
#if FFI_MMAP_EXEC_SELINUX
|
||||||
|
#include <sys/statfs.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static int selinux_enabled = -1;
|
||||||
|
|
||||||
|
static int
|
||||||
|
selinux_enabled_check (void)
|
||||||
|
{
|
||||||
|
struct statfs sfs;
|
||||||
|
FILE *f;
|
||||||
|
char *buf = NULL;
|
||||||
|
size_t len = 0;
|
||||||
|
|
||||||
|
if (statfs ("/selinux", &sfs) >= 0
|
||||||
|
&& (unsigned int) sfs.f_type == 0xf97cff8cU)
|
||||||
|
return 1;
|
||||||
|
f = fopen ("/proc/mounts", "r");
|
||||||
|
if (f == NULL)
|
||||||
|
return 0;
|
||||||
|
while (getline (&buf, &len, f) >= 0)
|
||||||
|
{
|
||||||
|
char *p = strchr (buf, ' ');
|
||||||
|
if (p == NULL)
|
||||||
|
break;
|
||||||
|
p = strchr (p + 1, ' ');
|
||||||
|
if (p == NULL)
|
||||||
|
break;
|
||||||
|
if (strncmp (p + 1, "selinuxfs ", 10) == 0)
|
||||||
|
{
|
||||||
|
free (buf);
|
||||||
|
fclose (f);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free (buf);
|
||||||
|
fclose (f);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define is_selinux_enabled() (selinux_enabled >= 0 ? selinux_enabled \
|
||||||
|
: (selinux_enabled = selinux_enabled_check ()))
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define is_selinux_enabled() 0
|
||||||
|
|
||||||
|
#endif /* !FFI_MMAP_EXEC_SELINUX */
|
||||||
|
|
||||||
|
#elif defined (__CYGWIN__)
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
|
/* Cygwin is Linux-like, but not quite that Linux-like. */
|
||||||
|
#define is_selinux_enabled() 0
|
||||||
|
|
||||||
|
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
|
||||||
|
|
||||||
|
/* Declare all functions defined in dlmalloc.c as static. */
|
||||||
|
static void *dlmalloc(size_t);
|
||||||
|
static void dlfree(void*);
|
||||||
|
static void *dlcalloc(size_t, size_t) MAYBE_UNUSED;
|
||||||
|
static void *dlrealloc(void *, size_t) MAYBE_UNUSED;
|
||||||
|
static void *dlmemalign(size_t, size_t) MAYBE_UNUSED;
|
||||||
|
static void *dlvalloc(size_t) MAYBE_UNUSED;
|
||||||
|
static int dlmallopt(int, int) MAYBE_UNUSED;
|
||||||
|
static size_t dlmalloc_footprint(void) MAYBE_UNUSED;
|
||||||
|
static size_t dlmalloc_max_footprint(void) MAYBE_UNUSED;
|
||||||
|
static void** dlindependent_calloc(size_t, size_t, void**) MAYBE_UNUSED;
|
||||||
|
static void** dlindependent_comalloc(size_t, size_t*, void**) MAYBE_UNUSED;
|
||||||
|
static void *dlpvalloc(size_t) MAYBE_UNUSED;
|
||||||
|
static int dlmalloc_trim(size_t) MAYBE_UNUSED;
|
||||||
|
static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
|
||||||
|
static void dlmalloc_stats(void) MAYBE_UNUSED;
|
||||||
|
|
||||||
|
#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
|
||||||
|
/* Use these for mmap and munmap within dlmalloc.c. */
|
||||||
|
static void *dlmmap(void *, size_t, int, int, int, off_t);
|
||||||
|
static int dlmunmap(void *, size_t);
|
||||||
|
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
|
||||||
|
|
||||||
|
#define mmap dlmmap
|
||||||
|
#define munmap dlmunmap
|
||||||
|
|
||||||
|
#include "dlmalloc.c"
|
||||||
|
|
||||||
|
#undef mmap
|
||||||
|
#undef munmap
|
||||||
|
|
||||||
|
#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
|
||||||
|
|
||||||
|
/* A mutex used to synchronize access to *exec* variables in this file. */
|
||||||
|
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
/* A file descriptor of a temporary file from which we'll map
|
||||||
|
executable pages. */
|
||||||
|
static int execfd = -1;
|
||||||
|
|
||||||
|
/* The amount of space already allocated from the temporary file. */
|
||||||
|
static size_t execsize = 0;
|
||||||
|
|
||||||
|
/* Open a temporary file name, and immediately unlink it. */
|
||||||
|
static int
|
||||||
|
open_temp_exec_file_name (char *name)
|
||||||
|
{
|
||||||
|
int fd = mkstemp (name);
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
|
unlink (name);
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open a temporary file in the named directory. */
|
||||||
|
static int
|
||||||
|
open_temp_exec_file_dir (const char *dir)
|
||||||
|
{
|
||||||
|
static const char suffix[] = "/ffiXXXXXX";
|
||||||
|
int lendir = strlen (dir);
|
||||||
|
char *tempname = __builtin_alloca (lendir + sizeof (suffix));
|
||||||
|
|
||||||
|
if (!tempname)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
memcpy (tempname, dir, lendir);
|
||||||
|
memcpy (tempname + lendir, suffix, sizeof (suffix));
|
||||||
|
|
||||||
|
return open_temp_exec_file_name (tempname);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open a temporary file in the directory in the named environment
|
||||||
|
variable. */
|
||||||
|
static int
|
||||||
|
open_temp_exec_file_env (const char *envvar)
|
||||||
|
{
|
||||||
|
const char *value = getenv (envvar);
|
||||||
|
|
||||||
|
if (!value)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return open_temp_exec_file_dir (value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_MNTENT
|
||||||
|
/* Open a temporary file in an executable and writable mount point
|
||||||
|
listed in the mounts file. Subsequent calls with the same mounts
|
||||||
|
keep searching for mount points in the same file. Providing NULL
|
||||||
|
as the mounts file closes the file. */
|
||||||
|
static int
|
||||||
|
open_temp_exec_file_mnt (const char *mounts)
|
||||||
|
{
|
||||||
|
static const char *last_mounts;
|
||||||
|
static FILE *last_mntent;
|
||||||
|
|
||||||
|
if (mounts != last_mounts)
|
||||||
|
{
|
||||||
|
if (last_mntent)
|
||||||
|
endmntent (last_mntent);
|
||||||
|
|
||||||
|
last_mounts = mounts;
|
||||||
|
|
||||||
|
if (mounts)
|
||||||
|
last_mntent = setmntent (mounts, "r");
|
||||||
|
else
|
||||||
|
last_mntent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!last_mntent)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
struct mntent mnt;
|
||||||
|
char buf[MAXPATHLEN * 3];
|
||||||
|
|
||||||
|
if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (hasmntopt (&mnt, "ro")
|
||||||
|
|| hasmntopt (&mnt, "noexec")
|
||||||
|
|| access (mnt.mnt_dir, W_OK))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fd = open_temp_exec_file_dir (mnt.mnt_dir);
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* HAVE_MNTENT */
|
||||||
|
|
||||||
|
/* Instructions to look for a location to hold a temporary file that
|
||||||
|
can be mapped in for execution. */
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
int (*func)(const char *);
|
||||||
|
const char *arg;
|
||||||
|
int repeat;
|
||||||
|
} open_temp_exec_file_opts[] = {
|
||||||
|
{ open_temp_exec_file_env, "TMPDIR", 0 },
|
||||||
|
{ open_temp_exec_file_dir, "/tmp", 0 },
|
||||||
|
{ open_temp_exec_file_dir, "/var/tmp", 0 },
|
||||||
|
{ open_temp_exec_file_dir, "/dev/shm", 0 },
|
||||||
|
{ open_temp_exec_file_env, "HOME", 0 },
|
||||||
|
#ifdef HAVE_MNTENT
|
||||||
|
{ open_temp_exec_file_mnt, "/etc/mtab", 1 },
|
||||||
|
{ open_temp_exec_file_mnt, "/proc/mounts", 1 },
|
||||||
|
#endif /* HAVE_MNTENT */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Current index into open_temp_exec_file_opts. */
|
||||||
|
static int open_temp_exec_file_opts_idx = 0;
|
||||||
|
|
||||||
|
/* Reset a current multi-call func, then advances to the next entry.
|
||||||
|
If we're at the last, go back to the first and return nonzero,
|
||||||
|
otherwise return zero. */
|
||||||
|
static int
|
||||||
|
open_temp_exec_file_opts_next (void)
|
||||||
|
{
|
||||||
|
if (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
|
||||||
|
open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func (NULL);
|
||||||
|
|
||||||
|
open_temp_exec_file_opts_idx++;
|
||||||
|
if (open_temp_exec_file_opts_idx
|
||||||
|
== (sizeof (open_temp_exec_file_opts)
|
||||||
|
/ sizeof (*open_temp_exec_file_opts)))
|
||||||
|
{
|
||||||
|
open_temp_exec_file_opts_idx = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return a file descriptor of a temporary zero-sized file in a
|
||||||
|
writable and exexutable filesystem. */
|
||||||
|
static int
|
||||||
|
open_temp_exec_file (void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
fd = open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func
|
||||||
|
(open_temp_exec_file_opts[open_temp_exec_file_opts_idx].arg);
|
||||||
|
|
||||||
|
if (!open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat
|
||||||
|
|| fd == -1)
|
||||||
|
{
|
||||||
|
if (open_temp_exec_file_opts_next ())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (fd == -1);
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map in a chunk of memory from the temporary exec file into separate
|
||||||
|
locations in the virtual memory address space, one writable and one
|
||||||
|
executable. Returns the address of the writable portion, after
|
||||||
|
storing an offset to the corresponding executable portion at the
|
||||||
|
last word of the requested chunk. */
|
||||||
|
static void *
|
||||||
|
dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset)
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
if (execfd == -1)
|
||||||
|
{
|
||||||
|
open_temp_exec_file_opts_idx = 0;
|
||||||
|
retry_open:
|
||||||
|
execfd = open_temp_exec_file ();
|
||||||
|
if (execfd == -1)
|
||||||
|
return MFAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = execsize;
|
||||||
|
|
||||||
|
if (ftruncate (execfd, offset + length))
|
||||||
|
return MFAIL;
|
||||||
|
|
||||||
|
flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS);
|
||||||
|
flags |= MAP_SHARED;
|
||||||
|
|
||||||
|
ptr = mmap (NULL, length, (prot & ~PROT_WRITE) | PROT_EXEC,
|
||||||
|
flags, execfd, offset);
|
||||||
|
if (ptr == MFAIL)
|
||||||
|
{
|
||||||
|
if (!offset)
|
||||||
|
{
|
||||||
|
close (execfd);
|
||||||
|
goto retry_open;
|
||||||
|
}
|
||||||
|
ftruncate (execfd, offset);
|
||||||
|
return MFAIL;
|
||||||
|
}
|
||||||
|
else if (!offset
|
||||||
|
&& open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
|
||||||
|
open_temp_exec_file_opts_next ();
|
||||||
|
|
||||||
|
start = mmap (start, length, prot, flags, execfd, offset);
|
||||||
|
|
||||||
|
if (start == MFAIL)
|
||||||
|
{
|
||||||
|
munmap (ptr, length);
|
||||||
|
ftruncate (execfd, offset);
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
mmap_exec_offset ((char *)start, length) = (char*)ptr - (char*)start;
|
||||||
|
|
||||||
|
execsize += length;
|
||||||
|
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map in a writable and executable chunk of memory if possible.
|
||||||
|
Failing that, fall back to dlmmap_locked. */
|
||||||
|
static void *
|
||||||
|
dlmmap (void *start, size_t length, int prot,
|
||||||
|
int flags, int fd, off_t offset)
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
assert (start == NULL && length % malloc_getpagesize == 0
|
||||||
|
&& prot == (PROT_READ | PROT_WRITE)
|
||||||
|
&& flags == (MAP_PRIVATE | MAP_ANONYMOUS)
|
||||||
|
&& fd == -1 && offset == 0);
|
||||||
|
|
||||||
|
#if FFI_CLOSURE_TEST
|
||||||
|
printf ("mapping in %zi\n", length);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (execfd == -1 && !is_selinux_enabled ())
|
||||||
|
{
|
||||||
|
ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
|
||||||
|
|
||||||
|
if (ptr != MFAIL || (errno != EPERM && errno != EACCES))
|
||||||
|
/* Cool, no need to mess with separate segments. */
|
||||||
|
return ptr;
|
||||||
|
|
||||||
|
/* If MREMAP_DUP is ever introduced and implemented, try mmap
|
||||||
|
with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with
|
||||||
|
MREMAP_DUP and prot at this point. */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (execsize == 0 || execfd == -1)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock (&open_temp_exec_file_mutex);
|
||||||
|
ptr = dlmmap_locked (start, length, prot, flags, offset);
|
||||||
|
pthread_mutex_unlock (&open_temp_exec_file_mutex);
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dlmmap_locked (start, length, prot, flags, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release memory at the given address, as well as the corresponding
|
||||||
|
executable page if it's separate. */
|
||||||
|
static int
|
||||||
|
dlmunmap (void *start, size_t length)
|
||||||
|
{
|
||||||
|
/* We don't bother decreasing execsize or truncating the file, since
|
||||||
|
we can't quite tell whether we're unmapping the end of the file.
|
||||||
|
We don't expect frequent deallocation anyway. If we did, we
|
||||||
|
could locate pages in the file by writing to the pages being
|
||||||
|
deallocated and checking that the file contents change.
|
||||||
|
Yuck. */
|
||||||
|
msegmentptr seg = segment_holding (gm, start);
|
||||||
|
void *code;
|
||||||
|
|
||||||
|
#if FFI_CLOSURE_TEST
|
||||||
|
printf ("unmapping %zi\n", length);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (seg && (code = add_segment_exec_offset (start, seg)) != start)
|
||||||
|
{
|
||||||
|
int ret = munmap (code, length);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return munmap (start, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if FFI_CLOSURE_FREE_CODE
|
||||||
|
/* Return segment holding given code address. */
|
||||||
|
static msegmentptr
|
||||||
|
segment_holding_code (mstate m, char* addr)
|
||||||
|
{
|
||||||
|
msegmentptr sp = &m->seg;
|
||||||
|
for (;;) {
|
||||||
|
if (addr >= add_segment_exec_offset (sp->base, sp)
|
||||||
|
&& addr < add_segment_exec_offset (sp->base, sp) + sp->size)
|
||||||
|
return sp;
|
||||||
|
if ((sp = sp->next) == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
|
||||||
|
|
||||||
|
/* Allocate a chunk of memory with the given size. Returns a pointer
|
||||||
|
to the writable address, and sets *CODE to the executable
|
||||||
|
corresponding virtual address. */
|
||||||
|
void *
|
||||||
|
ffi_closure_alloc (size_t size, void **code)
|
||||||
|
{
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
if (!code)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ptr = dlmalloc (size);
|
||||||
|
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
msegmentptr seg = segment_holding (gm, ptr);
|
||||||
|
|
||||||
|
*code = add_segment_exec_offset (ptr, seg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release a chunk of memory allocated with ffi_closure_alloc. If
|
||||||
|
FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
|
||||||
|
writable or the executable address given. Otherwise, only the
|
||||||
|
writable address can be provided here. */
|
||||||
|
void
|
||||||
|
ffi_closure_free (void *ptr)
|
||||||
|
{
|
||||||
|
#if FFI_CLOSURE_FREE_CODE
|
||||||
|
msegmentptr seg = segment_holding_code (gm, ptr);
|
||||||
|
|
||||||
|
if (seg)
|
||||||
|
ptr = sub_segment_exec_offset (ptr, seg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
dlfree (ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if FFI_CLOSURE_TEST
|
||||||
|
/* Do some internal sanity testing to make sure allocation and
|
||||||
|
deallocation of pages are working as intended. */
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
void *p[3];
|
||||||
|
#define GET(idx, len) do { p[idx] = dlmalloc (len); printf ("allocated %zi for p[%i]\n", (len), (idx)); } while (0)
|
||||||
|
#define PUT(idx) do { printf ("freeing p[%i]\n", (idx)); dlfree (p[idx]); } while (0)
|
||||||
|
GET (0, malloc_getpagesize / 2);
|
||||||
|
GET (1, 2 * malloc_getpagesize - 64 * sizeof (void*));
|
||||||
|
PUT (1);
|
||||||
|
GET (1, 2 * malloc_getpagesize);
|
||||||
|
GET (2, malloc_getpagesize / 2);
|
||||||
|
PUT (1);
|
||||||
|
PUT (0);
|
||||||
|
PUT (2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* FFI_CLOSURE_TEST */
|
||||||
|
# else /* ! FFI_MMAP_EXEC_WRIT */
|
||||||
|
|
||||||
|
/* On many systems, memory returned by malloc is writable and
|
||||||
|
executable, so just use it. */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void *
|
||||||
|
ffi_closure_alloc (size_t size, void **code)
|
||||||
|
{
|
||||||
|
if (!code)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return *code = malloc (size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ffi_closure_free (void *ptr)
|
||||||
|
{
|
||||||
|
free (ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
# endif /* ! FFI_MMAP_EXEC_WRIT */
|
||||||
|
#endif /* FFI_CLOSURES */
|
||||||
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2011-02-09 Anthony Green <green@moxielogic.com>
|
||||||
|
|
||||||
|
* README: Mention Interix.
|
||||||
|
|
||||||
|
2011-02-09 Jonathan Callen <abcd@gentoo.org>
|
||||||
|
|
||||||
|
* configure.ac: Add Interix to win32/cygwin/mingw case.
|
||||||
|
* configure: Ditto.
|
||||||
|
* src/closures.c: Treat Interix like Cygwin, instead of as a
|
||||||
|
generic win32.
|
||||||
|
|
||||||
2011-02-09 Anthony Green <green@moxielogic.com>
|
2011-02-09 Anthony Green <green@moxielogic.com>
|
||||||
|
|
||||||
* testsuite/libffi.call/err_bad_typedef.c: Remove xfail.
|
* testsuite/libffi.call/err_bad_typedef.c: Remove xfail.
|
||||||
|
|||||||
1
README
1
README
@@ -74,6 +74,7 @@ tested:
|
|||||||
| SPARC64 | Linux |
|
| SPARC64 | Linux |
|
||||||
| SPARC64 | FreeBSD |
|
| SPARC64 | FreeBSD |
|
||||||
| X86 | FreeBSD |
|
| X86 | FreeBSD |
|
||||||
|
| X86 | Interix |
|
||||||
| X86 | kFreeBSD |
|
| X86 | kFreeBSD |
|
||||||
| X86 | Linux |
|
| X86 | Linux |
|
||||||
| X86 | Mac OSX |
|
| X86 | Mac OSX |
|
||||||
|
|||||||
7954
aclocal.m4
vendored
7954
aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
2
configure
vendored
2
configure
vendored
@@ -12200,7 +12200,7 @@ case "$host" in
|
|||||||
i?86-*-freebsd* | i?86-*-openbsd*)
|
i?86-*-freebsd* | i?86-*-openbsd*)
|
||||||
TARGET=X86_FREEBSD; TARGETDIR=x86
|
TARGET=X86_FREEBSD; TARGETDIR=x86
|
||||||
;;
|
;;
|
||||||
i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
|
i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
|
||||||
TARGET=X86_WIN32; TARGETDIR=x86
|
TARGET=X86_WIN32; TARGETDIR=x86
|
||||||
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||||
# We must also check with_cross_host to decide if this is a native
|
# We must also check with_cross_host to decide if this is a native
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ case "$host" in
|
|||||||
i?86-*-freebsd* | i?86-*-openbsd*)
|
i?86-*-freebsd* | i?86-*-openbsd*)
|
||||||
TARGET=X86_FREEBSD; TARGETDIR=x86
|
TARGET=X86_FREEBSD; TARGETDIR=x86
|
||||||
;;
|
;;
|
||||||
i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
|
i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
|
||||||
TARGET=X86_WIN32; TARGETDIR=x86
|
TARGET=X86_WIN32; TARGETDIR=x86
|
||||||
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||||
# We must also check with_cross_host to decide if this is a native
|
# We must also check with_cross_host to decide if this is a native
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ ECHO_N = @ECHO_N@
|
|||||||
ECHO_T = @ECHO_T@
|
ECHO_T = @ECHO_T@
|
||||||
EGREP = @EGREP@
|
EGREP = @EGREP@
|
||||||
EXEEXT = @EXEEXT@
|
EXEEXT = @EXEEXT@
|
||||||
|
FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
|
||||||
FGREP = @FGREP@
|
FGREP = @FGREP@
|
||||||
GREP = @GREP@
|
GREP = @GREP@
|
||||||
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
|
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
|
||||||
@@ -192,6 +193,7 @@ psdir = @psdir@
|
|||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
sys_symbol_underscore = @sys_symbol_underscore@
|
||||||
sysconfdir = @sysconfdir@
|
sysconfdir = @sysconfdir@
|
||||||
target = @target@
|
target = @target@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ ECHO_N = @ECHO_N@
|
|||||||
ECHO_T = @ECHO_T@
|
ECHO_T = @ECHO_T@
|
||||||
EGREP = @EGREP@
|
EGREP = @EGREP@
|
||||||
EXEEXT = @EXEEXT@
|
EXEEXT = @EXEEXT@
|
||||||
|
FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
|
||||||
FGREP = @FGREP@
|
FGREP = @FGREP@
|
||||||
GREP = @GREP@
|
GREP = @GREP@
|
||||||
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
|
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
|
||||||
@@ -190,6 +191,7 @@ psdir = @psdir@
|
|||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
sys_symbol_underscore = @sys_symbol_underscore@
|
||||||
sysconfdir = @sysconfdir@
|
sysconfdir = @sysconfdir@
|
||||||
target = @target@
|
target = @target@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
|
|||||||
95
patches/interix
Normal file
95
patches/interix
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
Index: libffi/configure
|
||||||
|
===================================================================
|
||||||
|
--- libffi.orig/configure
|
||||||
|
+++ libffi/configure
|
||||||
|
@@ -12200,7 +12200,7 @@ case "$host" in
|
||||||
|
i?86-*-freebsd* | i?86-*-openbsd*)
|
||||||
|
TARGET=X86_FREEBSD; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
- i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
|
||||||
|
+ i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
|
||||||
|
TARGET=X86_WIN32; TARGETDIR=x86
|
||||||
|
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||||
|
# We must also check with_cross_host to decide if this is a native
|
||||||
|
Index: libffi/configure.ac
|
||||||
|
===================================================================
|
||||||
|
--- libffi.orig/configure.ac
|
||||||
|
+++ libffi/configure.ac
|
||||||
|
@@ -88,7 +88,7 @@ case "$host" in
|
||||||
|
i?86-*-freebsd* | i?86-*-openbsd*)
|
||||||
|
TARGET=X86_FREEBSD; TARGETDIR=x86
|
||||||
|
;;
|
||||||
|
- i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
|
||||||
|
+ i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
|
||||||
|
TARGET=X86_WIN32; TARGETDIR=x86
|
||||||
|
# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
|
||||||
|
# We must also check with_cross_host to decide if this is a native
|
||||||
|
Index: libffi/src/closures.c
|
||||||
|
===================================================================
|
||||||
|
--- libffi.orig/src/closures.c
|
||||||
|
+++ libffi/src/closures.c
|
||||||
|
@@ -198,11 +198,11 @@ static int dlmalloc_trim(size_t) MAYBE_U
|
||||||
|
static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
|
||||||
|
static void dlmalloc_stats(void) MAYBE_UNUSED;
|
||||||
|
|
||||||
|
-#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
|
||||||
|
+#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
|
||||||
|
/* Use these for mmap and munmap within dlmalloc.c. */
|
||||||
|
static void *dlmmap(void *, size_t, int, int, int, off_t);
|
||||||
|
static int dlmunmap(void *, size_t);
|
||||||
|
-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
|
||||||
|
+#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
|
||||||
|
|
||||||
|
#define mmap dlmmap
|
||||||
|
#define munmap dlmunmap
|
||||||
|
@@ -212,7 +212,7 @@ static int dlmunmap(void *, size_t);
|
||||||
|
#undef mmap
|
||||||
|
#undef munmap
|
||||||
|
|
||||||
|
-#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
|
||||||
|
+#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
|
||||||
|
|
||||||
|
/* A mutex used to synchronize access to *exec* variables in this file. */
|
||||||
|
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
@@ -527,7 +527,7 @@ segment_holding_code (mstate m, char* ad
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
|
||||||
|
+#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
|
||||||
|
|
||||||
|
/* Allocate a chunk of memory with the given size. Returns a pointer
|
||||||
|
to the writable address, and sets *CODE to the executable
|
||||||
|
Index: libffi/ChangeLog
|
||||||
|
===================================================================
|
||||||
|
--- libffi.orig/ChangeLog
|
||||||
|
+++ libffi/ChangeLog
|
||||||
|
@@ -1,5 +1,16 @@
|
||||||
|
2011-02-09 Anthony Green <green@moxielogic.com>
|
||||||
|
|
||||||
|
+ * README: Mention Interix.
|
||||||
|
+
|
||||||
|
+2011-02-09 Jonathan Callen <abcd@gentoo.org>
|
||||||
|
+
|
||||||
|
+ * configure.ac: Add Interix to win32/cygwin/mingw case.
|
||||||
|
+ * configure: Ditto.
|
||||||
|
+ * src/closures.c: Treat Interix like Cygwin, instead of as a
|
||||||
|
+ generic win32.
|
||||||
|
+
|
||||||
|
+2011-02-09 Anthony Green <green@moxielogic.com>
|
||||||
|
+
|
||||||
|
* testsuite/libffi.call/err_bad_typedef.c: Remove xfail.
|
||||||
|
* testsuite/libffi.call/err_bad_abi.c: Remove xfail.
|
||||||
|
* src/x86/ffi64.c (UNLIKELY, LIKELY): Define.
|
||||||
|
Index: libffi/README
|
||||||
|
===================================================================
|
||||||
|
--- libffi.orig/README
|
||||||
|
+++ libffi/README
|
||||||
|
@@ -74,6 +74,7 @@ tested:
|
||||||
|
| SPARC64 | Linux |
|
||||||
|
| SPARC64 | FreeBSD |
|
||||||
|
| X86 | FreeBSD |
|
||||||
|
+| X86 | Interix |
|
||||||
|
| X86 | kFreeBSD |
|
||||||
|
| X86 | Linux |
|
||||||
|
| X86 | Mac OSX |
|
||||||
@@ -14,3 +14,4 @@ hpux-mallinfo
|
|||||||
copyright-updates
|
copyright-updates
|
||||||
ios
|
ios
|
||||||
fix-xfails
|
fix-xfails
|
||||||
|
interix
|
||||||
|
|||||||
@@ -198,11 +198,11 @@ static int dlmalloc_trim(size_t) MAYBE_UNUSED;
|
|||||||
static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
|
static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
|
||||||
static void dlmalloc_stats(void) MAYBE_UNUSED;
|
static void dlmalloc_stats(void) MAYBE_UNUSED;
|
||||||
|
|
||||||
#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
|
#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
|
||||||
/* Use these for mmap and munmap within dlmalloc.c. */
|
/* Use these for mmap and munmap within dlmalloc.c. */
|
||||||
static void *dlmmap(void *, size_t, int, int, int, off_t);
|
static void *dlmmap(void *, size_t, int, int, int, off_t);
|
||||||
static int dlmunmap(void *, size_t);
|
static int dlmunmap(void *, size_t);
|
||||||
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
|
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
|
||||||
|
|
||||||
#define mmap dlmmap
|
#define mmap dlmmap
|
||||||
#define munmap dlmunmap
|
#define munmap dlmunmap
|
||||||
@@ -212,7 +212,7 @@ static int dlmunmap(void *, size_t);
|
|||||||
#undef mmap
|
#undef mmap
|
||||||
#undef munmap
|
#undef munmap
|
||||||
|
|
||||||
#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
|
#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
|
||||||
|
|
||||||
/* A mutex used to synchronize access to *exec* variables in this file. */
|
/* A mutex used to synchronize access to *exec* variables in this file. */
|
||||||
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
@@ -527,7 +527,7 @@ segment_holding_code (mstate m, char* addr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
|
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
|
||||||
|
|
||||||
/* Allocate a chunk of memory with the given size. Returns a pointer
|
/* Allocate a chunk of memory with the given size. Returns a pointer
|
||||||
to the writable address, and sets *CODE to the executable
|
to the writable address, and sets *CODE to the executable
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ ECHO_N = @ECHO_N@
|
|||||||
ECHO_T = @ECHO_T@
|
ECHO_T = @ECHO_T@
|
||||||
EGREP = @EGREP@
|
EGREP = @EGREP@
|
||||||
EXEEXT = @EXEEXT@
|
EXEEXT = @EXEEXT@
|
||||||
|
FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
|
||||||
FGREP = @FGREP@
|
FGREP = @FGREP@
|
||||||
GREP = @GREP@
|
GREP = @GREP@
|
||||||
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
|
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
|
||||||
@@ -167,6 +168,7 @@ psdir = @psdir@
|
|||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
sys_symbol_underscore = @sys_symbol_underscore@
|
||||||
sysconfdir = @sysconfdir@
|
sysconfdir = @sysconfdir@
|
||||||
target = @target@
|
target = @target@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
|
|||||||
Reference in New Issue
Block a user