Bug 810631 - Update libffi to version 3.1. r=jorendorff, r=glandium

This commit is contained in:
Ryan VanderMeulen 2014-05-13 14:51:01 -04:00
parent de1090e391
commit 9eebde7ec1
270 changed files with 44337 additions and 22297 deletions

View File

@ -46,14 +46,19 @@ if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then
# autotools can't quite handle an MSVC build environment yet. # autotools can't quite handle an MSVC build environment yet.
LDFLAGS= LDFLAGS=
CFLAGS= CFLAGS=
ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" SHELL=sh.exe" ac_configure_args="$ac_configure_args LD=link CPP=\"cl -nologo -EP\" \
CXXCPP=\"cl -nologo -EP\" SHELL=sh.exe"
case "${target_cpu}" in case "${target_cpu}" in
x86_64) x86_64)
# Need target since MSYS tools into mozilla-build may be 32bit # Need target since MSYS tools into mozilla-build may be 32bit
ac_configure_args="$ac_configure_args CC=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh -m64\"" ac_configure_args="$ac_configure_args \
CC=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh -m64\" \
CXX=\"$_topsrcdir/js/src/ctypes/libffi/msvcc.sh -m64\""
;; ;;
*) *)
ac_configure_args="$ac_configure_args CC=$_topsrcdir/js/src/ctypes/libffi/msvcc.sh" ac_configure_args="$ac_configure_args \
CC=$_topsrcdir/js/src/ctypes/libffi/msvcc.sh \
CXX=$_topsrcdir/js/src/ctypes/libffi/msvcc.sh"
;; ;;
esac esac
fi fi

View File

@ -39,6 +39,11 @@ SHARED_LIBRARY_LIBS += \
$(NULL) $(NULL)
endif endif
# Windows needs this to be linked with a static library.
ifndef MOZ_NATIVE_FFI
DEFINES += -DFFI_BUILDING
endif
endif # JS_HAS_CTYPES endif # JS_HAS_CTYPES
DASH_R = -r DASH_R = -r

View File

@ -0,0 +1,111 @@
Modifications to upstream libffi needed for the Mozilla build:
* Clear INFO_DEPS so that builds don't fail when makeinfo isn't present.
- This can be removed if https://github.com/atgreen/libffi/issues/111 is fixed.
* Various workarounds for pymake bugs.
- Once pymake support is fully deprecated, hunks 2 & 3 be safely removed.
diff --git a/js/src/ctypes/libffi/Makefile.in b/js/src/ctypes/libffi/Makefile.in
--- a/js/src/ctypes/libffi/Makefile.in
+++ b/js/src/ctypes/libffi/Makefile.in
@@ -358,17 +358,17 @@ am__v_TEXI2PDF_1 =
AM_V_texinfo = $(am__v_texinfo_@AM_V@)
am__v_texinfo_ = $(am__v_texinfo_@AM_DEFAULT_V@)
am__v_texinfo_0 = -q
am__v_texinfo_1 =
AM_V_texidevnull = $(am__v_texidevnull_@AM_V@)
am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@)
am__v_texidevnull_0 = > /dev/null
am__v_texidevnull_1 =
-INFO_DEPS = $(srcdir)/doc/libffi.info
+INFO_DEPS =
am__TEXINFO_TEX_DIR = $(srcdir)
DVIS = doc/libffi.dvi
PDFS = doc/libffi.pdf
PSS = doc/libffi.ps
HTMLS = doc/libffi.html
TEXINFOS = doc/libffi.texi
TEXI2DVI = texi2dvi
TEXI2PDF = $(TEXI2DVI) --pdf --batch
@@ -1292,57 +1292,57 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/freebsd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/sysv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/unix64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win32.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win64.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/xtensa/$(DEPDIR)/ffi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/xtensa/$(DEPDIR)/sysv.Plo@am__quote@
-.S.o:
+%.o: %.S
@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ $<
-.S.obj:
+%.obj: %.S
@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-.S.lo:
+%.lo: %.S
@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCCAS_TRUE@ $(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LTCPPASCOMPILE) -c -o $@ $<
-.c.o:
+%.o: %.c
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
-.c.obj:
+%.obj: %.c
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-.c.lo:
+%.lo: %.c
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
@@ -1443,17 +1443,17 @@ doc/libffi.html: doc/libffi.texi $(srcdi
-@rm -f vti.tmp
@cp $(srcdir)/doc/version.texi $@
mostlyclean-vti:
-rm -f vti.tmp
maintainer-clean-vti:
@MAINTAINER_MODE_TRUE@ -rm -f $(srcdir)/doc/stamp-vti $(srcdir)/doc/version.texi
-.dvi.ps:
+%.ps: %.dvi
$(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
$(DVIPS) $(AM_V_texinfo) -o $@ $<
uninstall-dvi-am:
@$(NORMAL_UNINSTALL)
@list='$(DVIS)'; test -n "$(dvidir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \

View File

@ -1,35 +1,6 @@
2010-01-15 Anthony Green <green@redhat.com> 2011-02-08 Andreas Tobler <andreast@fgznet.ch>
* README: Add notes on building with Microsoft Visual C++. * testsuite/lib/libffi.exp: Tweak for stand-alone mode.
2010-01-15 Daniel Witte <dwitte@mozilla.com>
* msvcc.sh: New file.
* src/x86/win32.S: Port assembly routines to MSVC and #ifdef.
* src/x86/ffi.c: Tweak function declaration and remove excess
parens.
* include/ffi.h.in: Add __declspec(align(8)) to typedef struct
ffi_closure.
* src/x86/ffi.c: Merge ffi_call_SYSV and ffi_call_STDCALL into new
function ffi_call_win32 on X86_WIN32.
* src/x86/win32.S (ffi_call_SYSV): Rename to ffi_call_win32.
(ffi_call_STDCALL): Remove.
* src/prep_cif.c (ffi_prep_cif): Move stack space allocation code
to ffi_prep_cif_machdep for x86.
* src/x86/ffi.c (ffi_prep_cif_machdep): To here.
2010-01-15 Oliver Kiddle <okiddle@yahoo.co.uk>
* src/x86/ffitarget.h (ffi_abi): Check for __i386 and __amd64 for
Sun Studio compiler compatibility.
2010-01-12 Conrad Irwin <conrad.irwin@gmail.com>
* doc/libffi.texi: Add closure example.
* doc/libffi.info: Rebuilt.
2009-12-25 Samuli Suominen <ssuominen@gentoo.org> 2009-12-25 Samuli Suominen <ssuominen@gentoo.org>
@ -603,8 +574,8 @@
* Makefile.am, include/Makefile.am: Move headers to * Makefile.am, include/Makefile.am: Move headers to
libffi_la_SOURCES for new automake. libffi_la_SOURCES for new automake.
* Makefile.in, include/Makefile.in: Rebuilt. * Makefile.in, include/Makefile.in: Rebuilt.
* testsuite/lib/wrapper.exp: Copied from gcc tree to allow for * testsuite/lib/wrapper.exp: Copied from gcc tree to allow for
execution outside of gcc tree. execution outside of gcc tree.
* testsuite/lib/target-libpath.exp: Ditto. * testsuite/lib/target-libpath.exp: Ditto.

View File

@ -2,7 +2,7 @@ The libffi version 1 ChangeLog archive.
Version 1 of libffi had per-directory ChangeLogs. Current and future Version 1 of libffi had per-directory ChangeLogs. Current and future
versions have a single ChangeLog file in the root directory. The versions have a single ChangeLog file in the root directory. The
version 1 ChangeLogs have all been concatonated into this file for version 1 ChangeLogs have all been concatenated into this file for
future reference only. future reference only.
--- libffi ---------------------------------------------------------------- --- libffi ----------------------------------------------------------------

View File

@ -1,4 +1,4 @@
libffi - Copyright (c) 1996-2009 Anthony Green, Red Hat, Inc and others. libffi - Copyright (c) 1996-2014 Anthony Green, Red Hat, Inc and others.
See source files for details. See source files for details.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -9,8 +9,8 @@ distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
the following conditions: the following conditions:
The above copyright notice and this permission notice shall be included The above copyright notice and this permission notice shall be
in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

View File

@ -2,37 +2,55 @@
AUTOMAKE_OPTIONS = foreign subdir-objects AUTOMAKE_OPTIONS = foreign subdir-objects
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = include testsuite man SUBDIRS = include testsuite man
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \
src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \ src/aarch64/ffi.c src/aarch64/ffitarget.h src/aarch64/sysv.S \
src/arm/ffi.c src/arm/sysv.S src/arm/ffitarget.h \ src/alpha/ffi.c src/alpha/osf.S \
src/avr32/ffi.c src/avr32/sysv.S src/avr32/ffitarget.h \ src/alpha/ffitarget.h src/arc/ffi.c src/arc/arcompact.S \
src/cris/ffi.c src/cris/sysv.S src/cris/ffitarget.h \ src/arc/ffitarget.h src/arm/ffi.c src/arm/sysv.S \
src/ia64/ffi.c src/ia64/ffitarget.h src/ia64/ia64_flags.h \ src/arm/ffitarget.h src/avr32/ffi.c src/avr32/sysv.S \
src/ia64/unix.S \ src/avr32/ffitarget.h src/cris/ffi.c src/cris/sysv.S \
src/mips/ffi.c src/mips/n32.S src/mips/o32.S \ src/cris/ffitarget.h src/ia64/ffi.c src/ia64/ffitarget.h \
src/mips/ffitarget.h \ src/ia64/ia64_flags.h src/ia64/unix.S src/mips/ffi.c \
src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \ src/mips/n32.S src/mips/o32.S src/metag/ffi.c \
src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \ src/metag/ffitarget.h src/metag/sysv.S src/moxie/ffi.c \
src/powerpc/ffi.c src/powerpc/sysv.S \ src/moxie/ffitarget.h src/moxie/eabi.S src/mips/ffitarget.h \
src/powerpc/linux64.S src/powerpc/linux64_closure.S \ src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \
src/powerpc/ppc_closure.S src/powerpc/asm.h \ src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \
src/powerpc/aix.S src/powerpc/darwin.S \ src/m88k/ffi.c src/m88k/obsd.S src/m88k/ffitarget.h \
src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \ src/microblaze/ffi.c src/microblaze/sysv.S \
src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \ src/microblaze/ffitarget.h \
src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \ src/nios2/ffi.c src/nios2/ffitarget.h src/nios2/sysv.S \
src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h \ src/powerpc/ffi.c src/powerpc/ffi_powerpc.h \
src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \ src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \
src/sparc/v8.S src/sparc/v9.S src/sparc/ffitarget.h \ src/powerpc/sysv.S src/powerpc/linux64.S \
src/sparc/ffi.c src/x86/darwin64.S \ src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/win64.S \ src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \
src/x86/darwin.S src/x86/freebsd.S \ src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \
src/x86/ffi64.c src/x86/unix64.S src/x86/ffitarget.h \ src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
src/pa/ffitarget.h src/pa/ffi.c src/pa/linux.S src/pa/hpux32.S \ src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
src/frv/ffi.c src/frv/eabi.S src/frv/ffitarget.h src/dlmalloc.c \ src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h src/sh64/ffi.c \
libtool-version ChangeLog.libffi m4/libtool.m4 \ src/sh64/sysv.S src/sh64/ffitarget.h src/sparc/v8.S \
m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 src/sparc/v9.S src/sparc/ffitarget.h src/sparc/ffi.c \
src/x86/darwin64.S src/x86/ffi.c src/x86/sysv.S \
src/x86/win32.S src/x86/darwin.S src/x86/win64.S \
src/x86/freebsd.S src/x86/ffi64.c src/x86/unix64.S \
src/x86/ffitarget.h src/pa/ffitarget.h src/pa/ffi.c \
src/pa/linux.S src/pa/hpux32.S src/frv/ffi.c src/bfin/ffi.c \
src/bfin/ffitarget.h src/bfin/sysv.S src/frv/eabi.S \
src/frv/ffitarget.h src/dlmalloc.c src/tile/ffi.c \
src/tile/ffitarget.h src/tile/tile.S libtool-version \
src/vax/ffi.c src/vax/ffitarget.h src/vax/elfbsd.S \
src/xtensa/ffitarget.h src/xtensa/ffi.c src/xtensa/sysv.S \
ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \
m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \
generate-darwin-source-and-headers.py \
libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \
libtool-ldflags ChangeLog.libffi-3.1
info_TEXINFOS = doc/libffi.texi info_TEXINFOS = doc/libffi.texi
@ -46,48 +64,49 @@ info_TEXINFOS = doc/libffi.texi
# values defined in terms of make variables, as is the case for CC and # values defined in terms of make variables, as is the case for CC and
# friends when we are called from the top level Makefile. # friends when we are called from the top level Makefile.
AM_MAKEFLAGS = \ AM_MAKEFLAGS = \
"AR_FLAGS=$(AR_FLAGS)" \ 'AR_FLAGS=$(AR_FLAGS)' \
"CC_FOR_BUILD=$(CC_FOR_BUILD)" \ 'CC_FOR_BUILD=$(CC_FOR_BUILD)' \
"CFLAGS=$(CFLAGS)" \ 'CFLAGS=$(CFLAGS)' \
"CXXFLAGS=$(CXXFLAGS)" \ 'CXXFLAGS=$(CXXFLAGS)' \
"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ 'CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)' \
"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \ 'CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)' \
"INSTALL=$(INSTALL)" \ 'INSTALL=$(INSTALL)' \
"INSTALL_DATA=$(INSTALL_DATA)" \ 'INSTALL_DATA=$(INSTALL_DATA)' \
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ 'INSTALL_PROGRAM=$(INSTALL_PROGRAM)' \
"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \ 'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
"JC1FLAGS=$(JC1FLAGS)" \ 'JC1FLAGS=$(JC1FLAGS)' \
"LDFLAGS=$(LDFLAGS)" \ 'LDFLAGS=$(LDFLAGS)' \
"LIBCFLAGS=$(LIBCFLAGS)" \ 'LIBCFLAGS=$(LIBCFLAGS)' \
"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \ 'LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)' \
"MAKE=$(MAKE)" \ 'MAKE=$(MAKE)' \
"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \ 'MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)' \
"PICFLAG=$(PICFLAG)" \ 'PICFLAG=$(PICFLAG)' \
"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \ 'PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)' \
"RUNTESTFLAGS=$(RUNTESTFLAGS)" \ 'RUNTESTFLAGS=$(RUNTESTFLAGS)' \
"SHELL=$(SHELL)" \ 'SHELL=$(SHELL)' \
"exec_prefix=$(exec_prefix)" \ 'exec_prefix=$(exec_prefix)' \
"infodir=$(infodir)" \ 'infodir=$(infodir)' \
"libdir=$(libdir)" \ 'libdir=$(libdir)' \
"mandir=$(mandir)" \ 'mandir=$(mandir)' \
"prefix=$(prefix)" \ 'prefix=$(prefix)' \
"AR=$(AR)" \ 'AR=$(AR)' \
"AS=$(AS)" \ 'AS=$(AS)' \
"CC=$(CC)" \ 'CC=$(CC)' \
"CXX=$(CXX)" \ 'CXX=$(CXX)' \
"LD=$(LD)" \ 'LD=$(LD)' \
"NM=$(NM)" \ 'NM=$(NM)' \
"RANLIB=$(RANLIB)" \ 'RANLIB=$(RANLIB)' \
"DESTDIR=$(DESTDIR)" 'DESTDIR=$(DESTDIR)'
# Subdir rules rely on $(FLAGS_TO_PASS)
FLAGS_TO_PASS = $(AM_MAKEFLAGS)
MAKEOVERRIDES= MAKEOVERRIDES=
ACLOCAL_AMFLAGS=$(ACLOCAL_AMFLAGS) -I m4 toolexeclib_LTLIBRARIES = libffi.la
lib_LTLIBRARIES = libffi.la
noinst_LTLIBRARIES = libffi_convenience.la noinst_LTLIBRARIES = libffi_convenience.la
libffi_la_SOURCES = src/debug.c src/prep_cif.c src/types.c \ libffi_la_SOURCES = src/prep_cif.c src/types.c \
src/raw_api.c src/java_raw_api.c src/closures.c src/raw_api.c src/java_raw_api.c src/closures.c
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
@ -95,14 +114,21 @@ pkgconfig_DATA = libffi.pc
nodist_libffi_la_SOURCES = nodist_libffi_la_SOURCES =
if FFI_DEBUG
nodist_libffi_la_SOURCES += src/debug.c
endif
if MIPS if MIPS
nodist_libffi_la_SOURCES += src/mips/ffi.c src/mips/o32.S src/mips/n32.S nodist_libffi_la_SOURCES += src/mips/ffi.c src/mips/o32.S src/mips/n32.S
endif endif
if BFIN
nodist_libffi_la_SOURCES += src/bfin/ffi.c src/bfin/sysv.S
endif
if X86 if X86
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S src/x86/win32.S
endif endif
if X86_FREEBSD if X86_FREEBSD
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/freebsd.S nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/freebsd.S src/x86/win32.S
endif endif
if X86_WIN32 if X86_WIN32
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win32.S nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win32.S
@ -112,6 +138,9 @@ nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win64.S
endif endif
if X86_DARWIN if X86_DARWIN
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
if X86_DARWIN32
nodist_libffi_la_SOURCES += src/x86/win32.S
endif
endif endif
if SPARC if SPARC
nodist_libffi_la_SOURCES += src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S nodist_libffi_la_SOURCES += src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S
@ -128,8 +157,20 @@ endif
if M68K if M68K
nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S
endif endif
if M88K
nodist_libffi_la_SOURCES += src/m88k/ffi.c src/m88k/obsd.S
endif
if MOXIE
nodist_libffi_la_SOURCES += src/moxie/ffi.c src/moxie/eabi.S
endif
if MICROBLAZE
nodist_libffi_la_SOURCES += src/microblaze/ffi.c src/microblaze/sysv.S
endif
if NIOS2
nodist_libffi_la_SOURCES += src/nios2/sysv.S src/nios2/ffi.c
endif
if POWERPC if POWERPC
nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
endif endif
if POWERPC_AIX if POWERPC_AIX
nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
@ -138,10 +179,19 @@ if POWERPC_DARWIN
nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
endif endif
if POWERPC_FREEBSD if POWERPC_FREEBSD
nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
endif
if AARCH64
nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c
endif
if ARC
nodist_libffi_la_SOURCES += src/arc/arcompact.S src/arc/ffi.c
endif endif
if ARM if ARM
nodist_libffi_la_SOURCES += src/arm/sysv.S src/arm/ffi.c nodist_libffi_la_SOURCES += src/arm/sysv.S src/arm/ffi.c
if FFI_EXEC_TRAMPOLINE_TABLE
nodist_libffi_la_SOURCES += src/arm/trampoline.S
endif
endif endif
if AVR32 if AVR32
nodist_libffi_la_SOURCES += src/avr32/sysv.S src/avr32/ffi.c nodist_libffi_la_SOURCES += src/avr32/sysv.S src/avr32/ffi.c
@ -152,9 +202,6 @@ endif
if FRV if FRV
nodist_libffi_la_SOURCES += src/frv/eabi.S src/frv/ffi.c nodist_libffi_la_SOURCES += src/frv/eabi.S src/frv/ffi.c
endif endif
if MOXIE
nodist_libffi_la_SOURCES += src/moxie/eabi.S src/moxie/ffi.c
endif
if S390 if S390
nodist_libffi_la_SOURCES += src/s390/sysv.S src/s390/ffi.c nodist_libffi_la_SOURCES += src/s390/sysv.S src/s390/ffi.c
endif endif
@ -173,26 +220,35 @@ endif
if PA_HPUX if PA_HPUX
nodist_libffi_la_SOURCES += src/pa/hpux32.S src/pa/ffi.c nodist_libffi_la_SOURCES += src/pa/hpux32.S src/pa/ffi.c
endif endif
if TILE
nodist_libffi_la_SOURCES += src/tile/tile.S src/tile/ffi.c
endif
if XTENSA
nodist_libffi_la_SOURCES += src/xtensa/sysv.S src/xtensa/ffi.c
endif
if METAG
nodist_libffi_la_SOURCES += src/metag/sysv.S src/metag/ffi.c
endif
if VAX
nodist_libffi_la_SOURCES += src/vax/elfbsd.S src/vax/ffi.c
endif
libffi_convenience_la_SOURCES = $(libffi_la_SOURCES) libffi_convenience_la_SOURCES = $(libffi_la_SOURCES)
nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
AM_CFLAGS = -Wall -g -fexceptions LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS))
AM_CFLAGS =
if FFI_DEBUG if FFI_DEBUG
# Build debug. Define FFI_DEBUG on the commandline so that, when building with # Build debug. Define FFI_DEBUG on the commandline so that, when building with
# MSVC, it can link against the debug CRT. # MSVC, it can link against the debug CRT.
AM_CFLAGS += -DFFI_DEBUG AM_CFLAGS += -DFFI_DEBUG
else
# Build opt.
AM_CFLAGS += -O2
endif endif
libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS)
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
AM_CCASFLAGS = $(AM_CPPFLAGS) AM_CCASFLAGS = $(AM_CPPFLAGS)
# No install-html or install-pdf support in automake yet dist-hook:
.PHONY: install-html install-pdf if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog
install-html:
install-pdf:

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
Status Status
====== ======
libffi-3.0.10 was released on XXXXXXXXXX, 2010. Check the libffi web libffi-3.1 was released on May 11, 2014. Check the libffi web page
page for updates: <URL:http://sourceware.org/libffi/>. for updates: <URL:http://sourceware.org/libffi/>.
What is libffi? What is libffi?
@ -43,47 +43,76 @@ Libffi has been ported to many different platforms.
For specific configuration details and testing status, please For specific configuration details and testing status, please
refer to the wiki page here: refer to the wiki page here:
http://www.moxielogic.org/wiki/index.php?title=Libffi_3.0.10 http://www.moxielogic.org/wiki/index.php?title=Libffi_3.1
At the time of release, the following basic configurations have been At the time of release, the following basic configurations have been
tested: tested:
|--------------+------------------| |-----------------+------------------+-------------------------|
| Architecture | Operating System | | Architecture | Operating System | Compiler |
|--------------+------------------| |-----------------+------------------+-------------------------|
| Alpha | Linux | | AArch64 (ARM64) | iOS | Clang |
| Alpha | Tru64 | | AArch64 | Linux | GCC |
| ARM | Linux | | Alpha | Linux | GCC |
| AVR32 | Linux | | Alpha | Tru64 | GCC |
| HPPA | HPUX | | ARC | Linux | GCC |
| IA-64 | Linux | | ARM | Linux | GCC |
| MIPS | IRIX | | ARM | iOS | GCC |
| MIPS | Linux | | AVR32 | Linux | GCC |
| MIPS64 | Linux | | Blackfin | uClinux | GCC |
| PowerPC | Linux | | HPPA | HPUX | GCC |
| PowerPC | Mac OSX | | IA-64 | Linux | GCC |
| PowerPC | FreeBSD | | M68K | FreeMiNT | GCC |
| PowerPC64 | Linux | | M68K | Linux | GCC |
| S390 | Linux | | M68K | RTEMS | GCC |
| S390X | Linux | | M88K | OpenBSD/mvme88k | GCC |
| SPARC | Linux | | Meta | Linux | GCC |
| SPARC | Solaris | | MicroBlaze | Linux | GCC |
| SPARC64 | Linux | | MIPS | IRIX | GCC |
| SPARC64 | FreeBSD | | MIPS | Linux | GCC |
| X86 | FreeBSD | | MIPS | RTEMS | GCC |
| X86 | kFreeBSD | | MIPS64 | Linux | GCC |
| X86 | Linux | | Moxie | Bare metal | GCC |
| X86 | Mac OSX | | Nios II | Linux | GCC |
| X86 | OpenBSD | | PowerPC 32-bit | AIX | IBM XL C |
| X86 | OS/2 | | PowerPC 64-bit | AIX | IBM XL C |
| X86 | Solaris | | PowerPC | AMIGA | GCC |
| X86 | Windows/Cygwin | | PowerPC | Linux | GCC |
| X86 | Windows/MingW | | PowerPC | Mac OSX | GCC |
| X86-64 | FreeBSD | | PowerPC | FreeBSD | GCC |
| X86-64 | Linux | | PowerPC 64-bit | FreeBSD | GCC |
| X86-64 | OpenBSD | | PowerPC 64-bit | Linux ELFv1 | GCC |
| X86-64 | Windows/MingW | | PowerPC 64-bit | Linux ELFv2 | GCC |
|--------------+------------------| | S390 | Linux | GCC |
| S390X | Linux | GCC |
| SPARC | Linux | GCC |
| SPARC | Solaris | GCC |
| SPARC | Solaris | Oracle Solaris Studio C |
| SPARC64 | Linux | GCC |
| SPARC64 | FreeBSD | GCC |
| SPARC64 | Solaris | Oracle Solaris Studio C |
| TILE-Gx/TILEPro | Linux | GCC |
| VAX | OpenBSD/vax | GCC |
| X86 | FreeBSD | GCC |
| X86 | GNU HURD | GCC |
| X86 | Interix | GCC |
| X86 | kFreeBSD | GCC |
| X86 | Linux | GCC |
| X86 | Mac OSX | GCC |
| X86 | OpenBSD | GCC |
| X86 | OS/2 | GCC |
| X86 | Solaris | GCC |
| X86 | Solaris | Oracle Solaris Studio C |
| X86 | Windows/Cygwin | GCC |
| X86 | Windows/MingW | GCC |
| X86-64 | FreeBSD | GCC |
| X86-64 | Linux | GCC |
| X86-64 | Linux/x32 | GCC |
| X86-64 | OpenBSD | GCC |
| X86-64 | Solaris | Oracle Solaris Studio C |
| X86-64 | Windows/MingW | GCC |
| Xtensa | Linux | GCC |
|-----------------+------------------+-------------------------|
Please send additional platform test results to Please send additional platform test results to
libffi-discuss@sourceware.org and feel free to update the wiki page libffi-discuss@sourceware.org and feel free to update the wiki page
@ -97,6 +126,9 @@ 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 "configure" program found in the root directory of the libffi source
distribution. distribution.
If you're building libffi directly from version control, configure won't
exist yet; run ./autogen.sh first.
You may want to tell configure where to install the libffi library and You may want to tell configure where to install the libffi library and
header files. To do that, use the --prefix configure switch. Libffi header files. To do that, use the --prefix configure switch. Libffi
will install under /usr/local by default. will install under /usr/local by default.
@ -114,18 +146,23 @@ It's also possible to build libffi on Windows platforms with
Microsoft's Visual C++ compiler. In this case, use the msvcc.sh Microsoft's Visual C++ compiler. In this case, use the msvcc.sh
wrapper script during configuration like so: wrapper script during configuration like so:
path/to/configure CC=path/to/msvcc.sh LD=link CPP=\"cl -nologo -EP\" path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP=\"cl -nologo -EP\"
For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64". For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64" and
You may also need to specify --build appropriately. When building with MSVC CXX="path/to/msvcc.sh -m64". You may also need to specify --build
under a MingW environment, you may need to remove the line in configure appropriately.
that sets 'fix_srcfile_path' to a 'cygpath' command. ('cygpath' is not
present in MingW, and is not required when using MingW-style paths.) 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, the 'libffi.xcodeproj' Xcode project is available.
Configure has many other options. Use "configure --help" to see them all. Configure has many other options. Use "configure --help" to see them all.
Once configure has finished, type "make". Note that you must be using 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. GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .
To ensure that libffi is working as advertised, type "make check". To ensure that libffi is working as advertised, type "make check".
This will require that you have DejaGNU installed. This will require that you have DejaGNU installed.
@ -136,13 +173,67 @@ To install the library and header files, type "make install".
History History
======= =======
See the ChangeLog files for details. See the git log for details at http://github.com/atgreen/libffi.
3.0.10 ???-??-?? 3.1 May-11-14
Fix the N64 build on mips-sgi-irix6.5. Add AArch64 (ARM64) iOS support.
Testsuite fixes for Tru64 Unix. Add Nios II support.
Add m88k and DEC VAX support.
Add support for stdcall, thiscall, and fastcall on non-Windows
32-bit x86 targets such as Linux.
Various Android, MIPS N32, x86, FreeBSD and UltraSPARC IIi
fixes.
Make the testsuite more robust: eliminate several spurious
failures, and respect the $CC and $CXX environment variables.
Archive off the manually maintained ChangeLog in favor of git
log.
3.0.13 Mar-17-13
Add Meta support.
Add missing Moxie bits.
Fix stack alignment bug on 32-bit x86.
Build fix for m68000 targets.
Build fix for soft-float Power targets.
Fix the install dir location for some platforms when building
with GCC (OS X, Solaris).
Fix Cygwin regression.
3.0.12 Feb-11-13
Add Moxie support.
Add AArch64 support.
Add Blackfin support.
Add TILE-Gx/TILEPro support.
Add MicroBlaze support.
Add Xtensa support.
Add support for PaX enabled kernels with MPROTECT.
Add support for native vendor compilers on
Solaris and AIX.
Work around LLVM/GCC interoperability issue on x86_64.
3.0.11 Apr-11-12
Lots of build fixes.
Add support for variadic functions (ffi_prep_cif_var).
Add Linux/x32 support.
Add thiscall, fastcall and MSVC cdecl support on Windows.
Add Amiga and newer MacOS support.
Add m68k FreeMiNT support.
Integration with iOS' xcode build tools.
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 builds with Microsoft's compiler.
Enable x86 builds with Sun'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 3.0.9 Dec-31-09
Add AVR32 and win64 ports. Add ARM softfp support. Add AVR32 and win64 ports. Add ARM softfp support.
@ -272,7 +363,7 @@ See the ChangeLog files for details.
Authors & Credits Authors & Credits
================= =================
libffi was originally written by Anthony Green <green@redhat.com>. libffi was originally written by Anthony Green <green@moxielogic.com>.
The developers of the GNU Compiler Collection project have made The developers of the GNU Compiler Collection project have made
innumerable valuable contributions. See the ChangeLog file for innumerable valuable contributions. See the ChangeLog file for
@ -287,15 +378,21 @@ Thorup.
Major processor architecture ports were contributed by the following Major processor architecture ports were contributed by the following
developers: developers:
aarch64 Marcus Shawcroft, James Greenhalgh
alpha Richard Henderson alpha Richard Henderson
arm Raffaele Sena arm Raffaele Sena
blackfin Alexandre Keunecke I. de Mendonca
cris Simon Posnjak, Hans-Peter Nilsson cris Simon Posnjak, Hans-Peter Nilsson
frv Anthony Green frv Anthony Green
ia64 Hans Boehm ia64 Hans Boehm
m32r Kazuhiro Inaoka m32r Kazuhiro Inaoka
m68k Andreas Schwab m68k Andreas Schwab
m88k Miod Vallat
microblaze Nathan Rossi
mips Anthony Green, Casey Marshall mips Anthony Green, Casey Marshall
mips64 David Daney mips64 David Daney
moxie Anthony Green
nios ii Sandra Loosemore
pa Randolph Chung, Dave Anglin, Andreas Tobler pa Randolph Chung, Dave Anglin, Andreas Tobler
powerpc Geoffrey Keating, Andreas Tobler, powerpc Geoffrey Keating, Andreas Tobler,
David Edelsohn, John Hornkvist David Edelsohn, John Hornkvist
@ -304,8 +401,11 @@ s390 Gerhard Tonn, Ulrich Weigand
sh Kaz Kojima sh Kaz Kojima
sh64 Kaz Kojima sh64 Kaz Kojima
sparc Anthony Green, Gordon Irlam sparc Anthony Green, Gordon Irlam
tile-gx/tilepro Walter Lee
vax Miod Vallat
x86 Anthony Green, Jon Beniston x86 Anthony Green, Jon Beniston
x86-64 Bo Thorsen x86-64 Bo Thorsen
xtensa Chris Zankel
Jesper Skov and Andrew Haley both did more than their fair share of Jesper Skov and Andrew Haley both did more than their fair share of
stepping through the code and tracking down bugs. stepping through the code and tracking down bugs.
@ -323,5 +423,6 @@ Alex Oliva solved the executable page problem for SElinux.
The list above is almost certainly incomplete and inaccurate. I'm The list above is almost certainly incomplete and inaccurate. I'm
happy to make corrections or additions upon request. happy to make corrections or additions upon request.
If you have a problem, or have found a bug, please send a note to If you have a problem, or have found a bug, please send a note to the
green@redhat.com. author at green@moxielogic.com, or the project mailing list at
libffi-discuss@sourceware.org.

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
#! /bin/sh #! /bin/sh
# Wrapper for compilers which do not understand `-c -o'. # Wrapper for compilers which do not understand '-c -o'.
scriptversion=2005-05-14.22 scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. # Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>. # Written by Tom Tromey <tromey@cygnus.com>.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -17,8 +17,7 @@ scriptversion=2005-05-14.22
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
@ -29,21 +28,224 @@ scriptversion=2005-05-14.22
# bugs to <bug-automake@gnu.org> or send patches to # bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>. # <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in case $1 in
'') '')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2 echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1; exit 1;
;; ;;
-h | --h*) -h | --h*)
cat <<\EOF cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS] Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand `-c -o'. Wrapper for compilers which do not understand '-c -o'.
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected. arguments, and rename the output as expected.
If you are trying to build a whole package this is not the If you are trying to build a whole package this is not the
right script to run: please start by reading the file `INSTALL'. right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>. Report bugs to <bug-automake@gnu.org>.
EOF EOF
@ -53,11 +255,13 @@ EOF
echo "compile $scriptversion" echo "compile $scriptversion"
exit $? exit $?
;; ;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac esac
ofile= ofile=
cfile= cfile=
eat=
for arg for arg
do do
@ -66,8 +270,8 @@ do
else else
case $1 in case $1 in
-o) -o)
# configure might choose to run compile as `compile cc -o foo foo.c'. # configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip `-o arg' only if arg is an object. # So we strip '-o arg' only if arg is an object.
eat=1 eat=1
case $2 in case $2 in
*.o | *.obj) *.o | *.obj)
@ -94,22 +298,22 @@ do
done done
if test -z "$ofile" || test -z "$cfile"; then if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a # If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a # pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no # normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also # '.c' file was seen then we are probably linking. That is also
# ok. # ok.
exec "$@" exec "$@"
fi fi
# Name of file we expect compiler to create. # Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory. # Create the lock directory.
# Note: use `[/.-]' here to ensure that we don't use the same name # Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected # that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build. # object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then if mkdir "$lockdir" >/dev/null 2>&1; then
break break
@ -124,9 +328,9 @@ trap "rmdir '$lockdir'; exit 1" 1 2 15
ret=$? ret=$?
if test -f "$cofile"; then if test -f "$cofile"; then
mv "$cofile" "$ofile" test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then elif test -f "${cofile}bj"; then
mv "${cofile}bj" "$ofile" test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi fi
rmdir "$lockdir" rmdir "$lockdir"
@ -138,5 +342,6 @@ exit $ret
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$" # time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End: # End:

View File

@ -1,14 +1,12 @@
#! /bin/sh #! /bin/sh
# Attempt to guess a canonical system name. # Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # Copyright 1992-2013 Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
timestamp='2009-11-19' timestamp='2013-06-10'
# This file is free software; you can redistribute it and/or modify it # This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by # under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or # the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, but # This program is distributed in the hope that it will be useful, but
@ -17,26 +15,22 @@ timestamp='2009-11-19'
# General Public License for more details. # General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, see <http://www.gnu.org/licenses/>.
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
# #
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under # configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program. # the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Originally written by Per Bothner. Please send patches (context
# diff format) to <config-patches@gnu.org> and include a ChangeLog
# entry.
# #
# This script attempts to guess a canonical system name similar to # Originally written by Per Bothner.
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
# #
# You can get the latest version of this script from: # You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
#
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
me=`echo "$0" | sed -e 's,.*/,,'` me=`echo "$0" | sed -e 's,.*/,,'`
@ -56,8 +50,7 @@ version="\
GNU config.guess ($timestamp) GNU config.guess ($timestamp)
Originally written by Per Bothner. Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, Copyright 1992-2013 Free Software Foundation, Inc.
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -139,12 +132,33 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_SYSTEM}" in
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
eval $set_cc_for_build
cat <<-EOF > $dummy.c
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
#else
LIBC=gnu
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
;;
esac
# Note: order is significant - the case branches are not exclusive. # Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*) *:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or # NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old # switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward # object file format. This provides both forward
@ -180,7 +194,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
fi fi
;; ;;
*) *)
os=netbsd os=netbsd
;; ;;
esac esac
# The OS release # The OS release
@ -201,6 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}" echo "${machine}-${os}${release}"
exit ;; exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
exit ;;
*:OpenBSD:*:*) *:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
@ -223,7 +241,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;; ;;
*5.*) *5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;; ;;
esac esac
# According to Compaq, /usr/sbin/psrinfo has been available on # According to Compaq, /usr/sbin/psrinfo has been available on
@ -269,7 +287,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Xn.n version is an unreleased experimental baselevel. # A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r. # 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit ;; # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
exitcode=$?
trap '' 0
exit $exitcode ;;
Alpha\ *:Windows_NT*:*) Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem? # How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead # Should we change UNAME_MACHINE based on the output of uname instead
@ -295,12 +316,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
echo s390-ibm-zvmoe echo s390-ibm-zvmoe
exit ;; exit ;;
*:OS400:*:*) *:OS400:*:*)
echo powerpc-ibm-os400 echo powerpc-ibm-os400
exit ;; exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE} echo arm-acorn-riscix${UNAME_RELEASE}
exit ;; exit ;;
arm:riscos:*:*|arm:RISCOS:*:*) arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos echo arm-unknown-riscos
exit ;; exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@ -333,6 +354,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;; exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux${UNAME_RELEASE}
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval $set_cc_for_build eval $set_cc_for_build
SUN_ARCH="i386" SUN_ARCH="i386"
@ -391,23 +415,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# MiNT. But MiNT is downward compatible to TOS, so this should # MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem. # be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE} echo m68k-atari-mint${UNAME_RELEASE}
exit ;; exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE} echo m68k-atari-mint${UNAME_RELEASE}
exit ;; exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE} echo m68k-atari-mint${UNAME_RELEASE}
exit ;; exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE} echo m68k-milan-mint${UNAME_RELEASE}
exit ;; exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE} echo m68k-hades-mint${UNAME_RELEASE}
exit ;; exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE} echo m68k-unknown-mint${UNAME_RELEASE}
exit ;; exit ;;
m68k:machten:*:*) m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE} echo m68k-apple-machten${UNAME_RELEASE}
exit ;; exit ;;
@ -477,8 +501,8 @@ EOF
echo m88k-motorola-sysv3 echo m88k-motorola-sysv3
exit ;; exit ;;
AViiON:dgux:*:*) AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures # DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p` UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@ -491,7 +515,7 @@ EOF
else else
echo i586-dg-dgux${UNAME_RELEASE} echo i586-dg-dgux${UNAME_RELEASE}
fi fi
exit ;; exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3) M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3 echo m88k-dolphin-sysv3
exit ;; exit ;;
@ -548,7 +572,7 @@ EOF
echo rs6000-ibm-aix3.2 echo rs6000-ibm-aix3.2
fi fi
exit ;; exit ;;
*:AIX:*:[456]) *:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000 IBM_ARCH=rs6000
@ -591,52 +615,52 @@ EOF
9000/[678][0-9][0-9]) 9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0 532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;; 32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;; 64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;; esac ;;
esac esac
fi fi
if [ "${HP_ARCH}" = "" ]; then if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE #define _HPUX_SOURCE
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
int main () int main ()
{ {
#if defined(_SC_KERNEL_BITS) #if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS); long bits = sysconf(_SC_KERNEL_BITS);
#endif #endif
long cpu = sysconf (_SC_CPU_VERSION); long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu) switch (cpu)
{ {
case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0: case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS) #if defined(_SC_KERNEL_BITS)
switch (bits) switch (bits)
{ {
case 64: puts ("hppa2.0w"); break; case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break; case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break; default: puts ("hppa2.0"); break;
} break; } break;
#else /* !defined(_SC_KERNEL_BITS) */ #else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break; puts ("hppa2.0"); break;
#endif #endif
default: puts ("hppa1.0"); break; default: puts ("hppa1.0"); break;
} }
exit (0); exit (0);
} }
EOF EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa test -z "$HP_ARCH" && HP_ARCH=hppa
@ -727,22 +751,22 @@ EOF
exit ;; exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd echo c1-convex-bsd
exit ;; exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc if getsysinfo -f scalar_acc
then echo c32-convex-bsd then echo c32-convex-bsd
else echo c2-convex-bsd else echo c2-convex-bsd
fi fi
exit ;; exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd echo c34-convex-bsd
exit ;; exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd echo c38-convex-bsd
exit ;; exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd echo c4-convex-bsd
exit ;; exit ;;
CRAY*Y-MP:*:*:*) CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;; exit ;;
@ -766,14 +790,14 @@ EOF
exit ;; exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;; exit ;;
5000:UNIX_System_V:4.*:*) 5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;; exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@ -785,30 +809,35 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;; exit ;;
*:FreeBSD:*:*) *:FreeBSD:*:*)
case ${UNAME_MACHINE} in UNAME_PROCESSOR=`/usr/bin/uname -p`
pc98) case ${UNAME_PROCESSOR} in
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
amd64) amd64)
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*) *)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac esac
exit ;; exit ;;
i*:CYGWIN*:*) i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin echo ${UNAME_MACHINE}-pc-cygwin
exit ;; exit ;;
*:MINGW64*:*)
echo ${UNAME_MACHINE}-pc-mingw64
exit ;;
*:MINGW*:*) *:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32 echo ${UNAME_MACHINE}-pc-mingw32
exit ;; exit ;;
i*:MSYS*:*)
echo ${UNAME_MACHINE}-pc-msys
exit ;;
i*:windows32*:*) i*:windows32*:*)
# uname -m includes "-pc" on this system. # uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32 echo ${UNAME_MACHINE}-mingw32
exit ;; exit ;;
i*:PW*:*) i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32 echo ${UNAME_MACHINE}-pc-pw32
exit ;; exit ;;
*:Interix*:*) *:Interix*:*)
case ${UNAME_MACHINE} in case ${UNAME_MACHINE} in
x86) x86)
echo i586-pc-interix${UNAME_RELEASE} echo i586-pc-interix${UNAME_RELEASE}
exit ;; exit ;;
@ -845,15 +874,22 @@ EOF
exit ;; exit ;;
*:GNU:*:*) *:GNU:*:*)
# the GNU system # the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;; exit ;;
*:GNU/*:*:*) *:GNU/*:*:*)
# other systems with GNU libc and userland # other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
exit ;; exit ;;
i*86:Minix:*:*) i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix echo ${UNAME_MACHINE}-pc-minix
exit ;; exit ;;
aarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
alpha:Linux:*:*) alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;; EV5) UNAME_MACHINE=alphaev5 ;;
@ -863,52 +899,56 @@ EOF
EV6) UNAME_MACHINE=alphaev6 ;; EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;; EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;; EV68*) UNAME_MACHINE=alphaev68 ;;
esac esac
objdump --private-headers /bin/sh | grep -q ld.so.1 objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
arm*:Linux:*:*) arm*:Linux:*:*)
eval $set_cc_for_build eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__ | grep -q __ARM_EABI__
then then
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
else else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
else
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
fi
fi fi
exit ;; exit ;;
avr32*:Linux:*:*) avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
cris:Linux:*:*) cris:Linux:*:*)
echo cris-axis-linux-gnu echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;; exit ;;
crisv32:Linux:*:*) crisv32:Linux:*:*)
echo crisv32-axis-linux-gnu echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;; exit ;;
frv:Linux:*:*) frv:Linux:*:*)
echo frv-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
hexagon:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
i*86:Linux:*:*) i*86:Linux:*:*)
LIBC=gnu echo ${UNAME_MACHINE}-pc-linux-${LIBC}
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit ;; exit ;;
ia64:Linux:*:*) ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
m32r*:Linux:*:*) m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
m68*:Linux:*:*) m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
mips:Linux:*:* | mips64:Linux:*:*) mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build eval $set_cc_for_build
@ -927,51 +967,63 @@ EOF
#endif #endif
EOF EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;; ;;
or1k:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
or32:Linux:*:*) or32:Linux:*:*)
echo or32-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
padre:Linux:*:*) padre:Linux:*:*)
echo sparc-unknown-linux-gnu echo sparc-unknown-linux-${LIBC}
exit ;; exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*) parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu echo hppa64-unknown-linux-${LIBC}
exit ;; exit ;;
parisc:Linux:*:* | hppa:Linux:*:*) parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level # Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;; PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
*) echo hppa-unknown-linux-gnu ;; *) echo hppa-unknown-linux-${LIBC} ;;
esac esac
exit ;; exit ;;
ppc64:Linux:*:*) ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu echo powerpc64-unknown-linux-${LIBC}
exit ;; exit ;;
ppc:Linux:*:*) ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu echo powerpc-unknown-linux-${LIBC}
exit ;;
ppc64le:Linux:*:*)
echo powerpc64le-unknown-linux-${LIBC}
exit ;;
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-${LIBC}
exit ;; exit ;;
s390:Linux:*:* | s390x:Linux:*:*) s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;; exit ;;
sh64*:Linux:*:*) sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
sh*:Linux:*:*) sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*) sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
tile*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
vax:Linux:*:*) vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu echo ${UNAME_MACHINE}-dec-linux-${LIBC}
exit ;; exit ;;
x86_64:Linux:*:*) x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
xtensa*:Linux:*:*) xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;; exit ;;
i*86:DYNIX/ptx:4*:*) i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@ -980,11 +1032,11 @@ EOF
echo i386-sequent-sysv4 echo i386-sequent-sysv4
exit ;; exit ;;
i*86:UNIX_SV:4.2MP:2.*) i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version # Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2... # number series starting with 2...
# I am not positive that other SVR4 systems won't match this, # I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms. # I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it. # Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit ;; exit ;;
i*86:OS/2:*:*) i*86:OS/2:*:*)
@ -1016,7 +1068,7 @@ EOF
fi fi
exit ;; exit ;;
i*86:*:5:[678]*) i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6. # UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;; *486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;; *Pentium) UNAME_MACHINE=i586 ;;
@ -1044,13 +1096,13 @@ EOF
exit ;; exit ;;
pc:*:*:*) pc:*:*:*)
# Left here for compatibility: # Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about # uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586. # the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub # Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configury will decide that # prints for the "djgpp" host, or else GDB configury will decide that
# this is a cross-build. # this is a cross-build.
echo i586-pc-msdosdjgpp echo i586-pc-msdosdjgpp
exit ;; exit ;;
Intel:Mach:3*:*) Intel:Mach:3*:*)
echo i386-pc-mach3 echo i386-pc-mach3
exit ;; exit ;;
@ -1085,8 +1137,8 @@ EOF
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;; && { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*) NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3' OS_REL='.3'
test -r /etc/.relid \ test -r /etc/.relid \
@ -1129,10 +1181,10 @@ EOF
echo ns32k-sni-sysv echo ns32k-sni-sysv
fi fi
exit ;; exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV> # says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4 echo i586-unisys-sysv4
exit ;; exit ;;
*:UNIX_System_V:4*:FTX*) *:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>. # From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm # How about differentiating between stratus architectures? -djm
@ -1158,11 +1210,11 @@ EOF
exit ;; exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE} echo mips-nec-sysv${UNAME_RELEASE}
else else
echo mips-unknown-sysv${UNAME_RELEASE} echo mips-unknown-sysv${UNAME_RELEASE}
fi fi
exit ;; exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos echo powerpc-be-beos
exit ;; exit ;;
@ -1175,6 +1227,9 @@ EOF
BePC:Haiku:*:*) # Haiku running on Intel PC compatible. BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku echo i586-pc-haiku
exit ;; exit ;;
x86_64:Haiku:*:*)
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*) SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE} echo sx4-nec-superux${UNAME_RELEASE}
exit ;; exit ;;
@ -1201,19 +1256,21 @@ EOF
exit ;; exit ;;
*:Darwin:*:*) *:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in eval $set_cc_for_build
i386) if test "$UNAME_PROCESSOR" = unknown ; then
eval $set_cc_for_build UNAME_PROCESSOR=powerpc
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then fi
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
grep IS_64BIT_ARCH >/dev/null (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
then grep IS_64BIT_ARCH >/dev/null
UNAME_PROCESSOR="x86_64" then
fi case $UNAME_PROCESSOR in
fi ;; i386) UNAME_PROCESSOR=x86_64 ;;
unknown) UNAME_PROCESSOR=powerpc ;; powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac esac
fi
fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;; exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*) *:procnto*:*:* | *:QNX:[0123456789]*:*)
@ -1227,7 +1284,10 @@ EOF
*:QNX:*:4*) *:QNX:*:4*)
echo i386-pc-qnx echo i386-pc-qnx
exit ;; exit ;;
NSE-?:NONSTOP_KERNEL:*:*) NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE} echo nse-tandem-nsk${UNAME_RELEASE}
exit ;; exit ;;
NSR-?:NONSTOP_KERNEL:*:*) NSR-?:NONSTOP_KERNEL:*:*)
@ -1272,13 +1332,13 @@ EOF
echo pdp10-unknown-its echo pdp10-unknown-its
exit ;; exit ;;
SEI:*:*:SEIUX) SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE} echo mips-sei-seiux${UNAME_RELEASE}
exit ;; exit ;;
*:DragonFly:*:*) *:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;; exit ;;
*:*VMS:*:*) *:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null` UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms ; exit ;; A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;;
@ -1296,11 +1356,11 @@ EOF
i*86:AROS:*:*) i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros echo ${UNAME_MACHINE}-pc-aros
exit ;; exit ;;
x86_64:VMkernel:*:*)
echo ${UNAME_MACHINE}-unknown-esx
exit ;;
esac esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build eval $set_cc_for_build
cat >$dummy.c <<EOF cat >$dummy.c <<EOF
#ifdef _SEQUENT_ #ifdef _SEQUENT_
@ -1318,11 +1378,11 @@ main ()
#include <sys/param.h> #include <sys/param.h>
printf ("m68k-sony-newsos%s\n", printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4 #ifdef NEWSOS4
"4" "4"
#else #else
"" ""
#endif #endif
); exit (0); ); exit (0);
#endif #endif
#endif #endif

View File

@ -1,38 +1,31 @@
#! /bin/sh #! /bin/sh
# Configuration validation subroutine script. # Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # Copyright 1992-2013 Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
timestamp='2011-01-03' timestamp='2013-08-10'
# This file is (in principle) common to ALL GNU software. # This file is free software; you can redistribute it and/or modify it
# The presence of a machine in this file suggests that SOME GNU software # under the terms of the GNU General Public License as published by
# can handle that machine. It does not imply ALL GNU software can. # the Free Software Foundation; either version 3 of the License, or
#
# This file 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 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful, but
# but WITHOUT ANY WARRANTY; without even the implied warranty of # WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# GNU General Public License for more details. # General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, see <http://www.gnu.org/licenses/>.
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
# #
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under # configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program. # the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches to <config-patches@gnu.org>. Submit a context # Please send patches with a ChangeLog entry to config-patches@gnu.org.
# diff and a properly formatted GNU ChangeLog entry.
# #
# Configuration subroutine to validate and canonicalize a configuration type. # Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument. # Supply the specified configuration type as an argument.
@ -75,8 +68,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\ version="\
GNU config.sub ($timestamp) GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, Copyright 1992-2013 Free Software Foundation, Inc.
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -123,13 +115,18 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations. # Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \ kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova* | wince-winmo*) storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;; ;;
android-linux)
os=-linux-android
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*) *)
basic_machine=`echo $1 | sed 's/-[^-]*$//'` basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ] if [ $basic_machine != $1 ]
@ -152,12 +149,12 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray | -microblaze) -apple | -axis | -knuth | -cray | -microblaze*)
os= os=
basic_machine=$1 basic_machine=$1
;; ;;
-bluegene*) -bluegene*)
os=-cnk os=-cnk
;; ;;
-sim | -cisco | -oki | -wec | -winbond) -sim | -cisco | -oki | -wec | -winbond)
os= os=
@ -173,10 +170,10 @@ case $os in
os=-chorusos os=-chorusos
basic_machine=$1 basic_machine=$1
;; ;;
-chorusrdb) -chorusrdb)
os=-chorusrdb os=-chorusrdb
basic_machine=$1 basic_machine=$1
;; ;;
-hiux*) -hiux*)
os=-hiuxwe2 os=-hiuxwe2
;; ;;
@ -221,6 +218,12 @@ case $os in
-isc*) -isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;; ;;
-lynx*178)
os=-lynxos178
;;
-lynx*5)
os=-lynxos5
;;
-lynx*) -lynx*)
os=-lynxos os=-lynxos
;; ;;
@ -245,20 +248,27 @@ case $basic_machine in
# Some are omitted here because they have special meanings below. # Some are omitted here because they have special meanings below.
1750a | 580 \ 1750a | 580 \
| a29k \ | a29k \
| aarch64 | aarch64_be \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \ | am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
| bfin \ | bfin \
| c4x | clipper \ | c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \ | d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \ | fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \ | i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \ | ip2k | iq2000 \
| le32 | le64 \
| lm32 \ | lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \ | m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \ | mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \ | mips16 \
| mips64 | mips64el \ | mips64 | mips64el \
@ -276,32 +286,45 @@ case $basic_machine in
| mipsisa64r2 | mipsisa64r2el \ | mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \ | mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \ | mipstx39 | mipstx39el \
| mn10200 | mn10300 \ | mn10200 | mn10300 \
| moxie \ | moxie \
| mt \ | mt \
| msp430 \ | msp430 \
| nios | nios2 \ | nds32 | nds32le | nds32be \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \ | ns16k | ns32k \
| or32 \ | open8 \
| or1k | or32 \
| pdp10 | pdp11 | pj | pjl \ | pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \ | pyramid \
| rl78 | rx \
| score \ | score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \ | sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \ | spu \
| tahoe | thumb | tic4x | tic80 | tron \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| v850 | v850e \ | ubicom32 \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| we32k \ | we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | x86 | xc16x | xstormy16 | xtensa \
| z8k | z80) | z8k | z80)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
;; ;;
m6811 | m68hc11 | m6812 | m68hc12) c54x)
# Motorola 68HC11/12. basic_machine=tic54x-unknown
;;
c55x)
basic_machine=tic55x-unknown
;;
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
os=-none os=-none
;; ;;
@ -311,6 +334,21 @@ case $basic_machine in
basic_machine=mt-unknown basic_machine=mt-unknown
;; ;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
xgate)
basic_machine=$basic_machine-unknown
os=-none
;;
xscaleeb)
basic_machine=armeb-unknown
;;
xscaleel)
basic_machine=armel-unknown
;;
# We use `pc' rather than `unknown' # We use `pc' rather than `unknown'
# because (1) that's what they normally are, and # because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users. # (2) the word "unknown" tends to confuse beginning users.
@ -325,25 +363,30 @@ case $basic_machine in
# Recognize the basic CPU types with company name. # Recognize the basic CPU types with company name.
580-* \ 580-* \
| a29k-* \ | a29k-* \
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \ | avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \ | bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \ | c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \ | d10v-* | d30v-* | dlx-* \
| elxsi-* \ | elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \ | h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \ | i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \ | ip2k-* | iq2000-* \
| le32-* | le64-* \
| lm32-* \ | lm32-* \
| m32c-* | m32r-* | m32rle-* \ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \ | mips16-* \
| mips64-* | mips64el-* \ | mips64-* | mips64el-* \
@ -361,28 +404,34 @@ case $basic_machine in
| mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \ | mipstx39-* | mipstx39el-* \
| mmix-* \ | mmix-* \
| mt-* \ | mt-* \
| msp430-* \ | msp430-* \
| nios-* | nios2-* \ | nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \ | none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \ | orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \ | pyramid-* \
| romp-* | rs6000-* \ | rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \ | sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \ | tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile*-* \
| tron-* \ | tron-* \
| v850-* | v850e-* | vax-* \ | ubicom32-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| we32k-* \ | we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \ | xstormy16-* | xtensa*-* \
| ymp-* \ | ymp-* \
| z8k-* | z80-*) | z8k-* | z80-*)
@ -407,7 +456,7 @@ case $basic_machine in
basic_machine=a29k-amd basic_machine=a29k-amd
os=-udi os=-udi
;; ;;
abacus) abacus)
basic_machine=abacus-unknown basic_machine=abacus-unknown
;; ;;
adobe68k) adobe68k)
@ -477,11 +526,20 @@ case $basic_machine in
basic_machine=powerpc-ibm basic_machine=powerpc-ibm
os=-cnk os=-cnk
;; ;;
c54x-*)
basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c55x-*)
basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c6x-*)
basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c90) c90)
basic_machine=c90-cray basic_machine=c90-cray
os=-unicos os=-unicos
;; ;;
cegcc) cegcc)
basic_machine=arm-unknown basic_machine=arm-unknown
os=-cegcc os=-cegcc
;; ;;
@ -513,7 +571,7 @@ case $basic_machine in
basic_machine=craynv-cray basic_machine=craynv-cray
os=-unicosmp os=-unicosmp
;; ;;
cr16) cr16 | cr16-*)
basic_machine=cr16-unknown basic_machine=cr16-unknown
os=-elf os=-elf
;; ;;
@ -671,7 +729,6 @@ case $basic_machine in
i370-ibm* | ibm*) i370-ibm* | ibm*)
basic_machine=i370-ibm basic_machine=i370-ibm
;; ;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32) i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32 os=-sysv32
@ -729,11 +786,15 @@ case $basic_machine in
basic_machine=ns32k-utek basic_machine=ns32k-utek
os=-sysv os=-sysv
;; ;;
microblaze) microblaze*)
basic_machine=microblaze-xilinx basic_machine=microblaze-xilinx
;; ;;
mingw64)
basic_machine=x86_64-pc
os=-mingw64
;;
mingw32) mingw32)
basic_machine=i386-pc basic_machine=i686-pc
os=-mingw32 os=-mingw32
;; ;;
mingw32ce) mingw32ce)
@ -768,10 +829,18 @@ case $basic_machine in
ms1-*) ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;; ;;
msys)
basic_machine=i686-pc
os=-msys
;;
mvs) mvs)
basic_machine=i370-ibm basic_machine=i370-ibm
os=-mvs os=-mvs
;; ;;
nacl)
basic_machine=le32-unknown
os=-nacl
;;
ncr3000) ncr3000)
basic_machine=i486-ncr basic_machine=i486-ncr
os=-sysv4 os=-sysv4
@ -836,6 +905,12 @@ case $basic_machine in
np1) np1)
basic_machine=np1-gould basic_machine=np1-gould
;; ;;
neo-tandem)
basic_machine=neo-tandem
;;
nse-tandem)
basic_machine=nse-tandem
;;
nsr-tandem) nsr-tandem)
basic_machine=nsr-tandem basic_machine=nsr-tandem
;; ;;
@ -918,9 +993,10 @@ case $basic_machine in
;; ;;
power) basic_machine=power-ibm power) basic_machine=power-ibm
;; ;;
ppc) basic_machine=powerpc-unknown ppc | ppcbe) basic_machine=powerpc-unknown
;; ;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;; ;;
ppcle | powerpclittle | ppc-le | powerpc-little) ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown basic_machine=powerpcle-unknown
@ -945,7 +1021,11 @@ case $basic_machine in
basic_machine=i586-unknown basic_machine=i586-unknown
os=-pw32 os=-pw32
;; ;;
rdos) rdos | rdos64)
basic_machine=x86_64-pc
os=-rdos
;;
rdos32)
basic_machine=i386-pc basic_machine=i386-pc
os=-rdos os=-rdos
;; ;;
@ -1014,6 +1094,9 @@ case $basic_machine in
basic_machine=i860-stratus basic_machine=i860-stratus
os=-sysv4 os=-sysv4
;; ;;
strongarm-* | thumb-*)
basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
sun2) sun2)
basic_machine=m68000-sun basic_machine=m68000-sun
;; ;;
@ -1070,20 +1153,8 @@ case $basic_machine in
basic_machine=t90-cray basic_machine=t90-cray
os=-unicos os=-unicos
;; ;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
tile*) tile*)
basic_machine=tile-unknown basic_machine=$basic_machine-unknown
os=-linux-gnu os=-linux-gnu
;; ;;
tx39) tx39)
@ -1153,6 +1224,9 @@ case $basic_machine in
xps | xps100) xps | xps100)
basic_machine=xps100-honeywell basic_machine=xps100-honeywell
;; ;;
xscale-* | xscalee[bl]-*)
basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
;;
ymp) ymp)
basic_machine=ymp-cray basic_machine=ymp-cray
os=-unicos os=-unicos
@ -1250,9 +1324,12 @@ esac
if [ x"$os" != x"" ] if [ x"$os" != x"" ]
then then
case $os in case $os in
# First match some system type aliases # First match some system type aliases
# that might get confused with valid system types. # that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception. # -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
;;
-solaris1 | -solaris1.*) -solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'` os=`echo $os | sed -e 's|solaris1|sunos4|'`
;; ;;
@ -1274,21 +1351,22 @@ case $os in
# -sysv* is not here because it comes later, after sysvr4. # -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -kopensolaris* \ | -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \ | -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \ | -bitrig* | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \ | -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \ | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@ -1296,7 +1374,7 @@ case $os in
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -winmo*) | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
# Remember, each alternative MUST END IN *, to match a version number. # Remember, each alternative MUST END IN *, to match a version number.
;; ;;
-qnx*) -qnx*)
@ -1335,12 +1413,9 @@ case $os in
-opened*) -opened*)
os=-openedition os=-openedition
;; ;;
-os400*) -os400*)
os=-os400 os=-os400
;; ;;
-wince-winmo*)
os=-wince-winmo
;;
-wince*) -wince*)
os=-wince os=-wince
;; ;;
@ -1387,7 +1462,7 @@ case $os in
-sinix*) -sinix*)
os=-sysv4 os=-sysv4
;; ;;
-tpf*) -tpf*)
os=-tpf os=-tpf
;; ;;
-triton*) -triton*)
@ -1423,18 +1498,14 @@ case $os in
-aros*) -aros*)
os=-aros os=-aros
;; ;;
-kaos*)
os=-kaos
;;
-zvmoe) -zvmoe)
os=-zvmoe os=-zvmoe
;; ;;
-dicos*) -dicos*)
os=-dicos os=-dicos
;; ;;
-android*) -nacl*)
os=-android ;;
;;
-none) -none)
;; ;;
*) *)
@ -1457,10 +1528,10 @@ else
# system, and we'll never get to this point. # system, and we'll never get to this point.
case $basic_machine in case $basic_machine in
score-*) score-*)
os=-elf os=-elf
;; ;;
spu-*) spu-*)
os=-elf os=-elf
;; ;;
*-acorn) *-acorn)
@ -1472,8 +1543,23 @@ case $basic_machine in
arm*-semi) arm*-semi)
os=-aout os=-aout
;; ;;
c4x-* | tic4x-*) c4x-* | tic4x-*)
os=-coff os=-coff
;;
c8051-*)
os=-elf
;;
hexagon-*)
os=-elf
;;
tic54x-*)
os=-coff
;;
tic55x-*)
os=-coff
;;
tic6x-*)
os=-coff
;; ;;
# This must come before the *-dec entry. # This must come before the *-dec entry.
pdp10-*) pdp10-*)
@ -1493,14 +1579,11 @@ case $basic_machine in
;; ;;
m68000-sun) m68000-sun)
os=-sunos3 os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;; ;;
m68*-cisco) m68*-cisco)
os=-aout os=-aout
;; ;;
mep-*) mep-*)
os=-elf os=-elf
;; ;;
mips*-cisco) mips*-cisco)
@ -1509,6 +1592,9 @@ case $basic_machine in
mips*-*) mips*-*)
os=-elf os=-elf
;; ;;
or1k-*)
os=-elf
;;
or32-*) or32-*)
os=-coff os=-coff
;; ;;
@ -1527,7 +1613,7 @@ case $basic_machine in
*-ibm) *-ibm)
os=-aix os=-aix
;; ;;
*-knuth) *-knuth)
os=-mmixware os=-mmixware
;; ;;
*-wec) *-wec)
@ -1689,9 +1775,6 @@ case $basic_machine in
-vos*) -vos*)
vendor=stratus vendor=stratus
;; ;;
*-android*|*-linuxandroid*)
vendor=linux-
;;
esac esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;; ;;

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,20 @@
dnl Process this with autoconf to create configure dnl Process this with autoconf to create configure
AC_PREREQ(2.63) AC_PREREQ(2.68)
AC_INIT([libffi], [3.0.10rc0], [http://gcc.gnu.org/bugs.html]) AC_INIT([libffi], [3.1], [http://github.com/atgreen/libffi/issues])
AC_CONFIG_HEADERS([fficonfig.h]) AC_CONFIG_HEADERS([fficonfig.h])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
target_alias=${target_alias-$host_alias} target_alias=${target_alias-$host_alias}
. ${srcdir}/configure.host case "${host}" in
frv*-elf)
LDFLAGS=`echo $LDFLAGS | sed "s/\-B[^ ]*libgloss\/frv\///"`\ -B`pwd`/../libgloss/frv/
;;
esac
AX_ENABLE_BUILDDIR
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
@ -23,9 +29,10 @@ m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
m4_define([_AC_ARG_VAR_PRECIOUS],[]) m4_define([_AC_ARG_VAR_PRECIOUS],[])
save_CFLAGS=$CFLAGS save_CFLAGS=$CFLAGS
AC_PROG_CC AC_PROG_CC
AC_PROG_CXX
CFLAGS=$save_CFLAGS CFLAGS=$save_CFLAGS
m4_undefine([_AC_ARG_VAR_PRECIOUS]) m4_undefine([_AC_ARG_VAR_PRECIOUS])
m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS]) m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
@ -34,6 +41,26 @@ AM_PROG_CC_C_O
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
# Test for 64-bit build.
AC_CHECK_SIZEOF([size_t])
AX_COMPILER_VENDOR
AX_CC_MAXOPT
# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro
# compiler.
if test "$ax_cv_c_compiler_vendor" != "sun"; then
AX_CFLAGS_WARN_ALL
fi
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -fexceptions"
fi
cat > local.exp <<EOF
set CC_FOR_TARGET "$CC"
set CXX_FOR_TARGET "$CXX"
EOF
AM_MAINTAINER_MODE AM_MAINTAINER_MODE
AC_CHECK_HEADERS(sys/mman.h) AC_CHECK_HEADERS(sys/mman.h)
@ -44,13 +71,22 @@ dnl The -no-testsuite modules omit the test subdir.
AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite) AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
TARGETDIR="unknown" TARGETDIR="unknown"
HAVE_LONG_DOUBLE_VARIANT=0
case "$host" in case "$host" in
aarch64*-*-*)
TARGET=AARCH64; TARGETDIR=aarch64
;;
alpha*-*-*) alpha*-*-*)
TARGET=ALPHA; TARGETDIR=alpha; TARGET=ALPHA; TARGETDIR=alpha;
# Support 128-bit long double, changeable via command-line switch. # Support 128-bit long double, changeable via command-line switch.
HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)' HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
;; ;;
arc*-*-*)
TARGET=ARC; TARGETDIR=arc
;;
arm*-*-*) arm*-*-*)
TARGET=ARM; TARGETDIR=arm TARGET=ARM; TARGETDIR=arm
;; ;;
@ -59,6 +95,10 @@ case "$host" in
TARGET=X86_64; TARGETDIR=x86 TARGET=X86_64; TARGETDIR=x86
;; ;;
amd64-*-freebsd*)
TARGET=X86_64; TARGETDIR=x86
;;
amd64-*-freebsd*) amd64-*-freebsd*)
TARGET=X86_64; TARGETDIR=x86 TARGET=X86_64; TARGETDIR=x86
;; ;;
@ -67,6 +107,10 @@ case "$host" in
TARGET=AVR32; TARGETDIR=avr32 TARGET=AVR32; TARGETDIR=avr32
;; ;;
bfin*)
TARGET=BFIN; TARGETDIR=bfin
;;
cris-*-*) cris-*-*)
TARGET=LIBFFI_CRIS; TARGETDIR=cris TARGET=LIBFFI_CRIS; TARGETDIR=cris
;; ;;
@ -75,7 +119,7 @@ case "$host" in
TARGET=FRV; TARGETDIR=frv TARGET=FRV; TARGETDIR=frv
;; ;;
hppa*-*-linux* | hppa*-*-openbsd* | parisc*-*-linux*) hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*)
TARGET=PA_LINUX; TARGETDIR=pa TARGET=PA_LINUX; TARGETDIR=pa
;; ;;
hppa*64-*-hpux*) hppa*64-*-hpux*)
@ -88,19 +132,61 @@ 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 this for sharedlib # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
AM_LTLDFLAGS="-no-undefined" # 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*) i?86-*-darwin*)
TARGET=X86_DARWIN; TARGETDIR=x86 TARGET=X86_DARWIN; TARGETDIR=x86
;; ;;
i?86-*-solaris2.1[[0-9]]*) i?86-*-solaris2.1[[0-9]]*)
TARGET=X86_64; TARGETDIR=x86 TARGETDIR=x86
if test $ac_cv_sizeof_size_t = 4; then
TARGET=X86;
else
TARGET=X86_64;
fi
;; ;;
i?86-*-*)
TARGET=X86; TARGETDIR=x86 x86_64-*-darwin*)
TARGET=X86_DARWIN; TARGETDIR=x86
;;
x86_64-*-cygwin* | x86_64-*-mingw*)
TARGET=X86_WIN64; 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-*-* | x86_64-*-*)
TARGETDIR=x86
if test $ac_cv_sizeof_size_t = 4; then
case "$host" in
*-gnux32)
TARGET=X86_64
;;
*)
TARGET=X86
;;
esac
else
TARGET=X86_64;
fi
;; ;;
ia64*-*-*) ia64*-*-*)
@ -115,7 +201,23 @@ case "$host" in
TARGET=M68K; TARGETDIR=m68k TARGET=M68K; TARGETDIR=m68k
;; ;;
mips-sgi-irix5.* | mips-sgi-irix6.*) m88k-*-*)
TARGET=M88K; TARGETDIR=m88k
;;
microblaze*-*-*)
TARGET=MICROBLAZE; TARGETDIR=microblaze
;;
moxie-*-*)
TARGET=MOXIE; TARGETDIR=moxie
;;
metag-*-*)
TARGET=METAG; TARGETDIR=metag
;;
mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
TARGET=MIPS; TARGETDIR=mips TARGET=MIPS; TARGETDIR=mips
;; ;;
mips*-*linux* | mips*-*-openbsd*) mips*-*linux* | mips*-*-openbsd*)
@ -124,17 +226,21 @@ case "$host" in
TARGET=MIPS; TARGETDIR=mips TARGET=MIPS; TARGETDIR=mips
;; ;;
moxie-*-*) nios2*-linux*)
TARGET=MOXIE; TARGETDIR=moxie TARGET=NIOS2; TARGETDIR=nios2
;; ;;
powerpc*-*-linux* | powerpc-*-sysv*) powerpc*-*-linux* | powerpc-*-sysv*)
TARGET=POWERPC; TARGETDIR=powerpc
HAVE_LONG_DOUBLE_VARIANT=1
;;
powerpc-*-amigaos*)
TARGET=POWERPC; TARGETDIR=powerpc TARGET=POWERPC; TARGETDIR=powerpc
;; ;;
powerpc-*-beos*) powerpc-*-beos*)
TARGET=POWERPC; TARGETDIR=powerpc TARGET=POWERPC; TARGETDIR=powerpc
;; ;;
powerpc-*-darwin*) powerpc-*-darwin* | powerpc64-*-darwin*)
TARGET=POWERPC_DARWIN; TARGETDIR=powerpc TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
;; ;;
powerpc-*-aix* | rs6000-*-aix*) powerpc-*-aix* | rs6000-*-aix*)
@ -142,6 +248,10 @@ case "$host" in
;; ;;
powerpc-*-freebsd* | powerpc-*-openbsd*) powerpc-*-freebsd* | powerpc-*-openbsd*)
TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
HAVE_LONG_DOUBLE_VARIANT=1
;;
powerpc64-*-freebsd*)
TARGET=POWERPC; TARGETDIR=powerpc
;; ;;
powerpc*-*-rtems*) powerpc*-*-rtems*)
TARGET=POWERPC; TARGETDIR=powerpc TARGET=POWERPC; TARGETDIR=powerpc
@ -162,17 +272,18 @@ case "$host" in
TARGET=SPARC; TARGETDIR=sparc TARGET=SPARC; TARGETDIR=sparc
;; ;;
x86_64-*-darwin*) tile*-*)
TARGET=X86_DARWIN; TARGETDIR=x86 TARGET=TILE; TARGETDIR=tile
;;
vax-*-*)
TARGET=VAX; TARGETDIR=vax
;; ;;
x86_64-*-cygwin* | x86_64-*-mingw*) xtensa*-*)
TARGET=X86_WIN64; TARGETDIR=x86 TARGET=XTENSA; TARGETDIR=xtensa
;; ;;
x86_64-*-*)
TARGET=X86_64; TARGETDIR=x86
;;
esac esac
AC_SUBST(AM_RUNTESTFLAGS) AC_SUBST(AM_RUNTESTFLAGS)
@ -183,21 +294,30 @@ if test $TARGETDIR = unknown; then
fi fi
AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS) AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN)
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC) AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
AM_CONDITIONAL(X86, test x$TARGET = xX86) AM_CONDITIONAL(X86, test x$TARGET = xX86)
AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD) AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32) AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64) AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN) AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
AM_CONDITIONAL(X86_DARWIN32, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 4)
AM_CONDITIONAL(X86_DARWIN64, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 8)
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA) AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
AM_CONDITIONAL(IA64, test x$TARGET = xIA64) AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
AM_CONDITIONAL(M32R, test x$TARGET = xM32R) AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
AM_CONDITIONAL(M68K, test x$TARGET = xM68K) AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
AM_CONDITIONAL(M88K, test x$TARGET = xM88K)
AM_CONDITIONAL(MICROBLAZE, test x$TARGET = xMICROBLAZE)
AM_CONDITIONAL(METAG, test x$TARGET = xMETAG)
AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE) AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE)
AM_CONDITIONAL(NIOS2, test x$TARGET = xNIOS2)
AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC) AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX) AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN) AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD) AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64)
AM_CONDITIONAL(ARC, test x$TARGET = xARC)
AM_CONDITIONAL(ARM, test x$TARGET = xARM) AM_CONDITIONAL(ARM, test x$TARGET = xARM)
AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32) AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS) AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
@ -209,6 +329,9 @@ AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX) AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX) AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX) AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
AM_CONDITIONAL(TILE, test x$TARGET = xTILE)
AM_CONDITIONAL(VAX, test x$TARGET = xVAX)
AM_CONDITIONAL(XTENSA, test x$TARGET = xXTENSA)
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_FUNCS(memcpy) AC_CHECK_FUNCS(memcpy)
@ -220,28 +343,24 @@ AC_CHECK_SIZEOF(long double)
# Also AC_SUBST this variable for ffi.h. # Also AC_SUBST this variable for ffi.h.
if test -z "$HAVE_LONG_DOUBLE"; then if test -z "$HAVE_LONG_DOUBLE"; then
HAVE_LONG_DOUBLE=0 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
if test $ac_cv_sizeof_long_double != 0; then if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
HAVE_LONG_DOUBLE=1 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]) else
if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; 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
fi fi
fi fi
AC_SUBST(HAVE_LONG_DOUBLE) AC_SUBST(HAVE_LONG_DOUBLE)
AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
AC_C_BIGENDIAN AC_C_BIGENDIAN
AC_CACHE_CHECK([assembler .cfi pseudo-op support], GCC_AS_CFI_PSEUDO_OP
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 if test x$TARGET = xSPARC; then
AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs], AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
@ -264,7 +383,7 @@ if test x$TARGET = xSPARC; then
libffi_cv_as_register_pseudo_op, [ libffi_cv_as_register_pseudo_op, [
libffi_cv_as_register_pseudo_op=unknown libffi_cv_as_register_pseudo_op=unknown
# Check if we have .register # Check if we have .register
AC_TRY_COMPILE([asm (".register %g2, #scratch");],, AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
[libffi_cv_as_register_pseudo_op=yes], [libffi_cv_as_register_pseudo_op=yes],
[libffi_cv_as_register_pseudo_op=no]) [libffi_cv_as_register_pseudo_op=no])
]) ])
@ -279,7 +398,7 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
libffi_cv_as_x86_pcrel, [ libffi_cv_as_x86_pcrel, [
libffi_cv_as_x86_pcrel=no libffi_cv_as_x86_pcrel=no
echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
if $CC $CFLAGS -c conftest.s > /dev/null; then if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
libffi_cv_as_x86_pcrel=yes libffi_cv_as_x86_pcrel=yes
fi fi
]) ])
@ -292,7 +411,7 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
libffi_cv_as_ascii_pseudo_op, [ libffi_cv_as_ascii_pseudo_op, [
libffi_cv_as_ascii_pseudo_op=unknown libffi_cv_as_ascii_pseudo_op=unknown
# Check if we have .ascii # Check if we have .ascii
AC_TRY_COMPILE([asm (".ascii \"string\"");],, AC_TRY_COMPILE(,[asm (".ascii \\"string\\"");],
[libffi_cv_as_ascii_pseudo_op=yes], [libffi_cv_as_ascii_pseudo_op=yes],
[libffi_cv_as_ascii_pseudo_op=no]) [libffi_cv_as_ascii_pseudo_op=no])
]) ])
@ -305,7 +424,7 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
libffi_cv_as_string_pseudo_op, [ libffi_cv_as_string_pseudo_op, [
libffi_cv_as_string_pseudo_op=unknown libffi_cv_as_string_pseudo_op=unknown
# Check if we have .string # Check if we have .string
AC_TRY_COMPILE([asm (".string \"string\"");],, AC_TRY_COMPILE(,[asm (".string \\"string\\"");],
[libffi_cv_as_string_pseudo_op=yes], [libffi_cv_as_string_pseudo_op=yes],
[libffi_cv_as_string_pseudo_op=no]) [libffi_cv_as_string_pseudo_op=no])
]) ])
@ -315,21 +434,35 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
fi fi
fi fi
if test x$TARGET = xX86_WIN64; then # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
LT_SYS_SYMBOL_USCORE AC_ARG_ENABLE(pax_emutramp,
if test "x$sys_symbol_underscore" = xyes; then [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.]) if test "$enable_pax_emutramp" = "yes"; then
fi AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
[Define this if you want to enable pax emulated trampolines])
fi)
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 case "$target" in
# Darwin 10 (OSX 10.6) and beyond allocate non-executable pages *arm*-apple-darwin*)
*-apple-darwin1* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*) 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-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1, AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
[Cannot use malloc on this target, so, we revert to [Cannot use malloc on this target, so, we revert to
alternative means]) alternative means])
;; ;;
esac 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 if test x$TARGET = xX86_64; then
AC_CACHE_CHECK([toolchain supports unwind section type], AC_CACHE_CHECK([toolchain supports unwind section type],
@ -362,44 +495,47 @@ EOF
fi fi
fi fi
AC_CACHE_CHECK([whether .eh_frame section should be read-only], if test "x$GCC" = "xyes"; then
libffi_cv_ro_eh_frame, [ AC_CACHE_CHECK([whether .eh_frame section should be read-only],
libffi_cv_ro_eh_frame=no libffi_cv_ro_eh_frame, [
echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c libffi_cv_ro_eh_frame=no
if $CC $CFLAGS -S -fpic -fexceptions -o conftest.s conftest.c > /dev/null 2>&1; then echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
if grep '.section.*eh_frame.*"a"' conftest.s > /dev/null; then if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
libffi_cv_ro_eh_frame=yes objdump -h conftest.o > conftest.dump 2>&1
elif grep '.section.*eh_frame.*#alloc' conftest.c \ libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
| grep -v '#write' > /dev/null; then libffi_test_line=`expr $libffi_eh_frame_line + 1`p
libffi_cv_ro_eh_frame=yes sed -n $libffi_test_line conftest.dump > conftest.line
fi if grep READONLY conftest.line > /dev/null; then
fi libffi_cv_ro_eh_frame=yes
rm -f conftest.* fi
]) fi
if test "x$libffi_cv_ro_eh_frame" = xyes; then rm -f conftest.*
AC_DEFINE(HAVE_RO_EH_FRAME, 1, ])
[Define if .eh_frame sections should be read-only.]) if test "x$libffi_cv_ro_eh_frame" = xyes; then
AC_DEFINE(EH_FRAME_FLAGS, "a", AC_DEFINE(HAVE_RO_EH_FRAME, 1,
[Define to the flags needed for the .section .eh_frame directive.]) [Define if .eh_frame sections should be read-only.])
else AC_DEFINE(EH_FRAME_FLAGS, "a",
AC_DEFINE(EH_FRAME_FLAGS, "aw", [Define to the flags needed for the .section .eh_frame directive. ])
[Define to the flags needed for the .section .eh_frame directive.]) else
fi 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")))], AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
libffi_cv_hidden_visibility_attribute, [ libffi_cv_hidden_visibility_attribute, [
echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > conftest.c echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c
libffi_cv_hidden_visibility_attribute=no 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 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 if grep '\.hidden.*foo' conftest.s >/dev/null; then
libffi_cv_hidden_visibility_attribute=yes libffi_cv_hidden_visibility_attribute=yes
fi fi
fi fi
rm -f conftest.* rm -f conftest.*
]) ])
if test $libffi_cv_hidden_visibility_attribute = yes; then if test $libffi_cv_hidden_visibility_attribute = yes; then
AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1, AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
[Define if __attribute__((visibility("hidden"))) is supported.]) [Define if __attribute__((visibility("hidden"))) is supported.])
fi
fi fi
AH_BOTTOM([ AH_BOTTOM([
@ -433,13 +569,14 @@ AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
AC_ARG_ENABLE(structs, AC_ARG_ENABLE(structs,
[ --disable-structs omit code for struct support], [ --disable-structs omit code for struct support],
if test "$enable_structs" = "no"; then if test "$enable_structs" = "no"; then
AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this is you do not want support for aggregate types.]) AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.])
fi) fi)
AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
AC_ARG_ENABLE(raw-api, AC_ARG_ENABLE(raw-api,
[ --disable-raw-api make the raw api unavailable], [ --disable-raw-api make the raw api unavailable],
if test "$enable_raw_api" = "no"; then 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.]) AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
fi) fi)
AC_ARG_ENABLE(purify-safety, AC_ARG_ENABLE(purify-safety,
@ -448,28 +585,28 @@ AC_ARG_ENABLE(purify-safety,
AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.]) AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
fi) fi)
if test -n "$with_cross_host" && # These variables are only ever used when we cross-build to X86_WIN32.
test x"$with_cross_host" != x"no"; then # And we only support this with GCC, so...
toolexecdir='$(exec_prefix)/$(target_alias)' if test "x$GCC" = "xyes"; then
toolexeclibdir='$(toolexecdir)/lib' 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 $CFLAGS -print-multi-os-directory`
case $multi_os_directory in
.) ;; # Avoid trailing /.
../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
esac
AC_SUBST(toolexecdir)
else else
toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
toolexeclibdir='$(libdir)' toolexeclibdir='$(libdir)'
fi 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) 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(include, [test -d include || mkdir include])
AC_CONFIG_COMMANDS(src, [ AC_CONFIG_COMMANDS(src, [
test -d src || mkdir src test -d src || mkdir src

View File

@ -1,11 +0,0 @@
# configure.host
#
# This shell script handles all host based configuration for libffi.
#
# THIS TABLE IS SORTED. KEEP IT THAT WAY.
case "${host}" in
frv*-elf)
LDFLAGS=`echo $LDFLAGS | sed "s/\-B[^ ]*libgloss\/frv\///"`\ -B`pwd`/../libgloss/frv/
;;
esac

View File

@ -1,10 +1,9 @@
#! /bin/sh #! /bin/sh
# depcomp - compile a program generating dependencies as side-effects # depcomp - compile a program generating dependencies as side-effects
scriptversion=2006-10-15.18 scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software # Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -17,9 +16,7 @@ scriptversion=2006-10-15.18
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
@ -30,9 +27,9 @@ scriptversion=2006-10-15.18
case $1 in case $1 in
'') '')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2 echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1; exit 1;
;; ;;
-h | --h*) -h | --h*)
cat <<\EOF cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS] Usage: depcomp [--help] [--version] PROGRAM [ARGS]
@ -42,11 +39,11 @@ as side-effects.
Environment variables: Environment variables:
depmode Dependency tracking mode. depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'. source Source file read by 'PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies. DEPDIR directory where to store dependencies.
depfile Dependency file to output. depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies. tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no). libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>. Report bugs to <bug-automake@gnu.org>.
@ -59,6 +56,66 @@ EOF
;; ;;
esac esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2 echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1 exit 1
@ -71,6 +128,9 @@ tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We # Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below, # parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case # to make depend.m4 easier to write. Note that we *cannot* use a case
@ -82,9 +142,32 @@ if test "$depmode" = hp; then
fi fi
if test "$depmode" = dashXmstdout; then if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument. # This is just like dashmstdout with a different argument.
dashmflag=-xM dashmflag=-xM
depmode=dashmstdout depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi fi
case "$depmode" in case "$depmode" in
@ -107,8 +190,7 @@ gcc3)
done done
"$@" "$@"
stat=$? stat=$?
if test $stat -eq 0; then : if test $stat -ne 0; then
else
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
exit $stat exit $stat
fi fi
@ -116,13 +198,17 @@ gcc3)
;; ;;
gcc) gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's ## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method: ## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end ## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly. ## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.) ## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). ## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse ## - Using -M directly means running the compiler twice (even worse
## than renaming). ## than renaming).
if test -z "$gccflag"; then if test -z "$gccflag"; then
@ -130,31 +216,31 @@ gcc)
fi fi
"$@" -Wp,"$gccflag$tmpdepfile" "$@" -Wp,"$gccflag$tmpdepfile"
stat=$? stat=$?
if test $stat -eq 0; then : if test $stat -ne 0; then
else
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
exit $stat exit $stat
fi fi
rm -f "$depfile" rm -f "$depfile"
echo "$object : \\" > "$depfile" echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz # The second -e expression handles DOS-style file names with drive
## The second -e expression handles DOS-style file names with drive letters. # letters.
sed -e 's/^[^:]*: / /' \ sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem. ## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file ## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is ## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding ## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do ## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly. ## this for us directly.
tr ' ' ' ## Some versions of gcc put a space before the ':'. On the theory
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as ## that the space means something, we add a space to the output as
## well. ## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation ## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround. ## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
;; ;;
@ -172,8 +258,7 @@ sgi)
"$@" -MDupdate "$tmpdepfile" "$@" -MDupdate "$tmpdepfile"
fi fi
stat=$? stat=$?
if test $stat -eq 0; then : if test $stat -ne 0; then
else
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
exit $stat exit $stat
fi fi
@ -181,99 +266,156 @@ sgi)
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile" echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be # Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle # clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in # lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the # the IRIX cc adds comments like '#:fec' to the end of the
# dependency line. # dependency line.
tr ' ' ' tr ' ' "$nl" < "$tmpdepfile" \
' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ | tr "$nl" ' ' >> "$depfile"
tr ' echo >> "$depfile"
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file. # The second pass generates a dummy entry for each header file.
tr ' ' ' tr ' ' "$nl" < "$tmpdepfile" \
' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile"
>> $depfile
else else
# The sourcefile does not contain any dependencies, so just make_dummy_depfile
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi fi
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
;; ;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix) aix)
# The C for AIX Compiler uses -M and outputs the dependencies # The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the # in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the # current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information. # start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases. # Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` set_dir_from "$object"
tmpdepfile="$stripped.u" set_base_from "$object"
if test "$libtool" = yes; then if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M "$@" -Wc,-M
else else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M "$@" -M
fi fi
stat=$? stat=$?
if test $stat -ne 0; then
if test -f "$tmpdepfile"; then : rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat exit $stat
fi fi
if test -f "$tmpdepfile"; then for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
outname="$stripped.o" do
# Each line is of the form `foo.o: dependent.h'. test -f "$tmpdepfile" && break
# Do two passes, one to just change these to done
# `$object: dependent.h' and one to simply `dependent.h:'. aix_post_process_depfile
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" ;;
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else tcc)
# The sourcefile does not contain any dependencies, so just # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# store a dummy comment line, to avoid errors with the Makefile # FIXME: That version still under development at the moment of writing.
# "include basename.Plo" scheme. # Make that this statement remains true also for stable, released
echo "#dummy" > "$depfile" # versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
;; ;;
icc) ## The order of this option in the case statement is important, since the
# Intel's C compiler understands `-MD -MF file'. However on ## shell code in configure will try each of these formats in the order
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c ## listed in this file. A plain '-MD' option would be understood by many
# ICC 7.0 will fill foo.d with something like ## compilers, so we must ensure this comes after the gcc and icc options.
# foo.o: sub/foo.c pgcc)
# foo.o: sub/foo.h # Portland's C compiler understands '-MD'.
# which is wrong. We want: # Will always output deps to 'file.d' where file is the root name of the
# sub/foo.o: sub/foo.c # source file under compilation, even if file resides in a subdirectory.
# sub/foo.o: sub/foo.h # The object file name does not affect the name of the '.d' file.
# sub/foo.c: # pgcc 10.2 will output
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h # foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ : # and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \ # foo.o: sub/foo.c ... \
# sub/foo.h ... \ # sub/foo.h ... \
# ... # ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
"$@" -MD -MF "$tmpdepfile" # For projects that build the same source file twice into different object
stat=$? # files, the pgcc approach of using the *source* file root name can cause
if test $stat -eq 0; then : # problems in parallel builds. Use a locking strategy to avoid stomping on
else # the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
exit $stat exit $stat
fi fi
@ -285,8 +427,8 @@ icc)
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation # Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround. # correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
sed -e 's/$/ :/' >> "$depfile" | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
;; ;;
@ -297,9 +439,8 @@ hp2)
# 'foo.d', which lands next to the object file, wherever that # 'foo.d', which lands next to the object file, wherever that
# happens to be. # happens to be.
# Much of this is similar to the tru64 case; see comments there. # Much of this is similar to the tru64 case; see comments there.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` set_dir_from "$object"
test "x$dir" = "x$object" && dir= set_base_from "$object"
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d tmpdepfile2=$dir.libs/$base.d
@ -310,8 +451,7 @@ hp2)
"$@" +Maked "$@" +Maked
fi fi
stat=$? stat=$?
if test $stat -eq 0; then : if test $stat -ne 0; then
else
rm -f "$tmpdepfile1" "$tmpdepfile2" rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat exit $stat
fi fi
@ -321,72 +461,107 @@ hp2)
test -f "$tmpdepfile" && break test -f "$tmpdepfile" && break
done done
if test -f "$tmpdepfile"; then if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add `dependent.h:' lines. # Add 'dependent.h:' lines.
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else else
echo "#dummy" > "$depfile" make_dummy_depfile
fi fi
rm -f "$tmpdepfile" "$tmpdepfile2" rm -f "$tmpdepfile" "$tmpdepfile2"
;; ;;
tru64) tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side # The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too. # dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected. # Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` set_dir_from "$object"
test "x$dir" = "x$object" && dir= set_base_from "$object"
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a # Libtool generates 2 separate objects for the 2 libraries. These
# static library. This mechanism is used in libtool 1.4 series to # two compilations output dependencies in $dir.libs/$base.o.d and
# handle both shared and static libraries in a single compilation. # in $dir$base.o.d. We have to check for both files, because
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # one of the two compilations can be disabled. We should prefer
# # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# With libtool 1.5 this exception was removed, and libtool now # automatically cleaned when .libs/ is deleted, while ignoring
# generates 2 separate objects for the 2 libraries. These two # the former would cause a distcleancheck panic.
# compilations output dependencies in $dir.libs/$base.o.d and tmpdepfile1=$dir$base.o.d # libtool 1.5
# in $dir$base.o.d. We have to check for both files, because tmpdepfile2=$dir.libs/$base.o.d # Likewise.
# one of the two compilations can be disabled. We should prefer tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is "$@" -Wc,-MD
# automatically cleaned when .libs/ is deleted, while ignoring else
# the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.d
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.d
tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir$base.d
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 "$@" -MD
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 fi
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$? stat=$?
if test $stat -eq 0; then : if test $stat -ne 0; then
else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat
exit $stat fi
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do do
test -f "$tmpdepfile" && break test -f "$tmpdepfile" && break
done done
if test -f "$tmpdepfile"; then # Same post-processing that is required for AIX mode.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" aix_post_process_depfile
# That's a tab and a space in the []. ;;
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else msvc7)
echo "#dummy" > "$depfile" if test "$libtool" = yes; then
fi showIncludes=-Wc,-showIncludes
rm -f "$tmpdepfile" else
;; showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect) #nosideeffect)
# This comment above is used by automake to tell side-effect # This comment above is used by automake to tell side-effect
@ -399,13 +574,13 @@ dashmstdout)
# Remove the call to Libtool. # Remove the call to Libtool.
if test "$libtool" = yes; then if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do while test "X$1" != 'X--mode=compile'; do
shift shift
done done
shift shift
fi fi
# Remove `-o $object'. # Remove '-o $object'.
IFS=" " IFS=" "
for arg for arg
do do
@ -425,18 +600,18 @@ dashmstdout)
done done
test -z "$dashmflag" && dashmflag=-M test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:' # Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames: # in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag | "$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile" rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile" cat < "$tmpdepfile" > "$depfile"
tr ' ' ' # Some versions of the HPUX 10.20 sed can't process this sed invocation
' < "$tmpdepfile" | \ # correctly. Breaking it into two sed invocations is a workaround.
## Some versions of the HPUX 10.20 sed can't process this invocation tr ' ' "$nl" < "$tmpdepfile" \
## correctly. Breaking it into two sed invocations is a workaround. | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
;; ;;
@ -450,41 +625,51 @@ makedepend)
"$@" || exit $? "$@" || exit $?
# Remove any Libtool call # Remove any Libtool call
if test "$libtool" = yes; then if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do while test "X$1" != 'X--mode=compile'; do
shift shift
done done
shift shift
fi fi
# X makedepend # X makedepend
shift shift
cleared=no cleared=no eat=no
for arg in "$@"; do for arg
do
case $cleared in case $cleared in
no) no)
set ""; shift set ""; shift
cleared=yes ;; cleared=yes ;;
esac esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in case "$arg" in
-D*|-I*) -D*|-I*)
set fnord "$@" "$arg"; shift ;; set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove # Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file. # the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object) -*|$object)
;; ;;
*) *)
set fnord "$@" "$arg"; shift ;; set fnord "$@" "$arg"; shift ;;
esac esac
done done
obj_suffix="`echo $object | sed 's/^.*\././'`" obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile" touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile" rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile" # makedepend may prepend the VPATH from the source file name to the object.
sed '1,2d' "$tmpdepfile" | tr ' ' ' # No need to regex-escape $object, excess matching of '.' is harmless.
' | \ sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
## Some versions of the HPUX 10.20 sed can't process this invocation # Some versions of the HPUX 10.20 sed can't process the last invocation
## correctly. Breaking it into two sed invocations is a workaround. # correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak rm -f "$tmpdepfile" "$tmpdepfile".bak
;; ;;
@ -495,13 +680,13 @@ cpp)
# Remove the call to Libtool. # Remove the call to Libtool.
if test "$libtool" = yes; then if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do while test "X$1" != 'X--mode=compile'; do
shift shift
done done
shift shift
fi fi
# Remove `-o $object'. # Remove '-o $object'.
IFS=" " IFS=" "
for arg for arg
do do
@ -520,10 +705,10 @@ cpp)
esac esac
done done
"$@" -E | "$@" -E \
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
sed '$ s: \\$::' > "$tmpdepfile" | sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile" rm -f "$depfile"
echo "$object : \\" > "$depfile" echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile" cat < "$tmpdepfile" >> "$depfile"
@ -533,35 +718,56 @@ cpp)
msvisualcpp) msvisualcpp)
# Important note: in order to support this mode, a compiler *must* # Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o, # always write the preprocessed file to stdout.
# because we must use -o when running libtool.
"$@" || exit $? "$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" " IFS=" "
for arg for arg
do do
case "$arg" in case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@" set fnord "$@"
shift shift
shift shift
;; ;;
*) *)
set fnord "$@" "$arg" set fnord "$@" "$arg"
shift shift
shift shift
;; ;;
esac esac
done done
"$@" -E | "$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile" rm -f "$depfile"
echo "$object : \\" > "$depfile" echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo " " >> "$depfile" echo "$tab" >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile" rm -f "$tmpdepfile"
;; ;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none) none)
exec "$@" exec "$@"
;; ;;
@ -580,5 +786,6 @@ exit 0
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$" # time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End: # End:

353
js/src/ctypes/libffi/doc/libffi.info Normal file → Executable file
View File

@ -1,17 +1,15 @@
This is ../libffi/doc/libffi.info, produced by makeinfo version 4.13 This is libffi.info, produced by makeinfo version 5.1 from libffi.texi.
from ../libffi/doc/libffi.texi.
This manual is for Libffi, a portable foreign-function interface This manual is for Libffi, a portable foreign-function interface
library. library.
Copyright (C) 2008, 2010 Red Hat, Inc. Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
Permission is granted to copy, distribute and/or modify this Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU General Public License as document under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or published by the Free Software Foundation; either version 2, or (at
(at your option) any later version. A copy of the license is your option) any later version. A copy of the license is included
included in the section entitled "GNU General Public License". in the section entitled "GNU General Public License".
INFO-DIR-SECTION Development INFO-DIR-SECTION Development
START-INFO-DIR-ENTRY START-INFO-DIR-ENTRY
@ -27,14 +25,13 @@ libffi
This manual is for Libffi, a portable foreign-function interface This manual is for Libffi, a portable foreign-function interface
library. library.
Copyright (C) 2008, 2010 Red Hat, Inc. Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
Permission is granted to copy, distribute and/or modify this Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU General Public License as document under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or published by the Free Software Foundation; either version 2, or (at
(at your option) any later version. A copy of the license is your option) any later version. A copy of the license is included
included in the section entitled "GNU General Public License". in the section entitled "GNU General Public License".
* Menu: * Menu:
@ -56,25 +53,25 @@ The calling convention is a set of assumptions made by the compiler
about where function arguments will be found on entry to a function. A about where function arguments will be found on entry to a function. A
calling convention also specifies where the return value for a function calling convention also specifies where the return value for a function
is found. The calling convention is also sometimes called the "ABI" or is found. The calling convention is also sometimes called the "ABI" or
"Application Binary Interface". "Application Binary Interface".
Some programs may not know at the time of compilation what arguments 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 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 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 given function. 'Libffi' can be used in such programs to provide a
bridge from the interpreter program to compiled code. bridge from the interpreter program to compiled code.
The `libffi' library provides a portable, high level programming The 'libffi' library provides a portable, high level programming
interface to various calling conventions. This allows a programmer to interface to various calling conventions. This allows a programmer to
call any function specified by a call interface description at run time. call any function specified by a call interface description at run time.
FFI stands for Foreign Function Interface. A foreign function FFI stands for Foreign Function Interface. A foreign function
interface is the popular name for the interface that allows code interface is the popular name for the interface that allows code written
written in one language to call code written in another language. The in one language to call code written in another language. The 'libffi'
`libffi' library really only provides the lowest, machine dependent library really only provides the lowest, machine dependent layer of a
layer of a fully featured foreign function interface. A layer must fully featured foreign function interface. A layer must exist above
exist above `libffi' that handles type conversions for values passed 'libffi' that handles type conversions for values passed between the two
between the two languages. languages.
 
File: libffi.info, Node: Using libffi, Next: Missing Features, Prev: Introduction, Up: Top File: libffi.info, Node: Using libffi, Next: Missing Features, Prev: Introduction, Up: Top
@ -97,54 +94,75 @@ File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
2.1 The Basics 2.1 The Basics
============== ==============
`Libffi' assumes that you have a pointer to the function you wish to 'Libffi' assumes that you have a pointer to the function you wish to
call and that you know the number and types of arguments to pass it, as call and that you know the number and types of arguments to pass it, as
well as the return type of the function. well as the return type of the function.
The first thing you must do is create an `ffi_cif' object that The first thing you must do is create an 'ffi_cif' object that
matches the signature of the function you wish to call. This is a matches the signature of the function you wish to call. This is a
separate step because it is common to make multiple calls using a separate step because it is common to make multiple calls using a single
single `ffi_cif'. The "cif" in `ffi_cif' stands for Call InterFace. 'ffi_cif'. The "cif" in 'ffi_cif' stands for Call InterFace. To
To prepare a call interface object, use the function `ffi_prep_cif'. prepare a call interface object, use the function 'ffi_prep_cif'.
-- Function: ffi_status ffi_prep_cif (ffi_cif *CIF, ffi_abi ABI, -- Function: ffi_status ffi_prep_cif (ffi_cif *CIF, ffi_abi ABI,
unsigned int NARGS, ffi_type *RTYPE, ffi_type **ARGTYPES) unsigned int NARGS, ffi_type *RTYPE, ffi_type **ARGTYPES)
This initializes CIF according to the given parameters. This initializes CIF according to the given parameters.
ABI is the ABI to use; normally `FFI_DEFAULT_ABI' is what you ABI is the ABI to use; normally 'FFI_DEFAULT_ABI' is what you want.
want. *note Multiple ABIs:: for more information. *note Multiple ABIs:: for more information.
NARGS is the number of arguments that this function accepts. NARGS is the number of arguments that this function accepts.
`libffi' does not yet handle varargs functions; see *note Missing
Features:: for more information.
RTYPE is a pointer to an `ffi_type' structure that describes the RTYPE is a pointer to an 'ffi_type' structure that describes the
return type of the function. *Note Types::. return type of the function. *Note Types::.
ARGTYPES is a vector of `ffi_type' pointers. ARGTYPES must have ARGTYPES is a vector of 'ffi_type' pointers. ARGTYPES must have
NARGS elements. If NARGS is 0, this argument is ignored. NARGS elements. If NARGS is 0, this argument is ignored.
`ffi_prep_cif' returns a `libffi' status code, of type 'ffi_prep_cif' returns a 'libffi' status code, of type
`ffi_status'. This will be either `FFI_OK' if everything worked 'ffi_status'. This will be either 'FFI_OK' if everything worked
properly; `FFI_BAD_TYPEDEF' if one of the `ffi_type' objects is properly; 'FFI_BAD_TYPEDEF' if one of the 'ffi_type' objects is
incorrect; or `FFI_BAD_ABI' if the ABI parameter is invalid. incorrect; or 'FFI_BAD_ABI' if the ABI parameter is invalid.
To call a function using an initialized `ffi_cif', use the If the function being called is variadic (varargs) then
`ffi_call' function: 'ffi_prep_cif_var' must be used instead of 'ffi_prep_cif'.
-- Function: ffi_status ffi_prep_cif_var (ffi_cif *CIF, ffi_abi varabi,
unsigned int NFIXEDARGS, unsigned int varntotalargs, ffi_type
*RTYPE, ffi_type **ARGTYPES)
This initializes CIF according to the given parameters for a call
to a variadic function. In general it's operation is the same as
for 'ffi_prep_cif' except that:
NFIXEDARGS is the number of fixed arguments, prior to any variadic
arguments. It must be greater than zero.
NTOTALARGS the total number of arguments, including variadic and
fixed arguments.
Note that, different cif's must be prepped for calls to the same
function when different numbers of arguments are passed.
Also note that a call to 'ffi_prep_cif_var' with
NFIXEDARGS=NOTOTALARGS is NOT equivalent to a call to
'ffi_prep_cif'.
To call a function using an initialized 'ffi_cif', use the 'ffi_call'
function:
-- Function: void ffi_call (ffi_cif *CIF, void *FN, void *RVALUE, void -- Function: void ffi_call (ffi_cif *CIF, void *FN, void *RVALUE, void
**AVALUES) **AVALUES)
This calls the function FN according to the description given in This calls the function FN according to the description given in
CIF. CIF must have already been prepared using `ffi_prep_cif'. CIF. CIF must have already been prepared using 'ffi_prep_cif'.
RVALUE is a pointer to a chunk of memory that will hold the result RVALUE is a pointer to a chunk of memory that will hold the result
of the function call. This must be large enough to hold the of the function call. This must be large enough to hold the
result and must be suitably aligned; it is the caller's result, no smaller than the system register size (generally 32 or
64 bits), and must be suitably aligned; it is the caller's
responsibility to ensure this. If CIF declares that the function responsibility to ensure this. If CIF declares that the function
returns `void' (using `ffi_type_void'), then RVALUE is ignored. returns 'void' (using 'ffi_type_void'), then RVALUE is ignored.
If RVALUE is `NULL', then the return value is discarded.
AVALUES is a vector of `void *' pointers that point to the memory AVALUES is a vector of 'void *' pointers that point to the memory
locations holding the argument values for a call. If CIF declares locations holding the argument values for a call. If CIF declares
that the function has no arguments (i.e., NARGS was 0), then that the function has no arguments (i.e., NARGS was 0), then
AVALUES is ignored. Note that argument values may be modified by AVALUES is ignored. Note that argument values may be modified by
@ -157,7 +175,7 @@ File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up:
2.2 Simple Example 2.2 Simple Example
================== ==================
Here is a trivial example that calls `puts' a few times. Here is a trivial example that calls 'puts' a few times.
#include <stdio.h> #include <stdio.h>
#include <ffi.h> #include <ffi.h>
@ -168,7 +186,7 @@ Here is a trivial example that calls `puts' a few times.
ffi_type *args[1]; ffi_type *args[1];
void *values[1]; void *values[1];
char *s; char *s;
int rc; ffi_arg rc;
/* Initialize the argument info vectors */ /* Initialize the argument info vectors */
args[0] = &ffi_type_pointer; args[0] = &ffi_type_pointer;
@ -176,7 +194,7 @@ Here is a trivial example that calls `puts' a few times.
/* Initialize the cif */ /* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint, args) == FFI_OK) &ffi_type_sint, args) == FFI_OK)
{ {
s = "Hello World!"; s = "Hello World!";
ffi_call(&cif, puts, &rc, values); ffi_call(&cif, puts, &rc, values);
@ -210,80 +228,80 @@ File: libffi.info, Node: Primitive Types, Next: Structures, Up: Types
2.3.1 Primitive Types 2.3.1 Primitive Types
--------------------- ---------------------
`Libffi' provides a number of built-in type descriptors that can be 'Libffi' provides a number of built-in type descriptors that can be used
used to describe argument and return types: to describe argument and return types:
`ffi_type_void' 'ffi_type_void'
The type `void'. This cannot be used for argument types, only for The type 'void'. This cannot be used for argument types, only for
return values. return values.
`ffi_type_uint8' 'ffi_type_uint8'
An unsigned, 8-bit integer type. An unsigned, 8-bit integer type.
`ffi_type_sint8' 'ffi_type_sint8'
A signed, 8-bit integer type. A signed, 8-bit integer type.
`ffi_type_uint16' 'ffi_type_uint16'
An unsigned, 16-bit integer type. An unsigned, 16-bit integer type.
`ffi_type_sint16' 'ffi_type_sint16'
A signed, 16-bit integer type. A signed, 16-bit integer type.
`ffi_type_uint32' 'ffi_type_uint32'
An unsigned, 32-bit integer type. An unsigned, 32-bit integer type.
`ffi_type_sint32' 'ffi_type_sint32'
A signed, 32-bit integer type. A signed, 32-bit integer type.
`ffi_type_uint64' 'ffi_type_uint64'
An unsigned, 64-bit integer type. An unsigned, 64-bit integer type.
`ffi_type_sint64' 'ffi_type_sint64'
A signed, 64-bit integer type. A signed, 64-bit integer type.
`ffi_type_float' 'ffi_type_float'
The C `float' type. The C 'float' type.
`ffi_type_double' 'ffi_type_double'
The C `double' type. The C 'double' type.
`ffi_type_uchar' 'ffi_type_uchar'
The C `unsigned char' type. The C 'unsigned char' type.
`ffi_type_schar' 'ffi_type_schar'
The C `signed char' type. (Note that there is not an exact The C 'signed char' type. (Note that there is not an exact
equivalent to the C `char' type in `libffi'; ordinarily you should equivalent to the C 'char' type in 'libffi'; ordinarily you should
either use `ffi_type_schar' or `ffi_type_uchar' depending on either use 'ffi_type_schar' or 'ffi_type_uchar' depending on
whether `char' is signed.) whether 'char' is signed.)
`ffi_type_ushort' 'ffi_type_ushort'
The C `unsigned short' type. The C 'unsigned short' type.
`ffi_type_sshort' 'ffi_type_sshort'
The C `short' type. The C 'short' type.
`ffi_type_uint' 'ffi_type_uint'
The C `unsigned int' type. The C 'unsigned int' type.
`ffi_type_sint' 'ffi_type_sint'
The C `int' type. The C 'int' type.
`ffi_type_ulong' 'ffi_type_ulong'
The C `unsigned long' type. The C 'unsigned long' type.
`ffi_type_slong' 'ffi_type_slong'
The C `long' type. The C 'long' type.
`ffi_type_longdouble' 'ffi_type_longdouble'
On platforms that have a C `long double' type, this is defined. On platforms that have a C 'long double' type, this is defined. On
On other platforms, it is not. other platforms, it is not.
`ffi_type_pointer' 'ffi_type_pointer'
A generic `void *' pointer. You should use this for all pointers, A generic 'void *' pointer. You should use this for all pointers,
regardless of their real type. regardless of their real type.
Each of these is of type `ffi_type', so you must take the address Each of these is of type 'ffi_type', so you must take the address
when passing to `ffi_prep_cif'. when passing to 'ffi_prep_cif'.
 
File: libffi.info, Node: Structures, Next: Type Example, Prev: Primitive Types, Up: Types File: libffi.info, Node: Structures, Next: Type Example, Prev: Primitive Types, Up: Types
@ -291,24 +309,24 @@ File: libffi.info, Node: Structures, Next: Type Example, Prev: Primitive Type
2.3.2 Structures 2.3.2 Structures
---------------- ----------------
Although `libffi' has no special support for unions or bit-fields, it Although 'libffi' has no special support for unions or bit-fields, it is
is perfectly happy passing structures back and forth. You must first perfectly happy passing structures back and forth. You must first
describe the structure to `libffi' by creating a new `ffi_type' object describe the structure to 'libffi' by creating a new 'ffi_type' object
for it. for it.
-- ffi_type: -- Data type: ffi_type
The `ffi_type' has the following members: The 'ffi_type' has the following members:
`size_t size' 'size_t size'
This is set by `libffi'; you should initialize it to zero. This is set by 'libffi'; you should initialize it to zero.
`unsigned short alignment' 'unsigned short alignment'
This is set by `libffi'; you should initialize it to zero. This is set by 'libffi'; you should initialize it to zero.
`unsigned short type' 'unsigned short type'
For a structure, this should be set to `FFI_TYPE_STRUCT'. For a structure, this should be set to 'FFI_TYPE_STRUCT'.
`ffi_type **elements' 'ffi_type **elements'
This is a `NULL'-terminated array of pointers to `ffi_type' This is a 'NULL'-terminated array of pointers to 'ffi_type'
objects. There is one element per field of the struct. objects. There is one element per field of the struct.
 
@ -317,8 +335,8 @@ File: libffi.info, Node: Type Example, Prev: Structures, Up: Types
2.3.3 Type Example 2.3.3 Type Example
------------------ ------------------
The following example initializes a `ffi_type' object representing the The following example initializes a 'ffi_type' object representing the
`tm' struct from Linux's `time.h'. 'tm' struct from Linux's 'time.h'.
Here is how the struct is defined: Here is how the struct is defined:
@ -337,7 +355,7 @@ The following example initializes a `ffi_type' object representing the
__const char *__tm_zone__; __const char *__tm_zone__;
}; };
Here is the corresponding code to describe this struct to `libffi': Here is the corresponding code to describe this struct to 'libffi':
{ {
ffi_type tm_type; ffi_type tm_type;
@ -345,6 +363,7 @@ The following example initializes a `ffi_type' object representing the
int i; int i;
tm_type.size = tm_type.alignment = 0; tm_type.size = tm_type.alignment = 0;
tm_type.type = FFI_TYPE_STRUCT;
tm_type.elements = &tm_type_elements; tm_type.elements = &tm_type_elements;
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
@ -365,9 +384,9 @@ File: libffi.info, Node: Multiple ABIs, Next: The Closure API, Prev: Types,
================= =================
A given platform may provide multiple different ABIs at once. For A given platform may provide multiple different ABIs at once. For
instance, the x86 platform has both `stdcall' and `fastcall' functions. instance, the x86 platform has both 'stdcall' and 'fastcall' functions.
`libffi' provides some support for this. However, this is 'libffi' provides some support for this. However, this is
necessarily platform-specific. necessarily platform-specific.
 
@ -376,32 +395,32 @@ File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multip
2.5 The Closure API 2.5 The Closure API
=================== ===================
`libffi' also provides a way to write a generic function - a function 'libffi' also provides a way to write a generic function - a function
that can accept and decode any combination of arguments. This can be that can accept and decode any combination of arguments. This can be
useful when writing an interpreter, or to provide wrappers for useful when writing an interpreter, or to provide wrappers for arbitrary
arbitrary functions. functions.
This facility is called the "closure API". Closures are not This facility is called the "closure API". Closures are not supported
supported on all platforms; you can check the `FFI_CLOSURES' define to on all platforms; you can check the 'FFI_CLOSURES' define to determine
determine whether they are supported on the current platform. whether they are supported on the current platform.
Because closures work by assembling a tiny function at runtime, they Because closures work by assembling a tiny function at runtime, they
require special allocation on platforms that have a non-executable require special allocation on platforms that have a non-executable heap.
heap. Memory management for closures is handled by a pair of functions: Memory management for closures is handled by a pair of functions:
-- Function: void *ffi_closure_alloc (size_t SIZE, void **CODE) -- Function: void *ffi_closure_alloc (size_t SIZE, void **CODE)
Allocate a chunk of memory holding SIZE bytes. This returns a Allocate a chunk of memory holding SIZE bytes. This returns a
pointer to the writable address, and sets *CODE to the pointer to the writable address, and sets *CODE to the
corresponding executable address. corresponding executable address.
SIZE should be sufficient to hold a `ffi_closure' object. SIZE should be sufficient to hold a 'ffi_closure' object.
-- Function: void ffi_closure_free (void *WRITABLE) -- Function: void ffi_closure_free (void *WRITABLE)
Free memory allocated using `ffi_closure_alloc'. The argument is Free memory allocated using 'ffi_closure_alloc'. The argument is
the writable address that was returned. the writable address that was returned.
Once you have allocated the memory for a closure, you must construct Once you have allocated the memory for a closure, you must construct
a `ffi_cif' describing the function call. Finally you can prepare the a 'ffi_cif' describing the function call. Finally you can prepare the
closure function: closure function:
-- Function: ffi_status ffi_prep_closure_loc (ffi_closure *CLOSURE, -- Function: ffi_status ffi_prep_closure_loc (ffi_closure *CLOSURE,
@ -409,40 +428,40 @@ closure function:
**ARGS, void *USER_DATA), void *USER_DATA, void *CODELOC) **ARGS, void *USER_DATA), void *USER_DATA, void *CODELOC)
Prepare a closure function. Prepare a closure function.
CLOSURE is the address of a `ffi_closure' object; this is the CLOSURE is the address of a 'ffi_closure' object; this is the
writable address returned by `ffi_closure_alloc'. writable address returned by 'ffi_closure_alloc'.
CIF is the `ffi_cif' describing the function parameters. CIF is the 'ffi_cif' describing the function parameters.
USER_DATA is an arbitrary datum that is passed, uninterpreted, to USER_DATA is an arbitrary datum that is passed, uninterpreted, to
your closure function. your closure function.
CODELOC is the executable address returned by `ffi_closure_alloc'. CODELOC is the executable address returned by 'ffi_closure_alloc'.
FUN is the function which will be called when the closure is FUN is the function which will be called when the closure is
invoked. It is called with the arguments: invoked. It is called with the arguments:
CIF CIF
The `ffi_cif' passed to `ffi_prep_closure_loc'. The 'ffi_cif' passed to 'ffi_prep_closure_loc'.
RET RET
A pointer to the memory used for the function's return value. A pointer to the memory used for the function's return value.
FUN must fill this, unless the function is declared as FUN must fill this, unless the function is declared as
returning `void'. returning 'void'.
ARGS ARGS
A vector of pointers to memory holding the arguments to the A vector of pointers to memory holding the arguments to the
function. function.
USER_DATA USER_DATA
The same USER_DATA that was passed to `ffi_prep_closure_loc'. The same USER_DATA that was passed to 'ffi_prep_closure_loc'.
`ffi_prep_closure_loc' will return `FFI_OK' if everything went ok, 'ffi_prep_closure_loc' will return 'FFI_OK' if everything went ok,
and something else on error. and something else on error.
After calling `ffi_prep_closure_loc', you can cast CODELOC to the After calling 'ffi_prep_closure_loc', you can cast CODELOC to the
appropriate pointer-to-function type. appropriate pointer-to-function type.
You may see old code referring to `ffi_prep_closure'. This function You may see old code referring to 'ffi_prep_closure'. This function
is deprecated, as it cannot handle the need for separate writable and is deprecated, as it cannot handle the need for separate writable and
executable addresses. executable addresses.
@ -452,26 +471,28 @@ File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using li
2.6 Closure Example 2.6 Closure Example
=================== ===================
A trivial example that creates a new `puts' by binding `fputs' with A trivial example that creates a new 'puts' by binding 'fputs' with
`stdin'. 'stdout'.
#include <stdio.h> #include <stdio.h>
#include <ffi.h> #include <ffi.h>
/* Acts like puts with the file given at time of enclosure. */ /* Acts like puts with the file given at time of enclosure. */
void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[], void puts_binding(ffi_cif *cif, void *ret, void* args[],
FILE *stream) void *stream)
{ {
*ret = fputs(*(char **)args[0], stream); *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
} }
typedef int (*puts_t)(char *);
int main() int main()
{ {
ffi_cif cif; ffi_cif cif;
ffi_type *args[1]; ffi_type *args[1];
ffi_closure *closure; ffi_closure *closure;
int (*bound_puts)(char *); void *bound_puts;
int rc; int rc;
/* Allocate closure and bound_puts */ /* Allocate closure and bound_puts */
@ -484,13 +505,13 @@ A trivial example that creates a new `puts' by binding `fputs' with
/* Initialize the cif */ /* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint, args) == FFI_OK) &ffi_type_sint, args) == FFI_OK)
{ {
/* Initialize the closure, setting stream to stdout */ /* Initialize the closure, setting stream to stdout */
if (ffi_prep_closure_loc(closure, &cif, puts_binding, if (ffi_prep_closure_loc(closure, &cif, puts_binding,
stdout, bound_puts) == FFI_OK) stdout, bound_puts) == FFI_OK)
{ {
rc = bound_puts("Hello World!"); rc = ((puts_t)bound_puts)("Hello World!");
/* rc now holds the result of the call to fputs */ /* rc now holds the result of the call to fputs */
} }
} }
@ -508,12 +529,10 @@ File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi,
3 Missing Features 3 Missing Features
****************** ******************
`libffi' is missing a few features. We welcome patches to add support 'libffi' is missing a few features. We welcome patches to add support
for these. for these.
* There is no support for calling varargs functions. This may work * Variadic closures.
on some platforms, depending on how the ABI is defined, but it is
not reliable.
* There is no support for bit fields in structures. * There is no support for bit fields in structures.
@ -521,6 +540,9 @@ for these.
* The "raw" API is undocumented. * The "raw" API is undocumented.
Note that variadic support is very new and tested on a relatively
small number of platforms.
 
File: libffi.info, Node: Index, Prev: Missing Features, Up: Top File: libffi.info, Node: Index, Prev: Missing Features, Up: Top
@ -530,7 +552,6 @@ Index
[index] [index]
* Menu: * Menu:
* : Structures. (line 12)
* ABI: Introduction. (line 13) * ABI: Introduction. (line 13)
* Application Binary Interface: Introduction. (line 13) * Application Binary Interface: Introduction. (line 13)
* calling convention: Introduction. (line 13) * calling convention: Introduction. (line 13)
@ -538,15 +559,18 @@ Index
* closure API: The Closure API. (line 13) * closure API: The Closure API. (line 13)
* closures: The Closure API. (line 13) * closures: The Closure API. (line 13)
* FFI: Introduction. (line 31) * FFI: Introduction. (line 31)
* ffi_call: The Basics. (line 41) * ffi_call: The Basics. (line 62)
* FFI_CLOSURES: The Closure API. (line 13)
* ffi_closure_alloc: The Closure API. (line 19) * ffi_closure_alloc: The Closure API. (line 19)
* ffi_closure_free: The Closure API. (line 26) * ffi_closure_free: The Closure API. (line 26)
* FFI_CLOSURES: The Closure API. (line 13)
* ffi_prep_cif: The Basics. (line 16) * ffi_prep_cif: The Basics. (line 16)
* ffi_prep_cif_var: The Basics. (line 39)
* ffi_prep_closure_loc: The Closure API. (line 34) * ffi_prep_closure_loc: The Closure API. (line 34)
* ffi_status <1>: The Closure API. (line 37) * ffi_status: The Basics. (line 16)
* ffi_status: The Basics. (line 18) * ffi_status <1>: The Basics. (line 39)
* ffi_status <2>: The Closure API. (line 34)
* ffi_type: Structures. (line 11) * ffi_type: Structures. (line 11)
* ffi_type <1>: Structures. (line 11)
* ffi_type_double: Primitive Types. (line 41) * ffi_type_double: Primitive Types. (line 41)
* ffi_type_float: Primitive Types. (line 38) * ffi_type_float: Primitive Types. (line 38)
* ffi_type_longdouble: Primitive Types. (line 71) * ffi_type_longdouble: Primitive Types. (line 71)
@ -569,25 +593,26 @@ Index
* ffi_type_ushort: Primitive Types. (line 53) * ffi_type_ushort: Primitive Types. (line 53)
* ffi_type_void: Primitive Types. (line 10) * ffi_type_void: Primitive Types. (line 10)
* Foreign Function Interface: Introduction. (line 31) * Foreign Function Interface: Introduction. (line 31)
* void <1>: The Closure API. (line 20) * void: The Basics. (line 62)
* void: The Basics. (line 43) * void <1>: The Closure API. (line 19)
* void <2>: The Closure API. (line 26)
 
Tag Table: Tag Table:
Node: Top706 Node: Top682
Node: Introduction1448 Node: Introduction1429
Node: Using libffi3084 Node: Using libffi3061
Node: The Basics3570 Node: The Basics3547
Node: Simple Example6356 Node: Simple Example7198
Node: Types7383 Node: Types8229
Node: Primitive Types7666 Node: Primitive Types8512
Node: Structures9486 Node: Structures10333
Node: Type Example10346 Node: Type Example11207
Node: Multiple ABIs11569 Node: Multiple ABIs12473
Node: The Closure API11940 Node: The Closure API12844
Node: Closure Example14884 Node: Closure Example15788
Node: Missing Features16443 Node: Missing Features17397
Node: Index16936 Node: Index17850
 
End Tag Table End Tag Table

View File

@ -19,7 +19,7 @@
This manual is for Libffi, a portable foreign-function interface This manual is for Libffi, a portable foreign-function interface
library. library.
Copyright @copyright{} 2008, 2010 Red Hat, Inc. Copyright @copyright{} 2008, 2010, 2011 Red Hat, Inc.
@quotation @quotation
Permission is granted to copy, distribute and/or modify this document Permission is granted to copy, distribute and/or modify this document
@ -133,8 +133,6 @@ This initializes @var{cif} according to the given parameters.
you want. @ref{Multiple ABIs} for more information. you want. @ref{Multiple ABIs} for more information.
@var{nargs} is the number of arguments that this function accepts. @var{nargs} is the number of arguments that this function accepts.
@samp{libffi} does not yet handle varargs functions; see @ref{Missing
Features} for more information.
@var{rtype} is a pointer to an @code{ffi_type} structure that @var{rtype} is a pointer to an @code{ffi_type} structure that
describes the return type of the function. @xref{Types}. describes the return type of the function. @xref{Types}.
@ -150,6 +148,30 @@ objects is incorrect; or @code{FFI_BAD_ABI} if the @var{abi} parameter
is invalid. is invalid.
@end defun @end defun
If the function being called is variadic (varargs) then
@code{ffi_prep_cif_var} must be used instead of @code{ffi_prep_cif}.
@findex ffi_prep_cif_var
@defun ffi_status ffi_prep_cif_var (ffi_cif *@var{cif}, ffi_abi var{abi}, unsigned int @var{nfixedargs}, unsigned int var{ntotalargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes})
This initializes @var{cif} according to the given parameters for
a call to a variadic function. In general it's operation is the
same as for @code{ffi_prep_cif} except that:
@var{nfixedargs} is the number of fixed arguments, prior to any
variadic arguments. It must be greater than zero.
@var{ntotalargs} the total number of arguments, including variadic
and fixed arguments.
Note that, different cif's must be prepped for calls to the same
function when different numbers of arguments are passed.
Also note that a call to @code{ffi_prep_cif_var} with
@var{nfixedargs}=@var{nototalargs} is NOT equivalent to a call to
@code{ffi_prep_cif}.
@end defun
To call a function using an initialized @code{ffi_cif}, use the To call a function using an initialized @code{ffi_cif}, use the
@code{ffi_call} function: @code{ffi_call} function:
@ -162,11 +184,11 @@ This calls the function @var{fn} according to the description given in
@var{rvalue} is a pointer to a chunk of memory that will hold the @var{rvalue} is a pointer to a chunk of memory that will hold the
result of the function call. This must be large enough to hold the result of the function call. This must be large enough to hold the
result and must be suitably aligned; it is the caller's responsibility result, no smaller than the system register size (generally 32 or 64
bits), and must be suitably aligned; it is the caller's responsibility
to ensure this. If @var{cif} declares that the function returns to ensure this. If @var{cif} declares that the function returns
@code{void} (using @code{ffi_type_void}), then @var{rvalue} is @code{void} (using @code{ffi_type_void}), then @var{rvalue} is
ignored. If @var{rvalue} is @samp{NULL}, then the return value is ignored.
discarded.
@var{avalues} is a vector of @code{void *} pointers that point to the @var{avalues} is a vector of @code{void *} pointers that point to the
memory locations holding the argument values for a call. If @var{cif} memory locations holding the argument values for a call. If @var{cif}
@ -192,7 +214,7 @@ int main()
ffi_type *args[1]; ffi_type *args[1];
void *values[1]; void *values[1];
char *s; char *s;
int rc; ffi_arg rc;
/* Initialize the argument info vectors */ /* Initialize the argument info vectors */
args[0] = &ffi_type_pointer; args[0] = &ffi_type_pointer;
@ -200,7 +222,7 @@ int main()
/* Initialize the cif */ /* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint, args) == FFI_OK) &ffi_type_sint, args) == FFI_OK)
@{ @{
s = "Hello World!"; s = "Hello World!";
ffi_call(&cif, puts, &rc, values); ffi_call(&cif, puts, &rc, values);
@ -338,7 +360,7 @@ You must first describe the structure to @samp{libffi} by creating a
new @code{ffi_type} object for it. new @code{ffi_type} object for it.
@tindex ffi_type @tindex ffi_type
@deftp ffi_type @deftp {Data type} ffi_type
The @code{ffi_type} has the following members: The @code{ffi_type} has the following members:
@table @code @table @code
@item size_t size @item size_t size
@ -392,6 +414,7 @@ Here is the corresponding code to describe this struct to
int i; int i;
tm_type.size = tm_type.alignment = 0; tm_type.size = tm_type.alignment = 0;
tm_type.type = FFI_TYPE_STRUCT;
tm_type.elements = &tm_type_elements; tm_type.elements = &tm_type_elements;
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
@ -511,28 +534,30 @@ writable and executable addresses.
@section Closure Example @section Closure Example
A trivial example that creates a new @code{puts} by binding A trivial example that creates a new @code{puts} by binding
@code{fputs} with @code{stdin}. @code{fputs} with @code{stdout}.
@example @example
#include <stdio.h> #include <stdio.h>
#include <ffi.h> #include <ffi.h>
/* Acts like puts with the file given at time of enclosure. */ /* Acts like puts with the file given at time of enclosure. */
void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[], void puts_binding(ffi_cif *cif, void *ret, void* args[],
FILE *stream) void *stream)
@{ @{
*ret = fputs(*(char **)args[0], stream); *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
@} @}
typedef int (*puts_t)(char *);
int main() int main()
@{ @{
ffi_cif cif; ffi_cif cif;
ffi_type *args[1]; ffi_type *args[1];
ffi_closure *closure; ffi_closure *closure;
int (*bound_puts)(char *); void *bound_puts;
int rc; int rc;
/* Allocate closure and bound_puts */ /* Allocate closure and bound_puts */
closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts); closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
@ -543,13 +568,13 @@ int main()
/* Initialize the cif */ /* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint, args) == FFI_OK) &ffi_type_sint, args) == FFI_OK)
@{ @{
/* Initialize the closure, setting stream to stdout */ /* Initialize the closure, setting stream to stdout */
if (ffi_prep_closure_loc(closure, &cif, puts_binding, if (ffi_prep_closure_loc(closure, &cif, puts_binding,
stdout, bound_puts) == FFI_OK) stdout, bound_puts) == FFI_OK)
@{ @{
rc = bound_puts("Hello World!"); rc = ((puts_t)bound_puts)("Hello World!");
/* rc now holds the result of the call to fputs */ /* rc now holds the result of the call to fputs */
@} @}
@} @}
@ -572,9 +597,7 @@ support for these.
@itemize @bullet @itemize @bullet
@item @item
There is no support for calling varargs functions. This may work on Variadic closures.
some platforms, depending on how the ABI is defined, but it is not
reliable.
@item @item
There is no support for bit fields in structures. There is no support for bit fields in structures.
@ -591,6 +614,8 @@ The ``raw'' API is undocumented.
@c anything else? @c anything else?
@end itemize @end itemize
Note that variadic support is very new and tested on a relatively
small number of platforms.
@node Index @node Index
@unnumbered Index @unnumbered Index

8
js/src/ctypes/libffi/doc/stamp-vti Normal file → Executable file
View File

@ -1,4 +1,4 @@
@set UPDATED 14 February 2008 @set UPDATED 25 April 2014
@set UPDATED-MONTH February 2008 @set UPDATED-MONTH April 2014
@set EDITION 3.0.8 @set EDITION 3.1
@set VERSION 3.0.8 @set VERSION 3.1

View File

@ -1,4 +1,4 @@
@set UPDATED 14 February 2008 @set UPDATED 25 April 2014
@set UPDATED-MONTH February 2008 @set UPDATED-MONTH April 2014
@set EDITION 3.0.8 @set EDITION 3.1
@set VERSION 3.0.8 @set VERSION 3.1

View File

@ -17,13 +17,19 @@
/* Define this if you want extra debugging. */ /* Define this if you want extra debugging. */
#undef FFI_DEBUG #undef FFI_DEBUG
/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
#undef FFI_EXEC_TRAMPOLINE_TABLE
/* Define this if you want to enable pax emulated trampolines */
#undef FFI_MMAP_EXEC_EMUTRAMP_PAX
/* Cannot use malloc on this target, so, we revert to alternative means */ /* Cannot use malloc on this target, so, we revert to alternative means */
#undef FFI_MMAP_EXEC_WRIT #undef FFI_MMAP_EXEC_WRIT
/* Define this is you do not want support for the raw API. */ /* Define this if you do not want support for the raw API. */
#undef FFI_NO_RAW_API #undef FFI_NO_RAW_API
/* Define this is you do not want support for aggregate types. */ /* Define this if you do not want support for aggregate types. */
#undef FFI_NO_STRUCTS #undef FFI_NO_STRUCTS
/* Define to 1 if you have `alloca', as a function or macro. */ /* Define to 1 if you have `alloca', as a function or macro. */
@ -67,6 +73,9 @@
/* Define if you have the long double type and it is bigger than a double */ /* Define if you have the long double type and it is bigger than a double */
#undef HAVE_LONG_DOUBLE #undef HAVE_LONG_DOUBLE
/* Define if you support more than one size of the long double type */
#undef HAVE_LONG_DOUBLE_VARIANT
/* Define to 1 if you have the `memcpy' function. */ /* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY #undef HAVE_MEMCPY
@ -116,9 +125,6 @@
*/ */
#undef LT_OBJDIR #undef LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */ /* Name of package */
#undef PACKAGE #undef PACKAGE
@ -146,6 +152,9 @@
/* The size of `long double', as computed by sizeof. */ /* The size of `long double', as computed by sizeof. */
#undef SIZEOF_LONG_DOUBLE #undef SIZEOF_LONG_DOUBLE
/* The size of `size_t', as computed by sizeof. */
#undef SIZEOF_SIZE_T
/* If using the C implementation of alloca, define if you know the /* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be direction of stack growth for your system; otherwise it will be
automatically deduced at runtime. automatically deduced at runtime.
@ -157,6 +166,9 @@
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS #undef STDC_HEADERS
/* Define if symbols are underscored. */
#undef SYMBOL_UNDERSCORE
/* Define this if you are using Purify and want to suppress spurious messages. /* Define this if you are using Purify and want to suppress spurious messages.
*/ */
#undef USING_PURIFY #undef USING_PURIFY
@ -176,6 +188,9 @@
# endif # endif
#endif #endif
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
#ifdef LIBFFI_ASM #ifdef LIBFFI_ASM

View File

@ -0,0 +1,209 @@
#!/usr/bin/env python
import subprocess
import os
import errno
import collections
import glob
import argparse
class Platform(object):
pass
class simulator_platform(Platform):
directory = 'darwin_ios'
sdk = 'iphonesimulator'
arch = 'i386'
triple = 'i386-apple-darwin11'
version_min = '-miphoneos-version-min=5.1.1'
prefix = "#ifdef __i386__\n\n"
suffix = "\n\n#endif"
src_dir = 'x86'
src_files = ['darwin.S', 'win32.S', 'ffi.c']
class simulator64_platform(Platform):
directory = 'darwin_ios'
sdk = 'iphonesimulator'
arch = 'x86_64'
triple = 'x86_64-apple-darwin13'
version_min = '-miphoneos-version-min=7.0'
prefix = "#ifdef __x86_64__\n\n"
suffix = "\n\n#endif"
src_dir = 'x86'
src_files = ['darwin64.S', 'ffi64.c']
class device_platform(Platform):
directory = 'darwin_ios'
sdk = 'iphoneos'
arch = 'armv7'
triple = 'arm-apple-darwin11'
version_min = '-miphoneos-version-min=5.1.1'
prefix = "#ifdef __arm__\n\n"
suffix = "\n\n#endif"
src_dir = 'arm'
src_files = ['sysv.S', 'trampoline.S', 'ffi.c']
class device64_platform(Platform):
directory = 'darwin_ios'
sdk = 'iphoneos'
arch = 'arm64'
triple = 'aarch64-apple-darwin13'
version_min = '-miphoneos-version-min=7.0'
prefix = "#ifdef __arm64__\n\n"
suffix = "\n\n#endif"
src_dir = 'aarch64'
src_files = ['sysv.S', 'ffi.c']
class desktop32_platform(Platform):
directory = 'darwin_osx'
sdk = 'macosx'
arch = 'i386'
triple = 'i386-apple-darwin10'
version_min = '-mmacosx-version-min=10.6'
src_dir = 'x86'
src_files = ['darwin.S', 'win32.S', 'ffi.c']
prefix = "#ifdef __i386__\n\n"
suffix = "\n\n#endif"
class desktop64_platform(Platform):
directory = 'darwin_osx'
sdk = 'macosx'
arch = 'x86_64'
triple = 'x86_64-apple-darwin10'
version_min = '-mmacosx-version-min=10.6'
prefix = "#ifdef __x86_64__\n\n"
suffix = "\n\n#endif"
src_dir = 'x86'
src_files = ['darwin64.S', 'ffi64.c']
def mkdir_p(path):
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST:
pass
else:
raise
def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''):
mkdir_p(dst_dir)
out_filename = filename
if file_suffix:
split_name = os.path.splitext(filename)
out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1])
with open(os.path.join(src_dir, filename)) as in_file:
with open(os.path.join(dst_dir, out_filename), 'w') as out_file:
if prefix:
out_file.write(prefix)
out_file.write(in_file.read())
if suffix:
out_file.write(suffix)
def list_files(src_dir, pattern=None, filelist=None):
if pattern: filelist = glob.iglob(os.path.join(src_dir, pattern))
for file in filelist:
yield os.path.basename(file)
def copy_files(src_dir, dst_dir, pattern=None, filelist=None, file_suffix=None, prefix=None, suffix=None):
for filename in list_files(src_dir, pattern=pattern, filelist=filelist):
move_file(src_dir, dst_dir, filename, file_suffix=file_suffix, prefix=prefix, suffix=suffix)
def copy_src_platform_files(platform):
src_dir = os.path.join('src', platform.src_dir)
dst_dir = os.path.join(platform.directory, 'src', platform.src_dir)
copy_files(src_dir, dst_dir, filelist=platform.src_files, file_suffix=platform.arch, prefix=platform.prefix, suffix=platform.suffix)
def build_target(platform, platform_headers):
def xcrun_cmd(cmd):
return 'xcrun -sdk %s %s -arch %s' % (platform.sdk, cmd, platform.arch)
tag='%s-%s' % (platform.sdk, platform.arch)
build_dir = 'build_%s' % tag
mkdir_p(build_dir)
env = dict(CC=xcrun_cmd('clang'),
LD=xcrun_cmd('ld'),
CFLAGS='%s' % (platform.version_min))
working_dir = os.getcwd()
try:
os.chdir(build_dir)
subprocess.check_call(['../configure', '-host', platform.triple], env=env)
finally:
os.chdir(working_dir)
for src_dir in [build_dir, os.path.join(build_dir, 'include')]:
copy_files(src_dir,
os.path.join(platform.directory, 'include'),
pattern='*.h',
file_suffix=platform.arch,
prefix=platform.prefix,
suffix=platform.suffix)
for filename in list_files(src_dir, pattern='*.h'):
platform_headers[filename].add((platform.prefix, platform.arch, platform.suffix))
def make_tramp():
with open('src/arm/trampoline.S', 'w') as tramp_out:
p = subprocess.Popen(['bash', 'src/arm/gentramp.sh'], stdout=tramp_out)
p.wait()
def generate_source_and_headers(generate_osx=True, generate_ios=True):
copy_files('src', 'darwin_common/src', pattern='*.c')
copy_files('include', 'darwin_common/include', pattern='*.h')
if generate_ios:
make_tramp()
copy_src_platform_files(simulator_platform)
copy_src_platform_files(simulator64_platform)
copy_src_platform_files(device_platform)
copy_src_platform_files(device64_platform)
if generate_osx:
copy_src_platform_files(desktop32_platform)
copy_src_platform_files(desktop64_platform)
platform_headers = collections.defaultdict(set)
if generate_ios:
build_target(simulator_platform, platform_headers)
build_target(simulator64_platform, platform_headers)
build_target(device_platform, platform_headers)
build_target(device64_platform, platform_headers)
if generate_osx:
build_target(desktop32_platform, platform_headers)
build_target(desktop64_platform, platform_headers)
mkdir_p('darwin_common/include')
for header_name, tag_tuples in platform_headers.iteritems():
basename, suffix = os.path.splitext(header_name)
with open(os.path.join('darwin_common/include', header_name), 'w') as header:
for tag_tuple in tag_tuples:
header.write('%s#include <%s_%s%s>\n%s\n' % (tag_tuple[0], basename, tag_tuple[1], suffix, tag_tuple[2]))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--only-ios', action='store_true', default=False)
parser.add_argument('--only-osx', action='store_true', default=False)
args = parser.parse_args()
generate_source_and_headers(generate_osx=not args.only_ios, generate_ios=not args.only_osx)

View File

@ -1,9 +1,8 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am. # Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # Copyright (C) 1994-2013 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved. # with or without modifications, as long as this notice is preserved.
@ -16,6 +15,51 @@
@SET_MAKE@ @SET_MAKE@
VPATH = @srcdir@ VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -36,10 +80,22 @@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
target_triplet = @target@ target_triplet = @target@
subdir = include subdir = include
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(srcdir)/ffi.h.in $(srcdir)/ffi.h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_cc_maxopt.m4 \
$(top_srcdir)/m4/ax_cflags_warn_all.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_compiler_vendor.m4 \
$(top_srcdir)/m4/ax_configure_args.m4 \
$(top_srcdir)/m4/ax_enable_builddir.m4 \
$(top_srcdir)/m4/ax_gcc_archflag.m4 \
$(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
@ -47,8 +103,25 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/fficonfig.h CONFIG_HEADER = $(top_builddir)/fficonfig.h
CONFIG_CLEAN_FILES = ffi.h ffitarget.h CONFIG_CLEAN_FILES = ffi.h ffitarget.h
CONFIG_CLEAN_VPATH_FILES = CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES = SOURCES =
DIST_SOURCES = DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \ am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@ -70,14 +143,38 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \ am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(includesdir)" am__installdirs = "$(DESTDIR)$(includesdir)"
HEADERS = $(nodist_includes_HEADERS) HEADERS = $(nodist_includes_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@ ALLOCA = @ALLOCA@
AMTAR = @AMTAR@ AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LTLDFLAGS = @AM_LTLDFLAGS@ AM_LTLDFLAGS = @AM_LTLDFLAGS@
AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@ AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
AR = @AR@ AR = @AR@
@ -93,9 +190,14 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
CPP = @CPP@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@ CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@ CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@ DEFS = @DEFS@
DEPDIR = @DEPDIR@ DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@ DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@ DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@ ECHO_C = @ECHO_C@
@ -103,9 +205,11 @@ 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@
HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
@ -121,6 +225,7 @@ LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@ LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@ MKDIR_P = @MKDIR_P@
NM = @NM@ NM = @NM@
NMEDIT = @NMEDIT@ NMEDIT = @NMEDIT@
@ -136,6 +241,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@ PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@ PATH_SEPARATOR = @PATH_SEPARATOR@
PRTDIAG = @PRTDIAG@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
SED = @SED@ SED = @SED@
SET_MAKE = @SET_MAKE@ SET_MAKE = @SET_MAKE@
@ -148,13 +254,16 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@ abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@ abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@ ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@ am__include = @am__include@
am__leading_dot = @am__leading_dot@ am__leading_dot = @am__leading_dot@
am__quote = @am__quote@ am__quote = @am__quote@
am__tar = @am__tar@ am__tar = @am__tar@
am__untar = @am__untar@ am__untar = @am__untar@
ax_enable_builddir_sed = @ax_enable_builddir_sed@
bindir = @bindir@ bindir = @bindir@
build = @build@ build = @build@
build_alias = @build_alias@ build_alias = @build_alias@
@ -180,7 +289,6 @@ libdir = @libdir@
libexecdir = @libexecdir@ libexecdir = @libexecdir@
localedir = @localedir@ localedir = @localedir@
localstatedir = @localstatedir@ localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@ mandir = @mandir@
mkdir_p = @mkdir_p@ mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@ oldincludedir = @oldincludedir@
@ -191,6 +299,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@
@ -250,8 +359,11 @@ clean-libtool:
-rm -rf .libs _libs -rm -rf .libs _libs
install-nodist_includesHEADERS: $(nodist_includes_HEADERS) install-nodist_includesHEADERS: $(nodist_includes_HEADERS)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
test -z "$(includesdir)" || $(MKDIR_P) "$(DESTDIR)$(includesdir)"
@list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \ @list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(includesdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(includesdir)" || exit 1; \
fi; \
for p in $$list; do \ for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \ echo "$$d$$p"; \
@ -265,30 +377,17 @@ uninstall-nodist_includesHEADERS:
@$(NORMAL_UNINSTALL) @$(NORMAL_UNINSTALL)
@list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \ @list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
test -n "$$files" || exit 0; \ dir='$(DESTDIR)$(includesdir)'; $(am__uninstall_files_from_dir)
echo " ( cd '$(DESTDIR)$(includesdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(includesdir)" && rm -f $$files
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) ID: $(am__tagged_files)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ $(am__define_uniq_tagged_files); mkid -fID $$unique
unique=`for i in $$list; do \ tags: tags-am
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ TAGS: tags
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(TAGS_FILES) $(LISP)
set x; \ set x; \
here=`pwd`; \ here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ $(am__define_uniq_tagged_files); \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \ shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \ test -n "$$unique" || unique=$$empty_fix; \
@ -300,15 +399,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$unique; \ $$unique; \
fi; \ fi; \
fi fi
ctags: CTAGS ctags: ctags-am
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP) CTAGS: ctags
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
unique=`for i in $$list; do \ $(am__define_uniq_tagged_files); \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \ test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique $$unique
@ -317,6 +412,21 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \ here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \ && $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here" && gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags: distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@ -368,10 +478,15 @@ install-am: all-am
installcheck: installcheck-am installcheck: installcheck-am
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ if test -z '$(STRIP)'; then \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
`test -z '$(STRIP)' || \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic: mostlyclean-generic:
clean-generic: clean-generic:
@ -452,18 +567,19 @@ uninstall-am: uninstall-nodist_includesHEADERS
.MAKE: install-am install-strip .MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool ctags distclean distclean-generic \ clean-libtool cscopelist-am ctags ctags-am distclean \
distclean-libtool distclean-tags distdir dvi dvi-am html \ distclean-generic distclean-libtool distclean-tags distdir dvi \
html-am info info-am install install-am install-data \ dvi-am html html-am info info-am install install-am \
install-data-am install-dvi install-dvi-am install-exec \ install-data install-data-am install-dvi install-dvi-am \
install-exec-am install-html install-html-am install-info \ install-exec install-exec-am install-html install-html-am \
install-info-am install-man install-nodist_includesHEADERS \ install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \ install-nodist_includesHEADERS install-pdf install-pdf-am \
install-strip installcheck installcheck-am installdirs \ install-ps install-ps-am install-strip installcheck \
maintainer-clean maintainer-clean-generic mostlyclean \ installcheck-am installdirs maintainer-clean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ maintainer-clean-generic mostlyclean mostlyclean-generic \
tags uninstall uninstall-am uninstall-nodist_includesHEADERS mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-nodist_includesHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.

View File

@ -1,16 +1,17 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
libffi @VERSION@ - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. libffi @VERSION@ - Copyright (c) 2011 Anthony Green
- Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person
a copy of this software and associated documentation files (the obtaining a copy of this software and associated documentation
``Software''), to deal in the Software without restriction, including files (the ``Software''), to deal in the Software without
without limitation the rights to use, copy, modify, merge, publish, restriction, including without limitation the rights to use, copy,
distribute, sublicense, and/or sell copies of the Software, and to modify, merge, publish, distribute, sublicense, and/or sell copies
permit persons to whom the Software is furnished to do so, subject to of the Software, and to permit persons to whom the Software is
the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included The above copyright notice and this permission notice shall be
in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@ -85,11 +86,15 @@ extern "C" {
#else #else
# ifdef LLONG_MAX # ifdef LLONG_MAX
# define FFI_LONG_LONG_MAX LLONG_MAX # define FFI_LONG_LONG_MAX LLONG_MAX
# ifdef _AIX52 /* or newer has C99 LLONG_MAX */
# undef FFI_64_BIT_MAX
# define FFI_64_BIT_MAX 9223372036854775807LL
# endif /* _AIX52 or newer */
# else # else
# ifdef __GNUC__ # ifdef __GNUC__
# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ # define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
# endif # endif
# ifdef _AIX # ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */
# ifndef __PPC64__ # ifndef __PPC64__
# if defined (__IBMC__) || defined (__IBMCPP__) # if defined (__IBMC__) || defined (__IBMCPP__)
# define FFI_LONG_LONG_MAX LONGLONG_MAX # define FFI_LONG_LONG_MAX LONGLONG_MAX
@ -161,22 +166,36 @@ typedef struct _ffi_type
#error "long size not supported" #error "long size not supported"
#endif #endif
/* Need minimal decorations for DLLs to works on Windows. */
/* GCC has autoimport and autoexport. Rely on Libtool to */
/* help MSVC export from a DLL, but always declare data */
/* to be imported for MSVC clients. This costs an extra */
/* indirection for MSVC clients using the static version */
/* of the library, but don't worry about that. Besides, */
/* as a workaround, they can define FFI_BUILDING if they */
/* *know* they are going to link with the static library. */
#if defined _MSC_VER && !defined FFI_BUILDING
#define FFI_EXTERN extern __declspec(dllimport)
#else
#define FFI_EXTERN extern
#endif
/* These are defined in types.c */ /* These are defined in types.c */
extern ffi_type ffi_type_void; FFI_EXTERN ffi_type ffi_type_void;
extern ffi_type ffi_type_uint8; FFI_EXTERN ffi_type ffi_type_uint8;
extern ffi_type ffi_type_sint8; FFI_EXTERN ffi_type ffi_type_sint8;
extern ffi_type ffi_type_uint16; FFI_EXTERN ffi_type ffi_type_uint16;
extern ffi_type ffi_type_sint16; FFI_EXTERN ffi_type ffi_type_sint16;
extern ffi_type ffi_type_uint32; FFI_EXTERN ffi_type ffi_type_uint32;
extern ffi_type ffi_type_sint32; FFI_EXTERN ffi_type ffi_type_sint32;
extern ffi_type ffi_type_uint64; FFI_EXTERN ffi_type ffi_type_uint64;
extern ffi_type ffi_type_sint64; FFI_EXTERN ffi_type ffi_type_sint64;
extern ffi_type ffi_type_float; FFI_EXTERN ffi_type ffi_type_float;
extern ffi_type ffi_type_double; FFI_EXTERN ffi_type ffi_type_double;
extern ffi_type ffi_type_pointer; FFI_EXTERN ffi_type ffi_type_pointer;
#if @HAVE_LONG_DOUBLE@ #if @HAVE_LONG_DOUBLE@
extern ffi_type ffi_type_longdouble; FFI_EXTERN ffi_type ffi_type_longdouble;
#else #else
#define ffi_type_longdouble ffi_type_double #define ffi_type_longdouble ffi_type_double
#endif #endif
@ -202,6 +221,20 @@ typedef struct {
#endif #endif
} ffi_cif; } ffi_cif;
#if HAVE_LONG_DOUBLE_VARIANT
/* Used to adjust size/alignment of ffi types. */
void ffi_prep_types (ffi_abi abi);
# endif
/* Used internally, but overridden by some architectures */
ffi_status ffi_prep_cif_core(ffi_cif *cif,
ffi_abi abi,
unsigned int isvariadic,
unsigned int nfixedargs,
unsigned int ntotalargs,
ffi_type *rtype,
ffi_type **atypes);
/* ---- Definitions for the raw API -------------------------------------- */ /* ---- Definitions for the raw API -------------------------------------- */
#ifndef FFI_SIZEOF_ARG #ifndef FFI_SIZEOF_ARG
@ -269,7 +302,12 @@ size_t ffi_java_raw_size (ffi_cif *cif);
__declspec(align(8)) __declspec(align(8))
#endif #endif
typedef struct { typedef struct {
#if @FFI_EXEC_TRAMPOLINE_TABLE@
void *trampoline_table;
void *trampoline_table_entry;
#else
char tramp[FFI_TRAMPOLINE_SIZE]; char tramp[FFI_TRAMPOLINE_SIZE];
#endif
ffi_cif *cif; ffi_cif *cif;
void (*fun)(ffi_cif*,void*,void**,void*); void (*fun)(ffi_cif*,void*,void**,void*);
void *user_data; void *user_data;
@ -277,6 +315,9 @@ typedef struct {
} ffi_closure __attribute__((aligned (8))); } ffi_closure __attribute__((aligned (8)));
#else #else
} ffi_closure; } ffi_closure;
# ifdef __sgi
# pragma pack 0
# endif
#endif #endif
void *ffi_closure_alloc (size_t size, void **code); void *ffi_closure_alloc (size_t size, void **code);
@ -295,9 +336,16 @@ ffi_prep_closure_loc (ffi_closure*,
void *user_data, void *user_data,
void*codeloc); void*codeloc);
#ifdef __sgi
# pragma pack 8
#endif
typedef struct { typedef struct {
#if @FFI_EXEC_TRAMPOLINE_TABLE@
void *trampoline_table;
void *trampoline_table_entry;
#else
char tramp[FFI_TRAMPOLINE_SIZE]; char tramp[FFI_TRAMPOLINE_SIZE];
#endif
ffi_cif *cif; ffi_cif *cif;
#if !FFI_NATIVE_RAW_API #if !FFI_NATIVE_RAW_API
@ -317,7 +365,12 @@ typedef struct {
} ffi_raw_closure; } ffi_raw_closure;
typedef struct { typedef struct {
#if @FFI_EXEC_TRAMPOLINE_TABLE@
void *trampoline_table;
void *trampoline_table_entry;
#else
char tramp[FFI_TRAMPOLINE_SIZE]; char tramp[FFI_TRAMPOLINE_SIZE];
#endif
ffi_cif *cif; ffi_cif *cif;
@ -373,6 +426,13 @@ ffi_status ffi_prep_cif(ffi_cif *cif,
ffi_type *rtype, ffi_type *rtype,
ffi_type **atypes); ffi_type **atypes);
ffi_status ffi_prep_cif_var(ffi_cif *cif,
ffi_abi abi,
unsigned int nfixedargs,
unsigned int ntotalargs,
ffi_type *rtype,
ffi_type **atypes);
void ffi_call(ffi_cif *cif, void ffi_call(ffi_cif *cif,
void (*fn)(void), void (*fn)(void),
void *rvalue, void *rvalue,

View File

@ -1,7 +1,8 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi_common.h - Copyright (c) 1996 Red Hat, Inc. ffi_common.h - Copyright (C) 2011, 2012, 2013 Anthony Green
Copyright (C) 2007 Free Software Foundation, Inc Copyright (C) 2007 Free Software Foundation, Inc
Copyright (c) 1996 Red Hat, Inc.
Common internal definitions and macros. Only necessary for building Common internal definitions and macros. Only necessary for building
libffi. libffi.
----------------------------------------------------------------------- */ ----------------------------------------------------------------------- */
@ -18,10 +19,14 @@ extern "C" {
/* Do not move this. Some versions of AIX are very picky about where /* Do not move this. Some versions of AIX are very picky about where
this is positioned. */ this is positioned. */
#ifdef __GNUC__ #ifdef __GNUC__
/* mingw64 defines this already in malloc.h. */ # if HAVE_ALLOCA_H
#ifndef alloca # include <alloca.h>
# define alloca __builtin_alloca # else
#endif /* mingw64 defines this already in malloc.h. */
# ifndef alloca
# define alloca __builtin_alloca
# endif
# endif
# define MAYBE_UNUSED __attribute__((__unused__)) # define MAYBE_UNUSED __attribute__((__unused__))
#else #else
# define MAYBE_UNUSED # define MAYBE_UNUSED
@ -29,17 +34,17 @@ extern "C" {
# include <alloca.h> # include <alloca.h>
# else # else
# ifdef _AIX # ifdef _AIX
#pragma alloca # pragma alloca
# else # else
# ifndef alloca /* predefined by HP cc +Olibcalls */ # ifndef alloca /* predefined by HP cc +Olibcalls */
# ifdef _MSC_VER # ifdef _MSC_VER
# define alloca _alloca # define alloca _alloca
# else # else
char *alloca (); char *alloca ();
# endif
# endif # endif
# endif # endif
# endif # endif
# endif
#endif #endif
/* Check for the existence of memcpy. */ /* Check for the existence of memcpy. */
@ -74,6 +79,8 @@ void ffi_type_test(ffi_type *a, char *file, int line);
/* Perform machine dependent cif processing */ /* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif); ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
unsigned int nfixedargs, unsigned int ntotalargs);
/* Extended cif, used in callback from assembly routine */ /* Extended cif, used in callback from assembly routine */
typedef struct typedef struct
@ -84,7 +91,7 @@ typedef struct
} extended_cif; } extended_cif;
/* Terse sized type definitions. */ /* Terse sized type definitions. */
#if defined(_MSC_VER) || defined(__sgi) #if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C)
typedef unsigned char UINT8; typedef unsigned char UINT8;
typedef signed char SINT8; typedef signed char SINT8;
typedef unsigned short UINT16; typedef unsigned short UINT16;
@ -112,11 +119,14 @@ typedef signed int SINT64 __attribute__((__mode__(__DI__)));
typedef float FLOAT32; typedef float FLOAT32;
#ifndef __GNUC__
#define __builtin_expect(x, expected_value) (x)
#endif
#define LIKELY(x) __builtin_expect(!!(x),1)
#define UNLIKELY(x) __builtin_expect((x)!=0,0)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# install - install a program, script, or datafile # install - install a program, script, or datafile
scriptversion=2004-12-17.09 scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was # This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the # later released in X11R6 (xc/config/util/install.sh) with the
@ -35,42 +35,72 @@ scriptversion=2004-12-17.09
# FSF changes to this file are in the public domain. # FSF changes to this file are in the public domain.
# #
# Calling this script install-sh is preferred over install.sh, to prevent # Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it # 'make' implicit rules from creating a file called install from it
# when there is no Makefile. # when there is no Makefile.
# #
# This script is compatible with the BSD install script, but was written # This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction # from scratch.
# shared with many OS's install programs.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script # set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it. # Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}" doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# put in absolute paths if you don't have them in your path; or use env. vars. # Put in absolute file names if you don't have them in your path;
# or use environment vars.
mvprog="${MVPROG-mv}" chgrpprog=${CHGRPPROG-chgrp}
cpprog="${CPPROG-cp}" chmodprog=${CHMODPROG-chmod}
chmodprog="${CHMODPROG-chmod}" chownprog=${CHOWNPROG-chown}
chownprog="${CHOWNPROG-chown}" cmpprog=${CMPPROG-cmp}
chgrpprog="${CHGRPPROG-chgrp}" cpprog=${CPPROG-cp}
stripprog="${STRIPPROG-strip}" mkdirprog=${MKDIRPROG-mkdir}
rmprog="${RMPROG-rm}" mvprog=${MVPROG-mv}
mkdirprog="${MKDIRPROG-mkdir}" rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd= chgrpcmd=
stripcmd= chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f" rmcmd="$rmprog -f"
mvcmd="$mvprog" stripcmd=
src= src=
dst= dst=
dir_arg= dir_arg=
dstarg= dst_arg=
copy_on_change=false
no_target_directory= no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES... or: $0 [OPTION]... -d DIRECTORIES...
@ -80,108 +110,148 @@ In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES. In the 4th, create DIRECTORIES.
Options: Options:
-c (ignored) --help display this help and exit.
-d create directories instead of installing files. --version display version info and exit.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE. -c (ignored)
-o USER $chownprog installed files to USER. -C install only if different (preserve the last data modification time)
-s $stripprog installed files. -d create directories instead of installing files.
-t DIRECTORY install into DIRECTORY. -g GROUP $chgrpprog installed files to GROUP.
-T report an error if DSTFILE is a directory. -m MODE $chmodprog installed files to MODE.
--help display this help and exit. -o USER $chownprog installed files to USER.
--version display version info and exit. -s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands: Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
" "
while test -n "$1"; do while test $# -ne 0; do
case $1 in case $1 in
-c) shift -c) ;;
continue;;
-d) dir_arg=true -C) copy_on_change=true;;
shift
continue;; -d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2" -g) chgrpcmd="$chgrpprog $2"
shift shift;;
shift
continue;;
--help) echo "$usage"; exit 0;; --help) echo "$usage"; exit $?;;
-m) chmodcmd="$chmodprog $2" -m) mode=$2
shift case $mode in
shift *' '* | *' '* | *'
continue;; '* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2" -o) chowncmd="$chownprog $2"
shift shift;;
shift
continue;;
-s) stripcmd=$stripprog -s) stripcmd=$stripprog;;
shift
continue;;
-t) dstarg=$2 -t) dst_arg=$2
shift # Protect names problematic for 'test' and other utilities.
shift case $dst_arg in
continue;; -* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true -T) no_target_directory=true;;
shift
continue;;
--version) echo "$0 $scriptversion"; exit 0;; --version) echo "$0 $scriptversion"; exit $?;;
*) # When -d is used, all remaining arguments are directories to create. --) shift
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;; break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac esac
shift
done done
if test -z "$1"; then if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2 echo "$0: no input file specified." >&2
exit 1 exit 1
fi fi
# It's OK to call `install-sh -d' without argument. # It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories. # This can happen when creating conditional directories.
exit 0 exit 0
fi fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src for src
do do
# Protect names starting with `-'. # Protect names problematic for 'test' and other utilities.
case $src in case $src in
-*) src=./$src ;; -* | [=\(\)!]) src=./$src;;
esac esac
if test -n "$dir_arg"; then if test -n "$dir_arg"; then
dst=$src dst=$src
src= dstdir=$dst
test -d "$dstdir"
if test -d "$dst"; then dstdir_status=$?
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad # might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'. # if $src (and thus $dsttmp) contains '*'.
@ -190,71 +260,194 @@ do
exit 1 exit 1
fi fi
if test -z "$dstarg"; then if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2 echo "$0: no destination specified." >&2
exit 1 exit 1
fi fi
dst=$dst_arg
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work # If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored. # if double slashes aren't ignored.
if test -d "$dst"; then if test -d "$dst"; then
if test -n "$no_target_directory"; then if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2 echo "$0: $dst_arg: Is a directory" >&2
exit 1 exit 1
fi fi
dst=$dst/`basename "$src"` dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi fi
fi fi
# This sed command emulates the dirname command. obsolete_mkdir_used=false
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
# Make sure that the destination directory exists. if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
# Skip lots of stat calls in the usual case. *[0-7])
if test ! -d "$dstdir"; then mkdir_umask=`expr $umask + 22 \
defaultIFS=' - $umask % 100 % 40 + $umask % 20 \
' - $umask % 10 % 4 + $umask % 2
IFS="${IFS-$defaultIFS}" `;;
*) mkdir_umask=$umask,go-w;;
esac
oIFS=$IFS # With -d, create the new directory with the user-specified mode.
# Some sh's can't handle IFS=/ for some reason. # Otherwise, rely on $mkdir_umask.
IFS='%' if test -n "$dir_arg"; then
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` mkdir_mode=-m$mode
shift else
IFS=$oIFS mkdir_mode=
fi
pathcomp= posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
while test $# -ne 0 ; do if (umask $mkdir_umask &&
pathcomp=$pathcomp$1 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift shift
if test ! -d "$pathcomp"; then $posix_glob set +f
$mkdirprog "$pathcomp" IFS=$oIFS
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This prefixes=
# is OK.
test -d "$pathcomp" || exit for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi fi
pathcomp=$pathcomp/ fi
done
fi fi
if test -n "$dir_arg"; then if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory. # Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_ dsttmp=$dstdir/_inst.$$_
@ -262,10 +455,9 @@ do
# Trap to clean up those temp files at exit. # Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name. # Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" && (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits. # and set any options; do chmod last to preserve setuid bits.
# #
@ -273,51 +465,63 @@ do
# ignore errors from any of these, just make sure not to ignore # ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command. # errors from the above "$doit $cpprog $src $dsttmp" command.
# #
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# Now rename the file to the real destination. # If -C, don't bother to copy if it wouldn't change the file.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ if $copy_on_change &&
|| { old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
# The rename failed, perhaps because mv can't rename something else new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location. eval "$initialize_posix_glob" &&
# We try this two ways since rm can't unlink itself on some $posix_glob set -f &&
# systems and the destination file might be busy for other set X $old && old=:$2:$4:$5:$6 &&
# reasons. In this case, the final cleanup might fail but the new set X $new && new=:$2:$4:$5:$6 &&
# file should still install successfully. $posix_glob set +f &&
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination. test "$old" = "$new" &&
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile" $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
} then
} rm -f "$dsttmp"
fi || { (exit 1); exit 1; } else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit 0
}
# Local variables: # Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$" # time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End: # End:

View File

@ -1,10 +1,11 @@
prefix=@prefix@ prefix=@prefix@
exec_prefix=@exec_prefix@ exec_prefix=@exec_prefix@
libdir=@libdir@ libdir=@libdir@
toolexeclibdir=@toolexeclibdir@
includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
Name: @PACKAGE_NAME@ Name: @PACKAGE_NAME@
Description: Library supporting Foreign Function Interfaces Description: Library supporting Foreign Function Interfaces
Version: @PACKAGE_VERSION@ Version: @PACKAGE_VERSION@
Libs: -L${libdir} -lffi Libs: -L${toolexeclibdir} -lffi
Cflags: -I${includedir} Cflags: -I${includedir}

View File

@ -0,0 +1,637 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
DBFA714A187F1D8600A76262 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; };
DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713F187F1D8600A76262 /* ffi_common.h */; };
DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7140187F1D8600A76262 /* fficonfig.h */; };
DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7141187F1D8600A76262 /* ffitarget.h */; };
DBFA714E187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; };
DBFA714F187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; };
DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; };
DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; };
DBFA7158187F1D8600A76262 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; };
DBFA7159187F1D8600A76262 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; };
DBFA715A187F1D8600A76262 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; };
DBFA715B187F1D8600A76262 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; };
DBFA7177187F1D9B00A76262 /* ffi_arm64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716C187F1D9B00A76262 /* ffi_arm64.c */; };
DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716D187F1D9B00A76262 /* sysv_arm64.S */; };
DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716F187F1D9B00A76262 /* ffi_armv7.c */; };
DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7170187F1D9B00A76262 /* sysv_armv7.S */; };
DBFA717B187F1D9B00A76262 /* trampoline_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */; };
DBFA717C187F1D9B00A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */; };
DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7174187F1D9B00A76262 /* darwin_i386.S */; };
DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */; };
DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7176187F1D9B00A76262 /* ffi_i386.c */; };
DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7182187F1DA100A76262 /* ffi_i386.h */; };
DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7183187F1DA100A76262 /* ffi_x86_64.h */; };
DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7184187F1DA100A76262 /* fficonfig_i386.h */; };
DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */; };
DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7186187F1DA100A76262 /* ffitarget_i386.h */; };
DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */; };
DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */; };
DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718B187F1DA100A76262 /* darwin_i386.S */; };
DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */; };
DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718D187F1DA100A76262 /* ffi_i386.c */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
DB13B1641849DF1E0010F42D /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 8;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
DB13B1661849DF1E0010F42D /* libffi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; };
DB13B1911849DF510010F42D /* ffi.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = ffi.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
DBFA713E187F1D8600A76262 /* ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi.h; sourceTree = "<group>"; };
DBFA713F187F1D8600A76262 /* ffi_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_common.h; sourceTree = "<group>"; };
DBFA7140187F1D8600A76262 /* fficonfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig.h; sourceTree = "<group>"; };
DBFA7141187F1D8600A76262 /* ffitarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget.h; sourceTree = "<group>"; };
DBFA7143187F1D8600A76262 /* closures.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = closures.c; sourceTree = "<group>"; };
DBFA7145187F1D8600A76262 /* dlmalloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dlmalloc.c; sourceTree = "<group>"; };
DBFA7147187F1D8600A76262 /* prep_cif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = prep_cif.c; sourceTree = "<group>"; };
DBFA7148187F1D8600A76262 /* raw_api.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = raw_api.c; sourceTree = "<group>"; };
DBFA7149187F1D8600A76262 /* types.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = types.c; sourceTree = "<group>"; };
DBFA715E187F1D9B00A76262 /* ffi_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_arm64.h; sourceTree = "<group>"; };
DBFA715F187F1D9B00A76262 /* ffi_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_armv7.h; sourceTree = "<group>"; };
DBFA7160187F1D9B00A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = "<group>"; };
DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = "<group>"; };
DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_arm64.h; sourceTree = "<group>"; };
DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_armv7.h; sourceTree = "<group>"; };
DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = "<group>"; };
DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = "<group>"; };
DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_arm64.h; sourceTree = "<group>"; };
DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_armv7.h; sourceTree = "<group>"; };
DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = "<group>"; };
DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = "<group>"; };
DBFA716C187F1D9B00A76262 /* ffi_arm64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_arm64.c; sourceTree = "<group>"; };
DBFA716D187F1D9B00A76262 /* sysv_arm64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_arm64.S; sourceTree = "<group>"; };
DBFA716F187F1D9B00A76262 /* ffi_armv7.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_armv7.c; sourceTree = "<group>"; };
DBFA7170187F1D9B00A76262 /* sysv_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_armv7.S; sourceTree = "<group>"; };
DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = trampoline_armv7.S; sourceTree = "<group>"; };
DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64_x86_64.S; sourceTree = "<group>"; };
DBFA7174187F1D9B00A76262 /* darwin_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin_i386.S; sourceTree = "<group>"; };
DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = "<group>"; };
DBFA7176187F1D9B00A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = "<group>"; };
DBFA7182187F1DA100A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = "<group>"; };
DBFA7183187F1DA100A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = "<group>"; };
DBFA7184187F1DA100A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = "<group>"; };
DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = "<group>"; };
DBFA7186187F1DA100A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = "<group>"; };
DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = "<group>"; };
DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64_x86_64.S; sourceTree = "<group>"; };
DBFA718B187F1DA100A76262 /* darwin_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin_i386.S; sourceTree = "<group>"; };
DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = "<group>"; };
DBFA718D187F1DA100A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXGroup section */
DB13B15B1849DEB70010F42D = {
isa = PBXGroup;
children = (
DBFA713C187F1D8600A76262 /* darwin_common */,
DBFA715C187F1D9B00A76262 /* darwin_ios */,
DBFA7180187F1DA100A76262 /* darwin_osx */,
DB13B1671849DF1E0010F42D /* Products */,
);
sourceTree = "<group>";
};
DB13B1671849DF1E0010F42D /* Products */ = {
isa = PBXGroup;
children = (
DB13B1661849DF1E0010F42D /* libffi.a */,
DB13B1911849DF510010F42D /* ffi.dylib */,
);
name = Products;
sourceTree = "<group>";
};
DBFA713C187F1D8600A76262 /* darwin_common */ = {
isa = PBXGroup;
children = (
DBFA713D187F1D8600A76262 /* include */,
DBFA7142187F1D8600A76262 /* src */,
);
path = "darwin_common";
sourceTree = "<group>";
};
DBFA713D187F1D8600A76262 /* include */ = {
isa = PBXGroup;
children = (
DBFA713E187F1D8600A76262 /* ffi.h */,
DBFA713F187F1D8600A76262 /* ffi_common.h */,
DBFA7140187F1D8600A76262 /* fficonfig.h */,
DBFA7141187F1D8600A76262 /* ffitarget.h */,
);
path = include;
sourceTree = "<group>";
};
DBFA7142187F1D8600A76262 /* src */ = {
isa = PBXGroup;
children = (
DBFA7143187F1D8600A76262 /* closures.c */,
DBFA7145187F1D8600A76262 /* dlmalloc.c */,
DBFA7147187F1D8600A76262 /* prep_cif.c */,
DBFA7148187F1D8600A76262 /* raw_api.c */,
DBFA7149187F1D8600A76262 /* types.c */,
);
path = src;
sourceTree = "<group>";
};
DBFA715C187F1D9B00A76262 /* darwin_ios */ = {
isa = PBXGroup;
children = (
DBFA715D187F1D9B00A76262 /* include */,
DBFA716A187F1D9B00A76262 /* src */,
);
path = "darwin_ios";
sourceTree = "<group>";
};
DBFA715D187F1D9B00A76262 /* include */ = {
isa = PBXGroup;
children = (
DBFA715E187F1D9B00A76262 /* ffi_arm64.h */,
DBFA715F187F1D9B00A76262 /* ffi_armv7.h */,
DBFA7160187F1D9B00A76262 /* ffi_i386.h */,
DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */,
DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */,
DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */,
DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */,
DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */,
DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */,
DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */,
DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */,
DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */,
);
path = include;
sourceTree = "<group>";
};
DBFA716A187F1D9B00A76262 /* src */ = {
isa = PBXGroup;
children = (
DBFA716B187F1D9B00A76262 /* aarch64 */,
DBFA716E187F1D9B00A76262 /* arm */,
DBFA7172187F1D9B00A76262 /* x86 */,
);
path = src;
sourceTree = "<group>";
};
DBFA716B187F1D9B00A76262 /* aarch64 */ = {
isa = PBXGroup;
children = (
DBFA716C187F1D9B00A76262 /* ffi_arm64.c */,
DBFA716D187F1D9B00A76262 /* sysv_arm64.S */,
);
path = aarch64;
sourceTree = "<group>";
};
DBFA716E187F1D9B00A76262 /* arm */ = {
isa = PBXGroup;
children = (
DBFA716F187F1D9B00A76262 /* ffi_armv7.c */,
DBFA7170187F1D9B00A76262 /* sysv_armv7.S */,
DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */,
);
path = arm;
sourceTree = "<group>";
};
DBFA7172187F1D9B00A76262 /* x86 */ = {
isa = PBXGroup;
children = (
DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */,
DBFA7174187F1D9B00A76262 /* darwin_i386.S */,
DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */,
DBFA7176187F1D9B00A76262 /* ffi_i386.c */,
);
path = x86;
sourceTree = "<group>";
};
DBFA7180187F1DA100A76262 /* darwin_osx */ = {
isa = PBXGroup;
children = (
DBFA7181187F1DA100A76262 /* include */,
DBFA7188187F1DA100A76262 /* src */,
);
path = "darwin_osx";
sourceTree = "<group>";
};
DBFA7181187F1DA100A76262 /* include */ = {
isa = PBXGroup;
children = (
DBFA7182187F1DA100A76262 /* ffi_i386.h */,
DBFA7183187F1DA100A76262 /* ffi_x86_64.h */,
DBFA7184187F1DA100A76262 /* fficonfig_i386.h */,
DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */,
DBFA7186187F1DA100A76262 /* ffitarget_i386.h */,
DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */,
);
path = include;
sourceTree = "<group>";
};
DBFA7188187F1DA100A76262 /* src */ = {
isa = PBXGroup;
children = (
DBFA7189187F1DA100A76262 /* x86 */,
);
path = src;
sourceTree = "<group>";
};
DBFA7189187F1DA100A76262 /* x86 */ = {
isa = PBXGroup;
children = (
DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */,
DBFA718B187F1DA100A76262 /* darwin_i386.S */,
DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */,
DBFA718D187F1DA100A76262 /* ffi_i386.c */,
);
path = x86;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
DB13B18F1849DF510010F42D /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */,
DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */,
DBFA714A187F1D8600A76262 /* ffi.h in Headers */,
DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */,
DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */,
DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */,
DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */,
DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */,
DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */,
DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
DB13B1651849DF1E0010F42D /* libffi-iOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = DB13B18B1849DF1E0010F42D /* Build configuration list for PBXNativeTarget "libffi-iOS" */;
buildPhases = (
DB13B3051849E01C0010F42D /* ShellScript */,
DB13B1621849DF1E0010F42D /* Sources */,
DB13B1641849DF1E0010F42D /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = "libffi-iOS";
productName = ffi;
productReference = DB13B1661849DF1E0010F42D /* libffi.a */;
productType = "com.apple.product-type.library.static";
};
DB13B1901849DF510010F42D /* libffi-Mac */ = {
isa = PBXNativeTarget;
buildConfigurationList = DB13B1B01849DF520010F42D /* Build configuration list for PBXNativeTarget "libffi-Mac" */;
buildPhases = (
DB13B3061849E0490010F42D /* ShellScript */,
DB13B18D1849DF510010F42D /* Sources */,
DB13B18F1849DF510010F42D /* Headers */,
);
buildRules = (
);
dependencies = (
);
name = "libffi-Mac";
productName = ffi;
productReference = DB13B1911849DF510010F42D /* ffi.dylib */;
productType = "com.apple.product-type.library.dynamic";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
DB13B15C1849DEB70010F42D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0510;
};
buildConfigurationList = DB13B15F1849DEB70010F42D /* Build configuration list for PBXProject "libffi" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = DB13B15B1849DEB70010F42D;
productRefGroup = DB13B1671849DF1E0010F42D /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
DB13B1651849DF1E0010F42D /* libffi-iOS */,
DB13B1901849DF510010F42D /* libffi-Mac */,
);
};
/* End PBXProject section */
/* Begin PBXShellScriptBuildPhase section */
DB13B3051849E01C0010F42D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/usr/bin/python generate-darwin-source-and-headers.py --only-ios";
};
DB13B3061849E0490010F42D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/usr/bin/python generate-darwin-source-and-headers.py --only-osx";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
DB13B1621849DF1E0010F42D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */,
DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */,
DBFA717B187F1D9B00A76262 /* trampoline_armv7.S in Sources */,
DBFA714E187F1D8600A76262 /* closures.c in Sources */,
DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */,
DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */,
DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */,
DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */,
DBFA7158187F1D8600A76262 /* raw_api.c in Sources */,
DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */,
DBFA717C187F1D9B00A76262 /* darwin64_x86_64.S in Sources */,
DBFA715A187F1D8600A76262 /* types.c in Sources */,
DBFA7177187F1D9B00A76262 /* ffi_arm64.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DB13B18D1849DF510010F42D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */,
DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */,
DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */,
DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */,
DBFA715B187F1D8600A76262 /* types.c in Sources */,
DBFA7159187F1D8600A76262 /* raw_api.c in Sources */,
DBFA714F187F1D8600A76262 /* closures.c in Sources */,
DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
DB13B1601849DEB70010F42D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(inherited)",
"darwin_common/include",
);
ONLY_ACTIVE_ARCH = YES;
};
name = Debug;
};
DB13B1611849DEB70010F42D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(inherited)",
"darwin_common/include",
);
};
name = Release;
};
DB13B1871849DF1E0010F42D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DSTROOT = /tmp/ffi.dst;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"darwin_ios/include",
);
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
"IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = ffi;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
};
name = Debug;
};
DB13B1881849DF1E0010F42D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DSTROOT = /tmp/ffi.dst;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"darwin_ios/include",
);
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
"IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = ffi;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
DB13B1B11849DF520010F42D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"darwin_osx/include",
);
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-Wl,-no_compact_unwind";
PRODUCT_NAME = ffi;
SDKROOT = macosx;
};
name = Debug;
};
DB13B1B21849DF520010F42D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
"darwin_osx/include",
);
MACOSX_DEPLOYMENT_TARGET = 10.6;
OTHER_LDFLAGS = "-Wl,-no_compact_unwind";
PRODUCT_NAME = ffi;
SDKROOT = macosx;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
DB13B15F1849DEB70010F42D /* Build configuration list for PBXProject "libffi" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DB13B1601849DEB70010F42D /* Debug */,
DB13B1611849DEB70010F42D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DB13B18B1849DF1E0010F42D /* Build configuration list for PBXNativeTarget "libffi-iOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DB13B1871849DF1E0010F42D /* Debug */,
DB13B1881849DF1E0010F42D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DB13B1B01849DF520010F42D /* Build configuration list for PBXNativeTarget "libffi-Mac" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DB13B1B11849DF520010F42D /* Debug */,
DB13B1B21849DF520010F42D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = DB13B15C1849DEB70010F42D /* Project object */;
}

View File

@ -0,0 +1,106 @@
#! /bin/sh
# Script to translate LDFLAGS into a form suitable for use with libtool.
# Copyright (C) 2005 Free Software Foundation, Inc.
#
# This file 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 2 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
# Contributed by CodeSourcery, LLC.
# This script is designed to be used from a Makefile that uses libtool
# to build libraries as follows:
#
# LTLDFLAGS = $(shell libtool-ldflags $(LDFLAGS))
#
# Then, use (LTLDFLAGS) in place of $(LDFLAGS) in your link line.
# The output of the script. This string is built up as we process the
# arguments.
result=
prev_arg=
for arg
do
case $arg in
-f*|--*)
# Libtool does not ascribe any special meaning options
# that begin with -f or with a double-dash. So, it will
# think these options are linker options, and prefix them
# with "-Wl,". Then, the compiler driver will ignore the
# options. So, we prefix these options with -Xcompiler to
# make clear to libtool that they are in fact compiler
# options.
case $prev_arg in
-Xpreprocessor|-Xcompiler|-Xlinker)
# This option is already prefixed; don't prefix it again.
;;
*)
result="$result -Xcompiler"
;;
esac
;;
*)
# We do not want to add -Xcompiler to other options because
# that would prevent libtool itself from recognizing them.
;;
esac
prev_arg=$arg
# If $(LDFLAGS) is (say):
# a "b'c d" e
# then the user expects that:
# $(LD) $(LDFLAGS)
# will pass three arguments to $(LD):
# 1) a
# 2) b'c d
# 3) e
# We must ensure, therefore, that the arguments are appropriately
# quoted so that using:
# libtool --mode=link ... $(LTLDFLAGS)
# will result in the same number of arguments being passed to
# libtool. In other words, when this script was invoked, the shell
# removed one level of quoting, present in $(LDFLAGS); we have to put
# it back.
# Quote any embedded single quotes.
case $arg in
*"'"*)
# The following command creates the script:
# 1s,^X,,;s|'|'"'"'|g
# which removes a leading X, and then quotes and embedded single
# quotes.
sed_script="1s,^X,,;s|'|'\"'\"'|g"
# Add a leading "X" so that if $arg starts with a dash,
# the echo command will not try to interpret the argument
# as a command-line option.
arg="X$arg"
# Generate the quoted string.
quoted_arg=`echo "$arg" | sed -e "$sed_script"`
;;
*)
quoted_arg=$arg
;;
esac
# Surround the entire argument with single quotes.
quoted_arg="'"$quoted_arg"'"
# Add it to the string.
result="$result $quoted_arg"
done
# Output the string we have built up.
echo "$result"

View File

@ -26,4 +26,4 @@
# release, then set age to 0. # release, then set age to 0.
# #
# CURRENT:REVISION:AGE # CURRENT:REVISION:AGE
5:10:0 6:1:0

4059
js/src/ctypes/libffi/ltmain.sh Executable file → Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
AC_DEFUN([GCC_AS_CFI_PSEUDO_OP],
[AC_CACHE_CHECK([assembler .cfi pseudo-op support],
gcc_cv_as_cfi_pseudo_op, [
gcc_cv_as_cfi_pseudo_op=unknown
AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],,
[gcc_cv_as_cfi_pseudo_op=yes],
[gcc_cv_as_cfi_pseudo_op=no])
])
if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then
AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1,
[Define if your assembler supports .cfi_* directives.])
fi
])

View File

@ -0,0 +1,69 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
#
# DESCRIPTION
#
# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
# added in between.
#
# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
# FLAG.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 2
AC_DEFUN([AX_APPEND_FLAG],
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl
AS_VAR_SET_IF(FLAGS,
[case " AS_VAR_GET(FLAGS) " in
*" $1 "*)
AC_RUN_LOG([: FLAGS already contains $1])
;;
*)
AC_RUN_LOG([: FLAGS="$FLAGS $1"])
AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"])
;;
esac],
[AS_VAR_SET(FLAGS,["$1"])])
AS_VAR_POPDEF([FLAGS])dnl
])dnl AX_APPEND_FLAG

View File

@ -0,0 +1,181 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cc_maxopt.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CC_MAXOPT
#
# DESCRIPTION
#
# Try to turn on "good" C optimization flags for various compilers and
# architectures, for some definition of "good". (In our case, good for
# FFTW and hopefully for other scientific codes. Modify as needed.)
#
# The user can override the flags by setting the CFLAGS environment
# variable. The user can also specify --enable-portable-binary in order to
# disable any optimization flags that might result in a binary that only
# runs on the host architecture.
#
# Note also that the flags assume that ANSI C aliasing rules are followed
# by the code (e.g. for gcc's -fstrict-aliasing), and that floating-point
# computations can be re-ordered as needed.
#
# Requires macros: AX_CHECK_COMPILE_FLAG, AX_COMPILER_VENDOR,
# AX_GCC_ARCHFLAG, AX_GCC_X86_CPUID.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2008 Matteo Frigo
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 13
AC_DEFUN([AX_CC_MAXOPT],
[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AX_COMPILER_VENDOR])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_ARG_ENABLE(portable-binary, [AS_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
acx_maxopt_portable=$enableval, acx_maxopt_portable=no)
# Try to determine "good" native compiler flags if none specified via CFLAGS
if test "$ac_test_CFLAGS" != "set"; then
CFLAGS=""
case $ax_cv_c_compiler_vendor in
dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
if test "x$acx_maxopt_portable" = xno; then
CFLAGS="$CFLAGS -arch host"
fi;;
sun) CFLAGS="-native -fast -xO5 -dalign"
if test "x$acx_maxopt_portable" = xyes; then
CFLAGS="$CFLAGS -xarch=generic"
fi;;
hp) CFLAGS="+Oall +Optrs_ansi +DSnative"
if test "x$acx_maxopt_portable" = xyes; then
CFLAGS="$CFLAGS +DAportable"
fi;;
ibm) if test "x$acx_maxopt_portable" = xno; then
xlc_opt="-qarch=auto -qtune=auto"
else
xlc_opt="-qtune=auto"
fi
AX_CHECK_COMPILE_FLAG($xlc_opt,
CFLAGS="-O3 -qansialias -w $xlc_opt",
[CFLAGS="-O3 -qansialias -w"
echo "******************************************************"
echo "* You seem to have the IBM C compiler. It is *"
echo "* recommended for best performance that you use: *"
echo "* *"
echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
echo "* ^^^ ^^^ *"
echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
echo "* CPU you have. (Set the CFLAGS environment var. *"
echo "* and re-run configure.) For more info, man cc. *"
echo "******************************************************"])
;;
intel) CFLAGS="-O3 -ansi_alias"
if test "x$acx_maxopt_portable" = xno; then
icc_archflag=unknown
icc_flags=""
case $host_cpu in
i686*|x86_64*)
# icc accepts gcc assembly syntax, so these should work:
AX_GCC_X86_CPUID(0)
AX_GCC_X86_CPUID(1)
case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG
*:756e6547:*:*) # Intel
case $ax_cv_gcc_x86_cpuid_1 in
*6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";;
*f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";;
*f??:*:*:*) icc_flags="-xN -xW -xK";;
esac ;;
esac ;;
esac
if test "x$icc_flags" != x; then
for flag in $icc_flags; do
AX_CHECK_COMPILE_FLAG($flag, [icc_archflag=$flag; break])
done
fi
AC_MSG_CHECKING([for icc architecture flag])
AC_MSG_RESULT($icc_archflag)
if test "x$icc_archflag" != xunknown; then
CFLAGS="$CFLAGS $icc_archflag"
fi
fi
;;
gnu)
# default optimization flags for gcc on all systems
CFLAGS="-O3 -fomit-frame-pointer"
# -malign-double for x86 systems
# LIBFFI -- DON'T DO THIS - CHANGES ABI
# AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double")
# -fstrict-aliasing for gcc-2.95+
AX_CHECK_COMPILE_FLAG(-fstrict-aliasing,
CFLAGS="$CFLAGS -fstrict-aliasing")
# note that we enable "unsafe" fp optimization with other compilers, too
AX_CHECK_COMPILE_FLAG(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
AX_GCC_ARCHFLAG($acx_maxopt_portable)
;;
esac
if test -z "$CFLAGS"; then
echo ""
echo "********************************************************"
echo "* WARNING: Don't know the best CFLAGS for this system *"
echo "* Use ./configure CFLAGS=... to specify your own flags *"
echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
echo "********************************************************"
echo ""
CFLAGS="-O3"
fi
AX_CHECK_COMPILE_FLAG($CFLAGS, [], [
echo ""
echo "********************************************************"
echo "* WARNING: The guessed CFLAGS don't seem to work with *"
echo "* your compiler. *"
echo "* Use ./configure CFLAGS=... to specify your own flags *"
echo "********************************************************"
echo ""
CFLAGS=""
])
fi
])

View File

@ -0,0 +1,122 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
# AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
# AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
#
# DESCRIPTION
#
# Try to find a compiler option that enables most reasonable warnings.
#
# For the GNU compiler it will be -Wall (and -ansi -pedantic) The result
# is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default.
#
# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX,
# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and
# Intel compilers. For a given compiler, the Fortran flags are much more
# experimental than their C equivalents.
#
# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS
# - $2 add-value-if-not-found : nothing
# - $3 action-if-found : add value to shellvariable
# - $4 action-if-not-found : nothing
#
# NOTE: These macros depend on AX_APPEND_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 14
AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
VAR,[VAR="no, unknown"
ac_save_[]FLAGS="$[]FLAGS"
for ac_arg dnl
in "-warn all % -warn all" dnl Intel
"-pedantic % -Wall" dnl GCC
"-xstrconst % -v" dnl Solaris C
"-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
"-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
"-ansi -ansiE % -fullwarn" dnl IRIX
"+ESlit % +w1" dnl HP-UX C
"-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
"-h conform % -h msglevel 2" dnl Cray C (Unicos)
#
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
done
FLAGS="$ac_save_[]FLAGS"
])
AS_VAR_POPDEF([FLAGS])dnl
AC_REQUIRE([AX_APPEND_FLAG])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
*) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;;
esac
AS_VAR_POPDEF([VAR])dnl
])dnl AX_FLAGS_WARN_ALL
dnl implementation tactics:
dnl the for-argument contains a list of options. The first part of
dnl these does only exist to detect the compiler - usually it is
dnl a global option to enable -ansi or -extrawarnings. All other
dnl compilers will fail about it. That was needed since a lot of
dnl compilers will give false positives for some option-syntax
dnl like -Woption or -Xoption as they think of it is a pass-through
dnl to later compile stages or something. The "%" is used as a
dnl delimiter. A non-option comment can be given after "%%" marks
dnl which will be shown but not added to the respective C/CXXFLAGS.
AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
AC_LANG_PUSH([C])
AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
AC_LANG_POP([C])
])
AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
AC_LANG_PUSH([C++])
AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
AC_LANG_POP([C++])
])
AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
AC_LANG_PUSH([Fortran])
AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
AC_LANG_POP([Fortran])
])

View File

@ -0,0 +1,72 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
#
# DESCRIPTION
#
# Check whether the given FLAG works with the current language's compiler
# or gives an error. (Warnings, however, are ignored)
#
# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
# success/failure.
#
# If EXTRA-FLAGS is defined, it is added to the current language's default
# flags (e.g. CFLAGS) when the check is done. The check is thus made with
# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
# force the compiler to issue an error when a bad flag is given.
#
# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 2
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS

View File

@ -0,0 +1,84 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_COMPILER_VENDOR
#
# DESCRIPTION
#
# Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun,
# hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft,
# watcom, etc. The vendor is returned in the cache variable
# $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2008 Matteo Frigo
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 11
AC_DEFUN([AX_COMPILER_VENDOR],
[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
[# note: don't check for gcc first since some other compilers define __GNUC__
vendors="intel: __ICC,__ECC,__INTEL_COMPILER
ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__
pathscale: __PATHCC__,__PATHSCALE__
clang: __clang__
gnu: __GNUC__
sun: __SUNPRO_C,__SUNPRO_CC
hp: __HP_cc,__HP_aCC
dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
borland: __BORLANDC__,__TURBOC__
comeau: __COMO__
cray: _CRAYC
kai: __KCC
lcc: __LCC__
sgi: __sgi,sgi
microsoft: _MSC_VER
metrowerks: __MWERKS__
watcom: __WATCOMC__
portland: __PGI
unknown: UNKNOWN"
for ventest in $vendors; do
case $ventest in
*:) vendor=$ventest; continue ;;
*) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;;
esac
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
#if !($vencpp)
thisisanerror;
#endif
])], [break])
done
ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1`
])
])

View File

@ -0,0 +1,70 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_configure_args.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CONFIGURE_ARGS
#
# DESCRIPTION
#
# Helper macro for AX_ENABLE_BUILDDIR.
#
# The traditional way of starting a subdir-configure is running the script
# with ${1+"$@"} but since autoconf 2.60 this is broken. Instead we have
# to rely on eval'ing $ac_configure_args however some old autoconf
# versions do not provide that. To ensure maximum portability of autoconf
# extension macros this helper can be AC_REQUIRE'd so that
# $ac_configure_args will alsways be present.
#
# Sadly, the traditional "exec $SHELL" of the enable_builddir macros is
# spoiled now and must be replaced by "eval + exit $?".
#
# Example:
#
# AC_DEFUN([AX_ENABLE_SUBDIR],[dnl
# AC_REQUIRE([AX_CONFIGURE_ARGS])dnl
# eval $SHELL $ac_configure_args || exit $?
# ...])
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 9
AC_DEFUN([AX_CONFIGURE_ARGS],[
# [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args
if test "${ac_configure_args+set}" != "set" ; then
ac_configure_args=
for ac_arg in ${1+"[$]@"}; do
ac_configure_args="$ac_configure_args '$ac_arg'"
done
fi
])

View File

@ -0,0 +1,300 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_enable_builddir.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_ENABLE_BUILDDIR [(dirstring-or-command [,Makefile.mk [,-all]])]
#
# DESCRIPTION
#
# If the current configure was run within the srcdir then we move all
# configure-files into a subdir and let the configure steps continue
# there. We provide an option --disable-builddir to suppress the move into
# a separate builddir.
#
# Defaults:
#
# $1 = $host (overridden with $HOST)
# $2 = Makefile.mk
# $3 = -all
#
# This macro must be called before AM_INIT_AUTOMAKE. It creates a default
# toplevel srcdir Makefile from the information found in the created
# toplevel builddir Makefile. It just copies the variables and
# rule-targets, each extended with a default rule-execution that recurses
# into the build directory of the current "HOST". You can override the
# auto-dection through `config.guess` and build-time of course, as in
#
# make HOST=i386-mingw-cross
#
# which can of course set at configure time as well using
#
# configure --host=i386-mingw-cross
#
# After the default has been created, additional rules can be appended
# that will not just recurse into the subdirectories and only ever exist
# in the srcdir toplevel makefile - these parts are read from the $2 =
# Makefile.mk file
#
# The automatic rules are usually scanning the toplevel Makefile for lines
# like '#### $host |$builddir' to recognize the place where to recurse
# into. Usually, the last one is the only one used. However, almost all
# targets have an additional "*-all" rule which makes the script to
# recurse into _all_ variants of the current HOST (!!) setting. The "-all"
# suffix can be overriden for the macro as well.
#
# a special rule is only given for things like "dist" that will copy the
# tarball from the builddir to the sourcedir (or $(PUB)) for reason of
# convenience.
#
# LICENSE
#
# Copyright (c) 2009 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2009 Alan Jenkins <alan-jenkins@tuffmail.co.uk>
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 23
AC_DEFUN([AX_ENABLE_BUILDDIR],[
AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl
AC_REQUIRE([AM_AUX_DIR_EXPAND])[]dnl
AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl
AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
SUB="."
AC_ARG_ENABLE([builddir], AS_HELP_STRING(
[--disable-builddir],[disable automatic build in subdir of sources])
,[SUB="$enableval"], [SUB="auto"])
if test ".$ac_srcdir_defaulted" != ".no" ; then
if test ".$srcdir" = ".." ; then
if test -f config.status ; then
AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build)
else
test ".$SUB" = "." && SUB="."
test ".$SUB" = ".no" && SUB="."
test ".$TARGET" = "." && TARGET="$target"
test ".$SUB" = ".auto" && SUB="m4_ifval([$1], [$1],[$TARGET])"
if test ".$SUB" != ".." ; then # we know where to go and
AS_MKDIR_P([$SUB])
echo __.$SUB.__ > $SUB/conftest.tmp
cd $SUB
if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then
rm conftest.tmp
AC_MSG_RESULT([continue configure in default builddir "./$SUB"])
else
AC_MSG_ERROR([could not change to default builddir "./$SUB"])
fi
srcdir=`echo "$SUB" |
sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'`
# going to restart from subdirectory location
test -f $srcdir/config.log && mv $srcdir/config.log .
test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h .
test -f $srcdir/conftest.log && mv $srcdir/conftest.log .
test -f $srcdir/$cache_file && mv $srcdir/$cache_file .
AC_MSG_RESULT(....exec $SHELL $srcdir/[$]0 "--srcdir=$srcdir" "--enable-builddir=$SUB" ${1+"[$]@"})
case "[$]0" in # restart
[/\\]*) eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
*) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
esac ; exit $?
fi
fi
fi fi
test ".$SUB" = ".auto" && SUB="."
dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec"
AC_PATH_PROG(SED,gsed sed, sed)
AUX="$am_aux_dir"
AS_VAR_POPDEF([SED])dnl
AS_VAR_POPDEF([AUX])dnl
AS_VAR_POPDEF([SUB])dnl
AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status ..............
AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl
AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl
AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl
AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
pushdef([END],[Makefile.mk])dnl
pushdef([_ALL],[ifelse([$3],,[-all],[$3])])dnl
SRC="$ax_enable_builddir_srcdir"
if test ".$SUB" = ".." ; then
if test -f "$TOP/Makefile" ; then
AC_MSG_NOTICE([skipping TOP/Makefile - left untouched])
else
AC_MSG_NOTICE([skipping TOP/Makefile - not created])
fi
else
if test -f "$SRC/Makefile" ; then
a=`grep "^VERSION " "$SRC/Makefile"` ; b=`grep "^VERSION " Makefile`
test "$a" != "$b" && rm "$SRC/Makefile"
fi
if test -f "$SRC/Makefile" ; then
echo "$SRC/Makefile : $SRC/Makefile.in" > $tmp/conftemp.mk
echo " []@ echo 'REMOVED,,,' >\$[]@" >> $tmp/conftemp.mk
eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null"
if grep '^REMOVED,,,' "$SRC/Makefile" >/dev/null
then rm $SRC/Makefile ; fi
cp $tmp/conftemp.mk $SRC/makefiles.mk~ ## DEBUGGING
fi
if test ! -f "$SRC/Makefile" ; then
AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile])
x='`' ; cat >$tmp/conftemp.sed <<_EOF
/^\$/n
x
/^\$/bS
x
/\\\\\$/{H;d;}
{H;s/.*//;x;}
bM
:S
x
/\\\\\$/{h;d;}
{h;s/.*//;x;}
:M
s/\\(\\n\\) /\\1 /g
/^ /d
/^[[ ]]*[[\\#]]/d
/^VPATH *=/d
s/^srcdir *=.*/srcdir = ./
s/^top_srcdir *=.*/top_srcdir = ./
/[[:=]]/!d
/^\\./d
dnl Now handle rules (i.e. lines containing ":" but not " = ").
/ = /b
/ .= /b
/:/!b
s/:.*/:/
s/ / /g
s/ \\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/ \\1 \\1[]_ALL\\2/g
s/^\\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/\\1 \\1[]_ALL\\2/
s/ / /g
/^all all[]_ALL[[ :]]/i\\
all-configured : all[]_ALL
dnl dist-all exists... and would make for dist-all-all
s/ [[a-zA-Z0-9-]]*[]_ALL [[a-zA-Z0-9-]]*[]_ALL[]_ALL//g
/[]_ALL[]_ALL/d
a\\
@ HOST="\$(HOST)\" \\\\\\
; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\
; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\
; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\
; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done
dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree)
/dist[]_ALL *:/a\\
@ HOST="\$(HOST)\" \\\\\\
; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
; found=$x echo \$\$BUILD | wc -w $x \\\\\\
; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\
; if test "\$\$found" -eq "0" ; then : \\\\\\
; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\
; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
dnl special rule add-on: "dist-foo" copies all the archives to $(PUB). (source tree)
/dist-[[a-zA-Z0-9]]*[]_ALL *:/a\\
@ HOST="\$(HOST)\" \\\\\\
; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\
; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
; found=$x echo \$\$BUILD | wc -w $x \\\\\\
; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\
; if test "\$\$found" -eq "0" ; then : \\\\\\
; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\
; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
dnl special rule add-on: "distclean" removes all local builddirs completely
/distclean[]_ALL *:/a\\
@ HOST="\$(HOST)\" \\\\\\
; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\
; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\
; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\
; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\
; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\
; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile
_EOF
cp "$tmp/conftemp.sed" "$SRC/makefile.sed~" ## DEBUGGING
$SED -f $tmp/conftemp.sed Makefile >$SRC/Makefile
if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then
AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])])
cat $SRC/END >>$SRC/Makefile
fi ; xxxx="####"
echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$SRC/Makefile
# sanity check
if grep '^; echo "MAKE ' $SRC/Makefile >/dev/null ; then
AC_MSG_NOTICE([buggy sed found - it deletes tab in "a" text parts])
$SED -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $SRC/Makefile \
>$SRC/Makefile~
(test -s $SRC/Makefile~ && mv $SRC/Makefile~ $SRC/Makefile) 2>/dev/null
fi
else
xxxx="\\#\\#\\#\\#"
# echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed
echo "s!^$xxxx [[^|]]* | *$SUB *\$!$xxxx ...... $SUB!" >$tmp/conftemp.sed
$SED -f "$tmp/conftemp.sed" "$SRC/Makefile" >$tmp/mkfile.tmp
cp "$tmp/conftemp.sed" "$SRC/makefiles.sed~" ## DEBUGGING
cp "$tmp/mkfile.tmp" "$SRC/makefiles.out~" ## DEBUGGING
if cmp -s "$SRC/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then
AC_MSG_NOTICE([keeping TOP/Makefile from earlier configure])
rm "$tmp/mkfile.tmp"
else
AC_MSG_NOTICE([reusing TOP/Makefile from earlier configure])
mv "$tmp/mkfile.tmp" "$SRC/Makefile"
fi
fi
AC_MSG_NOTICE([build in $SUB (HOST=$ax_enable_builddir_host)])
xxxx="####"
echo "$xxxx" "$ax_enable_builddir_host" "|$SUB" >>$SRC/Makefile
fi
popdef([END])dnl
AS_VAR_POPDEF([SED])dnl
AS_VAR_POPDEF([AUX])dnl
AS_VAR_POPDEF([SRC])dnl
AS_VAR_POPDEF([TOP])dnl
AS_VAR_POPDEF([SUB])dnl
],[dnl
ax_enable_builddir_srcdir="$srcdir" # $srcdir
ax_enable_builddir_host="$HOST" # $HOST / $host
ax_enable_builddir_version="$VERSION" # $VERSION
ax_enable_builddir_package="$PACKAGE" # $PACKAGE
ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX
ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED
ax_enable_builddir="$ax_enable_builddir" # $SUB
])dnl
])

View File

@ -0,0 +1,225 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_gcc_archflag.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_GCC_ARCHFLAG([PORTABLE?], [ACTION-SUCCESS], [ACTION-FAILURE])
#
# DESCRIPTION
#
# This macro tries to guess the "native" arch corresponding to the target
# architecture for use with gcc's -march=arch or -mtune=arch flags. If
# found, the cache variable $ax_cv_gcc_archflag is set to this flag and
# ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is set to
# "unknown" and ACTION-FAILURE is executed. The default ACTION-SUCCESS is
# to add $ax_cv_gcc_archflag to the end of $CFLAGS.
#
# PORTABLE? should be either [yes] (default) or [no]. In the former case,
# the flag is set to -mtune (or equivalent) so that the architecture is
# only used for tuning, but the instruction set used is still portable. In
# the latter case, the flag is set to -march (or equivalent) so that
# architecture-specific instructions are enabled.
#
# The user can specify --with-gcc-arch=<arch> in order to override the
# macro's choice of architecture, or --without-gcc-arch to disable this.
#
# When cross-compiling, or if $CC is not gcc, then ACTION-FAILURE is
# called unless the user specified --with-gcc-arch manually.
#
# Requires macros: AX_CHECK_COMPILE_FLAG, AX_GCC_X86_CPUID
#
# (The main emphasis here is on recent CPUs, on the principle that doing
# high-performance computing on old hardware is uncommon.)
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2008 Matteo Frigo
# Copyright (c) 2012 Tsukasa Oi
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 11
AC_DEFUN([AX_GCC_ARCHFLAG],
[AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=<arch>], [use architecture <arch> for gcc -march/-mtune, instead of guessing])],
ax_gcc_arch=$withval, ax_gcc_arch=yes)
AC_MSG_CHECKING([for gcc architecture flag])
AC_MSG_RESULT([])
AC_CACHE_VAL(ax_cv_gcc_archflag,
[
ax_cv_gcc_archflag="unknown"
if test "$GCC" = yes; then
if test "x$ax_gcc_arch" = xyes; then
ax_gcc_arch=""
if test "$cross_compiling" = no; then
case $host_cpu in
i[[3456]]86*|x86_64*) # use cpuid codes
AX_GCC_X86_CPUID(0)
AX_GCC_X86_CPUID(1)
case $ax_cv_gcc_x86_cpuid_0 in
*:756e6547:*:*) # Intel
case $ax_cv_gcc_x86_cpuid_1 in
*5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;;
*5??:*:*:*) ax_gcc_arch=pentium ;;
*0?6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
*0?6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
*0?6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
*0?6[[9de]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;;
*0?6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
*0?6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;;
*1?6[[7d]]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;;
*1?6[[aef]]?:*:*:*|*2?6[[5cef]]?:*:*:*) ax_gcc_arch="corei7 core2 pentium-m pentium3 pentiumpro" ;;
*1?6c?:*:*:*|*[[23]]?66?:*:*:*) ax_gcc_arch="atom core2 pentium-m pentium3 pentiumpro" ;;
*2?6[[ad]]?:*:*:*) ax_gcc_arch="corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
*0?6??:*:*:*) ax_gcc_arch=pentiumpro ;;
*6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;;
?000?f3[[347]]:*:*:*|?000?f4[1347]:*:*:*|?000?f6?:*:*:*)
case $host_cpu in
x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;;
*) ax_gcc_arch="prescott pentium4 pentiumpro" ;;
esac ;;
?000?f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";;
esac ;;
*:68747541:*:*) # AMD
case $ax_cv_gcc_x86_cpuid_1 in
*5[[67]]?:*:*:*) ax_gcc_arch=k6 ;;
*5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;;
*5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;;
*60?:*:*:*) ax_gcc_arch=k7 ;;
*6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;;
*6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;;
*67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;;
*6[[68a]]?:*:*:*)
AX_GCC_X86_CPUID(0x80000006) # L2 cache size
case $ax_cv_gcc_x86_cpuid_0x80000006 in
*:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256
ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;;
*) ax_gcc_arch="athlon-4 athlon k7" ;;
esac ;;
?00??f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;;
?00??f5?:*:*:*) ax_gcc_arch="opteron k8" ;;
?00??f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;;
?00??f??:*:*:*) ax_gcc_arch="k8" ;;
?05??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;;
?06??f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;;
*f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;;
esac ;;
*:746e6543:*:*) # IDT
case $ax_cv_gcc_x86_cpuid_1 in
*54?:*:*:*) ax_gcc_arch=winchip-c6 ;;
*58?:*:*:*) ax_gcc_arch=winchip2 ;;
*6[[78]]?:*:*:*) ax_gcc_arch=c3 ;;
*69?:*:*:*) ax_gcc_arch="c3-2 c3" ;;
esac ;;
esac
if test x"$ax_gcc_arch" = x; then # fallback
case $host_cpu in
i586*) ax_gcc_arch=pentium ;;
i686*) ax_gcc_arch=pentiumpro ;;
esac
fi
;;
sparc*)
AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/])
cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null`
cputype=`echo "$cputype" | tr -d ' -' | sed 's/SPARCIIi/SPARCII/' | tr $as_cr_LETTERS $as_cr_letters`
case $cputype in
*ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;;
*ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;;
*ultrasparc*) ax_gcc_arch="ultrasparc v9" ;;
*supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;;
*hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;;
*cypress*) ax_gcc_arch=cypress ;;
esac ;;
alphaev5) ax_gcc_arch=ev5 ;;
alphaev56) ax_gcc_arch=ev56 ;;
alphapca56) ax_gcc_arch="pca56 ev56" ;;
alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;;
alphaev6) ax_gcc_arch=ev6 ;;
alphaev67) ax_gcc_arch=ev67 ;;
alphaev68) ax_gcc_arch="ev68 ev67" ;;
alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;;
alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;;
alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;;
powerpc*)
cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null`
cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'`
case $cputype in
*750*) ax_gcc_arch="750 G3" ;;
*740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;;
*74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;;
*74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;;
*970*) ax_gcc_arch="970 G5 power4";;
*POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";;
*POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";;
603ev|8240) ax_gcc_arch="$cputype 603e 603";;
*) ax_gcc_arch=$cputype ;;
esac
ax_gcc_arch="$ax_gcc_arch powerpc"
;;
esac
fi # not cross-compiling
fi # guess arch
if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then
for arch in $ax_gcc_arch; do
if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code
flags="-mtune=$arch"
# -mcpu=$arch and m$arch generate nonportable code on every arch except
# x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr.
case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac
else
flags="-march=$arch -mcpu=$arch -m$arch"
fi
for flag in $flags; do
AX_CHECK_COMPILE_FLAG($flag, [ax_cv_gcc_archflag=$flag; break])
done
test "x$ax_cv_gcc_archflag" = xunknown || break
done
fi
fi # $GCC=yes
])
AC_MSG_CHECKING([for gcc architecture flag])
AC_MSG_RESULT($ax_cv_gcc_archflag)
if test "x$ax_cv_gcc_archflag" = xunknown; then
m4_default([$3],:)
else
m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"])
fi
])

View File

@ -0,0 +1,79 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_GCC_X86_CPUID(OP)
#
# DESCRIPTION
#
# On Pentium and later x86 processors, with gcc or a compiler that has a
# compatible syntax for inline assembly instructions, run a small program
# that executes the cpuid instruction with input OP. This can be used to
# detect the CPU type.
#
# On output, the values of the eax, ebx, ecx, and edx registers are stored
# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
# ax_cv_gcc_x86_cpuid_OP.
#
# If the cpuid instruction fails (because you are running a
# cross-compiler, or because you are not using gcc, or because you are on
# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
# is set to the string "unknown".
#
# This macro mainly exists to be used in AX_GCC_ARCHFLAG.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2008 Matteo Frigo
#
# 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 this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 7
AC_DEFUN([AX_GCC_X86_CPUID],
[AC_REQUIRE([AC_PROG_CC])
AC_LANG_PUSH([C])
AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
[AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
int op = $1, eax, ebx, ecx, edx;
FILE *f;
__asm__("cpuid"
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
: "a" (op));
f = fopen("conftest_cpuid", "w"); if (!f) return 1;
fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
fclose(f);
return 0;
])],
[ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
[ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
[ax_cv_gcc_x86_cpuid_$1=unknown])])
AC_LANG_POP([C])
])

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,14 @@
# Helper functions for option handling. -*- Autoconf -*- # Helper functions for option handling. -*- Autoconf -*-
# #
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# Written by Gary V. Vaughan, 2004 # Written by Gary V. Vaughan, 2004
# #
# This file is free software; the Free Software Foundation gives # This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without # unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved. # modifications, as long as this notice is preserved.
# serial 6 ltoptions.m4 # serial 7 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define. # This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@ -125,7 +126,7 @@ LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes [enable_win32_dll=yes
case $host in case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false) AC_CHECK_TOOL(OBJDUMP, objdump, false)
@ -133,13 +134,13 @@ case $host in
esac esac
test -z "$AS" && AS=as test -z "$AS" && AS=as
_LT_DECL([], [AS], [0], [Assembler program])dnl _LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll ])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL], AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
@ -325,9 +326,24 @@ dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# MODE is either `yes' or `no'. If omitted, it defaults to `both'. # MODE is either `yes' or `no'. If omitted, it defaults to `both'.
m4_define([_LT_WITH_PIC], m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic], [AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[pic_mode="$withval"], [lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for lt_pkg in $withval; do
IFS="$lt_save_ifs"
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[pic_mode=default]) [pic_mode=default])
test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default])

View File

@ -7,17 +7,17 @@
# unlimited permission to copy and/or distribute it, with or without # unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved. # modifications, as long as this notice is preserved.
# Generated from ltversion.in. # @configure_input@
# serial 3017 ltversion.m4 # serial 3337 ltversion.m4
# This file is part of GNU Libtool # This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.2.6b]) m4_define([LT_PACKAGE_VERSION], [2.4.2])
m4_define([LT_PACKAGE_REVISION], [1.3017]) m4_define([LT_PACKAGE_REVISION], [1.3337])
AC_DEFUN([LTVERSION_VERSION], AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.2.6b' [macro_version='2.4.2'
macro_revision='1.3017' macro_revision='1.3337'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0) _LT_DECL(, macro_revision, 0)
]) ])

View File

@ -1,13 +1,13 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
# #
# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004. # Written by Scott James Remnant, 2004.
# #
# This file is free software; the Free Software Foundation gives # This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without # unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved. # modifications, as long as this notice is preserved.
# serial 4 lt~obsolete.m4 # serial 5 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool. # These exist entirely to fool aclocal when bootstrapping libtool.
# #
@ -77,7 +77,6 @@ m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
@ -90,3 +89,10 @@ m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])

View File

@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS=foreign AUTOMAKE_OPTIONS=foreign
EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3

View File

@ -1,9 +1,8 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am. # Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # Copyright (C) 1994-2013 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved. # with or without modifications, as long as this notice is preserved.
@ -15,6 +14,51 @@
@SET_MAKE@ @SET_MAKE@
VPATH = @srcdir@ VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@ -35,9 +79,21 @@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
target_triplet = @target@ target_triplet = @target@
subdir = man subdir = man
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
$(top_srcdir)/m4/ax_append_flag.m4 \
$(top_srcdir)/m4/ax_cc_maxopt.m4 \
$(top_srcdir)/m4/ax_cflags_warn_all.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_compiler_vendor.m4 \
$(top_srcdir)/m4/ax_configure_args.m4 \
$(top_srcdir)/m4/ax_enable_builddir.m4 \
$(top_srcdir)/m4/ax_gcc_archflag.m4 \
$(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
@ -45,8 +101,25 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/fficonfig.h CONFIG_HEADER = $(top_builddir)/fficonfig.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES = CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES = SOURCES =
DIST_SOURCES = DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \ am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@ -68,14 +141,22 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \ am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
man3dir = $(mandir)/man3 man3dir = $(mandir)/man3
am__installdirs = "$(DESTDIR)$(man3dir)" am__installdirs = "$(DESTDIR)$(man3dir)"
NROFF = nroff NROFF = nroff
MANS = $(man_MANS) MANS = $(man_MANS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@ ALLOCA = @ALLOCA@
AMTAR = @AMTAR@ AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LTLDFLAGS = @AM_LTLDFLAGS@ AM_LTLDFLAGS = @AM_LTLDFLAGS@
AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@ AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
AR = @AR@ AR = @AR@
@ -91,9 +172,14 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
CPP = @CPP@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@ CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@ CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@ DEFS = @DEFS@
DEPDIR = @DEPDIR@ DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@ DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@ DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@ ECHO_C = @ECHO_C@
@ -101,9 +187,11 @@ 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@
HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
@ -119,6 +207,7 @@ LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@ LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@ MAINT = @MAINT@
MAKEINFO = @MAKEINFO@ MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@ MKDIR_P = @MKDIR_P@
NM = @NM@ NM = @NM@
NMEDIT = @NMEDIT@ NMEDIT = @NMEDIT@
@ -134,6 +223,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@ PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@ PATH_SEPARATOR = @PATH_SEPARATOR@
PRTDIAG = @PRTDIAG@
RANLIB = @RANLIB@ RANLIB = @RANLIB@
SED = @SED@ SED = @SED@
SET_MAKE = @SET_MAKE@ SET_MAKE = @SET_MAKE@
@ -146,13 +236,16 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@ abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@ abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@ ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@ am__include = @am__include@
am__leading_dot = @am__leading_dot@ am__leading_dot = @am__leading_dot@
am__quote = @am__quote@ am__quote = @am__quote@
am__tar = @am__tar@ am__tar = @am__tar@
am__untar = @am__untar@ am__untar = @am__untar@
ax_enable_builddir_sed = @ax_enable_builddir_sed@
bindir = @bindir@ bindir = @bindir@
build = @build@ build = @build@
build_alias = @build_alias@ build_alias = @build_alias@
@ -178,7 +271,6 @@ libdir = @libdir@
libexecdir = @libexecdir@ libexecdir = @libexecdir@
localedir = @localedir@ localedir = @localedir@
localstatedir = @localstatedir@ localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@ mandir = @mandir@
mkdir_p = @mkdir_p@ mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@ oldincludedir = @oldincludedir@
@ -189,6 +281,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@
@ -201,8 +294,8 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
all: all-am all: all-am
.SUFFIXES: .SUFFIXES:
@ -244,11 +337,18 @@ clean-libtool:
-rm -rf .libs _libs -rm -rf .libs _libs
install-man3: $(man_MANS) install-man3: $(man_MANS)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
test -z "$(man3dir)" || $(MKDIR_P) "$(DESTDIR)$(man3dir)" @list1=''; \
@list=''; test -n "$(man3dir)" || exit 0; \ list2='$(man_MANS)'; \
{ for i in $$list; do echo "$$i"; done; \ test -n "$(man3dir)" \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ && test -n "`echo $$list1$$list2`" \
sed -n '/\.3[a-z]*$$/p'; \ || exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.3[a-z]*$$/p'; \
fi; \
} | while read p; do \ } | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \ echo "$$d$$p"; echo "$$p"; \
@ -277,30 +377,15 @@ uninstall-man3:
sed -n '/\.3[a-z]*$$/p'; \ sed -n '/\.3[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
test -z "$$files" || { \ dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir)
echo " ( cd '$(DESTDIR)$(man3dir)' && rm -f" $$files ")"; \ tags TAGS:
cd "$(DESTDIR)$(man3dir)" && rm -f $$files; }
tags: TAGS
TAGS:
ctags: CTAGS ctags CTAGS:
CTAGS:
cscope cscopelist:
distdir: $(DISTFILES) distdir: $(DISTFILES)
@list='$(MANS)'; if test -n "$$list"; then \
list=`for p in $$list; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
if test -n "$$list" && \
grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
echo " typically \`make maintainer-clean' will remove them" >&2; \
exit 1; \
else :; fi; \
else :; fi
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \ list='$(DISTFILES)'; \
@ -347,10 +432,15 @@ install-am: all-am
installcheck: installcheck-am installcheck: installcheck-am
install-strip: install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ if test -z '$(STRIP)'; then \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
`test -z '$(STRIP)' || \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic: mostlyclean-generic:
clean-generic: clean-generic:
@ -433,16 +523,17 @@ uninstall-man: uninstall-man3
.MAKE: install-am install-strip .MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \ .PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \ cscopelist-am ctags-am distclean distclean-generic \
dvi-am html html-am info info-am install install-am \ distclean-libtool distdir dvi dvi-am html html-am info info-am \
install-data install-data-am install-dvi install-dvi-am \ install install-am install-data install-data-am install-dvi \
install-exec install-exec-am install-html install-html-am \ install-dvi-am install-exec install-exec-am install-html \
install-info install-info-am install-man install-man3 \ install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \ install-man3 install-pdf install-pdf-am install-ps \
install-strip installcheck installcheck-am installdirs \ install-ps-am install-strip installcheck installcheck-am \
maintainer-clean maintainer-clean-generic mostlyclean \ installdirs maintainer-clean maintainer-clean-generic \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
uninstall uninstall-am uninstall-man uninstall-man3 ps ps-am tags-am uninstall uninstall-am uninstall-man \
uninstall-man3
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.

View File

@ -16,6 +16,15 @@ libffi, -lffi
.Fa "ffi_type **atypes" .Fa "ffi_type **atypes"
.Fc .Fc
.Ft void .Ft void
.Fo ffi_prep_cif_var
.Fa "ffi_cif *cif"
.Fa "ffi_abi abi"
.Fa "unsigned int nfixedargs"
.Fa "unsigned int ntotalargs"
.Fa "ffi_type *rtype"
.Fa "ffi_type **atypes"
.Fc
.Ft void
.Fo ffi_call .Fo ffi_call
.Fa "ffi_cif *cif" .Fa "ffi_cif *cif"
.Fa "void (*fn)(void)" .Fa "void (*fn)(void)"
@ -28,4 +37,5 @@ generate a call to another function at runtime without requiring knowledge of
the called function's interface at compile time. the called function's interface at compile time.
.Sh SEE ALSO .Sh SEE ALSO
.Xr ffi_prep_cif 3 , .Xr ffi_prep_cif 3 ,
.Xr ffi_prep_cif_var 3 ,
.Xr ffi_call 3 .Xr ffi_call 3

View File

@ -37,7 +37,9 @@ structs that describe the data type, size and alignment of each argument.
points to an points to an
.Nm ffi_type .Nm ffi_type
that describes the data type, size and alignment of the that describes the data type, size and alignment of the
return value. return value. Note that to call a variadic function
.Nm ffi_prep_cif_var
must be used instead.
.Sh RETURN VALUES .Sh RETURN VALUES
Upon successful completion, Upon successful completion,
.Nm ffi_prep_cif .Nm ffi_prep_cif
@ -59,8 +61,8 @@ does not refer to a valid ABI,
.Nm FFI_BAD_ABI .Nm FFI_BAD_ABI
will be returned. Available ABIs are will be returned. Available ABIs are
defined in defined in
.Nm <ffitarget.h> .Nm <ffitarget.h> .
.
.Sh SEE ALSO .Sh SEE ALSO
.Xr ffi 3 , .Xr ffi 3 ,
.Xr ffi_call 3 .Xr ffi_call 3 ,
.Xr ffi_prep_cif_var 3

View File

@ -0,0 +1,73 @@
.Dd January 25, 2011
.Dt ffi_prep_cif_var 3
.Sh NAME
.Nm ffi_prep_cif_var
.Nd Prepare a
.Nm ffi_cif
structure for use with
.Nm ffi_call
for variadic functions.
.Sh SYNOPSIS
.In ffi.h
.Ft ffi_status
.Fo ffi_prep_cif_var
.Fa "ffi_cif *cif"
.Fa "ffi_abi abi"
.Fa "unsigned int nfixedargs"
.Fa "unsigned int ntotalargs"
.Fa "ffi_type *rtype"
.Fa "ffi_type **atypes"
.Fc
.Sh DESCRIPTION
The
.Nm ffi_prep_cif_var
function prepares a
.Nm ffi_cif
structure for use with
.Nm ffi_call
for variadic functions.
.Fa abi
specifies a set of calling conventions to use.
.Fa atypes
is an array of
.Fa ntotalargs
pointers to
.Nm ffi_type
structs that describe the data type, size and alignment of each argument.
.Fa rtype
points to an
.Nm ffi_type
that describes the data type, size and alignment of the
return value.
.Fa nfixedargs
must contain the number of fixed (non-variadic) arguments.
Note that to call a non-variadic function
.Nm ffi_prep_cif
must be used.
.Sh RETURN VALUES
Upon successful completion,
.Nm ffi_prep_cif_var
returns
.Nm FFI_OK .
It will return
.Nm FFI_BAD_TYPEDEF
if
.Fa cif
is
.Nm NULL
or
.Fa atypes
or
.Fa rtype
is malformed. If
.Fa abi
does not refer to a valid ABI,
.Nm FFI_BAD_ABI
will be returned. Available ABIs are
defined in
.Nm <ffitarget.h>
.
.Sh SEE ALSO
.Xr ffi 3 ,
.Xr ffi_call 3 ,
.Xr ffi_prep_cif 3

View File

@ -1,10 +1,9 @@
#!/bin/sh #!/bin/sh
# Get modification time of a file or directory and pretty-print it. # Get modification time of a file or directory and pretty-print it.
scriptversion=2005-06-29.22 scriptversion=2010-08-21.06; # UTC
# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 Free Software # Copyright (C) 1995-2013 Free Software Foundation, Inc.
# Foundation, Inc.
# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995 # written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -18,8 +17,7 @@ scriptversion=2005-06-29.22
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
@ -30,16 +28,26 @@ scriptversion=2005-06-29.22
# bugs to <bug-automake@gnu.org> or send patches to # bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>. # <automake-patches@gnu.org>.
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
fi
case $1 in case $1 in
'') '')
echo "$0: No file. Try \`$0 --help' for more information." 1>&2 echo "$0: No file. Try '$0 --help' for more information." 1>&2
exit 1; exit 1;
;; ;;
-h | --h*) -h | --h*)
cat <<\EOF cat <<\EOF
Usage: mdate-sh [--help] [--version] FILE Usage: mdate-sh [--help] [--version] FILE
Pretty-print the modification time of FILE. Pretty-print the modification day of FILE, in the format:
1 January 1970
Report bugs to <bug-automake@gnu.org>. Report bugs to <bug-automake@gnu.org>.
EOF EOF
@ -51,6 +59,13 @@ EOF
;; ;;
esac esac
error ()
{
echo "$0: $1" >&2
exit 1
}
# Prevent date giving response in another language. # Prevent date giving response in another language.
LANG=C LANG=C
export LANG export LANG
@ -60,7 +75,7 @@ LC_TIME=C
export LC_TIME export LC_TIME
# GNU ls changes its time format in response to the TIME_STYLE # GNU ls changes its time format in response to the TIME_STYLE
# variable. Since we cannot assume `unset' works, revert this # variable. Since we cannot assume 'unset' works, revert this
# variable to its documented default. # variable to its documented default.
if test "${TIME_STYLE+set}" = set; then if test "${TIME_STYLE+set}" = set; then
TIME_STYLE=posix-long-iso TIME_STYLE=posix-long-iso
@ -75,27 +90,32 @@ if ls -L /dev/null 1>/dev/null 2>&1; then
else else
ls_command='ls -l -d' ls_command='ls -l -d'
fi fi
# Avoid user/group names that might have spaces, when possible.
if ls -n /dev/null 1>/dev/null 2>&1; then
ls_command="$ls_command -n"
fi
# A `ls -l' line looks as follows on OS/2. # A 'ls -l' line looks as follows on OS/2.
# drwxrwx--- 0 Aug 11 2001 foo # drwxrwx--- 0 Aug 11 2001 foo
# This differs from Unix, which adds ownership information. # This differs from Unix, which adds ownership information.
# drwxrwx--- 2 root root 4096 Aug 11 2001 foo # drwxrwx--- 2 root root 4096 Aug 11 2001 foo
# #
# To find the date, we split the line on spaces and iterate on words # To find the date, we split the line on spaces and iterate on words
# until we find a month. This cannot work with files whose owner is a # until we find a month. This cannot work with files whose owner is a
# user named `Jan', or `Feb', etc. However, it's unlikely that `/' # user named "Jan", or "Feb", etc. However, it's unlikely that '/'
# will be owned by a user whose name is a month. So we first look at # will be owned by a user whose name is a month. So we first look at
# the extended ls output of the root directory to decide how many # the extended ls output of the root directory to decide how many
# words should be skipped to get the date. # words should be skipped to get the date.
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
set x`ls -l -d /` set x`$ls_command /`
# Find which argument is the month. # Find which argument is the month.
month= month=
command= command=
until test $month until test $month
do do
test $# -gt 0 || error "failed parsing '$ls_command /' output"
shift shift
# Add another shift to the command. # Add another shift to the command.
command="$command shift;" command="$command shift;"
@ -115,8 +135,10 @@ do
esac esac
done done
test -n "$month" || error "failed parsing '$ls_command /' output"
# Get the extended ls output of the file or directory. # Get the extended ls output of the file or directory.
set dummy x`eval "$ls_command \"\$save_arg1\""` set dummy x`eval "$ls_command \"\\\$save_arg1\""`
# Remove all preceding arguments # Remove all preceding arguments
eval $command eval $command
@ -197,5 +219,6 @@ echo $day $month $year
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$" # time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End: # End:

View File

@ -1,11 +1,10 @@
#! /bin/sh #! /bin/sh
# Common stub for a few missing GNU programs while installing. # Common wrapper for a few potentially missing GNU programs.
scriptversion=2005-06-08.21 scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Free Software Foundation, Inc. # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -18,9 +17,7 @@ scriptversion=2005-06-08.21
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
@ -28,63 +25,40 @@ scriptversion=2005-06-08.21
# the same distribution terms that you use for the rest of that program. # the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information" echo 1>&2 "Try '$0 --help' for more information"
exit 1 exit 1
fi fi
run=: case $1 in
# In the cases where this matters, `missing' is being run in the --is-lightweight)
# srcdir already. # Used by our autoconf macros to check whether the available missing
if test -f configure.ac; then # script is modern enough.
configure_ac=configure.ac exit 0
else ;;
configure_ac=configure.in
fi
msg="missing on your system" --run)
# Back-compat with the calling convention used by older automake.
case "$1" in shift
--run) ;;
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help) -h|--h|--he|--hel|--help)
echo "\ echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]... $0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
error status if there is no known handling for PROGRAM. to PROGRAM being missing or too old.
Options: Options:
-h, --help display this help and exit -h, --help display this help and exit
-v, --version output version information and exit -v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values: Supported PROGRAM values:
aclocal touch file \`aclocal.m4' aclocal autoconf autoheader autom4te automake makeinfo
autoconf touch file \`configure' bison yacc flex lex help2man
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
bison create \`y.tab.[ch]', if possible, from existing .[ch] 'g' are ignored when checking the name.
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>." Send bug reports to <bug-automake@gnu.org>."
exit $? exit $?
@ -96,265 +70,146 @@ Send bug reports to <bug-automake@gnu.org>."
;; ;;
-*) -*)
echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "$0: unknown '$1' option"
echo 1>&2 "Try \`$0 --help' for more information" echo 1>&2 "Try '$0 --help' for more information"
exit 1 exit 1
;; ;;
esac esac
# Now exit if we have it, but it failed. Also exit now if we # Run the given program, remember its exit status.
# don't have it and --version was passed (most likely to detect "$@"; st=$?
# the program).
case "$1" in # If it succeeded, we are done.
lex|yacc) test $st -eq 0 && exit 0
# Not GNU programs, they don't have --version.
# Also exit now if we it failed (or wasn't found), and '--version' was
# passed; such an option is passed most likely to detect whether the
# program is present and works.
case $2 in --version|--help) exit $st;; esac
# Exit code 63 means version mismatch. This often happens when the user
# tries to use an ancient version of a tool on a file that requires a
# minimum version.
if test $st -eq 63; then
msg="probably too old"
elif test $st -eq 127; then
# Program was missing.
msg="missing on your system"
else
# Program was found and executed, but failed. Give up.
exit $st
fi
perl_URL=http://www.perl.org/
flex_URL=http://flex.sourceforge.net/
gnu_software_URL=http://www.gnu.org/software
program_details ()
{
case $1 in
aclocal|automake)
echo "The '$1' program is part of the GNU Automake package:"
echo "<$gnu_software_URL/automake>"
echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/autoconf>"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
autoconf|autom4te|autoheader)
echo "The '$1' program is part of the GNU Autoconf package:"
echo "<$gnu_software_URL/autoconf/>"
echo "It also requires GNU m4 and Perl in order to run:"
echo "<$gnu_software_URL/m4/>"
echo "<$perl_URL>"
;;
esac
}
give_advice ()
{
# Normalize program name to check for.
normalized_program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
printf '%s\n' "'$1' is $msg."
configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
case $normalized_program in
autoconf*)
echo "You should only need it if you modified 'configure.ac',"
echo "or m4 files included by it."
program_details 'autoconf'
;;
autoheader*)
echo "You should only need it if you modified 'acconfig.h' or"
echo "$configure_deps."
program_details 'autoheader'
;;
automake*)
echo "You should only need it if you modified 'Makefile.am' or"
echo "$configure_deps."
program_details 'automake'
;;
aclocal*)
echo "You should only need it if you modified 'acinclude.m4' or"
echo "$configure_deps."
program_details 'aclocal'
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)
echo "You should only need it if you modified a '.y' file."
echo "You may want to install the GNU Bison package:"
echo "<$gnu_software_URL/bison/>"
;;
lex*|flex*)
echo "You should only need it if you modified a '.l' file."
echo "You may want to install the Fast Lexical Analyzer package:"
echo "<$flex_URL>"
;;
help2man*)
echo "You should only need it if you modified a dependency" \
"of a man page."
echo "You may want to install the GNU Help2man package:"
echo "<$gnu_software_URL/help2man/>"
;; ;;
makeinfo*)
echo "You should only need it if you modified a '.texi' file, or"
echo "any other file indirectly affecting the aspect of the manual."
echo "You might want to install the Texinfo package:"
echo "<$gnu_software_URL/texinfo/>"
echo "The spurious makeinfo call might also be the consequence of"
echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
echo "want to install GNU make:"
echo "<$gnu_software_URL/make/>"
;;
*)
echo "You might have modified some files without having the proper"
echo "tools for further handling them. Check the 'README' file, it"
echo "often tells you about the needed prerequisites for installing"
echo "this package. You may also peek at any GNU archive site, in"
echo "case some other package contains this missing '$1' program."
;;
esac
}
tar) give_advice "$1" | sed -e '1s/^/WARNING: /' \
if test -n "$run"; then -e '2,$s/^/ /' >&2
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*) # Propagate the correct exit status (expected to be 127 for a program
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # not found, 63 for a program that failed due to version mismatch).
# We have it, but it failed. exit $st
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
tar)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables: # Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$" # time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End: # End:

View File

@ -1,14 +1,48 @@
#!/bin/sh #!/bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public # ***** BEGIN LICENSE BLOCK *****
# License, v. 2.0. If a copy of the MPL was not distributed with this # Version: MPL 1.1/GPL 2.0/LGPL 2.1
# file, You can obtain one at http://mozilla.org/MPL/2.0/. #
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the MSVC wrappificator.
#
# The Initial Developer of the Original Code is
# Timothy Wall <twalljava@dev.java.net>.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Daniel Witte <dwitte@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
# #
# GCC-compatible wrapper for cl.exe and ml.exe. Arguments are given in GCC # GCC-compatible wrapper for cl.exe and ml.exe. Arguments are given in GCC
# format and translated into something sensible for cl or ml. # format and translated into something sensible for cl or ml.
# #
args_orig=$@
args="-nologo -W3" args="-nologo -W3"
md=-MD md=-MD
cl="cl" cl="cl"
@ -39,14 +73,35 @@ do
shift 1 shift 1
;; ;;
-O*) -O*)
# If we're optimizing, make sure we explicitly turn on some optimizations # Runtime error checks (enabled by setting -RTC1 in the -DFFI_DEBUG
# that are implicitly disabled by debug symbols (-Zi). # case below) are not compatible with optimization flags and will
args="$args $1 -OPT:REF -OPT:ICF -INCREMENTAL:NO" # cause the build to fail. Therefore, drop the optimization flag if
# -DFFI_DEBUG is also set.
case $args_orig in
*-DFFI_DEBUG*)
args="$args"
;;
*)
# The ax_cc_maxopt.m4 macro from the upstream autoconf-archive
# project doesn't support MSVC and therefore ends up trying to
# use -O3. Use the equivalent "max optimization" flag for MSVC
# instead of erroring out.
case $1 in
-O3)
args="$args -O2"
;;
*)
args="$args $1"
;;
esac
opt="true"
;;
esac
shift 1 shift 1
;; ;;
-g) -g)
# Enable debug symbol generation. # Enable debug symbol generation.
args="$args -Zi -DEBUG" args="$args -Zi"
shift 1 shift 1
;; ;;
-DFFI_DEBUG) -DFFI_DEBUG)
@ -93,6 +148,10 @@ do
# to do here. # to do here.
shift 1 shift 1
;; ;;
-pedantic)
# libffi tests -pedantic with -Wall, so drop it also.
shift 1
;;
-Werror) -Werror)
args="$args -WX" args="$args -WX"
shift 1 shift 1
@ -137,6 +196,13 @@ do
esac esac
done done
# If -Zi is specified, certain optimizations are implicitly disabled
# by MSVC. Add back those optimizations if this is an optimized build.
# NOTE: These arguments must come after all others.
if [ -n "$opt" ]; then
args="$args -link -OPT:REF -OPT:ICF -INCREMENTAL:NO"
fi
if [ -n "$assembly" ]; then if [ -n "$assembly" ]; then
if [ -z "$outdir" ]; then if [ -z "$outdir" ]; then
outdir="." outdir="."
@ -156,7 +222,10 @@ if [ -n "$assembly" ]; then
else else
args="$md $args" args="$md $args"
echo "$cl $args" echo "$cl $args"
eval "\"$cl\" $args" # Return an error code of 1 if an invalid command line parameter is passed
# instead of just ignoring it.
eval "(\"$cl\" $args 2>&1 1>&3 | \
awk '{print \$0} /D9002/ {error=1} END{exit error}' >&2) 3>&1"
result=$? result=$?
fi fi

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
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. */
#ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
typedef enum ffi_abi
{
FFI_FIRST_ABI = 0,
FFI_SYSV,
FFI_LAST_ABI,
FFI_DEFAULT_ABI = FFI_SYSV
} ffi_abi;
#endif
/* ---- Definitions for closures ----------------------------------------- */
#define FFI_CLOSURES 1
#define FFI_TRAMPOLINE_SIZE 36
#define FFI_NATIVE_RAW_API 0
/* ---- Internal ---- */
#if defined (__APPLE__)
#define FFI_TARGET_SPECIFIC_VARIADIC
#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_flags; unsigned aarch64_nfixedargs
#else
#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_flags
#endif
#define AARCH64_FFI_WITH_V_BIT 0
#define AARCH64_N_XREG 32
#define AARCH64_N_VREG 32
#define AARCH64_CALL_CONTEXT_SIZE (AARCH64_N_XREG * 8 + AARCH64_N_VREG * 16)
#endif

View File

@ -0,0 +1,333 @@
/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
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_MACHINE_ASM_H
#include <machine/asm.h>
#else
#ifdef __USER_LABEL_PREFIX__
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
/* Use the right prefix for global labels. */
#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
#else
#define CNAME(x) x
#endif
#endif
#define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#define cfi_restore(reg) .cfi_restore reg
#define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg
.text
.globl CNAME(ffi_call_SYSV)
#ifdef __ELF__
.type CNAME(ffi_call_SYSV), #function
#endif
#ifdef __APPLE__
.align 2
#endif
/* ffi_call_SYSV()
Create a stack frame, setup an argument context, call the callee
and extract the result.
The maximum required argument stack size is provided,
ffi_call_SYSV() allocates that stack space then calls the
prepare_fn to populate register context and stack. The
argument passing registers are loaded from the register
context and the callee called, on return the register passing
register are saved back to the context. Our caller will
extract the return value from the final state of the saved
register context.
Prototype:
extern unsigned
ffi_call_SYSV (void (*)(struct call_context *context, unsigned char *,
extended_cif *),
struct call_context *context,
extended_cif *,
size_t required_stack_size,
void (*fn)(void));
Therefore on entry we have:
x0 prepare_fn
x1 &context
x2 &ecif
x3 bytes
x4 fn
This function uses the following stack frame layout:
==
saved x30(lr)
x29(fp)-> saved x29(fp)
saved x24
saved x23
saved x22
sp' -> saved x21
...
sp -> (constructed callee stack arguments)
==
Voila! */
#define ffi_call_SYSV_FS (8 * 4)
.cfi_startproc
CNAME(ffi_call_SYSV):
stp x29, x30, [sp, #-16]!
cfi_adjust_cfa_offset (16)
cfi_rel_offset (x29, 0)
cfi_rel_offset (x30, 8)
mov x29, sp
cfi_def_cfa_register (x29)
sub sp, sp, #ffi_call_SYSV_FS
stp x21, x22, [sp, #0]
cfi_rel_offset (x21, 0 - ffi_call_SYSV_FS)
cfi_rel_offset (x22, 8 - ffi_call_SYSV_FS)
stp x23, x24, [sp, #16]
cfi_rel_offset (x23, 16 - ffi_call_SYSV_FS)
cfi_rel_offset (x24, 24 - ffi_call_SYSV_FS)
mov x21, x1
mov x22, x2
mov x24, x4
/* Allocate the stack space for the actual arguments, many
arguments will be passed in registers, but we assume
worst case and allocate sufficient stack for ALL of
the arguments. */
sub sp, sp, x3
/* unsigned (*prepare_fn) (struct call_context *context,
unsigned char *stack, extended_cif *ecif);
*/
mov x23, x0
mov x0, x1
mov x1, sp
/* x2 already in place */
blr x23
/* Preserve the flags returned. */
mov x23, x0
/* Figure out if we should touch the vector registers. */
tbz x23, #AARCH64_FFI_WITH_V_BIT, 1f
/* Load the vector argument passing registers. */
ldp q0, q1, [x21, #8*32 + 0]
ldp q2, q3, [x21, #8*32 + 32]
ldp q4, q5, [x21, #8*32 + 64]
ldp q6, q7, [x21, #8*32 + 96]
1:
/* Load the core argument passing registers. */
ldp x0, x1, [x21, #0]
ldp x2, x3, [x21, #16]
ldp x4, x5, [x21, #32]
ldp x6, x7, [x21, #48]
/* Don't forget x8 which may be holding the address of a return buffer.
*/
ldr x8, [x21, #8*8]
blr x24
/* Save the core argument passing registers. */
stp x0, x1, [x21, #0]
stp x2, x3, [x21, #16]
stp x4, x5, [x21, #32]
stp x6, x7, [x21, #48]
/* Note nothing useful ever comes back in x8! */
/* Figure out if we should touch the vector registers. */
tbz x23, #AARCH64_FFI_WITH_V_BIT, 1f
/* Save the vector argument passing registers. */
stp q0, q1, [x21, #8*32 + 0]
stp q2, q3, [x21, #8*32 + 32]
stp q4, q5, [x21, #8*32 + 64]
stp q6, q7, [x21, #8*32 + 96]
1:
/* All done, unwind our stack frame. */
ldp x21, x22, [x29, # - ffi_call_SYSV_FS]
cfi_restore (x21)
cfi_restore (x22)
ldp x23, x24, [x29, # - ffi_call_SYSV_FS + 16]
cfi_restore (x23)
cfi_restore (x24)
mov sp, x29
cfi_def_cfa_register (sp)
ldp x29, x30, [sp], #16
cfi_adjust_cfa_offset (-16)
cfi_restore (x29)
cfi_restore (x30)
ret
.cfi_endproc
#ifdef __ELF__
.size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV)
#endif
#define ffi_closure_SYSV_FS (8 * 2 + AARCH64_CALL_CONTEXT_SIZE)
/* ffi_closure_SYSV
Closure invocation glue. This is the low level code invoked directly by
the closure trampoline to setup and call a closure.
On entry x17 points to a struct trampoline_data, x16 has been clobbered
all other registers are preserved.
We allocate a call context and save the argument passing registers,
then invoked the generic C ffi_closure_SYSV_inner() function to do all
the real work, on return we load the result passing registers back from
the call context.
On entry
extern void
ffi_closure_SYSV (struct trampoline_data *);
struct trampoline_data
{
UINT64 *ffi_closure;
UINT64 flags;
};
This function uses the following stack frame layout:
==
saved x30(lr)
x29(fp)-> saved x29(fp)
saved x22
saved x21
...
sp -> call_context
==
Voila! */
.text
.globl CNAME(ffi_closure_SYSV)
#ifdef __APPLE__
.align 2
#endif
.cfi_startproc
CNAME(ffi_closure_SYSV):
stp x29, x30, [sp, #-16]!
cfi_adjust_cfa_offset (16)
cfi_rel_offset (x29, 0)
cfi_rel_offset (x30, 8)
mov x29, sp
cfi_def_cfa_register (x29)
sub sp, sp, #ffi_closure_SYSV_FS
stp x21, x22, [x29, #-16]
cfi_rel_offset (x21, -16)
cfi_rel_offset (x22, -8)
/* Load x21 with &call_context. */
mov x21, sp
/* Preserve our struct trampoline_data * */
mov x22, x17
/* Save the rest of the argument passing registers. */
stp x0, x1, [x21, #0]
stp x2, x3, [x21, #16]
stp x4, x5, [x21, #32]
stp x6, x7, [x21, #48]
/* Don't forget we may have been given a result scratch pad address.
*/
str x8, [x21, #64]
/* Figure out if we should touch the vector registers. */
ldr x0, [x22, #8]
tbz x0, #AARCH64_FFI_WITH_V_BIT, 1f
/* Save the argument passing vector registers. */
stp q0, q1, [x21, #8*32 + 0]
stp q2, q3, [x21, #8*32 + 32]
stp q4, q5, [x21, #8*32 + 64]
stp q6, q7, [x21, #8*32 + 96]
1:
/* Load &ffi_closure.. */
ldr x0, [x22, #0]
mov x1, x21
/* Compute the location of the stack at the point that the
trampoline was called. */
add x2, x29, #16
bl CNAME(ffi_closure_SYSV_inner)
/* Figure out if we should touch the vector registers. */
ldr x0, [x22, #8]
tbz x0, #AARCH64_FFI_WITH_V_BIT, 1f
/* Load the result passing vector registers. */
ldp q0, q1, [x21, #8*32 + 0]
ldp q2, q3, [x21, #8*32 + 32]
ldp q4, q5, [x21, #8*32 + 64]
ldp q6, q7, [x21, #8*32 + 96]
1:
/* Load the result passing core registers. */
ldp x0, x1, [x21, #0]
ldp x2, x3, [x21, #16]
ldp x4, x5, [x21, #32]
ldp x6, x7, [x21, #48]
/* Note nothing useful is returned in x8. */
/* We are done, unwind our frame. */
ldp x21, x22, [x29, #-16]
cfi_restore (x21)
cfi_restore (x22)
mov sp, x29
cfi_def_cfa_register (sp)
ldp x29, x30, [sp], #16
cfi_adjust_cfa_offset (-16)
cfi_restore (x29)
cfi_restore (x30)
ret
.cfi_endproc
#ifdef __ELF__
.size CNAME(ffi_closure_SYSV), .-CNAME(ffi_closure_SYSV)
#endif

View File

@ -1,5 +1,6 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998, 2001, 2007, 2008 Red Hat, Inc. ffi.c - Copyright (c) 2012 Anthony Green
Copyright (c) 1998, 2001, 2007, 2008 Red Hat, Inc.
Alpha Foreign Function Interface Alpha Foreign Function Interface
@ -178,6 +179,9 @@ ffi_prep_closure_loc (ffi_closure* closure,
{ {
unsigned int *tramp; unsigned int *tramp;
if (cif->abi != FFI_OSF)
return FFI_BAD_ABI;
tramp = (unsigned int *) &closure->tramp[0]; tramp = (unsigned int *) &closure->tramp[0];
tramp[0] = 0x47fb0401; /* mov $27,$1 */ tramp[0] = 0x47fb0401; /* mov $27,$1 */
tramp[1] = 0xa77b0010; /* ldq $27,16($27) */ tramp[1] = 0xa77b0010; /* ldq $27,16($27) */

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 1996-2003 Red Hat, Inc.
Target configuration macros for Alpha. Target configuration macros for Alpha.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -27,6 +28,10 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM #ifndef LIBFFI_ASM
typedef unsigned long ffi_arg; typedef unsigned long ffi_arg;
typedef signed long ffi_sarg; typedef signed long ffi_sarg;

View File

@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
osf.S - Copyright (c) 1998, 2001, 2007, 2008 Red Hat osf.S - Copyright (c) 1998, 2001, 2007, 2008, 2011 Red Hat
Alpha/OSF Foreign Function Interface Alpha/OSF Foreign Function Interface
@ -298,34 +298,52 @@ $load_table:
#error "osf.S out of sync with ffi.h" #error "osf.S out of sync with ffi.h"
#endif #endif
#ifdef __ELF__
# define UA_SI .4byte
# define FDE_ENCODING 0x1b /* pcrel sdata4 */
# define FDE_ENCODE(X) .4byte X-.
# define FDE_ARANGE(X) .4byte X
#elif defined __osf__
# define UA_SI .align 0; .long
# define FDE_ENCODING 0x50 /* aligned absolute */
# define FDE_ENCODE(X) .align 3; .quad X
# define FDE_ARANGE(X) .align 0; .quad X
#endif
#ifdef __ELF__ #ifdef __ELF__
.section .eh_frame,EH_FRAME_FLAGS,@progbits .section .eh_frame,EH_FRAME_FLAGS,@progbits
#elif defined __osf__
.data
.align 3
.globl _GLOBAL__F_ffi_call_osf
_GLOBAL__F_ffi_call_osf:
#endif
__FRAME_BEGIN__: __FRAME_BEGIN__:
.4byte $LECIE1-$LSCIE1 # Length of Common Information Entry UA_SI $LECIE1-$LSCIE1 # Length of Common Information Entry
$LSCIE1: $LSCIE1:
.4byte 0x0 # CIE Identifier Tag UA_SI 0x0 # CIE Identifier Tag
.byte 0x1 # CIE Version .byte 0x1 # CIE Version
.ascii "zR\0" # CIE Augmentation .ascii "zR\0" # CIE Augmentation
.byte 0x1 # uleb128 0x1; CIE Code Alignment Factor .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
.byte 0x78 # sleb128 -8; CIE Data Alignment Factor .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
.byte 26 # CIE RA Column .byte 26 # CIE RA Column
.byte 0x1 # uleb128 0x1; Augmentation size .byte 0x1 # uleb128 0x1; Augmentation size
.byte 0x1b # FDE Encoding (pcrel sdata4) .byte FDE_ENCODING # FDE Encoding
.byte 0xc # DW_CFA_def_cfa .byte 0xc # DW_CFA_def_cfa
.byte 30 # uleb128 column 30 .byte 30 # uleb128 column 30
.byte 0 # uleb128 offset 0 .byte 0 # uleb128 offset 0
.align 3 .align 3
$LECIE1: $LECIE1:
$LSFDE1: $LSFDE1:
.4byte $LEFDE1-$LASFDE1 # FDE Length UA_SI $LEFDE1-$LASFDE1 # FDE Length
$LASFDE1: $LASFDE1:
.4byte $LASFDE1-__FRAME_BEGIN__ # FDE CIE offset UA_SI $LASFDE1-__FRAME_BEGIN__ # FDE CIE offset
.4byte $LFB1-. # FDE initial location FDE_ENCODE($LFB1) # FDE initial location
.4byte $LFE1-$LFB1 # FDE address range FDE_ARANGE($LFE1-$LFB1) # FDE address range
.byte 0x0 # uleb128 0x0; Augmentation size .byte 0x0 # uleb128 0x0; Augmentation size
.byte 0x4 # DW_CFA_advance_loc4 .byte 0x4 # DW_CFA_advance_loc4
.4byte $LCFI1-$LFB1 UA_SI $LCFI1-$LFB1
.byte 0x9a # DW_CFA_offset, column 26 .byte 0x9a # DW_CFA_offset, column 26
.byte 4 # uleb128 4*-8 .byte 4 # uleb128 4*-8
.byte 0x8f # DW_CFA_offset, column 15 .byte 0x8f # DW_CFA_offset, column 15
@ -335,32 +353,35 @@ $LASFDE1:
.byte 32 # uleb128 offset 32 .byte 32 # uleb128 offset 32
.byte 0x4 # DW_CFA_advance_loc4 .byte 0x4 # DW_CFA_advance_loc4
.4byte $LCFI2-$LCFI1 UA_SI $LCFI2-$LCFI1
.byte 0xda # DW_CFA_restore, column 26 .byte 0xda # DW_CFA_restore, column 26
.align 3 .align 3
$LEFDE1: $LEFDE1:
$LSFDE3: $LSFDE3:
.4byte $LEFDE3-$LASFDE3 # FDE Length UA_SI $LEFDE3-$LASFDE3 # FDE Length
$LASFDE3: $LASFDE3:
.4byte $LASFDE3-__FRAME_BEGIN__ # FDE CIE offset UA_SI $LASFDE3-__FRAME_BEGIN__ # FDE CIE offset
.4byte $LFB2-. # FDE initial location FDE_ENCODE($LFB2) # FDE initial location
.4byte $LFE2-$LFB2 # FDE address range FDE_ARANGE($LFE2-$LFB2) # FDE address range
.byte 0x0 # uleb128 0x0; Augmentation size .byte 0x0 # uleb128 0x0; Augmentation size
.byte 0x4 # DW_CFA_advance_loc4 .byte 0x4 # DW_CFA_advance_loc4
.4byte $LCFI5-$LFB2 UA_SI $LCFI5-$LFB2
.byte 0xe # DW_CFA_def_cfa_offset .byte 0xe # DW_CFA_def_cfa_offset
.byte 0x80,0x1 # uleb128 128 .byte 0x80,0x1 # uleb128 128
.byte 0x4 # DW_CFA_advance_loc4 .byte 0x4 # DW_CFA_advance_loc4
.4byte $LCFI6-$LCFI5 UA_SI $LCFI6-$LCFI5
.byte 0x9a # DW_CFA_offset, column 26 .byte 0x9a # DW_CFA_offset, column 26
.byte 16 # uleb128 offset 16*-8 .byte 16 # uleb128 offset 16*-8
.align 3 .align 3
$LEFDE3: $LEFDE3:
#if defined __osf__
.align 0
.long 0 # End of Table
#endif
#ifdef __linux__ #if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits .section .note.GNU-stack,"",@progbits
#endif #endif
#endif

View File

@ -0,0 +1,135 @@
/* -----------------------------------------------------------------------
arcompact.S - Copyright (c) 2013 Synposys, Inc. (www.synopsys.com)
ARCompact 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 RENESAS TECHNOLOGY 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_MACHINE_ASM_H
#include <machine/asm.h>
#else
#define CNAME(x) x
#define ENTRY(x) .globl CNAME(x)` .type CNAME(x),%function` CNAME(x):
#endif
.text
/* R0: ffi_prep_args */
/* R1: &ecif */
/* R2: cif->bytes */
/* R3: fig->flags */
/* R4: ecif.rvalue */
/* R5: fn */
ENTRY(ffi_call_ARCompact)
/* Save registers. */
st.a fp, [sp, -4] /* fp + 20, fp */
push_s blink /* fp + 16, blink */
st.a r4, [sp, -4] /* fp + 12, ecif.rvalue */
push_s r3 /* fp + 8, fig->flags */
st.a r5, [sp, -4] /* fp + 4, fn */
push_s r2 /* fp + 0, cif->bytes */
mov fp, sp
/* Make room for all of the new args. */
sub sp, sp, r2
/* Place all of the ffi_prep_args in position. */
/* ffi_prep_args(char *stack, extended_cif *ecif) */
/* R1 already set. */
/* And call. */
jl_s.d [r0]
mov_s r0, sp
ld.ab r12, [fp, 4] /* cif->bytes */
ld.ab r11, [fp, 4] /* fn */
/* Move first 8 parameters in registers... */
ld_s r0, [sp]
ld_s r1, [sp, 4]
ld_s r2, [sp, 8]
ld_s r3, [sp, 12]
ld r4, [sp, 16]
ld r5, [sp, 20]
ld r6, [sp, 24]
ld r7, [sp, 28]
/* ...and adjust the stack. */
min r12, r12, 32
/* Call the function. */
jl.d [r11]
add sp, sp, r12
mov sp, fp
pop_s r3 /* fig->flags, return type */
pop_s r2 /* ecif.rvalue, pointer for return value */
/* If the return value pointer is NULL, assume no return value. */
breq.d r2, 0, epilogue
pop_s blink
/* Return INT. */
brne r3, FFI_TYPE_INT, return_double
b.d epilogue
st_s r0, [r2]
return_double:
brne r3, FFI_TYPE_DOUBLE, epilogue
st_s r0, [r2]
st_s r1, [r2,4]
epilogue:
j_s.d [blink]
ld.ab fp, [sp, 4]
ENTRY(ffi_closure_ARCompact)
st.a r0, [sp, -32]
st_s r1, [sp, 4]
st_s r2, [sp, 8]
st_s r3, [sp, 12]
st r4, [sp, 16]
st r5, [sp, 20]
st r6, [sp, 24]
st r7, [sp, 28]
/* pointer to arguments */
mov_s r2, sp
/* return value goes here */
sub sp, sp, 8
mov_s r1, sp
push_s blink
bl.d ffi_closure_inner_ARCompact
mov_s r0, r8 /* codeloc, set by trampoline */
pop_s blink
/* set return value to r1:r0 */
pop_s r0
pop_s r1
j_s.d [blink]
add_s sp, sp, 32

View File

@ -0,0 +1,268 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2013 Synopsys, Inc. (www.synopsys.com)
ARC 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 RENESAS TECHNOLOGY 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.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/cachectl.h>
/* for little endian ARC, the code is in fact stored as mixed endian for
performance reasons */
#if __BIG_ENDIAN__
#define CODE_ENDIAN(x) (x)
#else
#define CODE_ENDIAN(x) ( (((uint32_t) (x)) << 16) | (((uint32_t) (x)) >> 16))
#endif
/* ffi_prep_args is called by the assembly routine once stack
space has been allocated for the function's arguments. */
void
ffi_prep_args (char *stack, extended_cif * ecif)
{
unsigned int i;
int tmp;
void **p_argv;
char *argp;
ffi_type **p_arg;
tmp = 0;
argp = stack;
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
{
*(void **) argp = ecif->rvalue;
argp += 4;
}
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0); i--, p_arg++)
{
size_t z;
int alignment;
/* align alignment to 4 */
alignment = (((*p_arg)->alignment - 1) | 3) + 1;
/* Align if necessary. */
if ((alignment - 1) & (unsigned) argp)
argp = (char *) ALIGN (argp, alignment);
z = (*p_arg)->size;
if (z < sizeof (int))
{
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, *p_argv, (*p_arg)->size);
break;
default:
FFI_ASSERT (0);
}
}
else if (z == sizeof (int))
{
*(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv);
}
else
{
if ((*p_arg)->type == FFI_TYPE_STRUCT)
{
memcpy (argp, *p_argv, z);
}
else
{
/* Double or long long 64bit. */
memcpy (argp, *p_argv, z);
}
}
p_argv++;
argp += z;
}
return;
}
/* 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 = (unsigned) cif->rtype->type;
break;
case FFI_TYPE_STRUCT:
cif->flags = (unsigned) cif->rtype->type;
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
case FFI_TYPE_DOUBLE:
cif->flags = FFI_TYPE_DOUBLE;
break;
case FFI_TYPE_FLOAT:
default:
cif->flags = FFI_TYPE_INT;
break;
}
return FFI_OK;
}
extern void ffi_call_ARCompact (void (*)(char *, extended_cif *),
extended_cif *, unsigned, unsigned,
unsigned *, void (*fn) (void));
void
ffi_call (ffi_cif * cif, void (*fn) (void), 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))
{
ecif.rvalue = alloca (cif->rtype->size);
}
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_ARCOMPACT:
ffi_call_ARCompact (ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
break;
default:
FFI_ASSERT (0);
break;
}
}
int
ffi_closure_inner_ARCompact (ffi_closure * closure, void *rvalue,
ffi_arg * args)
{
void **arg_area, **p_argv;
ffi_cif *cif = closure->cif;
char *argp = (char *) args;
ffi_type **p_argt;
int i;
arg_area = (void **) alloca (cif->nargs * sizeof (void *));
/* handle hidden argument */
if (cif->flags == FFI_TYPE_STRUCT)
{
rvalue = *(void **) argp;
argp += 4;
}
p_argv = arg_area;
for (i = 0, p_argt = cif->arg_types; i < cif->nargs;
i++, p_argt++, p_argv++)
{
size_t z;
int alignment;
/* align alignment to 4 */
alignment = (((*p_argt)->alignment - 1) | 3) + 1;
/* Align if necessary. */
if ((alignment - 1) & (unsigned) argp)
argp = (char *) ALIGN (argp, alignment);
z = (*p_argt)->size;
*p_argv = (void *) argp;
argp += z;
}
(closure->fun) (cif, rvalue, arg_area, closure->user_data);
return cif->flags;
}
extern void ffi_closure_ARCompact (void);
ffi_status
ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif,
void (*fun) (ffi_cif *, void *, void **, void *),
void *user_data, void *codeloc)
{
uint32_t *tramp = (uint32_t *) & (closure->tramp[0]);
switch (cif->abi)
{
case FFI_ARCOMPACT:
FFI_ASSERT (tramp == codeloc);
tramp[0] = CODE_ENDIAN (0x200a1fc0); /* mov r8, pcl */
tramp[1] = CODE_ENDIAN (0x20200f80); /* j [long imm] */
tramp[2] = CODE_ENDIAN (ffi_closure_ARCompact);
break;
default:
return FFI_BAD_ABI;
}
closure->cif = cif;
closure->fun = fun;
closure->user_data = user_data;
cacheflush (codeloc, FFI_TRAMPOLINE_SIZE, BCACHE);
return FFI_OK;
}

View File

@ -0,0 +1,53 @@
/* -----------------------------------------------------------------------
ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 2013 Synopsys, Inc. (www.synopsys.com)
Target configuration macros for ARC.
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 RENESAS TECHNOLOGY 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.
----------------------------------------------------------------------- */
#ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
/* ---- Generic type definitions ----------------------------------------- */
#ifndef LIBFFI_ASM
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
typedef enum ffi_abi
{
FFI_FIRST_ABI = 0,
FFI_ARCOMPACT,
FFI_LAST_ABI,
FFI_DEFAULT_ABI = FFI_ARCOMPACT
} ffi_abi;
#endif
#define FFI_CLOSURES 1
#define FFI_TRAMPOLINE_SIZE 12
#define FFI_NATIVE_RAW_API 0
#endif

View File

@ -1,7 +1,11 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998, 2008 Red Hat, Inc. ffi.c - Copyright (c) 2011 Timothy Wall
Copyright (c) 2011 Plausible Labs Cooperative, Inc.
ARM Foreign Function Interface Copyright (c) 2011 Anthony Green
Copyright (c) 2011 Free Software Foundation
Copyright (c) 1998, 2008, 2011 Red Hat, Inc.
ARM Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
@ -33,6 +37,87 @@
static int vfp_type_p (ffi_type *); static int vfp_type_p (ffi_type *);
static void layout_vfp_args (ffi_cif *); static void layout_vfp_args (ffi_cif *);
int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space);
int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space);
static char* ffi_align(ffi_type **p_arg, char *argp)
{
/* Align if necessary */
register size_t alignment = (*p_arg)->alignment;
if (alignment < 4)
{
alignment = 4;
}
#ifdef _WIN32_WCE
if (alignment > 4)
{
alignment = 4;
}
#endif
if ((alignment - 1) & (unsigned) argp)
{
argp = (char *) ALIGN(argp, alignment);
}
if ((*p_arg)->type == FFI_TYPE_STRUCT)
{
argp = (char *) ALIGN(argp, 4);
}
return argp;
}
static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
{
register char* argp = stack;
register ffi_type **p_arg = arg_type;
register void **p_argv = arg;
register size_t z = (*p_arg)->size;
if (z < sizeof(int))
{
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, *p_argv, (*p_arg)->size);
break;
default:
FFI_ASSERT(0);
}
}
else if (z == sizeof(int))
{
if ((*p_arg)->type == FFI_TYPE_FLOAT)
*(float *) argp = *(float *)(* p_argv);
else
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
}
else if (z == sizeof(double) && (*p_arg)->type == FFI_TYPE_DOUBLE)
{
*(double *) argp = *(double *)(* p_argv);
}
else
{
memcpy(argp, *p_argv, z);
}
return z;
}
/* ffi_prep_args is called by the assembly routine once stack space /* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments has been allocated for the function's arguments
@ -40,14 +125,14 @@ static void layout_vfp_args (ffi_cif *);
value is cif->vfp_used (word bitset of VFP regs used for passing value is cif->vfp_used (word bitset of VFP regs used for passing
arguments). These are only used for the VFP hard-float ABI. arguments). These are only used for the VFP hard-float ABI.
*/ */
int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space) int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
{ {
register unsigned int i, vi = 0; register unsigned int i;
register void **p_argv; register void **p_argv;
register char *argp; register char *argp;
register ffi_type **p_arg; register ffi_type **p_arg;
argp = stack; argp = stack;
if ( ecif->cif->flags == FFI_TYPE_STRUCT ) { if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
*(void **) argp = ecif->rvalue; *(void **) argp = ecif->rvalue;
@ -58,75 +143,89 @@ int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space)
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0); (i != 0);
i--, p_arg++) i--, p_arg++, p_argv++)
{ {
size_t z; argp = ffi_align(p_arg, argp);
argp += ffi_put_arg(p_arg, p_argv, argp);
/* Allocated in VFP registers. */
if (ecif->cif->abi == FFI_VFP
&& vi < ecif->cif->vfp_nargs && vfp_type_p (*p_arg))
{
float* vfp_slot = vfp_space + ecif->cif->vfp_args[vi++];
if ((*p_arg)->type == FFI_TYPE_FLOAT)
*((float*)vfp_slot) = *((float*)*p_argv);
else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
*((double*)vfp_slot) = *((double*)*p_argv);
else
memcpy(vfp_slot, *p_argv, (*p_arg)->size);
p_argv++;
continue;
}
/* Align if necessary */
if (((*p_arg)->alignment - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, (*p_arg)->alignment);
}
if ((*p_arg)->type == FFI_TYPE_STRUCT)
argp = (char *) ALIGN(argp, 4);
z = (*p_arg)->size;
if (z < sizeof(int))
{
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, *p_argv, (*p_arg)->size);
break;
default:
FFI_ASSERT(0);
}
}
else if (z == sizeof(int))
{
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
}
else
{
memcpy(argp, *p_argv, z);
}
p_argv++;
argp += z;
} }
return 0;
}
int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
{
// make sure we are using FFI_VFP
FFI_ASSERT(ecif->cif->abi == FFI_VFP);
register unsigned int i, vi = 0;
register void **p_argv;
register char *argp, *regp, *eo_regp;
register ffi_type **p_arg;
char stack_used = 0;
char done_with_regs = 0;
char is_vfp_type;
/* the first 4 words on the stack are used for values passed in core
* registers. */
regp = stack;
eo_regp = argp = regp + 16;
/* if the function returns an FFI_TYPE_STRUCT in memory, that address is
* passed in r0 to the function */
if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
*(void **) regp = ecif->rvalue;
regp += 4;
}
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0);
i--, p_arg++, p_argv++)
{
is_vfp_type = vfp_type_p (*p_arg);
/* Allocated in VFP registers. */
if(vi < ecif->cif->vfp_nargs && is_vfp_type)
{
char *vfp_slot = (char *)(vfp_space + ecif->cif->vfp_args[vi++]);
ffi_put_arg(p_arg, p_argv, vfp_slot);
continue;
}
/* Try allocating in core registers. */
else if (!done_with_regs && !is_vfp_type)
{
char *tregp = ffi_align(p_arg, regp);
size_t size = (*p_arg)->size;
size = (size < 4)? 4 : size; // pad
/* Check if there is space left in the aligned register area to place
* the argument */
if(tregp + size <= eo_regp)
{
regp = tregp + ffi_put_arg(p_arg, p_argv, tregp);
done_with_regs = (regp == argp);
// ensure we did not write into the stack area
FFI_ASSERT(regp <= argp);
continue;
}
/* In case there are no arguments in the stack area yet,
the argument is passed in the remaining core registers and on the
stack. */
else if (!stack_used)
{
stack_used = 1;
done_with_regs = 1;
argp = tregp + ffi_put_arg(p_arg, p_argv, tregp);
FFI_ASSERT(eo_regp < argp);
continue;
}
}
/* Base case, arguments are passed on the stack */
stack_used = 1;
argp = ffi_align(p_arg, argp);
argp += ffi_put_arg(p_arg, p_argv, argp);
}
/* Indicate the VFP registers used. */ /* Indicate the VFP registers used. */
return ecif->cif->vfp_used; return ecif->cif->vfp_used;
} }
@ -186,6 +285,18 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
return FFI_OK; return FFI_OK;
} }
/* Perform machine dependent cif processing for variadic calls */
ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
unsigned int nfixedargs,
unsigned int ntotalargs)
{
/* VFP variadic calls actually use the SYSV ABI */
if (cif->abi == FFI_VFP)
cif->abi = FFI_SYSV;
return ffi_prep_cif_machdep(cif);
}
/* Prototypes for assembly functions, in sysv.S */ /* Prototypes for assembly functions, in sysv.S */
extern void ffi_call_SYSV (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *); extern void ffi_call_SYSV (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *);
extern void ffi_call_VFP (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *); extern void ffi_call_VFP (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *);
@ -199,13 +310,13 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
int vfp_struct = (cif->flags == FFI_TYPE_STRUCT_VFP_FLOAT int vfp_struct = (cif->flags == FFI_TYPE_STRUCT_VFP_FLOAT
|| cif->flags == FFI_TYPE_STRUCT_VFP_DOUBLE); || cif->flags == FFI_TYPE_STRUCT_VFP_DOUBLE);
unsigned int temp;
ecif.cif = cif; ecif.cif = cif;
ecif.avalue = avalue; ecif.avalue = avalue;
unsigned int temp;
/* If the return value is a struct and we don't have a return */ /* If the return value is a struct and we don't have a return */
/* value address then we need to make one */ /* value address then we need to make one */
if ((rvalue == NULL) && if ((rvalue == NULL) &&
(cif->flags == FFI_TYPE_STRUCT)) (cif->flags == FFI_TYPE_STRUCT))
@ -229,17 +340,27 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
break; break;
case FFI_VFP: case FFI_VFP:
#ifdef __ARM_EABI__
ffi_call_VFP (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue); ffi_call_VFP (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
break; break;
#endif
default: default:
FFI_ASSERT(0); FFI_ASSERT(0);
break; break;
} }
if (small_struct) if (small_struct)
memcpy (rvalue, &temp, cif->rtype->size); {
FFI_ASSERT(rvalue != NULL);
memcpy (rvalue, &temp, cif->rtype->size);
}
else if (vfp_struct) else if (vfp_struct)
memcpy (rvalue, ecif.rvalue, cif->rtype->size); {
FFI_ASSERT(rvalue != NULL);
memcpy (rvalue, ecif.rvalue, cif->rtype->size);
}
} }
/** private members **/ /** private members **/
@ -247,18 +368,18 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
void** args, ffi_cif* cif, float *vfp_stack); void** args, ffi_cif* cif, float *vfp_stack);
static void ffi_prep_incoming_args_VFP (char *stack, void **ret,
void** args, ffi_cif* cif, float *vfp_stack);
void ffi_closure_SYSV (ffi_closure *); void ffi_closure_SYSV (ffi_closure *);
void ffi_closure_VFP (ffi_closure *); void ffi_closure_VFP (ffi_closure *);
/* This function is jumped to by the trampoline */ /* This function is jumped to by the trampoline */
unsigned int unsigned int FFI_HIDDEN
ffi_closure_SYSV_inner (closure, respp, args, vfp_args) ffi_closure_inner (ffi_closure *closure,
ffi_closure *closure; void **respp, void *args, void *vfp_args)
void **respp;
void *args;
void *vfp_args;
{ {
// our various things... // our various things...
ffi_cif *cif; ffi_cif *cif;
@ -272,8 +393,10 @@ ffi_closure_SYSV_inner (closure, respp, args, vfp_args)
* value on the stack; and if the function returns * value on the stack; and if the function returns
* a structure, it will re-set RESP to point to the * a structure, it will re-set RESP to point to the
* structure return address. */ * structure return address. */
if (cif->abi == FFI_VFP)
ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args); ffi_prep_incoming_args_VFP(args, respp, arg_area, cif, vfp_args);
else
ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args);
(closure->fun) (cif, *respp, arg_area, closure->user_data); (closure->fun) (cif, *respp, arg_area, closure->user_data);
@ -288,7 +411,7 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
float *vfp_stack) float *vfp_stack)
/*@=exportheader@*/ /*@=exportheader@*/
{ {
register unsigned int i, vi = 0; register unsigned int i;
register void **p_argv; register void **p_argv;
register char *argp; register char *argp;
register ffi_type **p_arg; register ffi_type **p_arg;
@ -305,22 +428,8 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
{ {
size_t z; size_t z;
size_t alignment;
if (cif->abi == FFI_VFP
&& vi < cif->vfp_nargs && vfp_type_p (*p_arg))
{
*p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]);
continue;
}
alignment = (*p_arg)->alignment; argp = ffi_align(p_arg, argp);
if (alignment < 4)
alignment = 4;
/* Align if necessary */
if ((alignment - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, alignment);
}
z = (*p_arg)->size; z = (*p_arg)->size;
@ -335,20 +444,328 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
return; return;
} }
/*@-exportheader@*/
static void
ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
void **avalue, ffi_cif *cif,
/* Used only under VFP hard-float ABI. */
float *vfp_stack)
/*@=exportheader@*/
{
register unsigned int i, vi = 0;
register void **p_argv;
register char *argp, *regp, *eo_regp;
register ffi_type **p_arg;
char done_with_regs = 0;
char stack_used = 0;
char is_vfp_type;
FFI_ASSERT(cif->abi == FFI_VFP);
regp = stack;
eo_regp = argp = regp + 16;
if ( cif->flags == FFI_TYPE_STRUCT ) {
*rvalue = *(void **) regp;
regp += 4;
}
p_argv = avalue;
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
{
size_t z;
is_vfp_type = vfp_type_p (*p_arg);
if(vi < cif->vfp_nargs && is_vfp_type)
{
*p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]);
continue;
}
else if (!done_with_regs && !is_vfp_type)
{
char* tregp = ffi_align(p_arg, regp);
z = (*p_arg)->size;
z = (z < 4)? 4 : z; // pad
/* if the arguments either fits into the registers or uses registers
* and stack, while we haven't read other things from the stack */
if(tregp + z <= eo_regp || !stack_used)
{
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) tregp;
p_argv++;
regp = tregp + z;
// if we read past the last core register, make sure we have not read
// from the stack before and continue reading after regp
if(regp > eo_regp)
{
if(stack_used)
{
abort(); // we should never read past the end of the register
// are if the stack is already in use
}
argp = regp;
}
if(regp >= eo_regp)
{
done_with_regs = 1;
stack_used = 1;
}
continue;
}
}
stack_used = 1;
argp = ffi_align(p_arg, argp);
z = (*p_arg)->size;
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) argp;
p_argv++;
argp += z;
}
return;
}
/* How to make a trampoline. */ /* How to make a trampoline. */
extern unsigned int ffi_arm_trampoline[3];
#if FFI_EXEC_TRAMPOLINE_TABLE
#include <mach/mach.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
extern void *ffi_closure_trampoline_table_page;
typedef struct ffi_trampoline_table ffi_trampoline_table;
typedef struct ffi_trampoline_table_entry ffi_trampoline_table_entry;
struct ffi_trampoline_table {
/* contiguous writable and executable pages */
vm_address_t config_page;
vm_address_t trampoline_page;
/* free list tracking */
uint16_t free_count;
ffi_trampoline_table_entry *free_list;
ffi_trampoline_table_entry *free_list_pool;
ffi_trampoline_table *prev;
ffi_trampoline_table *next;
};
struct ffi_trampoline_table_entry {
void *(*trampoline)();
ffi_trampoline_table_entry *next;
};
/* Override the standard architecture trampoline size */
// XXX TODO - Fix
#undef FFI_TRAMPOLINE_SIZE
#define FFI_TRAMPOLINE_SIZE 12
/* The trampoline configuration is placed at 4080 bytes prior to the trampoline's entry point */
#define FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc) ((void **) (((uint8_t *) codeloc) - 4080));
/* The first 16 bytes of the config page are unused, as they are unaddressable from the trampoline page. */
#define FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET 16
/* Total number of trampolines that fit in one trampoline table */
#define FFI_TRAMPOLINE_COUNT ((PAGE_SIZE - FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) / FFI_TRAMPOLINE_SIZE)
static pthread_mutex_t ffi_trampoline_lock = PTHREAD_MUTEX_INITIALIZER;
static ffi_trampoline_table *ffi_trampoline_tables = NULL;
static ffi_trampoline_table *
ffi_trampoline_table_alloc ()
{
ffi_trampoline_table *table = NULL;
/* Loop until we can allocate two contiguous pages */
while (table == NULL) {
vm_address_t config_page = 0x0;
kern_return_t kt;
/* Try to allocate two pages */
kt = vm_allocate (mach_task_self (), &config_page, PAGE_SIZE*2, VM_FLAGS_ANYWHERE);
if (kt != KERN_SUCCESS) {
fprintf(stderr, "vm_allocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
break;
}
/* Now drop the second half of the allocation to make room for the trampoline table */
vm_address_t trampoline_page = config_page+PAGE_SIZE;
kt = vm_deallocate (mach_task_self (), trampoline_page, PAGE_SIZE);
if (kt != KERN_SUCCESS) {
fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
break;
}
/* Remap the trampoline table to directly follow the config page */
vm_prot_t cur_prot;
vm_prot_t max_prot;
kt = vm_remap (mach_task_self (), &trampoline_page, PAGE_SIZE, 0x0, FALSE, mach_task_self (), (vm_address_t) &ffi_closure_trampoline_table_page, FALSE, &cur_prot, &max_prot, VM_INHERIT_SHARE);
/* If we lost access to the destination trampoline page, drop our config allocation mapping and retry */
if (kt != KERN_SUCCESS) {
/* Log unexpected failures */
if (kt != KERN_NO_SPACE) {
fprintf(stderr, "vm_remap() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
}
vm_deallocate (mach_task_self (), config_page, PAGE_SIZE);
continue;
}
/* We have valid trampoline and config pages */
table = calloc (1, sizeof(ffi_trampoline_table));
table->free_count = FFI_TRAMPOLINE_COUNT;
table->config_page = config_page;
table->trampoline_page = trampoline_page;
/* Create and initialize the free list */
table->free_list_pool = calloc(FFI_TRAMPOLINE_COUNT, sizeof(ffi_trampoline_table_entry));
uint16_t i;
for (i = 0; i < table->free_count; i++) {
ffi_trampoline_table_entry *entry = &table->free_list_pool[i];
entry->trampoline = (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE));
if (i < table->free_count - 1)
entry->next = &table->free_list_pool[i+1];
}
table->free_list = table->free_list_pool;
}
return table;
}
void *
ffi_closure_alloc (size_t size, void **code)
{
/* Create the closure */
ffi_closure *closure = malloc(size);
if (closure == NULL)
return NULL;
pthread_mutex_lock(&ffi_trampoline_lock);
/* Check for an active trampoline table with available entries. */
ffi_trampoline_table *table = ffi_trampoline_tables;
if (table == NULL || table->free_list == NULL) {
table = ffi_trampoline_table_alloc ();
if (table == NULL) {
free(closure);
return NULL;
}
/* Insert the new table at the top of the list */
table->next = ffi_trampoline_tables;
if (table->next != NULL)
table->next->prev = table;
ffi_trampoline_tables = table;
}
/* Claim the free entry */
ffi_trampoline_table_entry *entry = ffi_trampoline_tables->free_list;
ffi_trampoline_tables->free_list = entry->next;
ffi_trampoline_tables->free_count--;
entry->next = NULL;
pthread_mutex_unlock(&ffi_trampoline_lock);
/* Initialize the return values */
*code = entry->trampoline;
closure->trampoline_table = table;
closure->trampoline_table_entry = entry;
return closure;
}
void
ffi_closure_free (void *ptr)
{
ffi_closure *closure = ptr;
pthread_mutex_lock(&ffi_trampoline_lock);
/* Fetch the table and entry references */
ffi_trampoline_table *table = closure->trampoline_table;
ffi_trampoline_table_entry *entry = closure->trampoline_table_entry;
/* Return the entry to the free list */
entry->next = table->free_list;
table->free_list = entry;
table->free_count++;
/* If all trampolines within this table are free, and at least one other table exists, deallocate
* the table */
if (table->free_count == FFI_TRAMPOLINE_COUNT && ffi_trampoline_tables != table) {
/* Remove from the list */
if (table->prev != NULL)
table->prev->next = table->next;
if (table->next != NULL)
table->next->prev = table->prev;
/* Deallocate pages */
kern_return_t kt;
kt = vm_deallocate (mach_task_self (), table->config_page, PAGE_SIZE);
if (kt != KERN_SUCCESS)
fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
kt = vm_deallocate (mach_task_self (), table->trampoline_page, PAGE_SIZE);
if (kt != KERN_SUCCESS)
fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
/* Deallocate free list */
free (table->free_list_pool);
free (table);
} else if (ffi_trampoline_tables != table) {
/* Otherwise, bump this table to the top of the list */
table->prev = NULL;
table->next = ffi_trampoline_tables;
if (ffi_trampoline_tables != NULL)
ffi_trampoline_tables->prev = table;
ffi_trampoline_tables = table;
}
pthread_mutex_unlock (&ffi_trampoline_lock);
/* Free the closure */
free (closure);
}
#else
#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \ unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \ unsigned int __ctx = (unsigned int)(CTX); \
*(unsigned int*) &__tramp[0] = 0xe92d000f; /* stmfd sp!, {r0-r3} */ \ unsigned char *insns = (unsigned char *)(CTX); \
*(unsigned int*) &__tramp[4] = 0xe59f0000; /* ldr r0, [pc] */ \ memcpy (__tramp, ffi_arm_trampoline, sizeof ffi_arm_trampoline); \
*(unsigned int*) &__tramp[8] = 0xe59ff000; /* ldr pc, [pc] */ \
*(unsigned int*) &__tramp[12] = __ctx; \ *(unsigned int*) &__tramp[12] = __ctx; \
*(unsigned int*) &__tramp[16] = __fun; \ *(unsigned int*) &__tramp[16] = __fun; \
__clear_cache((&__tramp[0]), (&__tramp[19])); \ __clear_cache((&__tramp[0]), (&__tramp[19])); /* Clear data mapping. */ \
__clear_cache(insns, insns + 3 * sizeof (unsigned int)); \
/* Clear instruction \
mapping. */ \
}) })
#endif
/* the cif must already be prep'ed */ /* the cif must already be prep'ed */
@ -363,15 +780,23 @@ ffi_prep_closure_loc (ffi_closure* closure,
if (cif->abi == FFI_SYSV) if (cif->abi == FFI_SYSV)
closure_func = &ffi_closure_SYSV; closure_func = &ffi_closure_SYSV;
#ifdef __ARM_EABI__
else if (cif->abi == FFI_VFP) else if (cif->abi == FFI_VFP)
closure_func = &ffi_closure_VFP; closure_func = &ffi_closure_VFP;
#endif
else else
FFI_ASSERT (0); return FFI_BAD_ABI;
#if FFI_EXEC_TRAMPOLINE_TABLE
void **config = FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc);
config[0] = closure;
config[1] = closure_func;
#else
FFI_INIT_TRAMPOLINE (&closure->tramp[0], \ FFI_INIT_TRAMPOLINE (&closure->tramp[0], \
closure_func, \ closure_func, \
codeloc); codeloc);
#endif
closure->cif = cif; closure->cif = cif;
closure->user_data = user_data; closure->user_data = user_data;
closure->fun = fun; closure->fun = fun;
@ -444,9 +869,9 @@ static int vfp_type_p (ffi_type *t)
return 0; return 0;
} }
static void place_vfp_arg (ffi_cif *cif, ffi_type *t) static int place_vfp_arg (ffi_cif *cif, ffi_type *t)
{ {
int reg = cif->vfp_reg_free; short reg = cif->vfp_reg_free;
int nregs = t->size / sizeof (float); int nregs = t->size / sizeof (float);
int align = ((t->type == FFI_TYPE_STRUCT_VFP_FLOAT int align = ((t->type == FFI_TYPE_STRUCT_VFP_FLOAT
|| t->type == FFI_TYPE_FLOAT) ? 1 : 2); || t->type == FFI_TYPE_FLOAT) ? 1 : 2);
@ -477,9 +902,13 @@ static void place_vfp_arg (ffi_cif *cif, ffi_type *t)
reg += 1; reg += 1;
cif->vfp_reg_free = reg; cif->vfp_reg_free = reg;
} }
return; return 0;
next_reg: ; next_reg: ;
} }
// done, mark all regs as used
cif->vfp_reg_free = 16;
cif->vfp_used = 0xFFFF;
return 1;
} }
static void layout_vfp_args (ffi_cif *cif) static void layout_vfp_args (ffi_cif *cif)
@ -494,7 +923,9 @@ static void layout_vfp_args (ffi_cif *cif)
for (i = 0; i < cif->nargs; i++) for (i = 0; i < cif->nargs; i++)
{ {
ffi_type *t = cif->arg_types[i]; ffi_type *t = cif->arg_types[i];
if (vfp_type_p (t)) if (vfp_type_p (t) && place_vfp_arg (cif, t) == 1)
place_vfp_arg (cif, t); {
break;
}
} }
} }

View File

@ -1,5 +1,8 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 2010 CodeSourcery
Copyright (c) 1996-2003 Red Hat, Inc.
Target configuration macros for ARM. Target configuration macros for ARM.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -27,6 +30,10 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM #ifndef LIBFFI_ASM
typedef unsigned long ffi_arg; typedef unsigned long ffi_arg;
typedef signed long ffi_sarg; typedef signed long ffi_sarg;
@ -37,9 +44,9 @@ typedef enum ffi_abi {
FFI_VFP, FFI_VFP,
FFI_LAST_ABI, FFI_LAST_ABI,
#ifdef __ARM_PCS_VFP #ifdef __ARM_PCS_VFP
FFI_DEFAULT_ABI = FFI_VFP FFI_DEFAULT_ABI = FFI_VFP,
#else #else
FFI_DEFAULT_ABI = FFI_SYSV FFI_DEFAULT_ABI = FFI_SYSV,
#endif #endif
} ffi_abi; } ffi_abi;
#endif #endif
@ -53,6 +60,8 @@ typedef enum ffi_abi {
#define FFI_TYPE_STRUCT_VFP_FLOAT (FFI_TYPE_LAST + 1) #define FFI_TYPE_STRUCT_VFP_FLOAT (FFI_TYPE_LAST + 1)
#define FFI_TYPE_STRUCT_VFP_DOUBLE (FFI_TYPE_LAST + 2) #define FFI_TYPE_STRUCT_VFP_DOUBLE (FFI_TYPE_LAST + 2)
#define FFI_TARGET_SPECIFIC_VARIADIC
/* ---- Definitions for closures ----------------------------------------- */ /* ---- Definitions for closures ----------------------------------------- */
#define FFI_CLOSURES 1 #define FFI_CLOSURES 1
@ -60,4 +69,3 @@ typedef enum ffi_abi {
#define FFI_NATIVE_RAW_API 0 #define FFI_NATIVE_RAW_API 0
#endif #endif

View File

@ -0,0 +1,118 @@
#!/bin/sh
# -----------------------------------------------------------------------
# gentramp.sh - Copyright (c) 2010, Plausible Labs Cooperative, Inc.
#
# ARM Trampoline Page Generator
#
# 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.
# -----------------------------------------------------------------------
PROGNAME=$0
# Each trampoline is exactly 3 instructions, or 12 bytes. If any of these values change,
# the entire arm trampoline implementation must be updated to match, too.
# Size of an individual trampoline, in bytes
TRAMPOLINE_SIZE=12
# Page size, in bytes
PAGE_SIZE=4096
# Compute the size of the reachable config page; The first 16 bytes of the config page
# are unreachable due to our maximum pc-relative ldr offset.
PAGE_AVAIL=`expr $PAGE_SIZE - 16`
# Compute the number of of available trampolines.
TRAMPOLINE_COUNT=`expr $PAGE_AVAIL / $TRAMPOLINE_SIZE`
header () {
echo "# GENERATED CODE - DO NOT EDIT"
echo "# This file was generated by $PROGNAME"
echo ""
# Write out the license header
cat << EOF
# Copyright (c) 2010, Plausible Labs Cooperative, Inc.
#
# 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.
# -----------------------------------------------------------------------
EOF
# Write out the trampoline table, aligned to the page boundary
echo ".text"
echo ".align 12"
echo ".globl _ffi_closure_trampoline_table_page"
echo "_ffi_closure_trampoline_table_page:"
}
# WARNING - Don't modify the trampoline code size without also updating the relevant libffi code
trampoline () {
cat << END
// trampoline
// Save to stack
stmfd sp!, {r0-r3}
// Load the context argument from the config page.
// This places the first usable config value at _ffi_closure_trampoline_table-4080
// This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
ldr r0, [pc, #-4092]
// Load the jump address from the config page.
ldr pc, [pc, #-4092]
END
}
main () {
# Write out the header
header
# Write out the trampolines
local i=0
while [ $i -lt ${TRAMPOLINE_COUNT} ]; do
trampoline
local i=`expr $i + 1`
done
}
main

View File

@ -1,5 +1,6 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
sysv.S - Copyright (c) 1998, 2008 Red Hat, Inc. sysv.S - Copyright (c) 1998, 2008, 2011 Red Hat, Inc.
Copyright (c) 2011 Plausible Labs Cooperative, Inc.
ARM Foreign Function Interface ARM Foreign Function Interface
@ -39,7 +40,11 @@
#else #else
#define CNAME(x) x #define CNAME(x) x
#endif #endif
#ifdef __APPLE__
#define ENTRY(x) .globl _##x; _##x:
#else
#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x): #define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
#endif /* __APPLE__ */
#endif #endif
#ifdef __ELF__ #ifdef __ELF__
@ -48,6 +53,12 @@
#define LSYM(x) x #define LSYM(x) x
#endif #endif
/* Use the SOFTFP return value ABI on Mac OS X, as per the iOS ABI
Function Call Guide */
#ifdef __APPLE__
#define __SOFTFP__
#endif
/* We need a better way of testing for this, but for now, this is all /* We need a better way of testing for this, but for now, this is all
we can do. */ we can do. */
@ This selects the minimum architecture level required. @ This selects the minimum architecture level required.
@ -98,30 +109,27 @@
#define UNWIND @ #define UNWIND @
#endif #endif
.syntax unified
#if defined(__thumb__) && !defined(__THUMB_INTERWORK__) #if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
.macro ARM_FUNC_START name #define ARM_FUNC_START(name) \
.text .text; \
.align 0 .align 2; \
.thumb .thumb; \
.thumb_func .thumb_func; \
ENTRY(\name) ENTRY(name); \
bx pc bx pc; \
nop nop; \
.arm .arm; \
UNWIND .fnstart UNWIND .fnstart; \
/* A hook to tell gdb that we've switched to ARM mode. Also used to call _L__##name:
directly from other local arm routines. */
_L__\name:
.endm
#else #else
.macro ARM_FUNC_START name #define ARM_FUNC_START(name) \
.text .text; \
.align 0 .align 2; \
.arm .arm; \
ENTRY(\name) ENTRY(name); \
UNWIND .fnstart UNWIND .fnstart
.endm
#endif #endif
.macro RETLDM regs=, cond=, dirn=ia .macro RETLDM regs=, cond=, dirn=ia
@ -141,15 +149,14 @@ _L__\name:
#endif #endif
.endm .endm
@ r0: ffi_prep_args
@ r0: fn
@ r1: &ecif @ r1: &ecif
@ r2: cif->bytes @ r2: cif->bytes
@ r3: fig->flags @ r3: fig->flags
@ sp+0: ecif.rvalue @ sp+0: ecif.rvalue
@ This assumes we are using gas. @ This assumes we are using gas.
ARM_FUNC_START ffi_call_SYSV ARM_FUNC_START(ffi_call_SYSV)
@ Save registers @ Save registers
stmfd sp!, {r0-r3, fp, lr} stmfd sp!, {r0-r3, fp, lr}
UNWIND .save {r0-r3, fp, lr} UNWIND .save {r0-r3, fp, lr}
@ -165,7 +172,7 @@ ARM_FUNC_START ffi_call_SYSV
@ r1 already set @ r1 already set
@ Call ffi_prep_args(stack, &ecif) @ Call ffi_prep_args(stack, &ecif)
bl ffi_prep_args bl CNAME(ffi_prep_args_SYSV)
@ move first 4 parameters in registers @ move first 4 parameters in registers
ldmia sp, {r0-r3} ldmia sp, {r0-r3}
@ -206,7 +213,7 @@ ARM_FUNC_START ffi_call_SYSV
#if defined(__SOFTFP__) || defined(__ARM_EABI__) #if defined(__SOFTFP__) || defined(__ARM_EABI__)
cmpne r3, #FFI_TYPE_DOUBLE cmpne r3, #FFI_TYPE_DOUBLE
#endif #endif
stmeqia r2, {r0, r1} stmiaeq r2, {r0, r1}
#if !defined(__SOFTFP__) && !defined(__ARM_EABI__) #if !defined(__SOFTFP__) && !defined(__ARM_EABI__)
beq LSYM(Lepilogue) beq LSYM(Lepilogue)
@ -222,130 +229,39 @@ ARM_FUNC_START ffi_call_SYSV
#endif #endif
LSYM(Lepilogue): LSYM(Lepilogue):
RETLDM "r0-r3,fp" #if defined (__INTERWORKING__)
ldmia sp!, {r0-r3,fp, lr}
bx lr
#else
ldmia sp!, {r0-r3,fp, pc}
#endif
.ffi_call_SYSV_end: .ffi_call_SYSV_end:
UNWIND .fnend UNWIND .fnend
#ifdef __ELF__
.size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV) .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
#endif
/* Below are VFP hard-float ABI call and closure implementations.
Add VFP FPU directive here. */
.fpu vfp
@ r0: fn
@ r1: &ecif
@ r2: cif->bytes
@ r3: fig->flags
@ sp+0: ecif.rvalue
ARM_FUNC_START ffi_call_VFP
@ Save registers
stmfd sp!, {r0-r3, fp, lr}
UNWIND .save {r0-r3, fp, lr}
mov fp, sp
UNWIND .setfp fp, sp
@ Make room for all of the new args.
sub sp, sp, r2
@ Make room for loading VFP args
sub sp, sp, #64
@ Place all of the ffi_prep_args in position
mov r0, sp
@ r1 already set
sub r2, fp, #64 @ VFP scratch space
@ Call ffi_prep_args(stack, &ecif, vfp_space)
bl ffi_prep_args
@ Load VFP register args if needed
cmp r0, #0
beq LSYM(Lbase_args)
@ Load only d0 if possible
cmp r0, #3
sub ip, fp, #64
flddle d0, [ip]
fldmiadgt ip, {d0-d7}
LSYM(Lbase_args):
@ move first 4 parameters in registers
ldmia sp, {r0-r3}
@ and adjust stack
sub lr, ip, sp @ cif->bytes == (fp - 64) - sp
ldr ip, [fp] @ load fn() in advance
cmp lr, #16
movhs lr, #16
add sp, sp, lr
@ call (fn) (...)
call_reg(ip)
@ Remove the space we pushed for the args
mov sp, fp
@ Load r2 with the pointer to storage for
@ the return value
ldr r2, [sp, #24]
@ Load r3 with the return type code
ldr r3, [sp, #12]
@ If the return value pointer is NULL,
@ assume no return value.
cmp r2, #0
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_INT
streq r0, [r2]
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_SINT64
stmeqia r2, {r0, r1}
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_FLOAT
fstseq s0, [r2]
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_DOUBLE
fstdeq d0, [r2]
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_STRUCT_VFP_FLOAT
cmpne r3, #FFI_TYPE_STRUCT_VFP_DOUBLE
fstmiadeq r2, {d0-d3}
LSYM(Lepilogue_vfp):
RETLDM "r0-r3,fp"
.ffi_call_VFP_end:
UNWIND .fnend
.size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP)
/* /*
unsigned int FFI_HIDDEN unsigned int FFI_HIDDEN
ffi_closure_SYSV_inner (closure, respp, args) ffi_closure_inner (closure, respp, args)
ffi_closure *closure; ffi_closure *closure;
void **respp; void **respp;
void *args; void *args;
*/ */
ARM_FUNC_START ffi_closure_SYSV ARM_FUNC_START(ffi_closure_SYSV)
UNWIND .pad #16 UNWIND .pad #16
add ip, sp, #16 add ip, sp, #16
stmfd sp!, {ip, lr} stmfd sp!, {ip, lr}
UNWIND .save {r0, lr} UNWIND .save {r0, lr}
add r2, sp, #8 add r2, sp, #8
.pad #16 UNWIND .pad #16
sub sp, sp, #16 sub sp, sp, #16
str sp, [sp, #8] str sp, [sp, #8]
add r1, sp, #8 add r1, sp, #8
bl ffi_closure_SYSV_inner bl CNAME(ffi_closure_inner)
cmp r0, #FFI_TYPE_INT cmp r0, #FFI_TYPE_INT
beq .Lretint beq .Lretint
@ -397,10 +313,113 @@ ARM_FUNC_START ffi_closure_SYSV
.ffi_closure_SYSV_end: .ffi_closure_SYSV_end:
UNWIND .fnend UNWIND .fnend
#ifdef __ELF__
.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV) .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
#endif
ARM_FUNC_START ffi_closure_VFP /* Below are VFP hard-float ABI call and closure implementations.
Add VFP FPU directive here. This is only compiled into the library
under EABI. */
#ifdef __ARM_EABI__
.fpu vfp
@ r0: fn
@ r1: &ecif
@ r2: cif->bytes
@ r3: fig->flags
@ sp+0: ecif.rvalue
ARM_FUNC_START(ffi_call_VFP)
@ Save registers
stmfd sp!, {r0-r3, fp, lr}
UNWIND .save {r0-r3, fp, lr}
mov fp, sp
UNWIND .setfp fp, sp
@ Make room for all of the new args.
sub sp, sp, r2
@ Make room for loading VFP args
sub sp, sp, #64
@ Place all of the ffi_prep_args in position
mov r0, sp
@ r1 already set
sub r2, fp, #64 @ VFP scratch space
@ Call ffi_prep_args(stack, &ecif, vfp_space)
bl CNAME(ffi_prep_args_VFP)
@ Load VFP register args if needed
cmp r0, #0
mov ip, fp
beq LSYM(Lbase_args)
@ Load only d0 if possible
cmp r0, #3
sub ip, fp, #64
flddle d0, [ip]
fldmiadgt ip, {d0-d7}
LSYM(Lbase_args):
@ move first 4 parameters in registers
ldmia sp, {r0-r3}
@ and adjust stack
sub lr, ip, sp @ cif->bytes == (fp - 64) - sp
ldr ip, [fp] @ load fn() in advance
cmp lr, #16
movhs lr, #16
add sp, sp, lr
@ call (fn) (...)
call_reg(ip)
@ Remove the space we pushed for the args
mov sp, fp
@ Load r2 with the pointer to storage for
@ the return value
ldr r2, [sp, #24]
@ Load r3 with the return type code
ldr r3, [sp, #12]
@ If the return value pointer is NULL,
@ assume no return value.
cmp r2, #0
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_INT
streq r0, [r2]
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_SINT64
stmeqia r2, {r0, r1}
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_FLOAT
fstseq s0, [r2]
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_DOUBLE
fstdeq d0, [r2]
beq LSYM(Lepilogue_vfp)
cmp r3, #FFI_TYPE_STRUCT_VFP_FLOAT
cmpne r3, #FFI_TYPE_STRUCT_VFP_DOUBLE
fstmiadeq r2, {d0-d3}
LSYM(Lepilogue_vfp):
RETLDM "r0-r3,fp"
.ffi_call_VFP_end:
UNWIND .fnend
.size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP)
ARM_FUNC_START(ffi_closure_VFP)
fstmfdd sp!, {d0-d7} fstmfdd sp!, {d0-d7}
@ r0-r3, then d0-d7 @ r0-r3, then d0-d7
UNWIND .pad #80 UNWIND .pad #80
@ -409,11 +428,11 @@ ARM_FUNC_START ffi_closure_VFP
UNWIND .save {r0, lr} UNWIND .save {r0, lr}
add r2, sp, #72 add r2, sp, #72
add r3, sp, #8 add r3, sp, #8
.pad #72 UNWIND .pad #72
sub sp, sp, #72 sub sp, sp, #72
str sp, [sp, #64] str sp, [sp, #64]
add r1, sp, #64 add r1, sp, #64
bl ffi_closure_SYSV_inner bl CNAME(ffi_closure_inner)
cmp r0, #FFI_TYPE_INT cmp r0, #FFI_TYPE_INT
beq .Lretint_vfp beq .Lretint_vfp
@ -460,6 +479,12 @@ ARM_FUNC_START ffi_closure_VFP
.ffi_closure_VFP_end: .ffi_closure_VFP_end:
UNWIND .fnend UNWIND .fnend
.size CNAME(ffi_closure_VFP),.ffi_closure_VFP_end-CNAME(ffi_closure_VFP) .size CNAME(ffi_closure_VFP),.ffi_closure_VFP_end-CNAME(ffi_closure_VFP)
#endif
ENTRY(ffi_arm_trampoline)
stmfd sp!, {r0-r3}
ldr r0, [pc]
ldr pc, [pc]
#if defined __ELF__ && defined __linux__ #if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk> ffi.c - Copyright (c) 2011 Anthony Green
Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
AVR32 Foreign Function Interface AVR32 Foreign Function Interface
@ -394,7 +395,8 @@ ffi_status ffi_prep_closure_loc(ffi_closure* closure, ffi_cif* cif,
void (*fun)(ffi_cif*, void*, void**, void*), void *user_data, void (*fun)(ffi_cif*, void*, void**, void*), void *user_data,
void *codeloc) void *codeloc)
{ {
FFI_ASSERT(cif->abi == FFI_SYSV); if (cif->abi != FFI_SYSV)
return FFI_BAD_ABI;
unsigned char *__tramp = (unsigned char*)(&closure->tramp[0]); unsigned char *__tramp = (unsigned char*)(&closure->tramp[0]);
unsigned int __fun = (unsigned int)(&ffi_closure_SYSV); unsigned int __fun = (unsigned int)(&ffi_closure_SYSV);

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk> ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
Target configuration macros for AVR32. Target configuration macros for AVR32.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -27,6 +28,10 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM #ifndef LIBFFI_ASM
typedef unsigned long ffi_arg; typedef unsigned long ffi_arg;
typedef signed long ffi_sarg; typedef signed long ffi_sarg;

View File

@ -0,0 +1,196 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2012 Alexandre K. I. de Mendonca <alexandre.keunecke@gmail.com>,
Paulo Pizarro <paulo.pizarro@gmail.com>
Blackfin 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.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
#include <stdio.h>
/* Maximum number of GPRs available for argument passing. */
#define MAX_GPRARGS 3
/*
* Return types
*/
#define FFIBFIN_RET_VOID 0
#define FFIBFIN_RET_BYTE 1
#define FFIBFIN_RET_HALFWORD 2
#define FFIBFIN_RET_INT64 3
#define FFIBFIN_RET_INT32 4
/*====================================================================*/
/* PROTOTYPE *
/*====================================================================*/
void ffi_prep_args(unsigned char *, extended_cif *);
/*====================================================================*/
/* Externals */
/* (Assembly) */
/*====================================================================*/
extern void ffi_call_SYSV(unsigned, extended_cif *, void(*)(unsigned char *, extended_cif *), unsigned, void *, void(*fn)(void));
/*====================================================================*/
/* Implementation */
/* */
/*====================================================================*/
/*
* This function calculates the return type (size) based on type.
*/
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
/* --------------------------------------*
* Return handling *
* --------------------------------------*/
switch (cif->rtype->type) {
case FFI_TYPE_VOID:
cif->flags = FFIBFIN_RET_VOID;
break;
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT16:
cif->flags = FFIBFIN_RET_HALFWORD;
break;
case FFI_TYPE_UINT8:
cif->flags = FFIBFIN_RET_BYTE;
break;
case FFI_TYPE_INT:
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
case FFI_TYPE_FLOAT:
case FFI_TYPE_POINTER:
case FFI_TYPE_SINT8:
cif->flags = FFIBFIN_RET_INT32;
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
case FFI_TYPE_DOUBLE:
cif->flags = FFIBFIN_RET_INT64;
break;
case FFI_TYPE_STRUCT:
if (cif->rtype->size <= 4){
cif->flags = FFIBFIN_RET_INT32;
}else if (cif->rtype->size == 8){
cif->flags = FFIBFIN_RET_INT64;
}else{
//it will return via a hidden pointer in P0
cif->flags = FFIBFIN_RET_VOID;
}
break;
default:
FFI_ASSERT(0);
break;
}
return FFI_OK;
}
/*
* This will prepare the arguments and will call the assembly routine
* cif = the call interface
* fn = the function to be called
* rvalue = the return value
* avalue = the arguments
*/
void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
{
int ret_type = cif->flags;
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
ecif.rvalue = rvalue;
switch (cif->abi) {
case FFI_SYSV:
ffi_call_SYSV(cif->bytes, &ecif, ffi_prep_args, ret_type, ecif.rvalue, fn);
break;
default:
FFI_ASSERT(0);
break;
}
}
/*
* This function prepares the parameters (copies them from the ecif to the stack)
* to call the function (ffi_prep_args is called by the assembly routine in file
* sysv.S, which also calls the actual function)
*/
void ffi_prep_args(unsigned char *stack, extended_cif *ecif)
{
register unsigned int i = 0;
void **p_argv;
unsigned char *argp;
ffi_type **p_arg;
argp = stack;
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)) {
z = sizeof(int);
switch ((*p_arg)->type) {
case FFI_TYPE_SINT8: {
signed char v = *(SINT8 *)(* p_argv);
signed int t = v;
*(signed int *) argp = t;
}
break;
case FFI_TYPE_UINT8: {
unsigned char v = *(UINT8 *)(* p_argv);
unsigned int t = v;
*(unsigned int *) argp = t;
}
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, *p_argv, (*p_arg)->size);
break;
default:
FFI_ASSERT(0);
break;
}
} else if (z == sizeof(int)) {
*(unsigned int *) argp = (unsigned int) * (UINT32 *)(* p_argv);
} else {
memcpy(argp, *p_argv, z);
}
p_argv++;
argp += z;
}
}

View File

@ -0,0 +1,43 @@
/* -----------------------------------------------------------------------
ffitarget.h - Copyright (c) 2012 Alexandre K. I. de Mendonca <alexandre.keunecke@gmail.com>
Blackfin 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.
----------------------------------------------------------------------- */
#ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H
#ifndef LIBFFI_ASM
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
FFI_SYSV,
FFI_LAST_ABI,
FFI_DEFAULT_ABI = FFI_SYSV
} ffi_abi;
#endif
#endif

View File

@ -0,0 +1,179 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2012 Alexandre K. I. de Mendonca <alexandre.keunecke@gmail.com>,
Paulo Pizarro <paulo.pizarro@gmail.com>
Blackfin 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>
.text
.align 4
/*
There is a "feature" in the bfin toolchain that it puts a _ before function names
that's why the function here it's called _ffi_call_SYSV and not ffi_call_SYSV
*/
.global _ffi_call_SYSV;
.type _ffi_call_SYSV, STT_FUNC;
.func ffi_call_SYSV
/*
cif->bytes = R0 (fp+8)
&ecif = R1 (fp+12)
ffi_prep_args = R2 (fp+16)
ret_type = stack (fp+20)
ecif.rvalue = stack (fp+24)
fn = stack (fp+28)
got (fp+32)
There is room for improvement here (we can use temporary registers
instead of saving the values in the memory)
REGS:
P5 => Stack pointer (function arguments)
R5 => cif->bytes
R4 => ret->type
FP-20 = P3
FP-16 = SP (parameters area)
FP-12 = SP (temp)
FP-08 = function return part 1 [R0]
FP-04 = function return part 2 [R1]
*/
_ffi_call_SYSV:
.prologue:
LINK 20;
[FP-20] = P3;
[FP+8] = R0;
[FP+12] = R1;
[FP+16] = R2;
.allocate_stack:
//alocate cif->bytes into the stack
R1 = [FP+8];
R0 = SP;
R0 = R0 - R1;
R1 = 4;
R0 = R0 - R1;
[FP-12] = SP;
SP = R0;
[FP-16] = SP;
.call_prep_args:
//get the addr of prep_args
P0 = [P3 + _ffi_prep_args@FUNCDESC_GOT17M4];
P1 = [P0];
P3 = [P0+4];
R0 = [FP-16];//SP (parameter area)
R1 = [FP+12];//ecif
call (P1);
.call_user_function:
//ajust SP so as to allow the user function access the parameters on the stack
SP = [FP-16]; //point to function parameters
R0 = [SP];
R1 = [SP+4];
R2 = [SP+8];
//load user function address
P0 = FP;
P0 +=28;
P1 = [P0];
P1 = [P1];
P3 = [P0+4];
/*
For functions returning aggregate values (struct) occupying more than 8 bytes,
the caller allocates the return value object on the stack and the address
of this object is passed to the callee as a hidden argument in register P0.
*/
P0 = [FP+24];
call (P1);
SP = [FP-12];
.compute_return:
P2 = [FP-20];
[FP-8] = R0;
[FP-4] = R1;
R0 = [FP+20];
R1 = R0 << 2;
R0 = [P2+.rettable@GOT17M4];
R0 = R1 + R0;
P2 = R0;
R1 = [P2];
P2 = [FP+-20];
R0 = [P2+.rettable@GOT17M4];
R0 = R1 + R0;
P2 = R0;
R0 = [FP-8];
R1 = [FP-4];
jump (P2);
/*
#define FFIBFIN_RET_VOID 0
#define FFIBFIN_RET_BYTE 1
#define FFIBFIN_RET_HALFWORD 2
#define FFIBFIN_RET_INT64 3
#define FFIBFIN_RET_INT32 4
*/
.align 4
.align 4
.rettable:
.dd .epilogue - .rettable
.dd .rbyte - .rettable;
.dd .rhalfword - .rettable;
.dd .rint64 - .rettable;
.dd .rint32 - .rettable;
.rbyte:
P0 = [FP+24];
R0 = R0.B (Z);
[P0] = R0;
JUMP .epilogue
.rhalfword:
P0 = [FP+24];
R0 = R0.L;
[P0] = R0;
JUMP .epilogue
.rint64:
P0 = [FP+24];// &rvalue
[P0] = R0;
[P0+4] = R1;
JUMP .epilogue
.rint32:
P0 = [FP+24];
[P0] = R0;
.epilogue:
R0 = [FP+8];
R1 = [FP+12];
R2 = [FP+16];
P3 = [FP-20];
UNLINK;
RTS;
.size _ffi_call_SYSV,.-_ffi_call_SYSV;
.endfunc

View File

@ -1,6 +1,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
closures.c - Copyright (c) 2007 Red Hat, Inc. closures.c - Copyright (c) 2007, 2009, 2010 Red Hat, Inc.
Copyright (C) 2007, 2009 Free Software Foundation, 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. Code to allocate and deallocate memory for closures.
@ -32,8 +33,8 @@
#include <ffi.h> #include <ffi.h>
#include <ffi_common.h> #include <ffi_common.h>
#ifndef FFI_MMAP_EXEC_WRIT #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
# if __gnu_linux__ # if __gnu_linux__ && !defined(__ANDROID__)
/* This macro indicates it may be forbidden to map anonymous memory /* This macro indicates it may be forbidden to map anonymous memory
with both write and execute permission. Code compiled when this with both write and execute permission. Code compiled when this
option is defined will attempt to map such pages once, but if it option is defined will attempt to map such pages once, but if it
@ -63,7 +64,11 @@
#if FFI_CLOSURES #if FFI_CLOSURES
# if FFI_MMAP_EXEC_WRIT # 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_LOCKS 1
#define USE_DL_PREFIX 1 #define USE_DL_PREFIX 1
@ -167,7 +172,42 @@ selinux_enabled_check (void)
#endif /* !FFI_MMAP_EXEC_SELINUX */ #endif /* !FFI_MMAP_EXEC_SELINUX */
#elif defined (__CYGWIN__) /* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */
#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX
#include <stdlib.h>
static int emutramp_enabled = -1;
static int
emutramp_enabled_check (void)
{
char *buf = NULL;
size_t len = 0;
FILE *f;
int ret;
f = fopen ("/proc/self/status", "r");
if (f == NULL)
return 0;
ret = 0;
while (getline (&buf, &len, f) != -1)
if (!strncmp (buf, "PaX:", 4))
{
char emutramp;
if (sscanf (buf, "%*s %*c%c", &emutramp) == 1)
ret = (emutramp == 'E');
break;
}
free (buf);
fclose (f);
return ret;
}
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
: (emutramp_enabled = emutramp_enabled_check ()))
#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
#elif defined (__CYGWIN__) || defined(__INTERIX)
#include <sys/mman.h> #include <sys/mman.h>
@ -176,6 +216,10 @@ selinux_enabled_check (void)
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */ #endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
#ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX
#define is_emutramp_enabled() 0
#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
/* Declare all functions defined in dlmalloc.c as static. */ /* Declare all functions defined in dlmalloc.c as static. */
static void *dlmalloc(size_t); static void *dlmalloc(size_t);
static void dlfree(void*); static void dlfree(void*);
@ -193,11 +237,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
@ -207,7 +251,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;
@ -236,7 +280,7 @@ static int
open_temp_exec_file_dir (const char *dir) open_temp_exec_file_dir (const char *dir)
{ {
static const char suffix[] = "/ffiXXXXXX"; static const char suffix[] = "/ffiXXXXXX";
int lendir = strlen (dir); size_t lendir = strlen (dir);
char *tempname = __builtin_alloca (lendir + sizeof (suffix)); char *tempname = __builtin_alloca (lendir + sizeof (suffix));
if (!tempname) if (!tempname)
@ -294,7 +338,7 @@ open_temp_exec_file_mnt (const char *mounts)
struct mntent mnt; struct mntent mnt;
char buf[MAXPATHLEN * 3]; char buf[MAXPATHLEN * 3];
if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf))) if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL)
return -1; return -1;
if (hasmntopt (&mnt, "ro") if (hasmntopt (&mnt, "ro")
@ -354,7 +398,7 @@ open_temp_exec_file_opts_next (void)
} }
/* Return a file descriptor of a temporary zero-sized file in a /* Return a file descriptor of a temporary zero-sized file in a
writable and exexutable filesystem. */ writable and executable filesystem. */
static int static int
open_temp_exec_file (void) open_temp_exec_file (void)
{ {
@ -453,6 +497,12 @@ dlmmap (void *start, size_t length, int prot,
printf ("mapping in %zi\n", length); printf ("mapping in %zi\n", length);
#endif #endif
if (execfd == -1 && is_emutramp_enabled ())
{
ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset);
return ptr;
}
if (execfd == -1 && !is_selinux_enabled ()) if (execfd == -1 && !is_selinux_enabled ())
{ {
ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset); ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
@ -522,7 +572,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

View File

@ -153,21 +153,24 @@ ffi_prep_args (char *stack, extended_cif * ecif)
return (struct_count); return (struct_count);
} }
ffi_status ffi_status FFI_HIDDEN
ffi_prep_cif (ffi_cif * cif, ffi_prep_cif_core (ffi_cif * cif,
ffi_abi abi, unsigned int nargs, ffi_abi abi, unsigned int isvariadic,
ffi_type * rtype, ffi_type ** atypes) unsigned int nfixedargs, unsigned int ntotalargs,
ffi_type * rtype, ffi_type ** atypes)
{ {
unsigned bytes = 0; unsigned bytes = 0;
unsigned int i; unsigned int i;
ffi_type **ptr; ffi_type **ptr;
FFI_ASSERT (cif != NULL); FFI_ASSERT (cif != NULL);
FFI_ASSERT((!isvariadic) || (nfixedargs >= 1));
FFI_ASSERT(nfixedargs <= ntotalargs);
FFI_ASSERT (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI); FFI_ASSERT (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI);
cif->abi = abi; cif->abi = abi;
cif->arg_types = atypes; cif->arg_types = atypes;
cif->nargs = nargs; cif->nargs = ntotalargs;
cif->rtype = rtype; cif->rtype = rtype;
cif->flags = 0; cif->flags = 0;

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 1996-2003 Red Hat, Inc.
Target configuration macros for CRIS. Target configuration macros for CRIS.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -27,6 +28,10 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM #ifndef LIBFFI_ASM
typedef unsigned long ffi_arg; typedef unsigned long ffi_arg;
typedef signed long ffi_sarg; typedef signed long ffi_sarg;

View File

@ -622,6 +622,9 @@ DEFAULT_MMAP_THRESHOLD default: 256K
#include "/usr/include/malloc.h" #include "/usr/include/malloc.h"
#else /* HAVE_USR_INCLUDE_MALLOC_H */ #else /* HAVE_USR_INCLUDE_MALLOC_H */
/* HP-UX's stdlib.h redefines mallinfo unless _STRUCT_MALLINFO is defined */
#define _STRUCT_MALLINFO
struct mallinfo { struct mallinfo {
MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
@ -1252,7 +1255,7 @@ extern void* sbrk(ptrdiff_t);
#define SIZE_T_BITSIZE (sizeof(size_t) << 3) #define SIZE_T_BITSIZE (sizeof(size_t) << 3)
/* Some constants coerced to size_t */ /* Some constants coerced to size_t */
/* Annoying but necessary to avoid errors on some plaftorms */ /* Annoying but necessary to avoid errors on some platforms */
#define SIZE_T_ZERO ((size_t)0) #define SIZE_T_ZERO ((size_t)0)
#define SIZE_T_ONE ((size_t)1) #define SIZE_T_ONE ((size_t)1)
#define SIZE_T_TWO ((size_t)2) #define SIZE_T_TWO ((size_t)2)
@ -1406,7 +1409,7 @@ static int win32munmap(void* ptr, size_t size) {
#define CALL_MORECORE(S) MFAIL #define CALL_MORECORE(S) MFAIL
#endif /* HAVE_MORECORE */ #endif /* HAVE_MORECORE */
/* mstate bit set if continguous morecore disabled or failed */ /* mstate bit set if contiguous morecore disabled or failed */
#define USE_NONCONTIGUOUS_BIT (4U) #define USE_NONCONTIGUOUS_BIT (4U)
/* segment bit set in create_mspace_with_base */ /* segment bit set in create_mspace_with_base */
@ -1658,7 +1661,7 @@ struct malloc_chunk {
typedef struct malloc_chunk mchunk; typedef struct malloc_chunk mchunk;
typedef struct malloc_chunk* mchunkptr; typedef struct malloc_chunk* mchunkptr;
typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */
typedef unsigned int bindex_t; /* Described below */ typedef size_t bindex_t; /* Described below */
typedef unsigned int binmap_t; /* Described below */ typedef unsigned int binmap_t; /* Described below */
typedef unsigned int flag_t; /* The type of various bit flag sets */ typedef unsigned int flag_t; /* The type of various bit flag sets */
@ -3087,8 +3090,8 @@ static void internal_malloc_stats(mstate m) {
and choose its bk node as its replacement. and choose its bk node as its replacement.
2. If x was the last node of its size, but not a leaf node, it must 2. If x was the last node of its size, but not a leaf node, it must
be replaced with a leaf node (not merely one with an open left or be replaced with a leaf node (not merely one with an open left or
right), to make sure that lefts and rights of descendents right), to make sure that lefts and rights of descendants
correspond properly to bit masks. We use the rightmost descendent correspond properly to bit masks. We use the rightmost descendant
of x. We could use any other leaf, but this is easy to locate and of x. We could use any other leaf, but this is easy to locate and
tends to counteract removal of leftmosts elsewhere, and so keeps tends to counteract removal of leftmosts elsewhere, and so keeps
paths shorter than minimally guaranteed. This doesn't loop much paths shorter than minimally guaranteed. This doesn't loop much
@ -3385,7 +3388,7 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
*ss = m->seg; /* Push current record */ *ss = m->seg; /* Push current record */
m->seg.base = tbase; m->seg.base = tbase;
m->seg.size = tsize; m->seg.size = tsize;
set_segment_flags(&m->seg, mmapped); (void)set_segment_flags(&m->seg, mmapped);
m->seg.next = ss; m->seg.next = ss;
/* Insert trailing fenceposts */ /* Insert trailing fenceposts */
@ -3545,7 +3548,7 @@ static void* sys_alloc(mstate m, size_t nb) {
if (!is_initialized(m)) { /* first-time initialization */ if (!is_initialized(m)) { /* first-time initialization */
m->seg.base = m->least_addr = tbase; m->seg.base = m->least_addr = tbase;
m->seg.size = tsize; m->seg.size = tsize;
set_segment_flags(&m->seg, mmap_flag); (void)set_segment_flags(&m->seg, mmap_flag);
m->magic = mparams.magic; m->magic = mparams.magic;
init_bins(m); init_bins(m);
if (is_global(m)) if (is_global(m))
@ -5088,10 +5091,10 @@ History:
Wolfram Gloger (Gloger@lrz.uni-muenchen.de). Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
* Use last_remainder in more cases. * Use last_remainder in more cases.
* Pack bins using idea from colin@nyx10.cs.du.edu * Pack bins using idea from colin@nyx10.cs.du.edu
* Use ordered bins instead of best-fit threshhold * Use ordered bins instead of best-fit threshold
* Eliminate block-local decls to simplify tracing and debugging. * Eliminate block-local decls to simplify tracing and debugging.
* Support another case of realloc via move into top * Support another case of realloc via move into top
* Fix error occuring when initial sbrk_base not word-aligned. * Fix error occurring when initial sbrk_base not word-aligned.
* Rely on page size for units instead of SBRK_UNIT to * Rely on page size for units instead of SBRK_UNIT to
avoid surprises about sbrk alignment conventions. avoid surprises about sbrk alignment conventions.
* Add mallinfo, mallopt. Thanks to Raymond Nijssen * Add mallinfo, mallopt. Thanks to Raymond Nijssen

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 1996-2004 Red Hat, Inc. ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 1996-2004 Red Hat, Inc.
Target configuration macros for FR-V Target configuration macros for FR-V
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -27,6 +28,10 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
/* ---- System specific configurations ----------------------------------- */ /* ---- System specific configurations ----------------------------------- */
#ifndef LIBFFI_ASM #ifndef LIBFFI_ASM

View File

@ -1,6 +1,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998, 2007, 2008 Red Hat, Inc. ffi.c - Copyright (c) 1998, 2007, 2008, 2012 Red Hat, Inc.
Copyright (c) 2000 Hewlett Packard Company Copyright (c) 2000 Hewlett Packard Company
Copyright (c) 2011 Anthony Green
IA64 Foreign Function Interface IA64 Foreign Function Interface
@ -324,13 +325,17 @@ ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
if (gpcount < 8 && fpcount < 8) if (gpcount < 8 && fpcount < 8)
stf_spill (&stack->fp_regs[fpcount++], *(float *)avalue[i]); stf_spill (&stack->fp_regs[fpcount++], *(float *)avalue[i]);
stack->gp_regs[gpcount++] = *(UINT32 *)avalue[i]; {
UINT32 tmp;
memcpy (&tmp, avalue[i], sizeof (UINT32));
stack->gp_regs[gpcount++] = tmp;
}
break; break;
case FFI_TYPE_DOUBLE: case FFI_TYPE_DOUBLE:
if (gpcount < 8 && fpcount < 8) if (gpcount < 8 && fpcount < 8)
stf_spill (&stack->fp_regs[fpcount++], *(double *)avalue[i]); stf_spill (&stack->fp_regs[fpcount++], *(double *)avalue[i]);
stack->gp_regs[gpcount++] = *(UINT64 *)avalue[i]; memcpy (&stack->gp_regs[gpcount++], avalue[i], sizeof (UINT64));
break; break;
case FFI_TYPE_LONGDOUBLE: case FFI_TYPE_LONGDOUBLE:
@ -396,7 +401,7 @@ ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
the closure (in the "trampoline" area), but we replace the gp the closure (in the "trampoline" area), but we replace the gp
pointer with a pointer to the closure itself. We also add the real pointer with a pointer to the closure itself. We also add the real
gp pointer to the closure. This allows the function entry code to gp pointer to the closure. This allows the function entry code to
both retrieve the user data, and to restire the correct gp pointer. */ both retrieve the user data, and to restore the correct gp pointer. */
extern void ffi_closure_unix (); extern void ffi_closure_unix ();
@ -425,7 +430,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
struct ffi_ia64_trampoline_struct *tramp; struct ffi_ia64_trampoline_struct *tramp;
struct ia64_fd *fd; struct ia64_fd *fd;
FFI_ASSERT (cif->abi == FFI_UNIX); if (cif->abi != FFI_UNIX)
return FFI_BAD_ABI;
tramp = (struct ffi_ia64_trampoline_struct *)closure->tramp; tramp = (struct ffi_ia64_trampoline_struct *)closure->tramp;
fd = (struct ia64_fd *)(void *)ffi_closure_unix; fd = (struct ia64_fd *)(void *)ffi_closure_unix;

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 1996-2003 Red Hat, Inc.
Target configuration macros for IA-64. Target configuration macros for IA-64.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -27,6 +28,10 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM #ifndef LIBFFI_ASM
typedef unsigned long long ffi_arg; typedef unsigned long long ffi_arg;
typedef signed long long ffi_sarg; typedef signed long long ffi_sarg;

View File

@ -311,7 +311,7 @@ ffi_java_translate_args (ffi_cif *cif, void *rvalue,
ffi_raw_closure *cl = (ffi_raw_closure*)user_data; ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
ffi_java_ptrarray_to_raw (cif, avalue, raw); ffi_java_ptrarray_to_raw (cif, avalue, raw);
(*cl->fun) (cif, rvalue, raw, cl->user_data); (*cl->fun) (cif, rvalue, (ffi_raw*)raw, cl->user_data);
ffi_java_raw_to_rvalue (cif, rvalue); ffi_java_raw_to_rvalue (cif, rvalue);
} }

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 2004 Renesas Technology. ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 2004 Renesas Technology.
Target configuration macros for M32R. Target configuration macros for M32R.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -26,6 +27,10 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
/* ---- Generic type definitions ----------------------------------------- */ /* ---- Generic type definitions ----------------------------------------- */
#ifndef LIBFFI_ASM #ifndef LIBFFI_ASM

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi.c ffi.c
m68k Foreign Function Interface m68k Foreign Function Interface
----------------------------------------------------------------------- */ ----------------------------------------------------------------------- */
#include <ffi.h> #include <ffi.h>
@ -9,8 +9,17 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#ifdef __rtems__
void rtems_cache_flush_multiple_data_lines( const void *, size_t );
#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
void ffi_call_SYSV (extended_cif *, void ffi_call_SYSV (extended_cif *,
unsigned, unsigned, unsigned, unsigned,
@ -35,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;
@ -47,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;
@ -71,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:
@ -103,6 +123,8 @@ ffi_prep_args (void *stack, extended_cif *ecif)
#define CIF_FLAGS_POINTER 32 #define CIF_FLAGS_POINTER 32
#define CIF_FLAGS_STRUCT1 64 #define CIF_FLAGS_STRUCT1 64
#define CIF_FLAGS_STRUCT2 128 #define CIF_FLAGS_STRUCT2 128
#define CIF_FLAGS_SINT8 256
#define CIF_FLAGS_SINT16 512
/* Perform machine dependent cif processing */ /* Perform machine dependent cif processing */
ffi_status ffi_status
@ -116,17 +138,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;
@ -144,9 +183,15 @@ ffi_prep_cif_machdep (ffi_cif *cif)
cif->flags = CIF_FLAGS_DOUBLE; cif->flags = CIF_FLAGS_DOUBLE;
break; break;
#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
case FFI_TYPE_POINTER: case FFI_TYPE_POINTER:
cif->flags = CIF_FLAGS_POINTER; cif->flags = CIF_FLAGS_POINTER;
@ -157,6 +202,14 @@ ffi_prep_cif_machdep (ffi_cif *cif)
cif->flags = CIF_FLAGS_DINT; cif->flags = CIF_FLAGS_DINT;
break; break;
case FFI_TYPE_SINT16:
cif->flags = CIF_FLAGS_SINT16;
break;
case FFI_TYPE_SINT8:
cif->flags = CIF_FLAGS_SINT8;
break;
default: default:
cif->flags = CIF_FLAGS_INT; cif->flags = CIF_FLAGS_INT;
break; break;
@ -212,6 +265,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);
@ -255,19 +328,31 @@ ffi_prep_closure_loc (ffi_closure* closure,
void *user_data, void *user_data,
void *codeloc) void *codeloc)
{ {
FFI_ASSERT (cif->abi == FFI_SYSV); if (cif->abi != FFI_SYSV)
return FFI_BAD_ABI;
*(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__
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, syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE,
FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE); FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE);
#endif
closure->cif = cif; closure->cif = cif;
closure->user_data = user_data; closure->user_data = user_data;
@ -275,4 +360,3 @@ ffi_prep_closure_loc (ffi_closure* closure,
return FFI_OK; return FFI_OK;
} }

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 1996-2003 Red Hat, Inc.
Target configuration macros for Motorola 68K. Target configuration macros for Motorola 68K.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -27,6 +28,10 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM #ifndef LIBFFI_ASM
typedef unsigned long ffi_arg; typedef unsigned long ffi_arg;
typedef signed long ffi_sarg; typedef signed long ffi_sarg;

View File

@ -1,8 +1,11 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
sysv.S - Copyright (c) 1998 Andreas Schwab
Copyright (c) 2008 Red Hat, Inc. sysv.S - Copyright (c) 2012 Alan Hourihane
Copyright (c) 1998, 2012 Andreas Schwab
m68k Foreign Function Interface Copyright (c) 2008 Red Hat, Inc.
Copyright (c) 2012 Thorsten Glaser
m68k Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
@ -39,15 +42,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)
@ -62,14 +71,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
@ -85,7 +98,12 @@ ffi_call_SYSV:
move.l 16(%fp),%d2 move.l 16(%fp),%d2
| If the return value pointer is NULL, assume no return value. | 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 tst.l %a1
#endif
jbeq noretval jbeq noretval
btst #0,%d2 btst #0,%d2
@ -103,25 +121,44 @@ retlongint:
retfloat: retfloat:
btst #2,%d2 btst #2,%d2
jbeq retdouble jbeq retdouble
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.s %fp0,(%a1) fmove.s %fp0,(%a1)
#else
move.l %d0,(%a1)
#endif
jbra epilogue jbra epilogue
retdouble: retdouble:
btst #3,%d2 btst #3,%d2
jbeq retlongdouble jbeq retlongdouble
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d %fp0,(%a1) fmove.d %fp0,(%a1)
#else
move.l %d0,(%a1)+
move.l %d1,(%a1)
#endif
jbra epilogue jbra epilogue
retlongdouble: retlongdouble:
btst #4,%d2 btst #4,%d2
jbeq retpointer jbeq retpointer
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.x %fp0,(%a1) fmove.x %fp0,(%a1)
#else
move.l %d0,(%a1)+
move.l %d1,(%a1)+
move.l %d2,(%a1)
#endif
jbra epilogue jbra epilogue
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:
@ -132,8 +169,28 @@ retstruct1:
retstruct2: retstruct2:
btst #7,%d2 btst #7,%d2
jbeq noretval jbeq retsint8
move.w %d0,(%a1) move.w %d0,(%a1)
jbra epilogue
retsint8:
btst #8,%d2
jbeq retsint16
| NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
ext.w %d0
ext.l %d0
#else
extb.l %d0
#endif
move.l %d0,(%a1)
jbra epilogue
retsint16:
btst #9,%d2
jbeq noretval
ext.l %d0
move.l %d0,(%a1)
noretval: noretval:
epilogue: epilogue:
@ -141,13 +198,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)
@ -157,16 +214,18 @@ 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
jne 1f jne 1f
jcc .Lcls_epilogue jcc .Lcls_epilogue
| CIF_FLAGS_INT
move.l -12(%fp),%d0 move.l -12(%fp),%d0
.Lcls_epilogue: .Lcls_epilogue:
| no CIF_FLAGS_*
unlk %fp unlk %fp
rts rts
1: 1:
@ -174,43 +233,80 @@ ffi_closure_SYSV:
lsr.l #2,%d0 lsr.l #2,%d0
jne 1f jne 1f
jcs .Lcls_ret_float jcs .Lcls_ret_float
| CIF_FLAGS_DINT
move.l (%a0)+,%d0 move.l (%a0)+,%d0
move.l (%a0),%d1 move.l (%a0),%d1
jra .Lcls_epilogue jra .Lcls_epilogue
.Lcls_ret_float: .Lcls_ret_float:
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.s (%a0),%fp0 fmove.s (%a0),%fp0
#else
move.l (%a0),%d0
#endif
jra .Lcls_epilogue jra .Lcls_epilogue
1: 1:
lsr.l #2,%d0 lsr.l #2,%d0
jne 1f jne 1f
jcs .Lcls_ret_ldouble jcs .Lcls_ret_ldouble
| CIF_FLAGS_DOUBLE
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.d (%a0),%fp0 fmove.d (%a0),%fp0
#else
move.l (%a0)+,%d0
move.l (%a0),%d1
#endif
jra .Lcls_epilogue jra .Lcls_epilogue
.Lcls_ret_ldouble: .Lcls_ret_ldouble:
#if defined(__MC68881__) || defined(__HAVE_68881__)
fmove.x (%a0),%fp0 fmove.x (%a0),%fp0
#else
move.l (%a0)+,%d0
move.l (%a0)+,%d1
move.l (%a0),%d2
#endif
jra .Lcls_epilogue jra .Lcls_epilogue
1: 1:
lsr.l #2,%d0 lsr.l #2,%d0
jne .Lcls_ret_struct2 jne 1f
jcs .Lcls_ret_struct1 jcs .Lcls_ret_struct1
| CIF_FLAGS_POINTER
move.l (%a0),%a0 move.l (%a0),%a0
move.l %a0,%d0 move.l %a0,%d0
jra .Lcls_epilogue jra .Lcls_epilogue
.Lcls_ret_struct1: .Lcls_ret_struct1:
move.b (%a0),%d0 move.b (%a0),%d0
jra .Lcls_epilogue jra .Lcls_epilogue
.Lcls_ret_struct2: 1:
lsr.l #2,%d0
jne 1f
jcs .Lcls_ret_sint8
| CIF_FLAGS_STRUCT2
move.w (%a0),%d0 move.w (%a0),%d0
jra .Lcls_epilogue jra .Lcls_epilogue
.Lcls_ret_sint8:
move.l (%a0),%d0
| NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
ext.w %d0
ext.l %d0
#else
extb.l %d0
#endif
jra .Lcls_epilogue
1:
| CIF_FLAGS_SINT16
move.l (%a0),%d0
ext.l %d0
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)
@ -220,14 +316,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

@ -0,0 +1,400 @@
/*
* Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
*
* 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.
*/
/*
* m88k Foreign Function Interface
*
* This file attempts to provide all the FFI entry points which can reliably
* be implemented in C.
*
* Only OpenBSD/m88k is currently supported; other platforms (such as
* Motorola's SysV/m88k) could be supported with the following tweaks:
*
* - non-OpenBSD systems use an `outgoing parameter area' as part of the
* 88BCS calling convention, which is not supported under OpenBSD from
* release 3.6 onwards. Supporting it should be as easy as taking it
* into account when adjusting the stack, in the assembly code.
*
* - the logic deciding whether a function argument gets passed through
* registers, or on the stack, has changed several times in OpenBSD in
* edge cases (especially for structs larger than 32 bytes being passed
* by value). The code below attemps to match the logic used by the
* system compiler of OpenBSD 5.3, i.e. gcc 3.3.6 with many m88k backend
* fixes.
*/
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
#include <unistd.h>
void ffi_call_OBSD (unsigned int, extended_cif *, unsigned int, void *,
void (*fn) ());
void *ffi_prep_args (void *, extended_cif *);
void ffi_closure_OBSD (ffi_closure *);
void ffi_closure_struct_OBSD (ffi_closure *);
unsigned int ffi_closure_OBSD_inner (ffi_closure *, void *, unsigned int *,
char *);
void ffi_cacheflush_OBSD (unsigned int, unsigned int);
#define CIF_FLAGS_INT (1 << 0)
#define CIF_FLAGS_DINT (1 << 1)
/*
* Foreign Function Interface API
*/
/* 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, *stackp;
unsigned int *regp;
unsigned int regused;
ffi_type **p_arg;
void *struct_value_ptr;
regp = (unsigned int *)stack;
stackp = (char *)(regp + 8);
regused = 0;
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;
unsigned short t, a;
z = (*p_arg)->size;
t = (*p_arg)->type;
a = (*p_arg)->alignment;
/*
* Figure out whether the argument can be passed through registers
* or on the stack.
* The rule is that registers can only receive simple types not larger
* than 64 bits, or structs the exact size of a register and aligned to
* the size of a register.
*/
if (t == FFI_TYPE_STRUCT)
{
if (z == sizeof (int) && a == sizeof (int) && regused < 8)
argp = (char *)regp;
else
argp = stackp;
}
else
{
if (z > sizeof (int) && regused < 8 - 1)
{
/* align to an even register pair */
if (regused & 1)
{
regp++;
regused++;
}
}
if (regused < 8)
argp = (char *)regp;
else
argp = stackp;
}
/* Enforce proper stack alignment of 64-bit types */
if (argp == stackp && a > sizeof (int))
{
stackp = (char *) ALIGN(stackp, a);
argp = stackp;
}
switch (t)
{
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_INT:
case FFI_TYPE_FLOAT:
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
case FFI_TYPE_POINTER:
*(unsigned int *) argp = *(unsigned int *) *p_argv;
break;
case FFI_TYPE_DOUBLE:
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_STRUCT:
memcpy (argp, *p_argv, z);
break;
default:
FFI_ASSERT (0);
}
/* Align if necessary. */
if ((sizeof (int) - 1) & z)
z = ALIGN(z, sizeof (int));
p_argv++;
/* Be careful, once all registers are filled, and about to continue
on stack, regp == stackp. Therefore the check for regused as well. */
if (argp == (char *)regp && regused < 8)
{
regp += z / sizeof (int);
regused += z / sizeof (int);
}
else
stackp += z;
}
return struct_value_ptr;
}
/* 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:
if (cif->rtype->size == sizeof (int) &&
cif->rtype->alignment == sizeof (int))
cif->flags = CIF_FLAGS_INT;
else
cif->flags = 0;
break;
case FFI_TYPE_DOUBLE:
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 != sizeof (int)
|| cif->rtype->alignment != sizeof (int)))
ecif.rvalue = alloca (cif->rtype->size);
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_OBSD:
ffi_call_OBSD (cif->bytes, &ecif, cif->flags, ecif.rvalue, fn);
break;
default:
FFI_ASSERT (0);
break;
}
}
/*
* Closure API
*/
static void
ffi_prep_closure_args_OBSD (ffi_cif *cif, void **avalue, unsigned int *regp,
char *stackp)
{
unsigned int i;
void **p_argv;
char *argp;
unsigned int regused;
ffi_type **p_arg;
regused = 0;
p_argv = avalue;
for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++)
{
size_t z;
unsigned short t, a;
z = (*p_arg)->size;
t = (*p_arg)->type;
a = (*p_arg)->alignment;
/*
* Figure out whether the argument has been passed through registers
* or on the stack.
* The rule is that registers can only receive simple types not larger
* than 64 bits, or structs the exact size of a register and aligned to
* the size of a register.
*/
if (t == FFI_TYPE_STRUCT)
{
if (z == sizeof (int) && a == sizeof (int) && regused < 8)
argp = (char *)regp;
else
argp = stackp;
}
else
{
if (z > sizeof (int) && regused < 8 - 1)
{
/* align to an even register pair */
if (regused & 1)
{
regp++;
regused++;
}
}
if (regused < 8)
argp = (char *)regp;
else
argp = stackp;
}
/* Enforce proper stack alignment of 64-bit types */
if (argp == stackp && a > sizeof (int))
{
stackp = (char *) ALIGN(stackp, a);
argp = stackp;
}
if (z < sizeof (int) && t != FFI_TYPE_STRUCT)
*p_argv = (void *) (argp + sizeof (int) - z);
else
*p_argv = (void *) argp;
/* Align if necessary */
if ((sizeof (int) - 1) & z)
z = ALIGN(z, sizeof (int));
p_argv++;
/* Be careful, once all registers are exhausted, and about to fetch from
stack, regp == stackp. Therefore the check for regused as well. */
if (argp == (char *)regp && regused < 8)
{
regp += z / sizeof (int);
regused += z / sizeof (int);
}
else
stackp += z;
}
}
unsigned int
ffi_closure_OBSD_inner (ffi_closure *closure, void *resp, unsigned int *regp,
char *stackp)
{
ffi_cif *cif;
void **arg_area;
cif = closure->cif;
arg_area = (void**) alloca (cif->nargs * sizeof (void *));
ffi_prep_closure_args_OBSD(cif, arg_area, regp, stackp);
(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)
{
unsigned int *tramp = (unsigned int *) codeloc;
void *fn;
FFI_ASSERT (cif->abi == FFI_OBSD);
if (cif->rtype->type == FFI_TYPE_STRUCT && !cif->flags)
fn = &ffi_closure_struct_OBSD;
else
fn = &ffi_closure_OBSD;
/* or.u %r10, %r0, %hi16(fn) */
tramp[0] = 0x5d400000 | (((unsigned int)fn) >> 16);
/* or.u %r13, %r0, %hi16(closure) */
tramp[1] = 0x5da00000 | ((unsigned int)closure >> 16);
/* or %r10, %r10, %lo16(fn) */
tramp[2] = 0x594a0000 | (((unsigned int)fn) & 0xffff);
/* jmp.n %r10 */
tramp[3] = 0xf400c40a;
/* or %r13, %r13, %lo16(closure) */
tramp[4] = 0x59ad0000 | ((unsigned int)closure & 0xffff);
ffi_cacheflush_OBSD((unsigned int)codeloc, FFI_TRAMPOLINE_SIZE);
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
return FFI_OK;
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
*
* 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.
*/
/*
* m88k Foreign Function Interface
*/
#ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H
#ifndef LIBFFI_ASM
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
FFI_OBSD,
FFI_DEFAULT_ABI = FFI_OBSD,
FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
} ffi_abi;
#endif
/* ---- Definitions for closures ----------------------------------------- */
#define FFI_CLOSURES 1
#define FFI_TRAMPOLINE_SIZE 0x14
#define FFI_NATIVE_RAW_API 0
#endif

View File

@ -0,0 +1,209 @@
/*
* Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
*
* 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.
*/
/*
* m88k Foreign Function Interface
*/
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
.text
/*
* ffi_cacheflush_OBSD(unsigned int addr, %r2
* unsigned int size); %r3
*/
.align 4
.globl ffi_cacheflush_OBSD
.type ffi_cacheflush_OBSD,@function
ffi_cacheflush_OBSD:
tb0 0, %r0, 451
or %r0, %r0, %r0
jmp %r1
.size ffi_cacheflush_OBSD, . - ffi_cacheflush_OBSD
/*
* ffi_call_OBSD(unsigned bytes, %r2
* extended_cif *ecif, %r3
* unsigned flags, %r4
* void *rvalue, %r5
* void (*fn)()); %r6
*/
.align 4
.globl ffi_call_OBSD
.type ffi_call_OBSD,@function
ffi_call_OBSD:
subu %r31, %r31, 32
st %r30, %r31, 4
st %r1, %r31, 0
addu %r30, %r31, 32
| Save the few arguments we'll need after ffi_prep_args()
st.d %r4, %r31, 8
st %r6, %r31, 16
| Allocate room for the image of r2-r9, and the stack space for
| the args (rounded to a 16-byte boundary)
addu %r2, %r2, (8 * 4) + 15
clr %r2, %r2, 4<0>
subu %r31, %r31, %r2
| Fill register and stack image
or %r2, %r31, %r0
#ifdef PIC
bsr ffi_prep_args#plt
#else
bsr ffi_prep_args
#endif
| Save pointer to return struct address, if any
or %r12, %r2, %r0
| Get function pointer
subu %r4, %r30, 32
ld %r1, %r4, 16
| Fetch the register arguments
ld.d %r2, %r31, (0 * 4)
ld.d %r4, %r31, (2 * 4)
ld.d %r6, %r31, (4 * 4)
ld.d %r8, %r31, (6 * 4)
addu %r31, %r31, (8 * 4)
| Invoke the function
jsr %r1
| Restore stack now that we don't need the args anymore
subu %r31, %r30, 32
| Figure out what to return as the function's return value
ld %r5, %r31, 12 | rvalue
ld %r4, %r31, 8 | flags
bcnd eq0, %r5, 9f
bb0 0, %r4, 1f | CIF_FLAGS_INT
st %r2, %r5, 0
br 9f
1:
bb0 1, %r4, 1f | CIF_FLAGS_DINT
st.d %r2, %r5, 0
br 9f
1:
9:
ld %r1, %r31, 0
ld %r30, %r31, 4
jmp.n %r1
addu %r31, %r31, 32
.size ffi_call_OBSD, . - ffi_call_OBSD
/*
* ffi_closure_OBSD(ffi_closure *closure); %r13
*/
.align 4
.globl ffi_closure_OBSD
.type ffi_closure_OBSD, @function
ffi_closure_OBSD:
subu %r31, %r31, 16
st %r30, %r31, 4
st %r1, %r31, 0
addu %r30, %r31, 16
| Make room on the stack for saved register arguments and return
| value
subu %r31, %r31, (8 * 4) + (2 * 4)
st.d %r2, %r31, (0 * 4)
st.d %r4, %r31, (2 * 4)
st.d %r6, %r31, (4 * 4)
st.d %r8, %r31, (6 * 4)
| Invoke the closure function
or %r5, %r30, 0 | calling stack
addu %r4, %r31, 0 | saved registers
addu %r3, %r31, (8 * 4) | return value
or %r2, %r13, %r0 | closure
#ifdef PIC
bsr ffi_closure_OBSD_inner#plt
#else
bsr ffi_closure_OBSD_inner
#endif
| Figure out what to return as the function's return value
bb0 0, %r2, 1f | CIF_FLAGS_INT
ld %r2, %r31, (8 * 4)
br 9f
1:
bb0 1, %r2, 1f | CIF_FLAGS_DINT
ld.d %r2, %r31, (8 * 4)
br 9f
1:
9:
subu %r31, %r30, 16
ld %r1, %r31, 0
ld %r30, %r31, 4
jmp.n %r1
addu %r31, %r31, 16
.size ffi_closure_OBSD,.-ffi_closure_OBSD
/*
* ffi_closure_struct_OBSD(ffi_closure *closure); %r13
*/
.align 4
.globl ffi_closure_struct_OBSD
.type ffi_closure_struct_OBSD, @function
ffi_closure_struct_OBSD:
subu %r31, %r31, 16
st %r30, %r31, 4
st %r1, %r31, 0
addu %r30, %r31, 16
| Make room on the stack for saved register arguments
subu %r31, %r31, (8 * 4)
st.d %r2, %r31, (0 * 4)
st.d %r4, %r31, (2 * 4)
st.d %r6, %r31, (4 * 4)
st.d %r8, %r31, (6 * 4)
| Invoke the closure function
or %r5, %r30, 0 | calling stack
addu %r4, %r31, 0 | saved registers
or %r3, %r12, 0 | return value
or %r2, %r13, %r0 | closure
#ifdef PIC
bsr ffi_closure_OBSD_inner#plt
#else
bsr ffi_closure_OBSD_inner
#endif
subu %r31, %r30, 16
ld %r1, %r31, 0
ld %r30, %r31, 4
jmp.n %r1
addu %r31, %r31, 16
.size ffi_closure_struct_OBSD,.-ffi_closure_struct_OBSD

View File

@ -0,0 +1,330 @@
/* ----------------------------------------------------------------------
ffi.c - Copyright (c) 2013 Imagination Technologies
Meta 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 SIMON POSNJAK 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.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
/*
* ffi_prep_args is called by the assembly routine once stack space has been
* allocated for the function's arguments
*/
unsigned int ffi_prep_args(char *stack, extended_cif *ecif)
{
register unsigned int i;
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
argp = stack;
/* Store return value */
if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
argp -= 4;
*(void **) argp = ecif->rvalue;
}
p_argv = ecif->avalue;
/* point to next location */
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; (i != 0); i--, p_arg++, p_argv++)
{
size_t z;
/* Move argp to address of argument */
z = (*p_arg)->size;
argp -= z;
/* Align if necessary */
argp = (char *) ALIGN_DOWN(ALIGN_DOWN(argp, (*p_arg)->alignment), 4);
if (z < sizeof(int)) {
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);
case FFI_TYPE_STRUCT:
memcpy(argp, *p_argv, (*p_arg)->size);
break;
default:
FFI_ASSERT(0);
}
} else if ( z == sizeof(int)) {
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
} else {
memcpy(argp, *p_argv, z);
}
}
/* return the size of the arguments to be passed in registers,
padded to an 8 byte boundary to preserve stack alignment */
return ALIGN(MIN(stack - argp, 6*4), 8);
}
/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
ffi_type **ptr;
unsigned i, bytes = 0;
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) {
if ((*ptr)->size == 0)
return FFI_BAD_TYPEDEF;
/* Perform a sanity check on the argument type, do this
check after the initialization. */
FFI_ASSERT_VALID_TYPE(*ptr);
/* Add any padding if necessary */
if (((*ptr)->alignment - 1) & bytes)
bytes = ALIGN(bytes, (*ptr)->alignment);
bytes += ALIGN((*ptr)->size, 4);
}
/* Ensure arg space is aligned to an 8-byte boundary */
bytes = ALIGN(bytes, 8);
/* Make space for the return structure pointer */
if (cif->rtype->type == FFI_TYPE_STRUCT) {
bytes += sizeof(void*);
/* Ensure stack is aligned to an 8-byte boundary */
bytes = ALIGN(bytes, 8);
}
cif->bytes = bytes;
/* Set the return type flag */
switch (cif->rtype->type) {
case FFI_TYPE_VOID:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags = (unsigned) cif->rtype->type;
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
cif->flags = (unsigned) FFI_TYPE_SINT64;
break;
case FFI_TYPE_STRUCT:
/* Meta can store return values which are <= 64 bits */
if (cif->rtype->size <= 4)
/* Returned to D0Re0 as 32-bit value */
cif->flags = (unsigned)FFI_TYPE_INT;
else if ((cif->rtype->size > 4) && (cif->rtype->size <= 8))
/* Returned valued is stored to D1Re0|R0Re0 */
cif->flags = (unsigned)FFI_TYPE_DOUBLE;
else
/* value stored in memory */
cif->flags = (unsigned)FFI_TYPE_STRUCT;
break;
default:
cif->flags = (unsigned)FFI_TYPE_INT;
break;
}
return FFI_OK;
}
extern void ffi_call_SYSV(void (*fn)(void), extended_cif *, unsigned, unsigned, double *);
/*
* Exported in API. Entry point
* cif -> ffi_cif object
* fn -> function pointer
* rvalue -> pointer to return value
* avalue -> vector of void * pointers pointing to memory locations holding the
* arguments
*/
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
extended_cif ecif;
int small_struct = (((cif->flags == FFI_TYPE_INT) || (cif->flags == FFI_TYPE_DOUBLE)) && (cif->rtype->type == FFI_TYPE_STRUCT));
ecif.cif = cif;
ecif.avalue = avalue;
double temp;
/*
* 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->flags == FFI_TYPE_STRUCT))
ecif.rvalue = alloca(cif->rtype->size);
else if (small_struct)
ecif.rvalue = &temp;
else
ecif.rvalue = rvalue;
switch (cif->abi) {
case FFI_SYSV:
ffi_call_SYSV(fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
break;
default:
FFI_ASSERT(0);
break;
}
if (small_struct)
memcpy (rvalue, &temp, cif->rtype->size);
}
/* private members */
static void ffi_prep_incoming_args_SYSV (char *, void **, void **,
ffi_cif*, float *);
void ffi_closure_SYSV (ffi_closure *);
/* Do NOT change that without changing the FFI_TRAMPOLINE_SIZE */
extern unsigned int ffi_metag_trampoline[10]; /* 10 instructions */
/* end of private members */
/*
* __tramp: trampoline memory location
* __fun: assembly routine
* __ctx: memory location for wrapper
*
* At this point, tramp[0] == __ctx !
*/
void ffi_init_trampoline(unsigned char *__tramp, unsigned int __fun, unsigned int __ctx) {
memcpy (__tramp, ffi_metag_trampoline, sizeof(ffi_metag_trampoline));
*(unsigned int*) &__tramp[40] = __ctx;
*(unsigned int*) &__tramp[44] = __fun;
/* This will flush the instruction cache */
__builtin_meta2_cachewd(&__tramp[0], 1);
__builtin_meta2_cachewd(&__tramp[47], 1);
}
/* the cif must already be prepared */
ffi_status
ffi_prep_closure_loc (ffi_closure *closure,
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data,
void *codeloc)
{
void (*closure_func)(ffi_closure*) = NULL;
if (cif->abi == FFI_SYSV)
closure_func = &ffi_closure_SYSV;
else
return FFI_BAD_ABI;
ffi_init_trampoline(
(unsigned char*)&closure->tramp[0],
(unsigned int)closure_func,
(unsigned int)codeloc);
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
return FFI_OK;
}
/* This function is jumped to by the trampoline */
unsigned int ffi_closure_SYSV_inner (closure, respp, args, vfp_args)
ffi_closure *closure;
void **respp;
void *args;
void *vfp_args;
{
ffi_cif *cif;
void **arg_area;
cif = closure->cif;
arg_area = (void**) alloca (cif->nargs * sizeof (void*));
/*
* This call will initialize ARG_AREA, such that each
* element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will re-set RESP to point to the
* structure return address.
*/
ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args);
(closure->fun) ( cif, *respp, arg_area, closure->user_data);
return cif->flags;
}
static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
void **avalue, ffi_cif *cif,
float *vfp_stack)
{
register unsigned int i;
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
/* stack points to original arguments */
argp = stack;
/* Store return value */
if ( cif->flags == FFI_TYPE_STRUCT ) {
argp -= 4;
*rvalue = *(void **) argp;
}
p_argv = avalue;
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) {
size_t z;
size_t alignment;
alignment = (*p_arg)->alignment;
if (alignment < 4)
alignment = 4;
if ((alignment - 1) & (unsigned)argp)
argp = (char *) ALIGN(argp, alignment);
z = (*p_arg)->size;
*p_argv = (void*) argp;
p_argv++;
argp -= z;
}
return;
}

View File

@ -0,0 +1,53 @@
/* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 2013 Imagination Technologies Ltd.
Target configuration macros for Meta
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.
----------------------------------------------------------------------- */
#ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
FFI_SYSV,
FFI_DEFAULT_ABI = FFI_SYSV,
FFI_LAST_ABI = FFI_DEFAULT_ABI + 1,
} ffi_abi;
#endif
/* ---- Definitions for closures ----------------------------------------- */
#define FFI_CLOSURES 1
#define FFI_TRAMPOLINE_SIZE 48
#define FFI_NATIVE_RAW_API 0
#endif

View File

@ -0,0 +1,311 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2013 Imagination Technologies Ltd.
Meta 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_MACHINE_ASM_H
#include <machine/asm.h>
#else
#ifdef __USER_LABEL_PREFIX__
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
/* Use the right prefix for global labels. */
#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
#else
#define CNAME(x) x
#endif
#define ENTRY(x) .globl CNAME(x); .type CNAME(x), %function; CNAME(x):
#endif
#ifdef __ELF__
#define LSYM(x) .x
#else
#define LSYM(x) x
#endif
.macro call_reg x=
.text
.balign 4
mov D1RtP, \x
swap D1RtP, PC
.endm
! Save register arguments
.macro SAVE_ARGS
.text
.balign 4
setl [A0StP++], D0Ar6, D1Ar5
setl [A0StP++], D0Ar4, D1Ar3
setl [A0StP++], D0Ar2, D1Ar1
.endm
! Save retrun, frame pointer and other regs
.macro SAVE_REGS regs=
.text
.balign 4
setl [A0StP++], D0FrT, D1RtP
! Needs to be a pair of regs
.ifnc "\regs",""
setl [A0StP++], \regs
.endif
.endm
! Declare a global function
.macro METAG_FUNC_START name
.text
.balign 4
ENTRY(\name)
.endm
! Return registers from the stack. Reverse SAVE_REGS operation
.macro RET_REGS regs=, cond=
.ifnc "\regs", ""
getl \regs, [--A0StP]
.endif
getl D0FrT, D1RtP, [--A0StP]
.endm
! Return arguments
.macro RET_ARGS
getl D0Ar2, D1Ar1, [--A0StP]
getl D0Ar4, D1Ar3, [--A0StP]
getl D0Ar6, D1Ar5, [--A0StP]
.endm
! D1Ar1: fn
! D0Ar2: &ecif
! D1Ar3: cif->bytes
! D0Ar4: fig->flags
! D1Ar5: ecif.rvalue
! This assumes we are using GNU as
METAG_FUNC_START ffi_call_SYSV
! Save argument registers
SAVE_ARGS
! new frame
mov D0FrT, A0FrP
add A0FrP, A0StP, #0
! Preserve the old frame pointer
SAVE_REGS "D1.5, D0.5"
! Make room for new args. cifs->bytes is the total space for input
! and return arguments
add A0StP, A0StP, D1Ar3
! Preserve cifs->bytes & fn
mov D0.5, D1Ar3
mov D1.5, D1Ar1
! Place all of the ffi_prep_args in position
mov D1Ar1, A0StP
! Call ffi_prep_args(stack, &ecif)
#ifdef __PIC__
callr D1RtP, CNAME(ffi_prep_args@PLT)
#else
callr D1RtP, CNAME(ffi_prep_args)
#endif
! Restore fn pointer
! The foreign stack should look like this
! XXXXX XXXXXX <--- stack pointer
! FnArgN rvalue
! FnArgN+2 FnArgN+1
! FnArgN+4 FnArgN+3
! ....
!
! A0StP now points to the first (or return) argument + 4
! Preserve cif->bytes
getl D0Ar2, D1Ar1, [--A0StP]
getl D0Ar4, D1Ar3, [--A0StP]
getl D0Ar6, D1Ar5, [--A0StP]
! Place A0StP to the first argument again
add A0StP, A0StP, #24 ! That's because we loaded 6 regs x 4 byte each
! A0FrP points to the initial stack without the reserved space for the
! cifs->bytes, whilst A0StP points to the stack after the space allocation
! fn was the first argument of ffi_call_SYSV.
! The stack at this point looks like this:
!
! A0StP(on entry to _SYSV) -> Arg6 Arg5 | low
! Arg4 Arg3 |
! Arg2 Arg1 |
! A0FrP ----> D0FrtP D1RtP |
! D1.5 D0.5 |
! A0StP(bf prep_args) -> FnArgn FnArgn-1 |
! FnArgn-2FnArgn-3 |
! ................ | <= cifs->bytes
! FnArg4 FnArg3 |
! A0StP (prv_A0StP+cifs->bytes) FnArg2 FnArg1 | high
!
! fn was in Arg1 so it's located in in A0FrP+#-0xC
!
! D0Re0 contains the size of arguments stored in registers
sub A0StP, A0StP, D0Re0
! Arg1 is the function pointer for the foreign call. This has been
! preserved in D1.5
! Time to call (fn). Arguments should be like this:
! Arg1-Arg6 are loaded to regs
! The rest of the arguments are stored in stack pointed by A0StP
call_reg D1.5
! Reset stack.
mov A0StP, A0FrP
! Load Arg1 with the pointer to storage for the return type
! This was stored in Arg5
getd D1Ar1, [A0FrP+#-20]
! Load D0Ar2 with the return type code. This was stored in Arg4 (flags)
getd D0Ar2, [A0FrP+#-16]
! We are ready to start processing the return value
! D0Re0 (and D1Re0) hold the return value
! If the return value is NULL, assume no return value
cmp D1Ar1, #0
beq LSYM(Lepilogue)
! return INT
cmp D0Ar2, #FFI_TYPE_INT
! Sadly, there is no setd{cc} instruction so we need to workaround that
bne .INT64
setd [D1Ar1], D0Re0
b LSYM(Lepilogue)
! return INT64
.INT64:
cmp D0Ar2, #FFI_TYPE_SINT64
setleq [D1Ar1], D0Re0, D1Re0
! return DOUBLE
cmp D0Ar2, #FFI_TYPE_DOUBLE
setl [D1AR1++], D0Re0, D1Re0
LSYM(Lepilogue):
! At this point, the stack pointer points right after the argument
! saved area. We need to restore 4 regs, therefore we need to move
! 16 bytes ahead.
add A0StP, A0StP, #16
RET_REGS "D1.5, D0.5"
RET_ARGS
getd D0Re0, [A0StP]
mov A0FrP, D0FrT
swap D1RtP, PC
.ffi_call_SYSV_end:
.size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
/*
(called by ffi_metag_trampoline)
void ffi_closure_SYSV (ffi_closure*)
(called by ffi_closure_SYSV)
unsigned int FFI_HIDDEN
ffi_closure_SYSV_inner (closure,respp, args)
ffi_closure *closure;
void **respp;
void *args;
*/
METAG_FUNC_START ffi_closure_SYSV
! We assume that D1Ar1 holds the address of the
! ffi_closure struct. We will use that to fetch the
! arguments. The stack pointer points to an empty space
! and it is ready to store more data.
! D1Ar1 is ready
! Allocate stack space for return value
add A0StP, A0StP, #8
! Store it to D0Ar2
sub D0Ar2, A0StP, #8
sub D1Ar3, A0FrP, #4
! D1Ar3 contains the address of the original D1Ar1 argument
! We need to subtract #4 later on
! Preverve D0Ar2
mov D0.5, D0Ar2
#ifdef __PIC__
callr D1RtP, CNAME(ffi_closure_SYSV_inner@PLT)
#else
callr D1RtP, CNAME(ffi_closure_SYSV_inner)
#endif
! Check the return value and store it to D0.5
cmp D0Re0, #FFI_TYPE_INT
beq .Lretint
cmp D0Re0, #FFI_TYPE_DOUBLE
beq .Lretdouble
.Lclosure_epilogue:
sub A0StP, A0StP, #8
RET_REGS "D1.5, D0.5"
RET_ARGS
swap D1RtP, PC
.Lretint:
setd [D0.5], D0Re0
b .Lclosure_epilogue
.Lretdouble:
setl [D0.5++], D0Re0, D1Re0
b .Lclosure_epilogue
.ffi_closure_SYSV_end:
.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
ENTRY(ffi_metag_trampoline)
SAVE_ARGS
! New frame
mov A0FrP, A0StP
SAVE_REGS "D1.5, D0.5"
mov D0.5, PC
! Load D1Ar1 the value of ffi_metag_trampoline
getd D1Ar1, [D0.5 + #8]
! Jump to ffi_closure_SYSV
getd PC, [D0.5 + #12]

View File

@ -0,0 +1,321 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2012, 2013 Xilinx, Inc
MicroBlaze 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.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_common.h>
extern void ffi_call_SYSV(void (*)(void*, extended_cif*), extended_cif*,
unsigned int, unsigned int, unsigned int*, void (*fn)(void),
unsigned int, unsigned int);
extern void ffi_closure_SYSV(void);
#define WORD_SIZE sizeof(unsigned int)
#define ARGS_REGISTER_SIZE (WORD_SIZE * 6)
#define WORD_ALIGN(x) ALIGN(x, WORD_SIZE)
/* 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;
ffi_type** p_arg;
void** p_argv;
void* stack_args_p = stack;
p_argv = ecif->avalue;
if (ecif == NULL || ecif->cif == NULL) {
return; /* no description to prepare */
}
if ((ecif->cif->rtype != NULL) &&
(ecif->cif->rtype->type == FFI_TYPE_STRUCT))
{
/* if return type is a struct which is referenced on the stack/reg5,
* by a pointer. Stored the return value pointer in r5.
*/
char* addr = stack_args_p;
memcpy(addr, &(ecif->rvalue), WORD_SIZE);
stack_args_p += WORD_SIZE;
}
if (ecif->avalue == NULL) {
return; /* no arguments to prepare */
}
for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs;
i++, p_arg++)
{
size_t size = (*p_arg)->size;
int type = (*p_arg)->type;
void* value = p_argv[i];
char* addr = stack_args_p;
int aligned_size = WORD_ALIGN(size);
/* force word alignment on the stack */
stack_args_p += aligned_size;
switch (type)
{
case FFI_TYPE_UINT8:
*(unsigned int *)addr = (unsigned int)*(UINT8*)(value);
break;
case FFI_TYPE_SINT8:
*(signed int *)addr = (signed int)*(SINT8*)(value);
break;
case FFI_TYPE_UINT16:
*(unsigned int *)addr = (unsigned int)*(UINT16*)(value);
break;
case FFI_TYPE_SINT16:
*(signed int *)addr = (signed int)*(SINT16*)(value);
break;
case FFI_TYPE_STRUCT:
#if __BIG_ENDIAN__
/*
* MicroBlaze toolchain appears to emit:
* bsrli r5, r5, 8 (caller)
* ...
* <branch to callee>
* ...
* bslli r5, r5, 8 (callee)
*
* For structs like "struct a { uint8_t a[3]; };", when passed
* by value.
*
* Structs like "struct b { uint16_t a; };" are also expected
* to be packed strangely in registers.
*
* This appears to be because the microblaze toolchain expects
* "struct b == uint16_t", which is only any issue for big
* endian.
*
* The following is a work around for big-endian only, for the
* above mentioned case, it will re-align the contents of a
* <= 3-byte struct value.
*/
if (size < WORD_SIZE)
{
memcpy (addr + (WORD_SIZE - size), value, size);
break;
}
#endif
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
case FFI_TYPE_FLOAT:
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
case FFI_TYPE_DOUBLE:
default:
memcpy(addr, value, aligned_size);
}
}
}
ffi_status ffi_prep_cif_machdep(ffi_cif* cif)
{
/* check ABI */
switch (cif->abi)
{
case FFI_SYSV:
break;
default:
return FFI_BAD_ABI;
}
return FFI_OK;
}
void ffi_call(ffi_cif* cif, void (*fn)(void), 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)) {
ecif.rvalue = alloca(cif->rtype->size);
} else {
ecif.rvalue = rvalue;
}
switch (cif->abi)
{
case FFI_SYSV:
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags,
ecif.rvalue, fn, cif->rtype->type, cif->rtype->size);
break;
default:
FFI_ASSERT(0);
break;
}
}
void ffi_closure_call_SYSV(void* register_args, void* stack_args,
ffi_closure* closure, void* rvalue,
unsigned int* rtype, unsigned int* rsize)
{
/* prepare arguments for closure call */
ffi_cif* cif = closure->cif;
ffi_type** arg_types = cif->arg_types;
/* re-allocate data for the args. This needs to be done in order to keep
* multi-word objects (e.g. structs) in contiguous memory. Callers are not
* required to store the value of args in the lower 6 words in the stack
* (although they are allocated in the stack).
*/
char* stackclone = alloca(cif->bytes);
void** avalue = alloca(cif->nargs * sizeof(void*));
void* struct_rvalue = NULL;
char* ptr = stackclone;
int i;
/* copy registers into stack clone */
int registers_used = cif->bytes;
if (registers_used > ARGS_REGISTER_SIZE) {
registers_used = ARGS_REGISTER_SIZE;
}
memcpy(stackclone, register_args, registers_used);
/* copy stack allocated args into stack clone */
if (cif->bytes > ARGS_REGISTER_SIZE) {
int stack_used = cif->bytes - ARGS_REGISTER_SIZE;
memcpy(stackclone + ARGS_REGISTER_SIZE, stack_args, stack_used);
}
/* preserve struct type return pointer passing */
if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) {
struct_rvalue = *((void**)ptr);
ptr += WORD_SIZE;
}
/* populate arg pointer list */
for (i = 0; i < cif->nargs; i++)
{
switch (arg_types[i]->type)
{
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
#ifdef __BIG_ENDIAN__
avalue[i] = ptr + 3;
#else
avalue[i] = ptr;
#endif
break;
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
#ifdef __BIG_ENDIAN__
avalue[i] = ptr + 2;
#else
avalue[i] = ptr;
#endif
break;
case FFI_TYPE_STRUCT:
#if __BIG_ENDIAN__
/*
* Work around strange ABI behaviour.
* (see info in ffi_prep_args)
*/
if (arg_types[i]->size < WORD_SIZE)
{
memcpy (ptr, ptr + (WORD_SIZE - arg_types[i]->size), arg_types[i]->size);
}
#endif
avalue[i] = (void*)ptr;
break;
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_DOUBLE:
avalue[i] = ptr;
break;
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
case FFI_TYPE_FLOAT:
default:
/* default 4-byte argument */
avalue[i] = ptr;
break;
}
ptr += WORD_ALIGN(arg_types[i]->size);
}
/* set the return type info passed back to the wrapper */
*rsize = cif->rtype->size;
*rtype = cif->rtype->type;
if (struct_rvalue != NULL) {
closure->fun(cif, struct_rvalue, avalue, closure->user_data);
/* copy struct return pointer value into function return value */
*((void**)rvalue) = struct_rvalue;
} else {
closure->fun(cif, rvalue, avalue, closure->user_data);
}
}
ffi_status ffi_prep_closure_loc(
ffi_closure* closure, ffi_cif* cif,
void (*fun)(ffi_cif*, void*, void**, void*),
void* user_data, void* codeloc)
{
unsigned long* tramp = (unsigned long*)&(closure->tramp[0]);
unsigned long cls = (unsigned long)codeloc;
unsigned long fn = 0;
unsigned long fn_closure_call_sysv = (unsigned long)ffi_closure_call_SYSV;
closure->cif = cif;
closure->fun = fun;
closure->user_data = user_data;
switch (cif->abi)
{
case FFI_SYSV:
fn = (unsigned long)ffi_closure_SYSV;
/* load r11 (temp) with fn */
/* imm fn(upper) */
tramp[0] = 0xb0000000 | ((fn >> 16) & 0xffff);
/* addik r11, r0, fn(lower) */
tramp[1] = 0x31600000 | (fn & 0xffff);
/* load r12 (temp) with cls */
/* imm cls(upper) */
tramp[2] = 0xb0000000 | ((cls >> 16) & 0xffff);
/* addik r12, r0, cls(lower) */
tramp[3] = 0x31800000 | (cls & 0xffff);
/* load r3 (temp) with ffi_closure_call_SYSV */
/* imm fn_closure_call_sysv(upper) */
tramp[4] = 0xb0000000 | ((fn_closure_call_sysv >> 16) & 0xffff);
/* addik r3, r0, fn_closure_call_sysv(lower) */
tramp[5] = 0x30600000 | (fn_closure_call_sysv & 0xffff);
/* branch/jump to address stored in r11 (fn) */
tramp[6] = 0x98085800; /* bra r11 */
break;
default:
return FFI_BAD_ABI;
}
return FFI_OK;
}

View File

@ -0,0 +1,53 @@
/* -----------------------------------------------------------------------
ffitarget.h - Copyright (c) 2012, 2013 Xilinx, Inc
Target configuration macros for MicroBlaze.
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.
----------------------------------------------------------------------- */
#ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifndef LIBFFI_ASM
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
FFI_SYSV,
FFI_LAST_ABI,
FFI_DEFAULT_ABI = FFI_SYSV
} ffi_abi;
#endif
/* Definitions for closures */
#define FFI_CLOSURES 1
#define FFI_NATIVE_RAW_API 0
#define FFI_TRAMPOLINE_SIZE (4*8)
#endif

View File

@ -0,0 +1,302 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2012, 2013 Xilinx, Inc
MicroBlaze 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>
/*
* arg[0] (r5) = ffi_prep_args,
* arg[1] (r6) = &ecif,
* arg[2] (r7) = cif->bytes,
* arg[3] (r8) = cif->flags,
* arg[4] (r9) = ecif.rvalue,
* arg[5] (r10) = fn
* arg[6] (sp[0]) = cif->rtype->type
* arg[7] (sp[4]) = cif->rtype->size
*/
.text
.globl ffi_call_SYSV
.type ffi_call_SYSV, @function
ffi_call_SYSV:
/* push callee saves */
addik r1, r1, -20
swi r19, r1, 0 /* Frame Pointer */
swi r20, r1, 4 /* PIC register */
swi r21, r1, 8 /* PIC register */
swi r22, r1, 12 /* save for locals */
swi r23, r1, 16 /* save for locals */
/* save the r5-r10 registers in the stack */
addik r1, r1, -24 /* increment sp to store 6x 32-bit words */
swi r5, r1, 0
swi r6, r1, 4
swi r7, r1, 8
swi r8, r1, 12
swi r9, r1, 16
swi r10, r1, 20
/* save function pointer */
addik r3, r5, 0 /* copy ffi_prep_args into r3 */
addik r22, r1, 0 /* save sp for unallocated args into r22 (callee-saved) */
addik r23, r10, 0 /* save function address into r23 (callee-saved) */
/* prepare stack with allocation for n (bytes = r7) args */
rsub r1, r7, r1 /* subtract bytes from sp */
/* prep args for ffi_prep_args call */
addik r5, r1, 0 /* store stack pointer into arg[0] */
/* r6 still holds ecif for arg[1] */
/* Call ffi_prep_args(stack, &ecif). */
addik r1, r1, -4
swi r15, r1, 0 /* store the link register in the frame */
brald r15, r3
nop /* branch has delay slot */
lwi r15, r1, 0
addik r1, r1, 4 /* restore the link register from the frame */
/* returns calling stack pointer location */
/* prepare args for fn call, prep_args populates them onto the stack */
lwi r5, r1, 0 /* arg[0] */
lwi r6, r1, 4 /* arg[1] */
lwi r7, r1, 8 /* arg[2] */
lwi r8, r1, 12 /* arg[3] */
lwi r9, r1, 16 /* arg[4] */
lwi r10, r1, 20 /* arg[5] */
/* call (fn) (...). */
addik r1, r1, -4
swi r15, r1, 0 /* store the link register in the frame */
brald r15, r23
nop /* branch has delay slot */
lwi r15, r1, 0
addik r1, r1, 4 /* restore the link register from the frame */
/* Remove the space we pushed for the args. */
addik r1, r22, 0 /* restore old SP */
/* restore this functions parameters */
lwi r5, r1, 0 /* arg[0] */
lwi r6, r1, 4 /* arg[1] */
lwi r7, r1, 8 /* arg[2] */
lwi r8, r1, 12 /* arg[3] */
lwi r9, r1, 16 /* arg[4] */
lwi r10, r1, 20 /* arg[5] */
addik r1, r1, 24 /* decrement sp to de-allocate 6x 32-bit words */
/* If the return value pointer is NULL, assume no return value. */
beqi r9, ffi_call_SYSV_end
lwi r22, r1, 48 /* get return type (20 for locals + 28 for arg[6]) */
lwi r23, r1, 52 /* get return size (20 for locals + 32 for arg[7]) */
/* Check if return type is actually a struct, do nothing */
rsubi r11, r22, FFI_TYPE_STRUCT
beqi r11, ffi_call_SYSV_end
/* Return 8bit */
rsubi r11, r23, 1
beqi r11, ffi_call_SYSV_store8
/* Return 16bit */
rsubi r11, r23, 2
beqi r11, ffi_call_SYSV_store16
/* Return 32bit */
rsubi r11, r23, 4
beqi r11, ffi_call_SYSV_store32
/* Return 64bit */
rsubi r11, r23, 8
beqi r11, ffi_call_SYSV_store64
/* Didn't match anything */
bri ffi_call_SYSV_end
ffi_call_SYSV_store64:
swi r3, r9, 0 /* store word r3 into return value */
swi r4, r9, 4 /* store word r4 into return value */
bri ffi_call_SYSV_end
ffi_call_SYSV_store32:
swi r3, r9, 0 /* store word r3 into return value */
bri ffi_call_SYSV_end
ffi_call_SYSV_store16:
#ifdef __BIG_ENDIAN__
shi r3, r9, 2 /* store half-word r3 into return value */
#else
shi r3, r9, 0 /* store half-word r3 into return value */
#endif
bri ffi_call_SYSV_end
ffi_call_SYSV_store8:
#ifdef __BIG_ENDIAN__
sbi r3, r9, 3 /* store byte r3 into return value */
#else
sbi r3, r9, 0 /* store byte r3 into return value */
#endif
bri ffi_call_SYSV_end
ffi_call_SYSV_end:
/* callee restores */
lwi r19, r1, 0 /* frame pointer */
lwi r20, r1, 4 /* PIC register */
lwi r21, r1, 8 /* PIC register */
lwi r22, r1, 12
lwi r23, r1, 16
addik r1, r1, 20
/* return from sub-routine (with delay slot) */
rtsd r15, 8
nop
.size ffi_call_SYSV, . - ffi_call_SYSV
/* ------------------------------------------------------------------------- */
/*
* args passed into this function, are passed down to the callee.
* this function is the target of the closure trampoline, as such r12 is
* a pointer to the closure object.
*/
.text
.globl ffi_closure_SYSV
.type ffi_closure_SYSV, @function
ffi_closure_SYSV:
/* push callee saves */
addik r11, r1, 28 /* save stack args start location (excluding regs/link) */
addik r1, r1, -12
swi r19, r1, 0 /* Frame Pointer */
swi r20, r1, 4 /* PIC register */
swi r21, r1, 8 /* PIC register */
/* store register args on stack */
addik r1, r1, -24
swi r5, r1, 0
swi r6, r1, 4
swi r7, r1, 8
swi r8, r1, 12
swi r9, r1, 16
swi r10, r1, 20
/* setup args */
addik r5, r1, 0 /* register_args */
addik r6, r11, 0 /* stack_args */
addik r7, r12, 0 /* closure object */
addik r1, r1, -8 /* allocate return value */
addik r8, r1, 0 /* void* rvalue */
addik r1, r1, -8 /* allocate for return type/size values */
addik r9, r1, 0 /* void* rtype */
addik r10, r1, 4 /* void* rsize */
/* call the wrap_call function */
addik r1, r1, -28 /* allocate args + link reg */
swi r15, r1, 0 /* store the link register in the frame */
brald r15, r3
nop /* branch has delay slot */
lwi r15, r1, 0
addik r1, r1, 28 /* restore the link register from the frame */
ffi_closure_SYSV_prepare_return:
lwi r9, r1, 0 /* rtype */
lwi r10, r1, 4 /* rsize */
addik r1, r1, 8 /* de-allocate return info values */
/* Check if return type is actually a struct, store 4 bytes */
rsubi r11, r9, FFI_TYPE_STRUCT
beqi r11, ffi_closure_SYSV_store32
/* Return 8bit */
rsubi r11, r10, 1
beqi r11, ffi_closure_SYSV_store8
/* Return 16bit */
rsubi r11, r10, 2
beqi r11, ffi_closure_SYSV_store16
/* Return 32bit */
rsubi r11, r10, 4
beqi r11, ffi_closure_SYSV_store32
/* Return 64bit */
rsubi r11, r10, 8
beqi r11, ffi_closure_SYSV_store64
/* Didn't match anything */
bri ffi_closure_SYSV_end
ffi_closure_SYSV_store64:
lwi r3, r1, 0 /* store word r3 into return value */
lwi r4, r1, 4 /* store word r4 into return value */
/* 64 bits == 2 words, no sign extend occurs */
bri ffi_closure_SYSV_end
ffi_closure_SYSV_store32:
lwi r3, r1, 0 /* store word r3 into return value */
/* 32 bits == 1 word, no sign extend occurs */
bri ffi_closure_SYSV_end
ffi_closure_SYSV_store16:
#ifdef __BIG_ENDIAN__
lhui r3, r1, 2 /* store half-word r3 into return value */
#else
lhui r3, r1, 0 /* store half-word r3 into return value */
#endif
rsubi r11, r9, FFI_TYPE_SINT16
bnei r11, ffi_closure_SYSV_end
sext16 r3, r3 /* fix sign extend of sint8 */
bri ffi_closure_SYSV_end
ffi_closure_SYSV_store8:
#ifdef __BIG_ENDIAN__
lbui r3, r1, 3 /* store byte r3 into return value */
#else
lbui r3, r1, 0 /* store byte r3 into return value */
#endif
rsubi r11, r9, FFI_TYPE_SINT8
bnei r11, ffi_closure_SYSV_end
sext8 r3, r3 /* fix sign extend of sint8 */
bri ffi_closure_SYSV_end
ffi_closure_SYSV_end:
addik r1, r1, 8 /* de-allocate return value */
/* de-allocate stored args */
addik r1, r1, 24
/* callee restores */
lwi r19, r1, 0 /* frame pointer */
lwi r20, r1, 4 /* PIC register */
lwi r21, r1, 8 /* PIC register */
addik r1, r1, 12
/* return from sub-routine (with delay slot) */
rtsd r15, 8
nop
.size ffi_closure_SYSV, . - ffi_closure_SYSV

View File

@ -1,6 +1,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1996, 2007, 2008 Red Hat, Inc. ffi.c - Copyright (c) 2011 Anthony Green
Copyright (c) 2008 David Daney Copyright (c) 2008 David Daney
Copyright (c) 1996, 2007, 2008, 2011 Red Hat, Inc.
MIPS Foreign Function Interface MIPS Foreign Function Interface
@ -169,7 +170,14 @@ static void ffi_prep_args(char *stack,
break; break;
case FFI_TYPE_UINT32: case FFI_TYPE_UINT32:
#ifdef FFI_MIPS_N32
/* The N32 ABI requires that 32-bit integers
be sign-extended to 64-bits, regardless of
whether they are signed or unsigned. */
*(ffi_arg *)argp = *(SINT32 *)(* p_argv);
#else
*(ffi_arg *)argp = *(UINT32 *)(* p_argv); *(ffi_arg *)argp = *(UINT32 *)(* p_argv);
#endif
break; break;
/* This can only happen with 64bit slots. */ /* This can only happen with 64bit slots. */
@ -666,10 +674,19 @@ ffi_prep_closure_loc (ffi_closure *closure,
char *clear_location = (char *) codeloc; char *clear_location = (char *) codeloc;
#if defined(FFI_MIPS_O32) #if defined(FFI_MIPS_O32)
FFI_ASSERT(cif->abi == FFI_O32 || cif->abi == FFI_O32_SOFT_FLOAT); if (cif->abi != FFI_O32 && cif->abi != FFI_O32_SOFT_FLOAT)
return FFI_BAD_ABI;
fn = ffi_closure_O32; fn = ffi_closure_O32;
#else /* FFI_MIPS_N32 */ #else
FFI_ASSERT(cif->abi == FFI_N32 || cif->abi == FFI_N64); #if _MIPS_SIM ==_ABIN32
if (cif->abi != FFI_N32
&& cif->abi != FFI_N32_SOFT_FLOAT)
return FFI_BAD_ABI;
#else
if (cif->abi != FFI_N64
&& cif->abi != FFI_N64_SOFT_FLOAT)
return FFI_BAD_ABI;
#endif
fn = ffi_closure_N32; fn = ffi_closure_N32;
#endif /* FFI_MIPS_O32 */ #endif /* FFI_MIPS_O32 */

View File

@ -1,5 +1,6 @@
/* -----------------------------------------------------------------*-C-*- /* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc. ffitarget.h - Copyright (c) 2012 Anthony Green
Copyright (c) 1996-2003 Red Hat, Inc.
Target configuration macros for MIPS. Target configuration macros for MIPS.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
@ -27,11 +28,23 @@
#ifndef LIBFFI_TARGET_H #ifndef LIBFFI_TARGET_H
#define LIBFFI_TARGET_H #define LIBFFI_TARGET_H
#ifndef LIBFFI_H
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
#endif
#ifdef linux #ifdef linux
# include <asm/sgidefs.h> # include <asm/sgidefs.h>
#elif defined(__rtems__)
/*
* Subprogram calling convention - copied from sgidefs.h
*/
#define _MIPS_SIM_ABI32 1
#define _MIPS_SIM_NABI32 2
#define _MIPS_SIM_ABI64 3
#elif !defined(__OpenBSD__) #elif !defined(__OpenBSD__)
# include <sgidefs.h> # include <sgidefs.h>
#endif #endif
# ifndef _ABIN32 # ifndef _ABIN32
# define _ABIN32 _MIPS_SIM_NABI32 # define _ABIN32 _MIPS_SIM_NABI32
# endif # endif
@ -43,7 +56,7 @@
# endif # endif
#if !defined(_MIPS_SIM) #if !defined(_MIPS_SIM)
-- something is very wrong -- # error -- something is very wrong --
#else #else
# if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64)) # if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
# define FFI_MIPS_N32 # define FFI_MIPS_N32
@ -51,7 +64,7 @@
# if (_MIPS_SIM==_ABIO32 && defined(_ABIO32)) # if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
# define FFI_MIPS_O32 # define FFI_MIPS_O32
# else # else
-- this is an unsupported platform -- # error -- this is an unsupported platform --
# endif # endif
# endif # endif
#endif #endif

View File

@ -43,6 +43,7 @@
#ifdef __GNUC__ #ifdef __GNUC__
.abicalls .abicalls
#endif #endif
.set mips4
.text .text
.align 2 .align 2
.globl ffi_call_N32 .globl ffi_call_N32
@ -107,10 +108,8 @@ loadregs:
REG_L t6, 3*FFI_SIZEOF_ARG($fp) # load the flags word into t6. REG_L t6, 3*FFI_SIZEOF_ARG($fp) # load the flags word into t6.
and t4, t6, ((1<<FFI_FLAG_BITS)-1) and t4, t6, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg1_floatp
REG_L a0, 0*FFI_SIZEOF_ARG(t9) REG_L a0, 0*FFI_SIZEOF_ARG(t9)
b arg1_next beqz t4, arg1_next
arg1_floatp:
bne t4, FFI_TYPE_FLOAT, arg1_doublep bne t4, FFI_TYPE_FLOAT, arg1_doublep
l.s $f12, 0*FFI_SIZEOF_ARG(t9) l.s $f12, 0*FFI_SIZEOF_ARG(t9)
b arg1_next b arg1_next
@ -120,10 +119,8 @@ arg1_next:
SRL t4, t6, 1*FFI_FLAG_BITS SRL t4, t6, 1*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1) and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg2_floatp
REG_L a1, 1*FFI_SIZEOF_ARG(t9) REG_L a1, 1*FFI_SIZEOF_ARG(t9)
b arg2_next beqz t4, arg2_next
arg2_floatp:
bne t4, FFI_TYPE_FLOAT, arg2_doublep bne t4, FFI_TYPE_FLOAT, arg2_doublep
l.s $f13, 1*FFI_SIZEOF_ARG(t9) l.s $f13, 1*FFI_SIZEOF_ARG(t9)
b arg2_next b arg2_next
@ -133,10 +130,8 @@ arg2_next:
SRL t4, t6, 2*FFI_FLAG_BITS SRL t4, t6, 2*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1) and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg3_floatp
REG_L a2, 2*FFI_SIZEOF_ARG(t9) REG_L a2, 2*FFI_SIZEOF_ARG(t9)
b arg3_next beqz t4, arg3_next
arg3_floatp:
bne t4, FFI_TYPE_FLOAT, arg3_doublep bne t4, FFI_TYPE_FLOAT, arg3_doublep
l.s $f14, 2*FFI_SIZEOF_ARG(t9) l.s $f14, 2*FFI_SIZEOF_ARG(t9)
b arg3_next b arg3_next
@ -146,10 +141,8 @@ arg3_next:
SRL t4, t6, 3*FFI_FLAG_BITS SRL t4, t6, 3*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1) and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg4_floatp
REG_L a3, 3*FFI_SIZEOF_ARG(t9) REG_L a3, 3*FFI_SIZEOF_ARG(t9)
b arg4_next beqz t4, arg4_next
arg4_floatp:
bne t4, FFI_TYPE_FLOAT, arg4_doublep bne t4, FFI_TYPE_FLOAT, arg4_doublep
l.s $f15, 3*FFI_SIZEOF_ARG(t9) l.s $f15, 3*FFI_SIZEOF_ARG(t9)
b arg4_next b arg4_next
@ -159,10 +152,8 @@ arg4_next:
SRL t4, t6, 4*FFI_FLAG_BITS SRL t4, t6, 4*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1) and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg5_floatp
REG_L a4, 4*FFI_SIZEOF_ARG(t9) REG_L a4, 4*FFI_SIZEOF_ARG(t9)
b arg5_next beqz t4, arg5_next
arg5_floatp:
bne t4, FFI_TYPE_FLOAT, arg5_doublep bne t4, FFI_TYPE_FLOAT, arg5_doublep
l.s $f16, 4*FFI_SIZEOF_ARG(t9) l.s $f16, 4*FFI_SIZEOF_ARG(t9)
b arg5_next b arg5_next
@ -172,10 +163,8 @@ arg5_next:
SRL t4, t6, 5*FFI_FLAG_BITS SRL t4, t6, 5*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1) and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg6_floatp
REG_L a5, 5*FFI_SIZEOF_ARG(t9) REG_L a5, 5*FFI_SIZEOF_ARG(t9)
b arg6_next beqz t4, arg6_next
arg6_floatp:
bne t4, FFI_TYPE_FLOAT, arg6_doublep bne t4, FFI_TYPE_FLOAT, arg6_doublep
l.s $f17, 5*FFI_SIZEOF_ARG(t9) l.s $f17, 5*FFI_SIZEOF_ARG(t9)
b arg6_next b arg6_next
@ -185,10 +174,8 @@ arg6_next:
SRL t4, t6, 6*FFI_FLAG_BITS SRL t4, t6, 6*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1) and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg7_floatp
REG_L a6, 6*FFI_SIZEOF_ARG(t9) REG_L a6, 6*FFI_SIZEOF_ARG(t9)
b arg7_next beqz t4, arg7_next
arg7_floatp:
bne t4, FFI_TYPE_FLOAT, arg7_doublep bne t4, FFI_TYPE_FLOAT, arg7_doublep
l.s $f18, 6*FFI_SIZEOF_ARG(t9) l.s $f18, 6*FFI_SIZEOF_ARG(t9)
b arg7_next b arg7_next
@ -198,10 +185,8 @@ arg7_next:
SRL t4, t6, 7*FFI_FLAG_BITS SRL t4, t6, 7*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1) and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg8_floatp
REG_L a7, 7*FFI_SIZEOF_ARG(t9) REG_L a7, 7*FFI_SIZEOF_ARG(t9)
b arg8_next beqz t4, arg8_next
arg8_floatp:
bne t4, FFI_TYPE_FLOAT, arg8_doublep bne t4, FFI_TYPE_FLOAT, arg8_doublep
l.s $f19, 7*FFI_SIZEOF_ARG(t9) l.s $f19, 7*FFI_SIZEOF_ARG(t9)
b arg8_next b arg8_next

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
eabi.S - Copyright (c) 2004 Anthony Green eabi.S - Copyright (c) 2012, 2013 Anthony Green
FR-V Assembly glue. Moxie Assembly glue.
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
@ -34,95 +34,68 @@
.globl ffi_call_EABI .globl ffi_call_EABI
.type ffi_call_EABI, @function .type ffi_call_EABI, @function
# gr8 : ffi_prep_args # $r0 : ffi_prep_args
# gr9 : &ecif # $r1 : &ecif
# gr10: cif->bytes # $r2 : cif->bytes
# gr11: fig->flags # $r3 : fig->flags
# gr12: ecif.rvalue # $r4 : ecif.rvalue
# gr13: fn # $r5 : fn
ffi_call_EABI: ffi_call_EABI:
addi sp, #-80, sp push $sp, $r6
sti fp, @(sp, #24) push $sp, $r7
addi sp, #24, fp push $sp, $r8
movsg lr, gr5 dec $sp, 24
/* Make room for the new arguments. */ /* Store incoming args on stack. */
/* subi sp, fp, gr10 */ sto.l 0($sp), $r0 /* ffi_prep_args */
sto.l 4($sp), $r1 /* ecif */
/* Store return address and incoming args on stack. */ sto.l 8($sp), $r2 /* bytes */
sti gr5, @(fp, #8) sto.l 12($sp), $r3 /* flags */
sti gr8, @(fp, #-4) sto.l 16($sp), $r4 /* &rvalue */
sti gr9, @(fp, #-8) sto.l 20($sp), $r5 /* fn */
sti gr10, @(fp, #-12)
sti gr11, @(fp, #-16)
sti gr12, @(fp, #-20)
sti gr13, @(fp, #-24)
sub sp, gr10, sp
/* Call ffi_prep_args. */ /* Call ffi_prep_args. */
ldi @(fp, #-4), gr4 mov $r6, $r4 /* Save result buffer */
addi sp, #0, gr8 mov $r7, $r5 /* Save the target fn */
ldi @(fp, #-8), gr9 mov $r8, $r3 /* Save the flags */
#ifdef __FRV_FDPIC__ sub.l $sp, $r2 /* Allocate stack space */
ldd @(gr4, gr0), gr14 mov $r0, $sp /* We can stomp over $r0 */
calll @(gr14, gr0) /* $r1 is already set up */
#else jsra ffi_prep_args
calll @(gr4, gr0)
#endif
/* ffi_prep_args returns the new stack pointer. */ /* Load register arguments. */
mov gr8, gr4 ldo.l $r0, 0($sp)
ldo.l $r1, 4($sp)
ldi @(sp, #0), gr8 ldo.l $r2, 8($sp)
ldi @(sp, #4), gr9 ldo.l $r3, 12($sp)
ldi @(sp, #8), gr10 ldo.l $r4, 16($sp)
ldi @(sp, #12), gr11 ldo.l $r5, 20($sp)
ldi @(sp, #16), gr12
ldi @(sp, #20), gr13
/* Always copy the return value pointer into the hidden
parameter register. This is only strictly necessary
when we're returning an aggregate type, but it doesn't
hurt to do this all the time, and it saves a branch. */
ldi @(fp, #-20), gr3
/* Use the ffi_prep_args return value for the new sp. */
mov gr4, sp
/* Call the target function. */ /* Call the target function. */
ldi @(fp, -24), gr4 jsr $r7
#ifdef __FRV_FDPIC__
ldd @(gr4, gr0), gr14
calll @(gr14, gr0)
#else
calll @(gr4, gr0)
#endif
/* Store the result. */ ldi.l $r7, 0xffffffff
ldi @(fp, #-16), gr10 /* fig->flags */ cmp $r8, $r7
ldi @(fp, #-20), gr4 /* ecif.rvalue */ beq retstruct
/* Is the return value stored in two registers? */ ldi.l $r7, 4
cmpi gr10, #8, icc0 cmp $r8, $r7
bne icc0, 0, .L2 bgt ret2reg
/* Yes, save them. */
sti gr8, @(gr4, #0)
sti gr9, @(gr4, #4)
bra .L3
.L2:
/* Is the return value a structure? */
cmpi gr10, #-1, icc0
beq icc0, 0, .L3
/* No, save a 4 byte return value. */
sti gr8, @(gr4, #0)
.L3:
/* Restore the stack, and return. */ st.l ($r6), $r0
ldi @(fp, 8), gr5 jmpa retdone
ld @(fp, gr0), fp
addi sp,#80,sp ret2reg:
jmpl @(gr5,gr0) st.l ($r6), $r0
sto.l 4($r6), $r1
retstruct:
retdone:
/* Return. */
ldo.l $r6, -4($fp)
ldo.l $r7, -8($fp)
ldo.l $r8, -12($fp)
ret
.size ffi_call_EABI, .-ffi_call_EABI .size ffi_call_EABI, .-ffi_call_EABI

View File

@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
ffi.c - Copyright (C) 2009 Anthony Green ffi.c - Copyright (C) 2012, 2013 Anthony Green
Moxie Foreign Function Interface Moxie Foreign Function Interface
@ -43,6 +43,12 @@ void *ffi_prep_args(char *stack, extended_cif *ecif)
p_argv = ecif->avalue; p_argv = ecif->avalue;
argp = stack; argp = stack;
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
{
*(void **) argp = ecif->rvalue;
argp += 4;
}
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0); (i != 0);
i--, p_arg++) i--, p_arg++)
@ -56,17 +62,6 @@ void *ffi_prep_args(char *stack, extended_cif *ecif)
z = sizeof(void*); z = sizeof(void*);
*(void **) argp = *p_argv; *(void **) argp = *p_argv;
} }
/* if ((*p_arg)->type == FFI_TYPE_FLOAT)
{
if (count > 24)
{
// This is going on the stack. Turn it into a double.
*(double *) argp = (double) *(float*)(* p_argv);
z = sizeof(double);
}
else
*(void **) argp = *(void **)(* p_argv);
} */
else if (z < sizeof(int)) else if (z < sizeof(int))
{ {
z = sizeof(int); z = sizeof(int);
@ -147,8 +142,7 @@ void ffi_call(ffi_cif *cif,
} }
else else
ecif.rvalue = rvalue; ecif.rvalue = rvalue;
switch (cif->abi) switch (cif->abi)
{ {
case FFI_EABI: case FFI_EABI:
@ -165,19 +159,25 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
unsigned arg4, unsigned arg5, unsigned arg6) unsigned arg4, unsigned arg5, unsigned arg6)
{ {
/* This function is called by a trampoline. The trampoline stows a /* This function is called by a trampoline. The trampoline stows a
pointer to the ffi_closure object in gr7. We must save this pointer to the ffi_closure object in $r7. We must save this
pointer in a place that will persist while we do our work. */ pointer in a place that will persist while we do our work. */
register ffi_closure *creg __asm__ ("gr7"); register ffi_closure *creg __asm__ ("$r12");
ffi_closure *closure = creg; ffi_closure *closure = creg;
/* Arguments that don't fit in registers are found on the stack /* Arguments that don't fit in registers are found on the stack
at a fixed offset above the current frame pointer. */ at a fixed offset above the current frame pointer. */
register char *frame_pointer __asm__ ("fp"); register char *frame_pointer __asm__ ("$fp");
char *stack_args = frame_pointer + 16;
/* Pointer to a struct return value. */
void *struct_rvalue = (void *) arg1;
/* 6 words reserved for register args + 3 words from jsr */
char *stack_args = frame_pointer + 9*4;
/* Lay the register arguments down in a continuous chunk of memory. */ /* Lay the register arguments down in a continuous chunk of memory. */
unsigned register_args[6] = unsigned register_args[6] =
{ arg1, arg2, arg3, arg4, arg5, arg6 }; { arg1, arg2, arg3, arg4, arg5, arg6 };
char *register_args_ptr = (char *) register_args;
ffi_cif *cif = closure->cif; ffi_cif *cif = closure->cif;
ffi_type **arg_types = cif->arg_types; ffi_type **arg_types = cif->arg_types;
@ -185,6 +185,12 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
char *ptr = (char *) register_args; char *ptr = (char *) register_args;
int i; int i;
/* preserve struct type return pointer passing */
if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) {
ptr += 4;
register_args_ptr = (char *)&register_args[1];
}
/* Find the address of each argument. */ /* Find the address of each argument. */
for (i = 0; i < cif->nargs; i++) for (i = 0; i < cif->nargs; i++)
{ {
@ -201,6 +207,7 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
case FFI_TYPE_SINT32: case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32: case FFI_TYPE_UINT32:
case FFI_TYPE_FLOAT: case FFI_TYPE_FLOAT:
case FFI_TYPE_POINTER:
avalue[i] = ptr; avalue[i] = ptr;
break; break;
case FFI_TYPE_STRUCT: case FFI_TYPE_STRUCT:
@ -216,30 +223,21 @@ void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
/* If we've handled more arguments than fit in registers, /* If we've handled more arguments than fit in registers,
start looking at the those passed on the stack. */ start looking at the those passed on the stack. */
if (ptr == ((char *)register_args + (6*4))) if (ptr == &register_args[6])
ptr = stack_args; ptr = stack_args;
} }
/* Invoke the closure. */ /* Invoke the closure. */
if (cif->rtype->type == FFI_TYPE_STRUCT) if (cif->rtype && (cif->rtype->type == FFI_TYPE_STRUCT))
{ {
/* The caller allocates space for the return structure, and (closure->fun) (cif, struct_rvalue, avalue, closure->user_data);
passes a pointer to this space in gr3. Use this value directly
as the return value. */
register void *return_struct_ptr __asm__("gr3");
(closure->fun) (cif, return_struct_ptr, avalue, closure->user_data);
} }
else else
{ {
/* Allocate space for the return value and call the function. */ /* Allocate space for the return value and call the function. */
long long rvalue; long long rvalue;
(closure->fun) (cif, &rvalue, avalue, closure->user_data); (closure->fun) (cif, &rvalue, avalue, closure->user_data);
asm ("mov $r12, %0\n ld.l $r0, ($r12)\n ldo.l $r1, 4($r12)" : : "r" (&rvalue));
/* Functions return 4-byte or smaller results in gr8. 8-byte
values also use gr9. We fill the both, even for small return
values, just to avoid a branch. */
asm ("ldi @(%0, #0), gr8" : : "r" (&rvalue));
asm ("ldi @(%0, #0), gr9" : : "r" (&((int *) &rvalue)[1]));
} }
} }
@ -250,27 +248,25 @@ ffi_prep_closure_loc (ffi_closure* closure,
void *user_data, void *user_data,
void *codeloc) void *codeloc)
{ {
unsigned int *tramp = (unsigned int *) &closure->tramp[0]; unsigned short *tramp = (unsigned short *) &closure->tramp[0];
unsigned long fn = (long) ffi_closure_eabi; unsigned long fn = (long) ffi_closure_eabi;
unsigned long cls = (long) codeloc; unsigned long cls = (long) codeloc;
int i;
if (cif->abi != FFI_EABI)
return FFI_BAD_ABI;
fn = (unsigned long) ffi_closure_eabi; fn = (unsigned long) ffi_closure_eabi;
tramp[0] = 0x8cfc0000 + (fn & 0xffff); /* setlos lo(fn), gr6 */ tramp[0] = 0x01e0; /* ldi.l $r7, .... */
tramp[1] = 0x8efc0000 + (cls & 0xffff); /* setlos lo(cls), gr7 */ tramp[1] = cls >> 16;
tramp[2] = 0x8cf80000 + (fn >> 16); /* sethi hi(fn), gr6 */ tramp[2] = cls & 0xffff;
tramp[3] = 0x8ef80000 + (cls >> 16); /* sethi hi(cls), gr7 */ tramp[3] = 0x1a00; /* jmpa .... */
tramp[4] = 0x80300006; /* jmpl @(gr0, gr6) */ tramp[4] = fn >> 16;
tramp[5] = fn & 0xffff;
closure->cif = cif; closure->cif = cif;
closure->fun = fun; closure->fun = fun;
closure->user_data = user_data; closure->user_data = user_data;
/* Cache flushing. */
for (i = 0; i < FFI_TRAMPOLINE_SIZE; i++)
__asm__ volatile ("dcf @(%0,%1)\n\tici @(%2,%1)" :: "r" (tramp), "r" (i),
"r" (codeloc));
return FFI_OK; return FFI_OK;
} }

Some files were not shown because too many files have changed in this diff Show More