Merged revisions 78968-78969 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78968 | matthias.klose | 2010-03-15 01:02:36 +0100 (Mon, 15 Mar 2010) | 226 lines

  - Issue #8142: Update libffi to the 3.0.9 release.
........
  r78969 | matthias.klose | 2010-03-15 01:36:18 +0100 (Mon, 15 Mar 2010) | 7 lines

  Backport from the libffi trunk:

  2010-02-15  Matthias Klose  <doko@ubuntu.com>

          * src/arm/sysv.S (__ARM_ARCH__): Define for processor
          __ARM_ARCH_7EM__.
........
This commit is contained in:
Matthias Klose 2010-03-15 13:25:28 +00:00
parent 4e0f8910bf
commit a8349756fa
213 changed files with 57893 additions and 28164 deletions

View File

@ -781,6 +781,8 @@ Library
Extension Modules
-----------------
- Issue #8142: Update libffi to the 3.0.9 release.
- Issue #6949: Allow the _dbm extension to be built with db 4.8.x.
- Issue #6544: fix a reference leak in the kqueue implementation's error

View File

@ -1,33 +1,18 @@
This file contains the diffs between the files in the libffi
subdirectory and the 'official' source files from
ftp://sourceware.org/pub/libffi/libffi-3.0.5.tar.gz
ftp://sourceware.org/pub/libffi/libffi-3.0.9.tar.gz
Index: libffi/aclocal.m4
===================================================================
--- libffi/aclocal.m4 (working copy)
+++ libffi/aclocal.m4 (revision 72475)
@@ -1155,7 +1155,7 @@
test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
- # We can hardcode non-existant directories.
+ # We can hardcode non-existent directories.
if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
# If the only mechanism to avoid hardcoding is shlibpath_var, we
# have to relink, otherwise we might link with an installed library
Index: libffi/configure.ac
===================================================================
--- libffi/configure.ac (working copy)
+++ libffi/configure.ac (revision 72475)
--- libffi/configure.ac.orig 2009-12-31 13:41:51.000000000 +0100
+++ libffi/configure.ac 2010-02-24 00:39:10.341610848 +0100
@@ -1,4 +1,7 @@
dnl Process this with autoconf to create configure
+#
+# file from libffi - slightly patched for ctypes
+#
AC_PREREQ(2.59)
AC_PREREQ(2.63)
@@ -83,6 +86,9 @@
@@ -91,6 +94,9 @@
i?86-*-solaris2.1[[0-9]]*)
TARGET=X86_64; TARGETDIR=x86
;;
@ -37,7 +22,7 @@ Index: libffi/configure.ac
i?86-*-*)
TARGET=X86; TARGETDIR=x86
;;
@@ -100,10 +106,10 @@
@@ -108,12 +114,12 @@
;;
mips-sgi-irix5.* | mips-sgi-irix6.*)
@ -45,12 +30,14 @@ Index: libffi/configure.ac
+ TARGET=MIPS_IRIX; TARGETDIR=mips
;;
mips*-*-linux*)
# Support 128-bit long double for NewABI.
HAVE_LONG_DOUBLE='defined(__mips64)'
- TARGET=MIPS; TARGETDIR=mips
+ TARGET=MIPS_LINUX; TARGETDIR=mips
+ TARGET=MIPS_IRIX; TARGETDIR=mips
;;
powerpc*-*-linux* | powerpc-*-sysv*)
@@ -156,7 +162,7 @@
@@ -170,7 +176,7 @@
AC_MSG_ERROR(["libffi has not been ported to $host."])
fi
@ -59,59 +46,21 @@ Index: libffi/configure.ac
AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
AM_CONDITIONAL(X86, test x$TARGET = xX86)
AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
@@ -360,6 +366,10 @@
@@ -399,6 +405,10 @@
AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
-AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
+AC_CONFIG_FILES(include/ffi.h)
+
+AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h)
+
+AC_CONFIG_FILES(fficonfig.py)
+
AC_OUTPUT
Index: libffi/configure
===================================================================
--- libffi/configure (working copy)
+++ libffi/configure (revision 72475)
@@ -9546,7 +9546,7 @@
test -n "$runpath_var" || \
test "X$hardcode_automatic" = "Xyes" ; then
- # We can hardcode non-existant directories.
+ # We can hardcode non-existent directories.
if test "$hardcode_direct" != no &&
# If the only mechanism to avoid hardcoding is shlibpath_var, we
# have to relink, otherwise we might link with an installed library
@@ -13514,7 +13514,7 @@
test -n "$runpath_var_CXX" || \
test "X$hardcode_automatic_CXX" = "Xyes" ; then
- # We can hardcode non-existant directories.
+ # We can hardcode non-existent directories.
if test "$hardcode_direct_CXX" != no &&
# If the only mechanism to avoid hardcoding is shlibpath_var, we
# have to relink, otherwise we might link with an installed library
@@ -16117,7 +16117,7 @@
test -n "$runpath_var_F77" || \
test "X$hardcode_automatic_F77" = "Xyes" ; then
- # We can hardcode non-existant directories.
+ # We can hardcode non-existent directories.
if test "$hardcode_direct_F77" != no &&
# If the only mechanism to avoid hardcoding is shlibpath_var, we
# have to relink, otherwise we might link with an installed library
@@ -18720,7 +18720,7 @@
test -n "$runpath_var_GCJ" || \
test "X$hardcode_automatic_GCJ" = "Xyes" ; then
- # We can hardcode non-existant directories.
+ # We can hardcode non-existent directories.
if test "$hardcode_direct_GCJ" != no &&
# If the only mechanism to avoid hardcoding is shlibpath_var, we
# have to relink, otherwise we might link with an installed library
@@ -20406,6 +20406,9 @@
--- libffi/configure.orig 2009-12-31 13:41:51.000000000 +0100
+++ libffi/configure 2010-02-24 00:41:59.829608794 +0100
@@ -12191,6 +12191,9 @@
i?86-*-solaris2.1[0-9]*)
TARGET=X86_64; TARGETDIR=x86
;;
@ -121,7 +70,7 @@ Index: libffi/configure
i?86-*-*)
TARGET=X86; TARGETDIR=x86
;;
@@ -20423,10 +20426,10 @@
@@ -12208,12 +12211,12 @@
;;
mips-sgi-irix5.* | mips-sgi-irix6.*)
@ -129,12 +78,14 @@ Index: libffi/configure
+ TARGET=MIPS_IRIX; TARGETDIR=mips
;;
mips*-*-linux*)
# Support 128-bit long double for NewABI.
HAVE_LONG_DOUBLE='defined(__mips64)'
- TARGET=MIPS; TARGETDIR=mips
+ TARGET=MIPS_LINUX; TARGETDIR=mips
+ TARGET=MIPS_IRIX; TARGETDIR=mips
;;
powerpc*-*-linux* | powerpc-*-sysv*)
@@ -20481,7 +20484,7 @@
@@ -12272,7 +12275,7 @@
{ (exit 1); exit 1; }; }
fi
@ -143,24 +94,22 @@ Index: libffi/configure
MIPS_TRUE=
MIPS_FALSE='#'
else
@@ -22712,9 +22715,15 @@
@@ -14667,7 +14670,13 @@
ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETDIR/ffitarget.h"
-ac_config_files="$ac_config_files include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc"
+ac_config_files="$ac_config_files include/ffi.h"
+
+
+ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h"
+
+
+ac_config_files="$ac_config_files fficonfig.py"
+
+
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@@ -23498,12 +23507,9 @@
@@ -15767,12 +15776,9 @@
"include") CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;;
"src") CONFIG_COMMANDS="$CONFIG_COMMANDS src" ;;
"include/ffitarget.h") CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETDIR/ffitarget.h" ;;
@ -173,13 +122,22 @@ Index: libffi/configure
+ "include/ffi_common.h") CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;;
+ "fficonfig.py") CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
Index: libffi/src/x86/ffi.c
===================================================================
--- libffi/src/x86/ffi.c (working copy)
+++ libffi/src/x86/ffi.c (revision 72475)
@@ -388,10 +388,10 @@
*) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
--- libffi/src/x86/ffi64.c.orig 2009-12-29 16:22:26.000000000 +0100
+++ libffi/src/x86/ffi64.c 2010-02-24 00:36:46.678610932 +0100
@@ -52,7 +52,7 @@
/* Register class used for passing given 64bit part of the argument.
These represent classes as documented by the PS ABI, with the exception
of SSESF, SSEDF classes, that are basically SSE class, just gcc will
- use SF or DFmode move instead of DImode to avoid reformating penalties.
+ use SF or DFmode move instead of DImode to avoid reformatting penalties.
Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
whenever possible (upper half does contain padding). */
--- libffi/src/x86/ffi.c.orig 2009-12-29 16:22:26.000000000 +0100
+++ libffi/src/x86/ffi.c 2010-02-24 00:36:46.678610932 +0100
@@ -594,10 +594,10 @@
return FFI_BAD_ABI;
}
@ -192,16 +150,3 @@ Index: libffi/src/x86/ffi.c
for (i = cif->nargs-1; i >= 0; i--)
{
Index: libffi/src/x86/ffi64.c
===================================================================
--- libffi/src/x86/ffi64.c (working copy)
+++ libffi/src/x86/ffi64.c (revision 72475)
@@ -52,7 +52,7 @@
/* Register class used for passing given 64bit part of the argument.
These represent classes as documented by the PS ABI, with the exception
of SSESF, SSEDF classes, that are basically SSE class, just gcc will
- use SF or DFmode move instead of DImode to avoid reformating penalties.
+ use SF or DFmode move instead of DImode to avoid reformatting penalties.
Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
whenever possible (upper half does contain padding). */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,658 @@
2009-12-27 Matthias Klose <doko@ubuntu.com>
* configure.ac (HAVE_LONG_DOUBLE): Define for mips when
appropriate.
* configure: Rebuilt.
2009-12-27 Anthony Green <green@redhat.com>
* testsuite/libffi.call/cls_longdouble.c: Don't xfail for ARM.
2009-12-26 Anthony Green <green@redhat.com>
* testsuite/libffi.call/huge_struct.c: Don't xfail for avr32*-*-*.
* testsuite/libffi.call/cls_longdouble_va.c: Mark as xfail for
avr32*-*-*.
* testsuite/libffi.call/cls_double_va.c: Ditto.
2009-12-26 Andreas Tobler <a.tobler@schweiz.org>
* testsuite/libffi.call/ffitest.h: Conditionally include stdint.h
and inttypes.h.
* testsuite/libffi.special/unwindtest.cc: Ditto.
* testsuite/libffi.call/huge_struct.c: Don't include stdint.h
directly.
2009-12-26 Andreas Tobler <a.tobler@schweiz.org>
* configure.ac: Add amd64-*-openbsd*.
* configure: Rebuilt.
* testsuite/lib/libffi-dg.exp (libffi_target_compile): Link
openbsd programs with -lpthread.
2009-12-26 Anthony Green <green@redhat.com>
* testsuite/libffi.call/cls_double_va.c,
testsuite/libffi.call/cls_longdouble.c,
testsuite/libffi.call/cls_longdouble_va.c,
testsuite/libffi.call/cls_pointer.c,
testsuite/libffi.call/cls_pointer_stack.c: Remove xfail for
mips*-*-* and arm*-*-*.
* testsuite/libffi.call/cls_align_longdouble_split.c,
testsuite/libffi.call/cls_align_longdouble_split2.c,
testsuite/libffi.call/stret_medium2.c,
testsuite/libffi.call/stret_medium.c,
testsuite/libffi.call/stret_large.c,
testsuite/libffi.call/stret_large2.c: Remove xfail for arm*-*-*.
2009-12-26 Andreas Tobler <a.tobler@schweiz.org>
Anthony Green <green@redhat.com>
* testsuite/libffi.call/huge_struct.c (test_large_fn): Replace
format code %p with %#lx because %p does not add a leading 0x on
Solaris. Also change relevant arguments to unsigned long.
2009-12-25 Samuli Suominen <ssuominen@gentoo.org>
* configure.ac: Undefine _AC_ARG_VAR_PRECIOUS for autoconf 2.64.
* configure: Rebuilt.
* fficonfig.h.in: Rebuilt.
2009-12-29 Kay Tietz <ktietz70@googlemail.com>
* testsuite/libffi.call/ffitest.h,
testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRuLL): Fix
definitions.
2009-12-25 Carlo Bramini <carlo.bramix@libero.it>
* configure.ac (AM_LTLDFLAGS): Define for windows hosts.
* Makefile.am (libffi_la_LDFLAGS): Add AM_LTLDFLAGS.
* configure: Rebuilt.
* Makefile.in: Rebuilt.
2009-12-24 Anthony Green <green@redhat.com>
* testsuite/libffi.call/huge_struct.c: Fix printf format, and
don't xfail x86 Linux.
* testsuite/libffi.call/huge_struct.c: Don't xfail mips.
* testsuite/libffi.call/cls_pointer.c: Ditto.
* testsuite/libffi.call/cls_pointer_stack.c: Ditto.
* testsuite/libffi.call/cls_longdouble_va.c: Ditto.
* testsuite/libffi.call/cls_longdouble.c: Ditto.
* testsuite/libffi.call/cls_double_va.c: Ditto.
2009-06-16 Andrew Haley <aph@redhat.com>
* testsuite/libffi.call/cls_align_sint64.c,
testsuite/libffi.call/cls_align_uint64.c,
testsuite/libffi.call/cls_longdouble_va.c,
testsuite/libffi.call/cls_ulonglong.c,
testsuite/libffi.call/return_ll1.c,
testsuite/libffi.call/stret_medium2.c: Fix printf format
specifiers.
* testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs.
* testsuite/libffi.call/float2.c: Fix dg-excess-errors.
* testsuite/libffi.call/ffitest.h,
testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define.
2009-06-12 Andrew Haley <aph@redhat.com>
* testsuite/libffi.call/cls_align_sint64.c,
testsuite/libffi.call/cls_align_uint64.c,
testsuite/libffi.call/cls_ulonglong.c,
testsuite/libffi.call/return_ll1.c,
testsuite/libffi.call/stret_medium2.c: Fix printf format
specifiers.
testsuite/libffi.special/unwindtest.cc: include stdint.h.
2009-06-11 Timothy Wall <twall@users.sf.net>
* Makefile.am,
configure.ac,
include/ffi.h.in,
include/ffi_common.h,
src/closures.c,
src/dlmalloc.c,
src/x86/ffi.c,
src/x86/ffitarget.h,
src/x86/win64.S (new),
README: Added win64 support (mingw or MSVC)
* Makefile.in,
include/Makefile.in,
man/Makefile.in,
testsuite/Makefile.in,
configure,
aclocal.m4: Regenerated
* ltcf-c.sh: properly escape cygwin/w32 path
* man/ffi_call.3: Clarify size requirements for return value.
* src/x86/ffi64.c: Fix filename in comment.
* src/x86/win32.S: Remove unused extern.
* testsuite/libffi.call/closure_fn0.c,
testsuite/libffi.call/closure_fn1.c,
testsuite/libffi.call/closure_fn2.c,
testsuite/libffi.call/closure_fn3.c,
testsuite/libffi.call/closure_fn4.c,
testsuite/libffi.call/closure_fn5.c,
testsuite/libffi.call/closure_fn6.c,
testsuite/libffi.call/closure_stdcall.c,
testsuite/libffi.call/cls_12byte.c,
testsuite/libffi.call/cls_16byte.c,
testsuite/libffi.call/cls_18byte.c,
testsuite/libffi.call/cls_19byte.c,
testsuite/libffi.call/cls_1_1byte.c,
testsuite/libffi.call/cls_20byte.c,
testsuite/libffi.call/cls_20byte1.c,
testsuite/libffi.call/cls_24byte.c,
testsuite/libffi.call/cls_2byte.c,
testsuite/libffi.call/cls_3_1byte.c,
testsuite/libffi.call/cls_3byte1.c,
testsuite/libffi.call/cls_3byte2.c,
testsuite/libffi.call/cls_4_1byte.c,
testsuite/libffi.call/cls_4byte.c,
testsuite/libffi.call/cls_5_1_byte.c,
testsuite/libffi.call/cls_5byte.c,
testsuite/libffi.call/cls_64byte.c,
testsuite/libffi.call/cls_6_1_byte.c,
testsuite/libffi.call/cls_6byte.c,
testsuite/libffi.call/cls_7_1_byte.c,
testsuite/libffi.call/cls_7byte.c,
testsuite/libffi.call/cls_8byte.c,
testsuite/libffi.call/cls_9byte1.c,
testsuite/libffi.call/cls_9byte2.c,
testsuite/libffi.call/cls_align_double.c,
testsuite/libffi.call/cls_align_float.c,
testsuite/libffi.call/cls_align_longdouble.c,
testsuite/libffi.call/cls_align_longdouble_split.c,
testsuite/libffi.call/cls_align_longdouble_split2.c,
testsuite/libffi.call/cls_align_pointer.c,
testsuite/libffi.call/cls_align_sint16.c,
testsuite/libffi.call/cls_align_sint32.c,
testsuite/libffi.call/cls_align_sint64.c,
testsuite/libffi.call/cls_align_uint16.c,
testsuite/libffi.call/cls_align_uint32.c,
testsuite/libffi.call/cls_align_uint64.c,
testsuite/libffi.call/cls_dbls_struct.c,
testsuite/libffi.call/cls_double.c,
testsuite/libffi.call/cls_double_va.c,
testsuite/libffi.call/cls_float.c,
testsuite/libffi.call/cls_longdouble.c,
testsuite/libffi.call/cls_longdouble_va.c,
testsuite/libffi.call/cls_multi_schar.c,
testsuite/libffi.call/cls_multi_sshort.c,
testsuite/libffi.call/cls_multi_sshortchar.c,
testsuite/libffi.call/cls_multi_uchar.c,
testsuite/libffi.call/cls_multi_ushort.c,
testsuite/libffi.call/cls_multi_ushortchar.c,
testsuite/libffi.call/cls_pointer.c,
testsuite/libffi.call/cls_pointer_stack.c,
testsuite/libffi.call/cls_schar.c,
testsuite/libffi.call/cls_sint.c,
testsuite/libffi.call/cls_sshort.c,
testsuite/libffi.call/cls_uchar.c,
testsuite/libffi.call/cls_uint.c,
testsuite/libffi.call/cls_ulonglong.c,
testsuite/libffi.call/cls_ushort.c,
testsuite/libffi.call/err_bad_abi.c,
testsuite/libffi.call/err_bad_typedef.c,
testsuite/libffi.call/float2.c,
testsuite/libffi.call/huge_struct.c,
testsuite/libffi.call/nested_struct.c,
testsuite/libffi.call/nested_struct1.c,
testsuite/libffi.call/nested_struct10.c,
testsuite/libffi.call/nested_struct2.c,
testsuite/libffi.call/nested_struct3.c,
testsuite/libffi.call/nested_struct4.c,
testsuite/libffi.call/nested_struct5.c,
testsuite/libffi.call/nested_struct6.c,
testsuite/libffi.call/nested_struct7.c,
testsuite/libffi.call/nested_struct8.c,
testsuite/libffi.call/nested_struct9.c,
testsuite/libffi.call/problem1.c,
testsuite/libffi.call/return_ldl.c,
testsuite/libffi.call/return_ll1.c,
testsuite/libffi.call/stret_large.c,
testsuite/libffi.call/stret_large2.c,
testsuite/libffi.call/stret_medium.c,
testsuite/libffi.call/stret_medium2.c,
testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead
of checking for MMAP. Use intptr_t instead of long casts.
2009-06-04 Andrew Haley <aph@redhat.com>
* src/powerpc/ffitarget.h: Fix misapplied merge from gcc.
2009-06-04 Andrew Haley <aph@redhat.com>
* src/mips/o32.S,
src/mips/n32.S: Fix licence formatting.
2009-06-04 Andrew Haley <aph@redhat.com>
* src/x86/darwin.S: Fix licence formatting.
src/x86/win32.S: Likewise.
src/sh64/sysv.S: Likewise.
src/sh/sysv.S: Likewise.
2009-06-04 Andrew Haley <aph@redhat.com>
* src/sh64/ffi.c: Remove lint directives. Was missing from merge
of Andreas Tobler's patch from 2006-04-22.
2009-06-04 Andrew Haley <aph@redhat.com>
* src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of
2007-03-07.
2008-12-26 Timothy Wall <twall@users.sf.net>
* testsuite/libffi.call/cls_longdouble.c,
testsuite/libffi.call/cls_longdouble_va.c,
testsuite/libffi.call/cls_align_longdouble.c,
testsuite/libffi.call/cls_align_longdouble_split.c,
testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected
failures on x86_64 cygwin/mingw.
2008-12-22 Timothy Wall <twall@users.sf.net>
* testsuite/libffi.call/closure_fn0.c,
testsuite/libffi.call/closure_fn1.c,
testsuite/libffi.call/closure_fn2.c,
testsuite/libffi.call/closure_fn3.c,
testsuite/libffi.call/closure_fn4.c,
testsuite/libffi.call/closure_fn5.c,
testsuite/libffi.call/closure_fn6.c,
testsuite/libffi.call/closure_loc_fn0.c,
testsuite/libffi.call/closure_stdcall.c,
testsuite/libffi.call/cls_align_pointer.c,
testsuite/libffi.call/cls_pointer.c,
testsuite/libffi.call/cls_pointer_stack.c: use portable cast from
pointer to integer (intptr_t).
* testsuite/libffi.call/cls_longdouble.c: disable for win64.
2008-12-19 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.8.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* libtool-version: Increment revision.
* README: Update for new release.
2008-11-11 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.7.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* libtool-version: Increment revision.
* README: Update for new release.
2008-08-25 Andreas Tobler <a.tobler@schweiz.org>
* src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and
FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum.
Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT.
Adjust copyright notice.
* src/powerpc/ffi.c: Add two new flags to indicate if we have one
register or two register to use for FFI_SYSV structs.
(ffi_prep_cif_machdep): Pass the right register flag introduced above.
(ffi_closure_helper_SYSV): Fix the return type for
FFI_SYSV_TYPE_SMALL_STRUCT. Comment.
Adjust copyright notice.
2008-07-24 Anthony Green <green@redhat.com>
* testsuite/libffi.call/cls_dbls_struct.c,
testsuite/libffi.call/cls_double_va.c,
testsuite/libffi.call/cls_longdouble.c,
testsuite/libffi.call/cls_longdouble_va.c,
testsuite/libffi.call/cls_pointer.c,
testsuite/libffi.call/cls_pointer_stack.c,
testsuite/libffi.call/err_bad_abi.c: Clean up failures from
compiler warnings.
2008-07-17 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.6.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* libtool-version: Increment revision. Add documentation.
* README: Update for new release.
2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
* src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned
int.
2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
* src/sh/sysv.S: Add .note.GNU-stack on Linux.
* src/sh64/sysv.S: Likewise.
2008-04-03 Anthony Green <green@redhat.com>
* libffi.pc.in (Libs): Add -L${libdir}.
* configure.ac: Bump version to 3.0.5.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* libtool-version: Increment revision.
* README: Update for new release.
2008-04-03 Anthony Green <green@redhat.com>
Xerces Ranby <xerxes@zafena.se>
* include/ffi.h.in: Wrap definition of target architecture to
protect from double definitions.
2008-03-22 Moriyoshi Koizumi <moriyoshi@gmail.com>
* src/x86/ffi.c (ffi_prep_closure_loc): Fix for bug revealed in
closure_loc_fn0.c.
* testsuite/libffi.call/closure_loc_fn0.c (closure_loc_test_fn0):
New test.
2008-03-04 Anthony Green <green@redhat.com>
Blake Chaffin
hos@tamanegi.org
* testsuite/libffi.call/cls_align_longdouble_split2.c
testsuite/libffi.call/cls_align_longdouble_split.c
testsuite/libffi.call/cls_dbls_struct.c
testsuite/libffi.call/cls_double_va.c
testsuite/libffi.call/cls_longdouble.c
testsuite/libffi.call/cls_longdouble_va.c
testsuite/libffi.call/cls_pointer.c
testsuite/libffi.call/cls_pointer_stack.c
testsuite/libffi.call/err_bad_abi.c
testsuite/libffi.call/err_bad_typedef.c
testsuite/libffi.call/huge_struct.c
testsuite/libffi.call/stret_large2.c
testsuite/libffi.call/stret_large.c
testsuite/libffi.call/stret_medium2.c
testsuite/libffi.call/stret_medium.c: New tests from Apple.
2008-02-26 Jakub Jelinek <jakub@redhat.com>
Anthony Green <green@redhat.com>
* src/alpha/osf.S: Add .note.GNU-stack on Linux.
* src/s390/sysv.S: Likewise.
* src/powerpc/linux64.S: Likewise.
* src/powerpc/linux64_closure.S: Likewise.
* src/powerpc/ppc_closure.S: Likewise.
* src/powerpc/sysv.S: Likewise.
* src/x86/unix64.S: Likewise.
* src/x86/sysv.S: Likewise.
* src/sparc/v8.S: Likewise.
* src/sparc/v9.S: Likewise.
* src/m68k/sysv.S: Likewise.
* src/ia64/unix.S: Likewise.
* src/arm/sysv.S: Likewise.
2008-02-26 Anthony Green <green@redhat.com>
Thomas Heller <theller@ctypes.org>
* src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C
comment.
2008-02-26 Anthony Green <green@redhat.org>
Thomas Heller <theller@ctypes.org>
* include/ffi.h.in: Change void (*)() to void (*)(void).
2008-02-26 Anthony Green <green@redhat.org>
Thomas Heller <theller@ctypes.org>
* src/alpha/ffi.c: Change void (*)() to void (*)(void).
src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c,
src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c,
src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S,
src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c,
src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c,
src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S,
src/x86/ffi64.c: Ditto.
2008-02-24 Anthony Green <green@redhat.org>
* configure.ac: Accept openbsd*, not just openbsd.
Bump version to 3.0.4.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* libtool-version: Increment revision.
* README: Update for new release.
2008-02-22 Anthony Green <green@redhat.com>
* README: Clean up list of tested platforms.
2008-02-22 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.3.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* libtool-version: Increment revision.
* README: Update for new release. Clean up test docs.
2008-02-22 Bjoern Koenig <bkoenig@alpha-tierchen.de>
Andreas Tobler <a.tobler@schweiz.org>
* configure.ac: Add amd64-*-freebsd* target.
* configure: Regenerate.
2008-02-22 Thomas Heller <theller@ctypes.org>
* configure.ac: Add x86 OpenBSD support.
* configure: Rebuilt.
2008-02-21 Thomas Heller <theller@ctypes.org>
* README: Change "make test" to "make check".
2008-02-21 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.2.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* libtool-version: Increment revision.
* README: Update for new release.
2008-02-21 Björn König <bkoenig@alpha-tierchen.de>
* src/x86/freebsd.S: New file.
* configure.ac: Add x86 FreeBSD support.
* Makefile.am: Ditto.
2008-02-15 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.1.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* libtool-version: Increment revision.
* README: Update for new release.
2008-02-15 David Daney <ddaney@avtrex.com>
* src/mips/ffi.c: Remove extra '>' from include directive.
(ffi_prep_closure_loc): Use clear_location instead of tramp.
2008-02-15 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 3.0.0.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
2008-02-15 David Daney <ddaney@avtrex.com>
* src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE):
Define (conditionally), and use it to include cachectl.h.
(ffi_prep_closure_loc): Fix cache flushing.
* src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define.
2008-02-15 Anthony Green <green@redhat.com>
* man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3:
Update dates and remove all references to ffi_prep_closure.
* configure.ac: Bump version to 2.99.9.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
2008-02-15 Anthony Green <green@redhat.com>
* man/ffi_prep_closure.3: Delete.
* man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3.
(man_MANS): Ditto.
* man/Makefile.in: Rebuilt.
* configure.ac: Bump version to 2.99.8.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
2008-02-14 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 2.99.7.
* configure, doc/stamp-vti, doc/version.texi: Rebuilt.
* include/ffi.h.in LICENSE src/debug.c src/closures.c
src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h
src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c
src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S
src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c
src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c
src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S
src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h
src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c
src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S
src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h
src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h
src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S
src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h
src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S
src/arm/ffitarget.h src/prep_cif.c: Update license text.
2008-02-14 Anthony Green <green@redhat.com>
* README: Update tested platforms.
* configure.ac: Bump version to 2.99.6.
* configure: Rebuilt.
2008-02-14 Anthony Green <green@redhat.com>
* configure.ac: Bump version to 2.99.5.
* configure: Rebuilt.
* Makefile.am (EXTRA_DIST): Add darwin64.S
* Makefile.in: Rebuilt.
* testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree.
* LICENSE: Update WARRANTY.
2008-02-14 Anthony Green <green@redhat.com>
* libffi.pc.in (libdir): Fix libdir definition.
* configure.ac: Bump version to 2.99.4.
* configure: Rebuilt.
2008-02-14 Anthony Green <green@redhat.com>
* README: Update.
* libffi.info: New file.
* doc/stamp-vti: New file.
* configure.ac: Bump version to 2.99.3.
* configure: Rebuilt.
2008-02-14 Anthony Green <green@redhat.com>
* Makefile.am (SUBDIRS): Add man dir.
* Makefile.in: Rebuilt.
* configure.ac: Create Makefile.
* configure: Rebuilt.
* man/ffi_call.3 man/ffi_prep_cif.3 man/ffi_prep_closure.3
man/Makefile.am man/Makefile.in: New files.
2008-02-14 Tom Tromey <tromey@redhat.com>
* aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt.
* mdate-sh, texinfo.tex: New files.
* Makefile.am (info_TEXINFOS): New variable.
* doc/libffi.texi: New file.
* doc/version.texi: Likewise.
2008-02-14 Anthony Green <green@redhat.com>
* Makefile.am (AM_CFLAGS): Don't compile with -D$(TARGET).
(lib_LTLIBRARIES): Define.
(toolexeclib_LIBRARIES): Undefine.
* Makefile.in: Rebuilt.
* configure.ac: Reset version to 2.99.1.
* configure.in: Rebuilt.
2008-02-14 Anthony Green <green@redhat.com>
* libffi.pc.in: Use @PACKAGE_NAME@ and @PACKAGE_VERSION@.
* configure.ac: Reset version to 2.99.1.
* configure.in: Rebuilt.
* Makefile.am (EXTRA_DIST): Add ChangeLog.libffi.
* Makefile.in: Rebuilt.
* LICENSE: Update copyright notice.
2008-02-14 Anthony Green <green@redhat.com>
* include/Makefile.am (nodist_includes_HEADERS): Define. Don't
distribute ffitarget.h or ffi.h from the build include dir.
* Makefile.in: Rebuilt.
2008-02-14 Anthony Green <green@redhat.com>
* include/Makefile.am (includesdir): Install headers under libdir.
(pkgconfigdir): Define. Install libffi.pc.
* include/Makefile.in: Rebuilt.
* libffi.pc.in: Create.
* libtool-version: Increment CURRENT
* configure.ac: Add libffi.pc.in
* configure: Rebuilt.
2008-02-03 Anthony Green <green@redhat.com>
* include/Makefile.am (includesdir): Fix header install with
DESTDIR.
* include/Makefile.in: Rebuilt.
2008-02-03 Timothy Wall <twall@users.sf.net>
* src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return
offset based on code pointer, not data pointer.
2008-02-01 Anthony Green <green@redhat.com>
* include/Makefile.am: Fix header installs.
* Makefile.am: Ditto.
* include/Makefile.in: Rebuilt.
* Makefile.in: Ditto.
2008-02-01 Anthony Green <green@redhat.com>
* src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL,
FFI_INIT_TRAMPOLINE): Revert my broken changes to twall's last
patch.
2008-01-31 Anthony Green <green@redhat.com>
* Makefile.am (EXTRA_DIST): Add missing files.
* testsuite/Makefile.am: Ditto.
* Makefile.in, testsuite/Makefile.in: Rebuilt.
2008-01-31 Timothy Wall <twall@users.sf.net>
* testsuite/libffi.call/closure_stdcall.c: Add test for stdcall
closures.
* src/x86/ffitarget.h: Increase size of trampoline for stdcall
closures.
* src/x86/win32.S: Add assembly for stdcall closure.
* src/x86/ffi.c: Initialize stdcall closure trampoline.
2008-01-30 H.J. Lu <hongjiu.lu@intel.com>
PR libffi/34612
* src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
returning struct.
* testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer"
tests.
2008-01-30 Anthony Green <green@redhat.com>
* Makefile.am, include/Makefile.am: Move headers to
libffi_la_SOURCES for new automake.
* Makefile.in, include/Makefile.in: Rebuilt.
* testsuite/lib/wrapper.exp: Copied from gcc tree to allow for
execution outside of gcc tree.
* testsuite/lib/target-libpath.exp: Ditto.
* testsuite/lib/libffi-dg.exp: Many changes to allow for execution
outside of gcc tree.

View File

@ -0,0 +1,40 @@
2004-01-14 Kelley Cook <kcook@gcc.gnu.org>
* configure.in: Add in AC_PREREQ(2.13)
2003-02-20 Alexandre Oliva <aoliva@redhat.com>
* configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to
config.status.
* configure: Rebuilt.
2002-01-27 Alexandre Oliva <aoliva@redhat.com>
* configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST.
Remove USE_LIBDIR conditional.
* Makefile.am (toolexecdir, toolexeclibdir): Don't override.
* Makefile.in, configure: Rebuilt.
Mon Aug 9 18:33:38 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* include/Makefile.in: Rebuilt.
* Makefile.in: Rebuilt
* Makefile.am (toolexeclibdir): Add $(MULTISUBDIR) even for native
builds.
Use USE_LIBDIR.
* configure: Rebuilt.
* configure.in (USE_LIBDIR): Define for native builds.
Use lowercase in configure --help explanations.
1999-08-08 Anthony Green <green@cygnus.com>
* include/ffi.h.in (FFI_FN): Remove `...'.
1999-08-08 Anthony Green <green@cygnus.com>
* Makefile.in: Rebuilt.
* Makefile.am (AM_CFLAGS): Compile with -fexceptions.
* src/x86/sysv.S: Add exception handling metadata.

View File

@ -0,0 +1,764 @@
The libffi version 1 ChangeLog archive.
Version 1 of libffi had per-directory ChangeLogs. Current and future
versions have a single ChangeLog file in the root directory. The
version 1 ChangeLogs have all been concatonated into this file for
future reference only.
--- libffi ----------------------------------------------------------------
Mon Oct 5 02:17:50 1998 Anthony Green <green@cygnus.com>
* configure.in: Boosted rev.
* configure, Makefile.in, aclocal.m4: Rebuilt.
* README: Boosted rev and updated release notes.
Mon Oct 5 01:03:03 1998 Anthony Green <green@cygnus.com>
* configure.in: Boosted rev.
* configure, Makefile.in, aclocal.m4: Rebuilt.
* README: Boosted rev and updated release notes.
1998-07-25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* m68k/ffi.c (ffi_prep_cif_machdep): Use bitmask for cif->flags.
Correctly handle small structures.
(ffi_prep_args): Also handle small structures.
(ffi_call): Pass size of return type to ffi_call_SYSV.
* m68k/sysv.S: Adjust for above changes. Correctly align small
structures in the return value.
* types.c (uint64, sint64) [M68K]: Change alignment to 4.
Fri Apr 17 17:26:58 1998 Anthony Green <green@hoser.cygnus.com>
* configure.in: Boosted rev.
* configure,Makefile.in,aclocal.m4: Rebuilt.
* README: Boosted rev and added release notes.
Sun Feb 22 00:50:41 1998 Geoff Keating <geoffk@ozemail.com.au>
* configure.in: Add PowerPC config bits.
1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* configure.in: Add m68k config bits. Change AC_CANONICAL_SYSTEM
to AC_CANONICAL_HOST, this is not a compiler. Use $host instead
of $target. Remove AC_CHECK_SIZEOF(char), we already know the
result. Fix argument of AC_ARG_ENABLE.
* configure, fficonfig.h.in: Rebuilt.
Tue Feb 10 20:53:40 1998 Richard Henderson <rth@cygnus.com>
* configure.in: Add Alpha config bits.
Tue May 13 13:39:20 1997 Anthony Green <green@hoser.cygnus.com>
* README: Updated dates and reworded Irix comments.
* configure.in: Removed AC_PROG_RANLIB.
* Makefile.in, aclocal.m4, config.guess, config.sub, configure,
ltmain.sh, */Makefile.in: libtoolized again and rebuilt with
automake and autoconf.
Sat May 10 18:44:50 1997 Tom Tromey <tromey@cygnus.com>
* configure, aclocal.m4: Rebuilt.
* configure.in: Don't compute EXTRADIST; now handled in
src/Makefile.in. Removed macros implied by AM_INIT_AUTOMAKE.
Don't run AM_MAINTAINER_MODE.
Thu May 8 14:34:05 1997 Anthony Green <green@hoser.cygnus.com>
* missing, ltmain.sh, ltconfig.sh: Created. These are new files
required by automake and libtool.
* README: Boosted rev to 1.14. Added notes.
* acconfig.h: Moved PACKAGE and VERSION for new automake.
* configure.in: Changes for libtool.
* Makefile.am (check): make test now make check. Uses libtool now.
* Makefile.in, configure.in, aclocal.h, fficonfig.h.in: Rebuilt.
Thu May 1 16:27:07 1997 Anthony Green <green@hoser.cygnus.com>
* missing: Added file required by new automake.
Tue Nov 26 14:10:42 1996 Anthony Green <green@csk3.cygnus.com>
* acconfig.h: Added USING_PURIFY flag. This is defined when
--enable-purify-safety was used at configure time.
* configure.in (allsources): Added --enable-purify-safety switch.
(VERSION): Boosted rev to 1.13.
* configure: Rebuilt.
Fri Nov 22 06:46:12 1996 Anthony Green <green@rtl.cygnus.com>
* configure.in (VERSION): Boosted rev to 1.12.
Removed special CFLAGS hack for gcc.
* configure: Rebuilt.
* README: Boosted rev to 1.12. Added notes.
* Many files: Cygnus Support changed to Cygnus Solutions.
Wed Oct 30 11:15:25 1996 Anthony Green <green@rtl.cygnus.com>
* configure.in (VERSION): Boosted rev to 1.11.
* configure: Rebuilt.
* README: Boosted rev to 1.11. Added notes about GNU make.
Tue Oct 29 12:25:12 1996 Anthony Green <green@rtl.cygnus.com>
* configure.in: Fixed -Wall trick.
(VERSION): Boosted rev.
* configure: Rebuilt
* acconfig.h: Needed for --enable-debug configure switch.
* README: Boosted rev to 1.09. Added more notes on building
libffi, and LCLint.
* configure.in: Added --enable-debug switch. Boosted rev to
1.09.
* configure: Rebuilt
Tue Oct 15 13:11:28 1996 Anthony Green <green@hoser.cygnus.com>
* configure.in (VERSION): Boosted rev to 1.08
* configure: Rebuilt.
* README: Added n32 bug fix notes.
* Makefile.am: Added "make lint" production.
* Makefile.in: Rebuilt.
Mon Oct 14 10:54:46 1996 Anthony Green <green@rtl.cygnus.com>
* README: Added web page reference.
* configure.in, README: Boosted rev to 1.05
* configure: Rebuilt.
* README: Fixed n32 sample code.
Fri Oct 11 17:09:28 1996 Anthony Green <green@rtl.cygnus.com>
* README: Added sparc notes.
* configure.in, README: Boosted rev to 1.04.
* configure: Rebuilt.
Thu Oct 10 10:31:03 1996 Anthony Green <green@rtl.cygnus.com>
* configure.in, README: Boosted rev to 1.03.
* configure: Rebuilt.
* README: Added struct notes.
* Makefile.am (EXTRA_DIST): Added LICENSE to distribution.
* Makefile.in: Rebuilt.
* README: Removed Linux section. No special notes now
because aggregates arg/return types work.
Wed Oct 9 16:16:42 1996 Anthony Green <green@rtl.cygnus.com>
* README, configure.in (VERSION): Boosted rev to 1.02
* configure: Rebuilt.
Tue Oct 8 11:56:33 1996 Anthony Green <green@rtl.cygnus.com>
* README (NOTE): Added n32 notes.
* Makefile.am: Added test production.
* Makefile: Rebuilt
* README: spell checked!
* configure.in (VERSION): Boosted rev to 1.01
* configure: Rebuilt.
Mon Oct 7 15:50:22 1996 Anthony Green <green@rtl.cygnus.com>
* configure.in: Added nasty bit to support SGI tools.
* configure: Rebuilt.
* README: Added SGI notes. Added note about automake bug.
Mon Oct 7 11:00:28 1996 Anthony Green <green@hoser.cygnus.com>
* README: Rewrote intro, and fixed examples.
Fri Oct 4 10:19:55 1996 Anthony Green <green@hoser.cygnus.com>
* configure.in: -D$TARGET is no longer used as a compiler switch.
It is now inserted into ffi.h at configure time.
* configure: Rebuilt.
* FFI_ABI and FFI_STATUS are now ffi_abi and ffi_status.
Thu Oct 3 13:47:34 1996 Anthony Green <green@hoser.cygnus.com>
* README, LICENSE: Created. Wrote some docs.
* configure.in: Don't barf on i586-unknown-linuxaout.
Added EXTRADIST code for "make dist".
* configure: Rebuilt.
* */Makefile.in: Rebuilt with patched automake.
Tue Oct 1 17:12:25 1996 Anthony Green <green@rtl.cygnus.com>
* Makefile.am, aclocal.m4, config.guess, config.sub,
configure.in, fficonfig.h.in, install-sh, mkinstalldirs,
stamp-h.in: Created
* Makefile.in, configure: Generated
--- libffi/include --------------------------------------------------------
Tue Feb 24 13:09:36 1998 Anthony Green <green@gerbil.cygnus.com>
* ffi_mips.h: Updated FFI_TYPE_STRUCT_* values based on
ffi.h.in changes. This is a work-around for SGI's "simple"
assembler.
Sun Feb 22 00:51:55 1998 Geoff Keating <geoffk@ozemail.com.au>
* ffi.h.in: PowerPC support.
1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* ffi.h.in: Add m68k support.
(FFI_TYPE_LONGDOUBLE): Make it a separate value.
Tue Feb 10 20:55:16 1998 Richard Henderson <rth@cygnus.com>
* ffi.h.in (SIZEOF_ARG): Use a pointer type by default.
* ffi.h.in: Alpha support.
Fri Nov 22 06:48:45 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.h.in, ffi_common.h: Cygnus Support -> Cygnus Solutions.
Wed Nov 20 22:31:01 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.h.in: Added ffi_type_void definition.
Tue Oct 29 12:22:40 1996 Anthony Green <green@rtl.cygnus.com>
* Makefile.am (hack_DATA): Always install ffi_mips.h.
* ffi.h.in: Removed FFI_DEBUG. It's now in the correct
place (acconfig.h).
Added #include <stddef.h> for size_t definition.
Tue Oct 15 17:23:35 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.h.in, ffi_common.h, ffi_mips.h: More clean up.
Commented out #define of FFI_DEBUG.
Tue Oct 15 13:01:06 1996 Anthony Green <green@rtl.cygnus.com>
* ffi_common.h: Added bool definition.
* ffi.h.in, ffi_common.h: Clean up based on LCLint output.
Added funny /*@...@*/ comments to annotate source.
Mon Oct 14 12:29:23 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.h.in: Interface changes based on feedback from Jim
Blandy.
Fri Oct 11 16:49:35 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.h.in: Small change for sparc support.
Thu Oct 10 14:53:37 1996 Anthony Green <green@rtl.cygnus.com>
* ffi_mips.h: Added FFI_TYPE_STRUCT_* definitions for
special structure return types.
Wed Oct 9 13:55:57 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.h.in: Added SIZEOF_ARG definition for X86
Tue Oct 8 11:40:36 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.h.in (FFI_FN): Added macro for eliminating compiler warnings.
Use it to case your function pointers to the proper type.
* ffi_mips.h (SIZEOF_ARG): Added magic to fix type promotion bug.
* Makefile.am (EXTRA_DIST): Added ffi_mips.h to EXTRA_DIST.
* Makefile: Rebuilt.
* ffi_mips.h: Created. Moved all common mips definitions here.
Mon Oct 7 10:58:12 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.h.in: The SGI assember is very picky about parens. Redefined
some macros to avoid problems.
* ffi.h.in: Added FFI_DEFAULT_ABI definitions. Also added
externs for pointer, and 64bit integral ffi_types.
Fri Oct 4 09:51:37 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.h.in: Added FFI_ABI member to ffi_cif and changed
function prototypes accordingly.
Added #define @TARGET@. Now programs including ffi.h don't
have to specify this themselves.
Thu Oct 3 15:36:44 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.h.in: Changed ffi_prep_cif's values from void* to void**
* Makefile.am (EXTRA_DIST): Added EXTRA_DIST for "make dist"
to work.
* Makefile.in: Regenerated.
Wed Oct 2 10:16:59 1996 Anthony Green <green@hoser.cygnus.com>
* Makefile.am: Created
* Makefile.in: Generated
* ffi_common.h: Added rcsid comment
Tue Oct 1 17:13:51 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.h.in, ffi_common.h: Created
--- libffi/src ------------------------------------------------------------
Mon Oct 5 02:17:50 1998 Anthony Green <green@cygnus.com>
* arm/ffi.c, arm/sysv.S: Created.
* Makefile.am: Added arm files.
* Makefile.in: Rebuilt.
Mon Oct 5 01:41:38 1998 Anthony Green <green@rtl.cygnus.com>
* Makefile.am (libffi_la_LDFLAGS): Incremented revision.
Sun Oct 4 16:27:17 1998 Anthony Green <green@cygnus.com>
* alpha/osf.S (ffi_call_osf): Patch for DU assembler.
* ffitest.c (main): long long and long double return values work
for x86.
Fri Apr 17 11:50:58 1998 Anthony Green <green@hoser.cygnus.com>
* Makefile.in: Rebuilt.
* ffitest.c (main): Floating point tests not executed for systems
with broken lond double (SunOS 4 w/ GCC).
* types.c: Fixed x86 alignment info for long long types.
Thu Apr 16 07:15:28 1998 Anthony Green <green@ada.cygnus.com>
* ffitest.c: Added more notes about GCC bugs under Irix 6.
Wed Apr 15 08:42:22 1998 Anthony Green <green@hoser.cygnus.com>
* ffitest.c (struct5): New test function.
(main): New test with struct5.
Thu Mar 5 10:48:11 1998 Anthony Green <green@tootie.to.cygnus.com>
* prep_cif.c (initialize_aggregate): Fix assertion for
nested structures.
Tue Feb 24 16:33:41 1998 Anthony Green <green@hoser.cygnus.com>
* prep_cif.c (ffi_prep_cif): Added long double support for sparc.
Sun Feb 22 00:52:18 1998 Geoff Keating <geoffk@ozemail.com.au>
* powerpc/asm.h: New file.
* powerpc/ffi.c: New file.
* powerpc/sysv.S: New file.
* Makefile.am: PowerPC port.
* ffitest.c (main): Allow all tests to run even in presence of gcc
bug on PowerPC.
1998-02-17 Anthony Green <green@hoser.cygnus.com>
* mips/ffi.c: Fixed comment typo.
* x86/ffi.c (ffi_prep_cif_machdep), x86/sysv.S (retfloat):
Fixed x86 long double return handling.
* types.c: Fixed x86 long double alignment info.
1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* types.c: Add m68k support.
* ffitest.c (floating): Add long double parameter.
(return_ll, ldblit): New functions to test long long and long
double return value.
(main): Fix type error in assignment of ts[1-4]_type.elements.
Add tests for long long and long double arguments and return
values.
* prep_cif.c (ffi_prep_cif) [M68K]: Don't allocate argument for
struct value pointer.
* m68k/ffi.c, m68k/sysv.S: New files.
* Makefile.am: Add bits for m68k port. Add kludge to work around
automake deficiency.
(test): Don't require "." in $PATH.
* Makefile.in: Rebuilt.
Wed Feb 11 07:36:50 1998 Anthony Green <green@hoser.cygnus.com>
* Makefile.in: Rebuilt.
Tue Feb 10 20:56:00 1998 Richard Henderson <rth@cygnus.com>
* alpha/ffi.c, alpha/osf.S: New files.
* Makefile.am: Alpha port.
Tue Nov 18 14:12:07 1997 Anthony Green <green@hoser.cygnus.com>
* mips/ffi.c (ffi_prep_cif_machdep): Initialize rstruct_flag
for n32.
Tue Jun 3 17:18:20 1997 Anthony Green <green@hoser.cygnus.com>
* ffitest.c (main): Added hack to get structure tests working
correctly.
Sat May 10 19:06:42 1997 Tom Tromey <tromey@cygnus.com>
* Makefile.in: Rebuilt.
* Makefile.am (EXTRA_DIST): Explicitly list all distributable
files in subdirs.
(VERSION, CC): Removed.
Thu May 8 17:19:01 1997 Anthony Green <green@hoser.cygnus.com>
* Makefile.am: Many changes for new automake and libtool.
* Makefile.in: Rebuilt.
Fri Nov 22 06:57:56 1996 Anthony Green <green@rtl.cygnus.com>
* ffitest.c (main): Fixed test case for non mips machines.
Wed Nov 20 22:31:59 1996 Anthony Green <green@hoser.cygnus.com>
* types.c: Added ffi_type_void declaration.
Tue Oct 29 13:07:19 1996 Anthony Green <green@rtl.cygnus.com>
* ffitest.c (main): Fixed character constants.
(main): Emit warning for structure test 3 failure on Sun.
* Makefile.am (VPATH): Fixed VPATH def'n so automake won't
strip it out.
Moved distdir hack from libffi to automake.
(ffitest): Added missing -c for $(COMPILE) (change in automake).
* Makefile.in: Rebuilt.
Tue Oct 15 13:08:20 1996 Anthony Green <green@hoser.cygnus.com>
* Makefile.am: Added "make lint" production.
* Makefile.in: Rebuilt.
* prep_cif.c (STACK_ARG_SIZE): Improved STACK_ARG_SIZE macro.
Clean up based on LCLint output. Added funny /*@...@*/ comments to
annotate source.
* ffitest.c, debug.c: Cleaned up code.
Mon Oct 14 12:26:56 1996 Anthony Green <green@rtl.cygnus.com>
* ffitest.c: Changes based on interface changes.
* prep_cif.c (ffi_prep_cif): Cleaned up interface based on
feedback from Jim Blandy.
Fri Oct 11 15:53:18 1996 Anthony Green <green@rtl.cygnus.com>
* ffitest.c: Reordered tests while porting to sparc.
Made changes to handle lame structure passing for sparc.
Removed calls to fflush().
* prep_cif.c (ffi_prep_cif): Added special case for sparc
aggregate type arguments.
Thu Oct 10 09:56:51 1996 Anthony Green <green@rtl.cygnus.com>
* ffitest.c (main): Added structure passing/returning tests.
* prep_cif.c (ffi_prep_cif): Perform proper initialization
of structure return types if needed.
(initialize_aggregate): Bug fix
Wed Oct 9 16:04:20 1996 Anthony Green <green@rtl.cygnus.com>
* types.c: Added special definitions for x86 (double doesn't
need double word alignment).
* ffitest.c: Added many tests
Tue Oct 8 09:19:22 1996 Anthony Green <green@rtl.cygnus.com>
* prep_cif.c (ffi_prep_cif): Fixed assertion.
* debug.c (ffi_assert): Must return a non void now.
* Makefile.am: Added test production.
* Makefile: Rebuilt.
* ffitest.c (main): Created.
* types.c: Created. Stripped common code out of */ffi.c.
* prep_cif.c: Added missing stdlib.h include.
* debug.c (ffi_type_test): Used "a" to eliminate compiler
warnings in non-debug builds. Included ffi_common.h.
Mon Oct 7 15:36:42 1996 Anthony Green <green@rtl.cygnus.com>
* Makefile.am: Added a rule for .s -> .o
This is required by the SGI compiler.
* Makefile: Rebuilt.
Fri Oct 4 09:51:08 1996 Anthony Green <green@hoser.cygnus.com>
* prep_cif.c (initialize_aggregate): Moved abi specification
to ffi_prep_cif().
Thu Oct 3 15:37:37 1996 Anthony Green <green@hoser.cygnus.com>
* prep_cif.c (ffi_prep_cif): Changed values from void* to void**.
(initialize_aggregate): Fixed aggregate type initialization.
* Makefile.am (EXTRA_DIST): Added support code for "make dist".
* Makefile.in: Regenerated.
Wed Oct 2 11:41:57 1996 Anthony Green <green@hoser.cygnus.com>
* debug.c, prep_cif: Created.
* Makefile.am: Added debug.o and prep_cif.o to OBJ.
* Makefile.in: Regenerated.
* Makefile.am (INCLUDES): Added missing -I../include
* Makefile.in: Regenerated.
Tue Oct 1 17:11:51 1996 Anthony Green <green@rtl.cygnus.com>
* error.c, Makefile.am: Created.
* Makefile.in: Generated.
--- libffi/src/x86 --------------------------------------------------------
Sun Oct 4 16:27:17 1998 Anthony Green <green@cygnus.com>
* sysv.S (retlongdouble): Fixed long long return value support.
* ffi.c (ffi_prep_cif_machdep): Ditto.
Wed May 13 04:30:33 1998 Anthony Green <green@raft.ppp.tsoft.net>
* ffi.c (ffi_prep_cif_machdep): Fixed long double return value
support.
Wed Apr 15 08:43:20 1998 Anthony Green <green@hoser.cygnus.com>
* ffi.c (ffi_prep_args): small struct support was missing.
Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
* objects.mak: Removed.
Mon Dec 2 15:12:58 1996 Tom Tromey <tromey@cygnus.com>
* sysv.S: Use .balign, for a.out Linux boxes.
Tue Oct 15 13:06:50 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.c: Clean up based on LCLint output.
Added funny /*@...@*/ comments to annotate source.
Fri Oct 11 16:43:38 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c (ffi_call): Added assertion for bad ABIs.
Wed Oct 9 13:57:27 1996 Anthony Green <green@rtl.cygnus.com>
* sysv.S (retdouble): Fixed double return problems.
* ffi.c (ffi_call): Corrected fn arg definition.
(ffi_prep_cif_machdep): Fixed double return problems
Tue Oct 8 12:12:49 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c: Moved ffi_type definitions to types.c.
(ffi_prep_args): Fixed type promotion bug.
Mon Oct 7 15:53:06 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c (FFI_*_TYPEDEF): Removed redundant ';'
Fri Oct 4 09:54:53 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.c (ffi_call): Removed FFI_ABI arg, and swapped
remaining args.
Wed Oct 2 10:07:05 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.c, sysv.S, objects.mak: Created.
(ffi_prep_cif): cif->rvalue no longer initialized to NULL.
(ffi_prep_cif_machdep): Moved machine independent cif processing
to src/prep_cif.c. Introduced ffi_prep_cif_machdep().
--- libffi/src/mips -------------------------------------------------------
Tue Feb 17 17:18:07 1998 Anthony Green <green@hoser.cygnus.com>
* o32.S: Fixed typo in comment.
* ffi.c (ffi_prep_cif_machdep): Fixed argument processing.
Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
* o32.s, n32.s: Wrappers for SGI tool support.
* objects.mak: Removed.
Tue Oct 29 14:37:45 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c (ffi_prep_args): Changed int z to size_t z.
Tue Oct 15 13:17:25 1996 Anthony Green <green@hoser.cygnus.com>
* n32.S: Fixed bad stack munging.
* ffi.c: Moved prototypes for ffi_call_?32() to here from
ffi_mips.h because extended_cif is not defined in ffi_mips.h.
Mon Oct 14 12:42:02 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c: Interface changes based on feedback from Jim Blandy.
Thu Oct 10 11:22:16 1996 Anthony Green <green@rtl.cygnus.com>
* n32.S, ffi.c: Lots of changes to support passing and
returning structures with the n32 calling convention.
* n32.S: Fixed fn pointer bug.
* ffi.c (ffi_prep_cif_machdep): Fix for o32 structure
return values.
(ffi_prep_args): Fixed n32 structure passing when structures
partially fit in registers.
Wed Oct 9 13:49:25 1996 Anthony Green <green@rtl.cygnus.com>
* objects.mak: Added n32.o.
* n32.S: Created.
* ffi.c (ffi_prep_args): Added magic to support proper
n32 processing.
Tue Oct 8 10:37:35 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c: Moved ffi_type definitions to types.c.
(ffi_prep_args): Fixed type promotion bug.
* o32.S: This code is only built for o32 compiles.
A lot of the #define cruft has moved to ffi_mips.h.
* ffi.c (ffi_prep_cif_machdep): Fixed arg flags. Second arg
is only processed if the first is either a float or double.
Mon Oct 7 15:33:59 1996 Anthony Green <green@rtl.cygnus.com>
* o32.S: Modified to compile under each of o32, n32 and n64.
* ffi.c (FFI_*_TYPEDEF): Removed redundant ';'
Fri Oct 4 09:53:25 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.c (ffi_call): Removed FFI_ABI arg, and swapped
remaining args.
Wed Oct 2 17:41:22 1996 Anthony Green <green@rtl.cygnus.com>
* o32.S: Removed crufty definitions.
Wed Oct 2 12:53:42 1996 Anthony Green <green@hoser.cygnus.com>
* ffi.c (ffi_prep_cif): cif->rvalue no longer initialized to NULL.
(ffi_prep_cif_machdep): Moved all machine independent cif processing
to src/prep_cif.c. Introduced ffi_prep_cif_machdep. Return types
of FFI_TYPE_STRUCT are no different than FFI_TYPE_INT.
Tue Oct 1 17:11:02 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c, o32.S, object.mak: Created
--- libffi/src/sparc ------------------------------------------------------
Tue Feb 24 16:33:18 1998 Anthony Green <green@hoser.cygnus.com>
* ffi.c (ffi_prep_args): Added long double support.
Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
* objects.mak: Removed.
Thu May 1 16:07:56 1997 Anthony Green <green@hoser.cygnus.com>
* v8.S: Fixed minor portability problem reported by
Russ McManus <mcmanr@eq.gs.com>.
Tue Nov 26 14:12:43 1996 Anthony Green <green@csk3.cygnus.com>
* v8.S: Used STACKFRAME define elsewhere.
* ffi.c (ffi_prep_args): Zero out space when USING_PURIFY
is set.
(ffi_prep_cif_machdep): Allocate the correct stack frame
space for functions with < 6 args.
Tue Oct 29 15:08:55 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c (ffi_prep_args): int z is now size_t z.
Mon Oct 14 13:31:24 1996 Anthony Green <green@rtl.cygnus.com>
* v8.S (ffi_call_V8): Gordon rewrites this again. It looks
great now.
* ffi.c (ffi_call): The comment about hijacked registers
is no longer valid after gordoni hacked v8.S.
* v8.S (ffi_call_V8): Rewrote with gordoni. Much simpler.
* v8.S, ffi.c: ffi_call() had changed to accept more than
two args, so v8.S had to change (because it hijacks incoming
arg registers).
* ffi.c: Interface changes based on feedback from Jim Blandy.
Thu Oct 10 17:48:16 1996 Anthony Green <green@rtl.cygnus.com>
* ffi.c, v8.S, objects.mak: Created.

View File

@ -1,4 +1,4 @@
libffi - Copyright (c) 1996-2008 Red Hat, Inc and others.
libffi - Copyright (c) 1996-2009 Anthony Green, Red Hat, Inc and others.
See source files for details.
Permission is hereby granted, free of charge, to any person obtaining

View File

@ -7,6 +7,7 @@ SUBDIRS = include testsuite man
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
src/arm/ffi.c src/arm/sysv.S src/arm/ffitarget.h \
src/avr32/ffi.c src/avr32/sysv.S src/avr32/ffitarget.h \
src/cris/ffi.c src/cris/sysv.S src/cris/ffitarget.h \
src/ia64/ffi.c src/ia64/ffitarget.h src/ia64/ia64_flags.h \
src/ia64/unix.S \
@ -25,12 +26,13 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
src/sh64/ffi.c src/sh64/sysv.S src/sh64/ffitarget.h \
src/sparc/v8.S 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/freebsd.S \
src/x86/ffi.c src/x86/sysv.S src/x86/win32.S src/x86/win64.S \
src/x86/darwin.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/frv/eabi.S src/frv/ffitarget.h src/dlmalloc.c \
libtool-version ChangeLog.libffi
libtool-version ChangeLog.libffi m4/libtool.m4 \
m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4
info_TEXINFOS = doc/libffi.texi
@ -79,6 +81,8 @@ AM_MAKEFLAGS = \
MAKEOVERRIDES=
ACLOCAL_AMFLAGS=$(ACLOCAL_AMFLAGS) -I m4
lib_LTLIBRARIES = libffi.la
noinst_LTLIBRARIES = libffi_convenience.la
@ -102,6 +106,9 @@ endif
if X86_WIN32
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win32.S
endif
if X86_WIN64
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win64.S
endif
if X86_DARWIN
nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
endif
@ -135,6 +142,9 @@ endif
if ARM
nodist_libffi_la_SOURCES += src/arm/sysv.S src/arm/ffi.c
endif
if AVR32
nodist_libffi_la_SOURCES += src/avr32/sysv.S src/avr32/ffi.c
endif
if LIBFFI_CRIS
nodist_libffi_la_SOURCES += src/cris/sysv.S src/cris/ffi.c
endif
@ -165,7 +175,7 @@ nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
AM_CFLAGS = -Wall -g -fexceptions
libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
libffi_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(AM_LTLDFLAGS)
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
AM_CCASFLAGS = $(AM_CPPFLAGS)

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
Status
======
libffi-3.0.5 was released on April 3, 2008. Check the libffi web
libffi-3.0.9 was released on December 31, 2009. Check the libffi web
page for updates: <URL:http://sourceware.org/libffi/>.
@ -9,27 +9,27 @@ What is libffi?
===============
Compilers for high level languages generate code that follow certain
conventions. These conventions are necessary, in part, for separate
compilation to work. One such convention is the "calling convention".
The "calling convention" is a set of assumptions made by the compiler
about where function arguments will be found on entry to a function.
A "calling convention" also specifies where the return value for a
function is found.
conventions. These conventions are necessary, in part, for separate
compilation to work. One such convention is the "calling
convention". The "calling convention" is essentially a set of
assumptions made by the compiler about where function arguments will
be found on entry to a function. A "calling convention" also specifies
where the return value for a function is found.
Some programs may not know at the time of compilation what arguments
are to be passed to a function. For instance, an interpreter may be
are to be passed to a function. For instance, an interpreter may be
told at run-time about the number and types of arguments used to call
a given function. Libffi can be used in such programs to provide a
a given function. Libffi can be used in such programs to provide a
bridge from the interpreter program to compiled code.
The libffi library provides a portable, high level programming
interface to various calling conventions. This allows a programmer to
interface to various calling conventions. This allows a programmer to
call any function specified by a call interface description at run
time.
time.
FFI stands for Foreign Function Interface. A foreign function
interface is the popular name for the interface that allows code
written in one language to call code written in another language. The
written in one language to call code written in another language. The
libffi library really only provides the lowest, machine dependent
layer of a fully featured foreign function interface. A layer must
exist above libffi that handles type conversions for values passed
@ -39,36 +39,56 @@ between the two languages.
Supported Platforms
===================
Libffi has been ported to many different platforms, although this
release was only tested on:
Libffi has been ported to many different platforms.
For specific configuration details and testing status, please
refer to the wiki page here:
http://www.moxielogic.org/wiki/index.php?title=Libffi_3.0.9
At the time of release, the following basic configurations have been
tested:
|--------------+------------------|
| Architecture | Operating System |
|--------------+------------------|
| Alpha | Linux |
| ARM | Linux |
| AVR32 | Linux |
| HPPA | HPUX |
| IA-64 | Linux |
| MIPS | IRIX |
| MIPS | Linux |
| MIPS64 | Linux |
| PowerPC | Linux |
| PowerPC | Mac OSX |
| PowerPC | FreeBSD |
| PowerPC64 | Linux |
| S390 | Linux |
| S390X | Linux |
| SPARC | Linux |
| SPARC | Solaris |
| SPARC64 | Linux |
| SPARC64 | FreeBSD |
| X86 | FreeBSD |
| X86 | kFreeBSD |
| X86 | Linux |
| X86 | Mac OSX |
| X86 | OpenBSD |
| X86 | Solaris |
| X86 | Windows/Cygwin |
| X86 | Windows/MingW |
| X86-64 | FreeBSD |
| X86-64 | Linux |
| X86-64 | OpenBSD |
|--------------+------------------|
arm oabi linux
arm eabi linux
hppa linux
mips o32 linux (little endian)
powerpc darwin
powerpc64 linux
sparc solaris
sparc64 solaris
x86 cygwin
x86 darwin
x86 freebsd
x86 linux
x86 openbsd
x86-64 darwin
x86-64 linux
x86-64 OS X
x86-64 freebsd
Please send additional platform test results to
libffi-discuss@sourceware.org.
libffi-discuss@sourceware.org and feel free to update the wiki page
above.
Installing libffi
=================
[Note: before actually performing any of these installation steps,
you may wish to read the "Platform Specific Notes" below.]
First you must configure the distribution for your particular
system. Go to the directory you wish to build libffi in and run the
"configure" program found in the root directory of the libffi source
@ -98,66 +118,29 @@ This will require that you have DejaGNU installed.
To install the library and header files, type "make install".
Platform Specific Notes
=======================
MIPS - Irix 5.3 & 6.x
---------------------
Irix 6.2 and better supports three different calling conventions: o32,
n32 and n64. Currently, libffi only supports both o32 and n32 under
Irix 6.x, but only o32 under Irix 5.3. Libffi will automatically be
configured for whichever calling convention it was built for.
By default, the configure script will try to build libffi with the GNU
development tools. To build libffi with the SGI development tools, set
the environment variable CC to either "cc -32" or "cc -n32" before
running configure under Irix 6.x (depending on whether you want an o32
or n32 library), or just "cc" for Irix 5.3.
With the n32 calling convention, when returning structures smaller
than 16 bytes, be sure to provide an RVALUE that is 8 byte aligned.
Here's one way of forcing this:
double struct_storage[2];
my_small_struct *s = (my_small_struct *) struct_storage;
/* Use s for RVALUE */
If you don't do this you are liable to get spurious bus errors.
"long long" values are not supported yet.
You must use GNU Make to build libffi on SGI platforms.
PowerPC System V ABI
--------------------
There are two `System V ABI's which libffi implements for PowerPC.
They differ only in how small structures are returned from functions.
In the FFI_SYSV version, structures that are 8 bytes or smaller are
returned in registers. This is what GCC does when it is configured
for solaris, and is what the System V ABI I have (dated September
1995) says.
In the FFI_GCC_SYSV version, all structures are returned the same way:
by passing a pointer as the first argument to the function. This is
what GCC does when it is configured for linux or a generic sysv
target.
EGCS 1.0.1 (and probably other versions of EGCS/GCC) also has a
inconsistency with the SysV ABI: When a procedure is called with many
floating-point arguments, some of them get put on the stack. They are
all supposed to be stored in double-precision format, even if they are
only single-precision, but EGCS stores single-precision arguments as
single-precision anyway. This causes one test to fail (the `many
arguments' test).
History
=======
See the ChangeLog files for details.
3.0.9 Dec-31-09
Add AVR32 and win64 ports. Add ARM softfp support.
Many fixes for AIX, Solaris, HP-UX, *BSD.
Several PowerPC and x86-64 bug fixes.
Build DLL for windows.
3.0.8 Dec-19-08
Add *BSD, BeOS, and PA-Linux support.
3.0.7 Nov-11-08
Fix for ppc FreeBSD.
(thanks to Andreas Tobler)
3.0.6 Jul-17-08
Fix for closures on sh.
Mark the sh/sh64 stack as non-executable.
(both thanks to Kaz Kojima)
3.0.5 Apr-3-08
Fix libffi.pc file.
Fix #define ARM for IcedTea users.

File diff suppressed because it is too large Load Diff

142
Modules/_ctypes/libffi/compile Executable file
View File

@ -0,0 +1,142 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
scriptversion=2005-05-14.22
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.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 2, 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.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand `-c -o'.
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file `INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
esac
ofile=
cfile=
eat=
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'.
# So we strip `-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# 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
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
# Create the lock directory.
# 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
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -1,10 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
# Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
timestamp='2007-05-17'
timestamp='2009-11-19'
# 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
@ -27,16 +27,16 @@ timestamp='2007-05-17'
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner <per@bothner.com>.
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
# 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
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit build system type.
# 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
me=`echo "$0" | sed -e 's,.*/,,'`
@ -56,8 +56,8 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -170,7 +170,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null
| grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
@ -324,14 +324,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7; exit ;;
esac ;;
s390x:SunOS:*:*)
echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
i86pc:SunOS:5.*:* | ix86xen:SunOS:5.*:*)
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval $set_cc_for_build
SUN_ARCH="i386"
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH="x86_64"
fi
fi
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
@ -532,7 +548,7 @@ EOF
echo rs6000-ibm-aix3.2
fi
exit ;;
*:AIX:*:[45])
*:AIX:*:[456])
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
IBM_ARCH=rs6000
@ -640,7 +656,7 @@ EOF
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
grep __LP64__ >/dev/null
grep -q __LP64__
then
HP_ARCH="hppa2.0w"
else
@ -791,18 +807,24 @@ EOF
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
*:Interix*:[3456]*)
*:Interix*:*)
case ${UNAME_MACHINE} in
x86)
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
EM64T | authenticamd)
authenticamd | genuineintel | EM64T)
echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
IA64)
echo ia64-unknown-interix${UNAME_RELEASE}
exit ;;
esac ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit ;;
8664:Windows_NT:*)
echo x86_64-pc-mks
exit ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
@ -832,8 +854,29 @@ EOF
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;;
arm*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
@ -847,6 +890,17 @@ EOF
frv:Linux:*:*)
echo frv-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
LIBC=gnu
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 ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
@ -856,74 +910,33 @@ EOF
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
mips:Linux:*:*)
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips
#undef mipsel
#undef ${UNAME_MACHINE}
#undef ${UNAME_MACHINE}el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
CPU=${UNAME_MACHINE}el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
CPU=${UNAME_MACHINE}
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips64
#undef mips64el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mips64el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips64
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
@ -933,8 +946,11 @@ EOF
*) echo hppa-unknown-linux-gnu ;;
esac
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
@ -954,72 +970,9 @@ EOF
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
exit ;;
xtensa:Linux:*:*)
echo xtensa-unknown-linux-gnu
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
# Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
s/.*supported targets: *//
s/ .*//
p'`
case "$ld_supported_targets" in
elf32-i386)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit ;;
"")
# Either a pre-BFD a.out linker (linux-gnuoldld) or
# one that does not give us useful --help.
echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
exit ;;
esac
# Determine whether the default compiler is a.out or elf
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^LIBC/{
s: ::g
p
}'`"
test x"${LIBC}" != x && {
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit
}
test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
@ -1048,7 +1001,7 @@ EOF
i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable
exit ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit ;;
i*86:*DOS:*:*)
@ -1092,8 +1045,11 @@ EOF
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386.
echo i386-pc-msdosdjgpp
# the processor, so we play safe by assuming i586.
# 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
# this is a cross-build.
echo i586-pc-msdosdjgpp
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
@ -1131,6 +1087,16 @@ EOF
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit ;;
@ -1143,7 +1109,7 @@ EOF
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit ;;
SM[BE]S:UNIX_SV:*:*)
@ -1206,6 +1172,9 @@ EOF
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
exit ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
@ -1233,6 +1202,16 @@ EOF
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
i386)
eval $set_cc_for_build
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
fi ;;
unknown) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
@ -1314,6 +1293,9 @@ EOF
i*86:rdos:*:*)
echo ${UNAME_MACHINE}-pc-rdos
exit ;;
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
@ -1474,9 +1456,9 @@ This script, last modified $timestamp, has failed to recognize
the operating system you are using. It is advised that you
download the most up to date version of the config scripts from
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
and
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
If the version you run ($0) is already up to date, please
send the following data and any information you think might be

View File

@ -1,10 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
# Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
timestamp='2007-04-29'
timestamp='2009-11-07'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@ -32,13 +32,16 @@ timestamp='2007-04-29'
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
# diff and a properly formatted GNU ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
@ -72,8 +75,8 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -122,6 +125,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
@ -148,10 +152,13 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray)
-apple | -axis | -knuth | -cray | -microblaze)
os=
basic_machine=$1
;;
-bluegene*)
os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
@ -249,13 +256,16 @@ case $basic_machine in
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep \
| maxq | mb | microblaze | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64vr | mips64vrel \
| mips64octeon | mips64octeonel \
| mips64orion | mips64orionel \
| mips64r5900 | mips64r5900el \
| mips64vr | mips64vrel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
@ -268,6 +278,7 @@ case $basic_machine in
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nios | nios2 \
@ -276,20 +287,22 @@ case $basic_machine in
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| rx \
| score \
| sh | sh[1234] | sh[24]a | 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 \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| ubicom32 \
| v850 | v850e \
| we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k)
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
m6811 | m68hc11 | m6812 | m68hc12 | picochip)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
@ -329,14 +342,17 @@ case $basic_machine in
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64vr-* | mips64vrel-* \
| mips64octeon-* | mips64octeonel-* \
| mips64orion-* | mips64orionel-* \
| mips64r5900-* | mips64r5900el-* \
| mips64vr-* | mips64vrel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
@ -357,21 +373,26 @@ case $basic_machine in
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-*)
| z8k-* | z80-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=$basic_machine-unknown
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@ -435,6 +456,10 @@ case $basic_machine in
basic_machine=m68k-apollo
os=-bsd
;;
aros)
basic_machine=i386-pc
os=-aros
;;
aux)
basic_machine=m68k-apple
os=-aux
@ -443,10 +468,26 @@ case $basic_machine in
basic_machine=ns32k-sequent
os=-dynix
;;
blackfin)
basic_machine=bfin-unknown
os=-linux
;;
blackfin-*)
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
bluegene*)
basic_machine=powerpc-ibm
os=-cnk
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
@ -475,8 +516,8 @@ case $basic_machine in
basic_machine=craynv-cray
os=-unicosmp
;;
cr16c)
basic_machine=cr16c-unknown
cr16)
basic_machine=cr16-unknown
os=-elf
;;
crds | unos)
@ -514,6 +555,10 @@ case $basic_machine in
basic_machine=m88k-motorola
os=-sysv3
;;
dicos)
basic_machine=i686-pc
os=-dicos
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
@ -668,6 +713,14 @@ case $basic_machine in
basic_machine=m68k-isi
os=-sysv
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
m88k-omron*)
basic_machine=m88k-omron
;;
@ -679,6 +732,9 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
microblaze)
basic_machine=microblaze-xilinx
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
@ -813,6 +869,14 @@ case $basic_machine in
basic_machine=i860-intel
os=-osf
;;
parisc)
basic_machine=hppa-unknown
os=-linux
;;
parisc-*)
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
pbd)
basic_machine=sparc-tti
;;
@ -1021,6 +1085,10 @@ case $basic_machine in
basic_machine=tic6x-unknown
os=-coff
;;
tile*)
basic_machine=tile-unknown
os=-linux-gnu
;;
tx39)
basic_machine=mipstx39-unknown
;;
@ -1096,6 +1164,10 @@ case $basic_machine in
basic_machine=z8k-unknown
os=-sim
;;
z80-*-coff)
basic_machine=z80-unknown
os=-sim
;;
none)
basic_machine=none-none
os=-none
@ -1134,7 +1206,7 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
@ -1204,10 +1276,11 @@ case $os in
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
@ -1216,7 +1289,7 @@ case $os in
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
@ -1226,7 +1299,7 @@ case $os in
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
| -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@ -1356,6 +1429,9 @@ case $os in
-zvmoe)
os=-zvmoe
;;
-dicos*)
os=-dicos
;;
-none)
;;
*)
@ -1553,7 +1629,7 @@ case $basic_machine in
-sunos*)
vendor=sun
;;
-aix*)
-cnk*|-aix*)
vendor=ibm
;;
-beos*)

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,9 @@ dnl Process this with autoconf to create configure
# file from libffi - slightly patched for ctypes
#
AC_PREREQ(2.59)
AC_PREREQ(2.63)
AC_INIT([libffi], [3.0.5], [http://gcc.gnu.org/bugs.html])
AC_INIT([libffi], [3.0.9], [http://gcc.gnu.org/bugs.html])
AC_CONFIG_HEADERS([fficonfig.h])
AC_CANONICAL_SYSTEM
@ -23,6 +23,7 @@ AM_INIT_AUTOMAKE
m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
m4_define([_AC_ARG_VAR_PRECIOUS],[])
AC_PROG_CC
m4_undefine([_AC_ARG_VAR_PRECIOUS])
m4_rename([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
AC_SUBST(CFLAGS)
@ -30,6 +31,7 @@ AC_SUBST(CFLAGS)
AM_PROG_AS
AM_PROG_CC_C_O
AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
AM_MAINTAINER_MODE
@ -52,10 +54,14 @@ case "$host" in
TARGET=ARM; TARGETDIR=arm
;;
amd64-*-freebsd*)
amd64-*-freebsd* | amd64-*-openbsd*)
TARGET=X86_64; TARGETDIR=x86
;;
avr32*-*-*)
TARGET=AVR32; TARGETDIR=avr32
;;
cris-*-*)
TARGET=LIBFFI_CRIS; TARGETDIR=cris
;;
@ -74,11 +80,13 @@ case "$host" in
TARGET=PA_HPUX; TARGETDIR=pa
;;
i386-*-freebsd* | i386-*-openbsd*)
i?86-*-freebsd* | i?86-*-openbsd*)
TARGET=X86_FREEBSD; TARGETDIR=x86
;;
i?86-win32* | i?86-*-cygwin* | i?86-*-mingw*)
TARGET=X86_WIN32; TARGETDIR=x86
# All mingw/cygwin/win32 builds require this for sharedlib
AM_LTLDFLAGS="-no-undefined"
;;
i?86-*-darwin*)
TARGET=X86_DARWIN; TARGETDIR=x86
@ -109,7 +117,9 @@ case "$host" in
TARGET=MIPS_IRIX; TARGETDIR=mips
;;
mips*-*-linux*)
TARGET=MIPS_LINUX; TARGETDIR=mips
# Support 128-bit long double for NewABI.
HAVE_LONG_DOUBLE='defined(__mips64)'
TARGET=MIPS_IRIX; TARGETDIR=mips
;;
powerpc*-*-linux* | powerpc-*-sysv*)
@ -149,14 +159,18 @@ case "$host" in
x86_64-*-darwin*)
TARGET=X86_DARWIN; TARGETDIR=x86
;;
x86_64-*-cygwin* | x86_64-*-mingw*)
TARGET=X86_WIN64; TARGETDIR=x86
;;
x86_64-*-*)
TARGET=X86_64; TARGETDIR=x86
;;
esac
AC_SUBST(AM_RUNTESTFLAGS)
AC_SUBST(AM_LTLDFLAGS)
if test $TARGETDIR = unknown; then
AC_MSG_ERROR(["libffi has not been ported to $host."])
@ -167,6 +181,7 @@ AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
AM_CONDITIONAL(X86, test x$TARGET = xX86)
AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
@ -177,6 +192,7 @@ AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
AM_CONDITIONAL(ARM, test x$TARGET = xARM)
AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
AM_CONDITIONAL(FRV, test x$TARGET = xFRV)
AM_CONDITIONAL(S390, test x$TARGET = xS390)
@ -251,6 +267,29 @@ if test x$TARGET = xSPARC; then
fi
fi
if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
AC_CACHE_CHECK([assembler supports pc related relocs],
libffi_cv_as_x86_pcrel, [
libffi_cv_as_x86_pcrel=yes
echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
if $CC $CFLAGS -c conftest.s 2>&1 | grep -i warning > /dev/null; then
libffi_cv_as_x86_pcrel=no
fi
])
if test "x$libffi_cv_as_x86_pcrel" = xyes; then
AC_DEFINE(HAVE_AS_X86_PCREL, 1,
[Define if your assembler supports PC relative relocs.])
fi
fi
case "$target" in
*-apple-darwin10* | *-*-freebsd* | *-*-openbsd* | *-pc-solaris*)
AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
[Cannot use malloc on this target, so, we revert to
alternative means])
;;
esac
AC_CACHE_CHECK([whether .eh_frame section should be read-only],
libffi_cv_ro_eh_frame, [
libffi_cv_ro_eh_frame=no

584
Modules/_ctypes/libffi/depcomp Executable file
View File

@ -0,0 +1,584 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2006-10-15.18
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, 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.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# 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
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - 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.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## 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
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$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
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# 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
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# 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
# 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;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
# Add `dependent.h:' lines.
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# 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
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mechanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# 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
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# 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.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -0,0 +1,533 @@
This is ../libffi/doc/libffi.info, produced by makeinfo version 4.13
from ../libffi/doc/libffi.texi.
This manual is for Libffi, a portable foreign-function interface
library.
Copyright (C) 2008 Red Hat, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or
(at your option) any later version. A copy of the license is
included in the section entitled "GNU General Public License".
INFO-DIR-SECTION Development
START-INFO-DIR-ENTRY
* libffi: (libffi). Portable foreign-function interface library.
END-INFO-DIR-ENTRY

File: libffi.info, Node: Top, Next: Introduction, Up: (dir)
libffi
******
This manual is for Libffi, a portable foreign-function interface
library.
Copyright (C) 2008 Red Hat, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or
(at your option) any later version. A copy of the license is
included in the section entitled "GNU General Public License".
* Menu:
* Introduction:: What is libffi?
* Using libffi:: How to use libffi.
* Missing Features:: Things libffi can't do.
* Index:: Index.

File: libffi.info, Node: Introduction, Next: Using libffi, Prev: Top, Up: Top
1 What is libffi?
*****************
Compilers for high level languages generate code that follow certain
conventions. These conventions are necessary, in part, for separate
compilation to work. One such convention is the "calling convention".
The calling convention is a set of assumptions made by the compiler
about where function arguments will be found on entry to a function. A
calling convention also specifies where the return value for a function
is found. The calling convention is also sometimes called the "ABI" or
"Application Binary Interface".
Some programs may not know at the time of compilation what arguments
are to be passed to a function. For instance, an interpreter may be
told at run-time about the number and types of arguments used to call a
given function. `Libffi' can be used in such programs to provide a
bridge from the interpreter program to compiled code.
The `libffi' library provides a portable, high level programming
interface to various calling conventions. This allows a programmer to
call any function specified by a call interface description at run time.
FFI stands for Foreign Function Interface. A foreign function
interface is the popular name for the interface that allows code
written in one language to call code written in another language. The
`libffi' library really only provides the lowest, machine dependent
layer of a fully featured foreign function interface. A layer must
exist above `libffi' that handles type conversions for values passed
between the two languages.

File: libffi.info, Node: Using libffi, Next: Missing Features, Prev: Introduction, Up: Top
2 Using libffi
**************
* Menu:
* The Basics:: The basic libffi API.
* Simple Example:: A simple example.
* Types:: libffi type descriptions.
* Multiple ABIs:: Different passing styles on one platform.
* The Closure API:: Writing a generic function.

File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
2.1 The Basics
==============
`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
well as the return type of the function.
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
separate step because it is common to make multiple calls using a
single `ffi_cif'. The "cif" in `ffi_cif' stands for Call InterFace.
To prepare a call interface object, use the function `ffi_prep_cif'.
-- Function: ffi_status ffi_prep_cif (ffi_cif *CIF, ffi_abi ABI,
unsigned int NARGS, ffi_type *RTYPE, ffi_type **ARGTYPES)
This initializes CIF according to the given parameters.
ABI is the ABI to use; normally `FFI_DEFAULT_ABI' is what you
want. *note Multiple ABIs:: for more information.
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
return type of the function. *Note Types::.
ARGTYPES is a vector of `ffi_type' pointers. ARGTYPES must have
NARGS elements. If NARGS is 0, this argument is ignored.
`ffi_prep_cif' returns a `libffi' status code, of type
`ffi_status'. This will be either `FFI_OK' if everything worked
properly; `FFI_BAD_TYPEDEF' if one of the `ffi_type' objects is
incorrect; or `FFI_BAD_ABI' if the ABI parameter is invalid.
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
**AVALUES)
This calls the function FN according to the description given in
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
of the function call. This must be large enough to hold the
result and must be suitably aligned; it is the caller's
responsibility to ensure this. If CIF declares that the function
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
locations holding the argument values for a call. If CIF declares
that the function has no arguments (i.e., NARGS was 0), then
AVALUES is ignored.

File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
2.2 Simple Example
==================
Here is a trivial example that calls `puts' a few times.
#include <stdio.h>
#include <ffi.h>
int main()
{
ffi_cif cif;
ffi_type *args[1];
void *values[1];
char *s;
int rc;
/* Initialize the argument info vectors */
args[0] = &ffi_type_pointer;
values[0] = &s;
/* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint, args) == FFI_OK)
{
s = "Hello World!";
ffi_call(&cif, puts, &rc, values);
/* rc now holds the result of the call to puts */
/* values holds a pointer to the function's arg, so to
call puts() again all we need to do is change the
value of s */
s = "This is cool!";
ffi_call(&cif, puts, &rc, values);
}
return 0;
}

File: libffi.info, Node: Types, Next: Multiple ABIs, Prev: Simple Example, Up: Using libffi
2.3 Types
=========
* Menu:
* Primitive Types:: Built-in types.
* Structures:: Structure types.
* Type Example:: Structure type example.

File: libffi.info, Node: Primitive Types, Next: Structures, Up: Types
2.3.1 Primitive Types
---------------------
`Libffi' provides a number of built-in type descriptors that can be
used to describe argument and return types:
`ffi_type_void'
The type `void'. This cannot be used for argument types, only for
return values.
`ffi_type_uint8'
An unsigned, 8-bit integer type.
`ffi_type_sint8'
A signed, 8-bit integer type.
`ffi_type_uint16'
An unsigned, 16-bit integer type.
`ffi_type_sint16'
A signed, 16-bit integer type.
`ffi_type_uint32'
An unsigned, 32-bit integer type.
`ffi_type_sint32'
A signed, 32-bit integer type.
`ffi_type_uint64'
An unsigned, 64-bit integer type.
`ffi_type_sint64'
A signed, 64-bit integer type.
`ffi_type_float'
The C `float' type.
`ffi_type_double'
The C `double' type.
`ffi_type_uchar'
The C `unsigned char' type.
`ffi_type_schar'
The C `signed char' type. (Note that there is not an exact
equivalent to the C `char' type in `libffi'; ordinarily you should
either use `ffi_type_schar' or `ffi_type_uchar' depending on
whether `char' is signed.)
`ffi_type_ushort'
The C `unsigned short' type.
`ffi_type_sshort'
The C `short' type.
`ffi_type_uint'
The C `unsigned int' type.
`ffi_type_sint'
The C `int' type.
`ffi_type_ulong'
The C `unsigned long' type.
`ffi_type_slong'
The C `long' type.
`ffi_type_longdouble'
On platforms that have a C `long double' type, this is defined.
On other platforms, it is not.
`ffi_type_pointer'
A generic `void *' pointer. You should use this for all pointers,
regardless of their real type.
Each of these is of type `ffi_type', so you must take the address
when passing to `ffi_prep_cif'.

File: libffi.info, Node: Structures, Next: Type Example, Prev: Primitive Types, Up: Types
2.3.2 Structures
----------------
Although `libffi' has no special support for unions or bit-fields, it
is perfectly happy passing structures back and forth. You must first
describe the structure to `libffi' by creating a new `ffi_type' object
for it.
-- ffi_type:
The `ffi_type' has the following members:
`size_t size'
This is set by `libffi'; you should initialize it to zero.
`unsigned short alignment'
This is set by `libffi'; you should initialize it to zero.
`unsigned short type'
For a structure, this should be set to `FFI_TYPE_STRUCT'.
`ffi_type **elements'
This is a `NULL'-terminated array of pointers to `ffi_type'
objects. There is one element per field of the struct.

File: libffi.info, Node: Type Example, Prev: Structures, Up: Types
2.3.3 Type Example
------------------
The following example initializes a `ffi_type' object representing the
`tm' struct from Linux's `time.h'.
Here is how the struct is defined:
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
/* Those are for future use. */
long int __tm_gmtoff__;
__const char *__tm_zone__;
};
Here is the corresponding code to describe this struct to `libffi':
{
ffi_type tm_type;
ffi_type *tm_type_elements[12];
int i;
tm_type.size = tm_type.alignment = 0;
tm_type.elements = &tm_type_elements;
for (i = 0; i < 9; i++)
tm_type_elements[i] = &ffi_type_sint;
tm_type_elements[9] = &ffi_type_slong;
tm_type_elements[10] = &ffi_type_pointer;
tm_type_elements[11] = NULL;
/* tm_type can now be used to represent tm argument types and
return types for ffi_prep_cif() */
}

File: libffi.info, Node: Multiple ABIs, Next: The Closure API, Prev: Types, Up: Using libffi
2.4 Multiple ABIs
=================
A given platform may provide multiple different ABIs at once. For
instance, the x86 platform has both `stdcall' and `fastcall' functions.
`libffi' provides some support for this. However, this is
necessarily platform-specific.

File: libffi.info, Node: The Closure API, Prev: Multiple ABIs, Up: Using libffi
2.5 The Closure API
===================
`libffi' also provides a way to write a generic function - a function
that can accept and decode any combination of arguments. This can be
useful when writing an interpreter, or to provide wrappers for
arbitrary functions.
This facility is called the "closure API". Closures are not
supported on all platforms; you can check the `FFI_CLOSURES' define to
determine whether they are supported on the current platform.
Because closures work by assembling a tiny function at runtime, they
require special allocation on platforms that have a non-executable
heap. Memory management for closures is handled by a pair of functions:
-- Function: void *ffi_closure_alloc (size_t SIZE, void **CODE)
Allocate a chunk of memory holding SIZE bytes. This returns a
pointer to the writable address, and sets *CODE to the
corresponding executable address.
SIZE should be sufficient to hold a `ffi_closure' object.
-- Function: void ffi_closure_free (void *WRITABLE)
Free memory allocated using `ffi_closure_alloc'. The argument is
the writable address that was returned.
Once you have allocated the memory for a closure, you must construct
a `ffi_cif' describing the function call. Finally you can prepare the
closure function:
-- Function: ffi_status ffi_prep_closure_loc (ffi_closure *CLOSURE,
ffi_cif *CIF, void (*FUN) (ffi_cif *CIF, void *RET, void
**ARGS, void *USER_DATA), void *USER_DATA, void *CODELOC)
Prepare a closure function.
CLOSURE is the address of a `ffi_closure' object; this is the
writable address returned by `ffi_closure_alloc'.
CIF is the `ffi_cif' describing the function parameters.
USER_DATA is an arbitrary datum that is passed, uninterpreted, to
your closure function.
CODELOC is the executable address returned by `ffi_closure_alloc'.
FUN is the function which will be called when the closure is
invoked. It is called with the arguments:
CIF
The `ffi_cif' passed to `ffi_prep_closure_loc'.
RET
A pointer to the memory used for the function's return value.
FUN must fill this, unless the function is declared as
returning `void'.
ARGS
A vector of pointers to memory holding the arguments to the
function.
USER_DATA
The same USER_DATA that was passed to `ffi_prep_closure_loc'.
`ffi_prep_closure_loc' will return `FFI_OK' if everything went ok,
and something else on error.
After calling `ffi_prep_closure_loc', you can cast CODELOC to the
appropriate pointer-to-function type.
You may see old code referring to `ffi_prep_closure'. This function
is deprecated, as it cannot handle the need for separate writable and
executable addresses.

File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
3 Missing Features
******************
`libffi' is missing a few features. We welcome patches to add support
for these.
* There is no support for calling varargs functions. This may work
on some platforms, depending on how the ABI is defined, but it is
not reliable.
* There is no support for bit fields in structures.
* The closure API is
* The "raw" API is undocumented.

File: libffi.info, Node: Index, Prev: Missing Features, Up: Top
Index
*****
[index]
* Menu:
* : Structures. (line 12)
* ABI: Introduction. (line 13)
* Application Binary Interface: Introduction. (line 13)
* calling convention: Introduction. (line 13)
* cif: The Basics. (line 14)
* closure API: The Closure API. (line 13)
* closures: The Closure API. (line 13)
* FFI: Introduction. (line 31)
* ffi_call: The Basics. (line 41)
* ffi_closure_alloca: The Closure API. (line 19)
* ffi_closure_free: The Closure API. (line 26)
* FFI_CLOSURES: The Closure API. (line 13)
* ffi_prep_cif: The Basics. (line 16)
* ffi_prep_closure_loc: The Closure API. (line 34)
* ffi_status <1>: The Closure API. (line 37)
* ffi_status: The Basics. (line 18)
* ffi_type: Structures. (line 11)
* ffi_type_double: Primitive Types. (line 41)
* ffi_type_float: Primitive Types. (line 38)
* ffi_type_longdouble: Primitive Types. (line 71)
* ffi_type_pointer: Primitive Types. (line 75)
* ffi_type_schar: Primitive Types. (line 47)
* ffi_type_sint: Primitive Types. (line 62)
* ffi_type_sint16: Primitive Types. (line 23)
* ffi_type_sint32: Primitive Types. (line 29)
* ffi_type_sint64: Primitive Types. (line 35)
* ffi_type_sint8: Primitive Types. (line 17)
* ffi_type_slong: Primitive Types. (line 68)
* ffi_type_sshort: Primitive Types. (line 56)
* ffi_type_uchar: Primitive Types. (line 44)
* ffi_type_uint: Primitive Types. (line 59)
* ffi_type_uint16: Primitive Types. (line 20)
* ffi_type_uint32: Primitive Types. (line 26)
* ffi_type_uint64: Primitive Types. (line 32)
* ffi_type_uint8: Primitive Types. (line 14)
* ffi_type_ulong: Primitive Types. (line 65)
* ffi_type_ushort: Primitive Types. (line 53)
* ffi_type_void: Primitive Types. (line 10)
* Foreign Function Interface: Introduction. (line 31)
* void <1>: The Closure API. (line 20)
* void: The Basics. (line 43)

Tag Table:
Node: Top700
Node: Introduction1436
Node: Using libffi3072
Node: The Basics3507
Node: Simple Example6114
Node: Types7141
Node: Primitive Types7424
Node: Structures9244
Node: Type Example10104
Node: Multiple ABIs11327
Node: The Closure API11698
Node: Missing Features14618
Node: Index15111

End Tag Table

View File

@ -0,0 +1,541 @@
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename libffi.info
@settitle libffi
@setchapternewpage off
@c %**end of header
@c Merge the standard indexes into a single one.
@syncodeindex fn cp
@syncodeindex vr cp
@syncodeindex ky cp
@syncodeindex pg cp
@syncodeindex tp cp
@include version.texi
@copying
This manual is for Libffi, a portable foreign-function interface
library.
Copyright @copyright{} 2008 Red Hat, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version. A copy of the license is included in the
section entitled ``GNU General Public License''.
@end quotation
@end copying
@dircategory Development
@direntry
* libffi: (libffi). Portable foreign-function interface library.
@end direntry
@titlepage
@title Libffi
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@ifnottex
@node Top
@top libffi
@insertcopying
@menu
* Introduction:: What is libffi?
* Using libffi:: How to use libffi.
* Missing Features:: Things libffi can't do.
* Index:: Index.
@end menu
@end ifnottex
@node Introduction
@chapter What is libffi?
Compilers for high level languages generate code that follow certain
conventions. These conventions are necessary, in part, for separate
compilation to work. One such convention is the @dfn{calling
convention}. 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 calling convention also specifies where the return
value for a function is found. The calling convention is also
sometimes called the @dfn{ABI} or @dfn{Application Binary Interface}.
@cindex calling convention
@cindex ABI
@cindex Application Binary Interface
Some programs may not know at the time of compilation what arguments
are to be passed to a function. For instance, an interpreter may be
told at run-time about the number and types of arguments used to call
a given function. @samp{Libffi} can be used in such programs to
provide a bridge from the interpreter program to compiled code.
The @samp{libffi} library provides a portable, high level programming
interface to various calling conventions. This allows a programmer to
call any function specified by a call interface description at run
time.
@acronym{FFI} stands for Foreign Function Interface. A foreign
function interface is the popular name for the interface that allows
code written in one language to call code written in another language.
The @samp{libffi} library really only provides the lowest, machine
dependent layer of a fully featured foreign function interface. A
layer must exist above @samp{libffi} that handles type conversions for
values passed between the two languages.
@cindex FFI
@cindex Foreign Function Interface
@node Using libffi
@chapter Using libffi
@menu
* The Basics:: The basic libffi API.
* Simple Example:: A simple example.
* Types:: libffi type descriptions.
* Multiple ABIs:: Different passing styles on one platform.
* The Closure API:: Writing a generic function.
@end menu
@node The Basics
@section The Basics
@samp{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 well as the return type of the function.
The first thing you must do is create an @code{ffi_cif} object that
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
single @code{ffi_cif}. The @dfn{cif} in @code{ffi_cif} stands for
Call InterFace. To prepare a call interface object, use the function
@code{ffi_prep_cif}.
@cindex cif
@findex ffi_prep_cif
@defun ffi_status ffi_prep_cif (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes})
This initializes @var{cif} according to the given parameters.
@var{abi} is the ABI to use; normally @code{FFI_DEFAULT_ABI} is what
you want. @ref{Multiple ABIs} for more information.
@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
describes the return type of the function. @xref{Types}.
@var{argtypes} is a vector of @code{ffi_type} pointers.
@var{argtypes} must have @var{nargs} elements. If @var{nargs} is 0,
this argument is ignored.
@code{ffi_prep_cif} returns a @code{libffi} status code, of type
@code{ffi_status}. This will be either @code{FFI_OK} if everything
worked properly; @code{FFI_BAD_TYPEDEF} if one of the @code{ffi_type}
objects is incorrect; or @code{FFI_BAD_ABI} if the @var{abi} parameter
is invalid.
@end defun
To call a function using an initialized @code{ffi_cif}, use the
@code{ffi_call} function:
@findex ffi_call
@defun void ffi_call (ffi_cif *@var{cif}, void *@var{fn}, void *@var{rvalue}, void **@var{avalues})
This calls the function @var{fn} according to the description given in
@var{cif}. @var{cif} must have already been prepared using
@code{ffi_prep_cif}.
@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 and must be suitably aligned; it is the caller's responsibility
to ensure this. If @var{cif} declares that the function returns
@code{void} (using @code{ffi_type_void}), then @var{rvalue} is
ignored. If @var{rvalue} is @samp{NULL}, then the return value is
discarded.
@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}
declares that the function has no arguments (i.e., @var{nargs} was 0),
then @var{avalues} is ignored.
@end defun
@node Simple Example
@section Simple Example
Here is a trivial example that calls @code{puts} a few times.
@example
#include <stdio.h>
#include <ffi.h>
int main()
@{
ffi_cif cif;
ffi_type *args[1];
void *values[1];
char *s;
int rc;
/* Initialize the argument info vectors */
args[0] = &ffi_type_pointer;
values[0] = &s;
/* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint, args) == FFI_OK)
@{
s = "Hello World!";
ffi_call(&cif, puts, &rc, values);
/* rc now holds the result of the call to puts */
/* values holds a pointer to the function's arg, so to
call puts() again all we need to do is change the
value of s */
s = "This is cool!";
ffi_call(&cif, puts, &rc, values);
@}
return 0;
@}
@end example
@node Types
@section Types
@menu
* Primitive Types:: Built-in types.
* Structures:: Structure types.
* Type Example:: Structure type example.
@end menu
@node Primitive Types
@subsection Primitive Types
@code{Libffi} provides a number of built-in type descriptors that can
be used to describe argument and return types:
@table @code
@item ffi_type_void
@tindex ffi_type_void
The type @code{void}. This cannot be used for argument types, only
for return values.
@item ffi_type_uint8
@tindex ffi_type_uint8
An unsigned, 8-bit integer type.
@item ffi_type_sint8
@tindex ffi_type_sint8
A signed, 8-bit integer type.
@item ffi_type_uint16
@tindex ffi_type_uint16
An unsigned, 16-bit integer type.
@item ffi_type_sint16
@tindex ffi_type_sint16
A signed, 16-bit integer type.
@item ffi_type_uint32
@tindex ffi_type_uint32
An unsigned, 32-bit integer type.
@item ffi_type_sint32
@tindex ffi_type_sint32
A signed, 32-bit integer type.
@item ffi_type_uint64
@tindex ffi_type_uint64
An unsigned, 64-bit integer type.
@item ffi_type_sint64
@tindex ffi_type_sint64
A signed, 64-bit integer type.
@item ffi_type_float
@tindex ffi_type_float
The C @code{float} type.
@item ffi_type_double
@tindex ffi_type_double
The C @code{double} type.
@item ffi_type_uchar
@tindex ffi_type_uchar
The C @code{unsigned char} type.
@item ffi_type_schar
@tindex ffi_type_schar
The C @code{signed char} type. (Note that there is not an exact
equivalent to the C @code{char} type in @code{libffi}; ordinarily you
should either use @code{ffi_type_schar} or @code{ffi_type_uchar}
depending on whether @code{char} is signed.)
@item ffi_type_ushort
@tindex ffi_type_ushort
The C @code{unsigned short} type.
@item ffi_type_sshort
@tindex ffi_type_sshort
The C @code{short} type.
@item ffi_type_uint
@tindex ffi_type_uint
The C @code{unsigned int} type.
@item ffi_type_sint
@tindex ffi_type_sint
The C @code{int} type.
@item ffi_type_ulong
@tindex ffi_type_ulong
The C @code{unsigned long} type.
@item ffi_type_slong
@tindex ffi_type_slong
The C @code{long} type.
@item ffi_type_longdouble
@tindex ffi_type_longdouble
On platforms that have a C @code{long double} type, this is defined.
On other platforms, it is not.
@item ffi_type_pointer
@tindex ffi_type_pointer
A generic @code{void *} pointer. You should use this for all
pointers, regardless of their real type.
@end table
Each of these is of type @code{ffi_type}, so you must take the address
when passing to @code{ffi_prep_cif}.
@node Structures
@subsection Structures
Although @samp{libffi} has no special support for unions or
bit-fields, it is perfectly happy passing structures back and forth.
You must first describe the structure to @samp{libffi} by creating a
new @code{ffi_type} object for it.
@tindex ffi_type
@deftp ffi_type
The @code{ffi_type} has the following members:
@table @code
@item size_t size
This is set by @code{libffi}; you should initialize it to zero.
@item unsigned short alignment
This is set by @code{libffi}; you should initialize it to zero.
@item unsigned short type
For a structure, this should be set to @code{FFI_TYPE_STRUCT}.
@item ffi_type **elements
This is a @samp{NULL}-terminated array of pointers to @code{ffi_type}
objects. There is one element per field of the struct.
@end table
@end deftp
@node Type Example
@subsection Type Example
The following example initializes a @code{ffi_type} object
representing the @code{tm} struct from Linux's @file{time.h}.
Here is how the struct is defined:
@example
struct tm @{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
/* Those are for future use. */
long int __tm_gmtoff__;
__const char *__tm_zone__;
@};
@end example
Here is the corresponding code to describe this struct to
@code{libffi}:
@example
@{
ffi_type tm_type;
ffi_type *tm_type_elements[12];
int i;
tm_type.size = tm_type.alignment = 0;
tm_type.elements = &tm_type_elements;
for (i = 0; i < 9; i++)
tm_type_elements[i] = &ffi_type_sint;
tm_type_elements[9] = &ffi_type_slong;
tm_type_elements[10] = &ffi_type_pointer;
tm_type_elements[11] = NULL;
/* tm_type can now be used to represent tm argument types and
return types for ffi_prep_cif() */
@}
@end example
@node Multiple ABIs
@section Multiple ABIs
A given platform may provide multiple different ABIs at once. For
instance, the x86 platform has both @samp{stdcall} and @samp{fastcall}
functions.
@code{libffi} provides some support for this. However, this is
necessarily platform-specific.
@c FIXME: document the platforms
@node The Closure API
@section The Closure API
@code{libffi} also provides a way to write a generic function -- a
function that can accept and decode any combination of arguments.
This can be useful when writing an interpreter, or to provide wrappers
for arbitrary functions.
This facility is called the @dfn{closure API}. Closures are not
supported on all platforms; you can check the @code{FFI_CLOSURES}
define to determine whether they are supported on the current
platform.
@cindex closures
@cindex closure API
@findex FFI_CLOSURES
Because closures work by assembling a tiny function at runtime, they
require special allocation on platforms that have a non-executable
heap. Memory management for closures is handled by a pair of
functions:
@findex ffi_closure_alloca
@defun void *ffi_closure_alloc (size_t @var{size}, void **@var{code})
Allocate a chunk of memory holding @var{size} bytes. This returns a
pointer to the writable address, and sets *@var{code} to the
corresponding executable address.
@var{size} should be sufficient to hold a @code{ffi_closure} object.
@end defun
@findex ffi_closure_free
@defun void ffi_closure_free (void *@var{writable})
Free memory allocated using @code{ffi_closure_alloc}. The argument is
the writable address that was returned.
@end defun
Once you have allocated the memory for a closure, you must construct a
@code{ffi_cif} describing the function call. Finally you can prepare
the closure function:
@findex ffi_prep_closure_loc
@defun ffi_status ffi_prep_closure_loc (ffi_closure *@var{closure}, ffi_cif *@var{cif}, void (*@var{fun}) (ffi_cif *@var{cif}, void *@var{ret}, void **@var{args}, void *@var{user_data}), void *@var{user_data}, void *@var{codeloc})
Prepare a closure function.
@var{closure} is the address of a @code{ffi_closure} object; this is
the writable address returned by @code{ffi_closure_alloc}.
@var{cif} is the @code{ffi_cif} describing the function parameters.
@var{user_data} is an arbitrary datum that is passed, uninterpreted,
to your closure function.
@var{codeloc} is the executable address returned by
@code{ffi_closure_alloc}.
@var{fun} is the function which will be called when the closure is
invoked. It is called with the arguments:
@table @var
@item cif
The @code{ffi_cif} passed to @code{ffi_prep_closure_loc}.
@item ret
A pointer to the memory used for the function's return value.
@var{fun} must fill this, unless the function is declared as returning
@code{void}.
@c FIXME: is this NULL for void-returning functions?
@item args
A vector of pointers to memory holding the arguments to the function.
@item user_data
The same @var{user_data} that was passed to
@code{ffi_prep_closure_loc}.
@end table
@code{ffi_prep_closure_loc} will return @code{FFI_OK} if everything
went ok, and something else on error.
@c FIXME: what?
After calling @code{ffi_prep_closure_loc}, you can cast @var{codeloc}
to the appropriate pointer-to-function type.
@end defun
@c FIXME: example
You may see old code referring to @code{ffi_prep_closure}. This
function is deprecated, as it cannot handle the need for separate
writable and executable addresses.
@node Missing Features
@chapter Missing Features
@code{libffi} is missing a few features. We welcome patches to add
support for these.
@itemize @bullet
@item
There is no support for calling varargs functions. This may work on
some platforms, depending on how the ABI is defined, but it is not
reliable.
@item
There is no support for bit fields in structures.
@item
The closure API is
@item
The ``raw'' API is undocumented.
@c argument promotion?
@c unions?
@c anything else?
@end itemize
@node Index
@unnumbered Index
@printindex cp
@bye

View File

@ -0,0 +1,4 @@
@set UPDATED 29 December 2009
@set UPDATED-MONTH December 2009
@set EDITION 3.0.9
@set VERSION 3.0.9

View File

@ -0,0 +1,4 @@
@set UPDATED 29 December 2009
@set UPDATED-MONTH December 2009
@set EDITION 3.0.9
@set VERSION 3.0.9

View File

@ -1,5 +1,8 @@
/* fficonfig.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
@ -14,6 +17,9 @@
/* Define this if you want extra debugging. */
#undef FFI_DEBUG
/* Cannot use malloc on this target, so, we revert to alternative means */
#undef FFI_MMAP_EXEC_WRIT
/* Define this is you do not want support for the raw API. */
#undef FFI_NO_RAW_API
@ -37,6 +43,9 @@
*/
#undef HAVE_AS_SPARC_UA_PCREL
/* Define if your assembler supports PC relative relocs. */
#undef HAVE_AS_X86_PCREL
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
@ -94,6 +103,10 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
@ -139,9 +152,17 @@
/* Version number of package */
#undef VERSION
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE

View File

@ -6,4 +6,4 @@ DISTCLEANFILES=ffitarget.h
EXTRA_DIST=ffi.h.in ffi_common.h
includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
nodist_includes_HEADERS = ffi.h ffitarget.h
nodist_includes_HEADERS = ffi.h ffitarget.h

View File

@ -1,8 +1,9 @@
# Makefile.in generated by automake 1.10 from Makefile.am.
# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006 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
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -16,8 +17,9 @@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
@ -41,9 +43,10 @@ am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/fficonfig.h
CONFIG_CLEAN_FILES = ffi.h ffitarget.h
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@ -51,9 +54,23 @@ am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(includesdir)"
nodist_includesHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(nodist_includes_HEADERS)
ETAGS = etags
CTAGS = ctags
@ -75,21 +92,17 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
FGREP = @FGREP@
GREP = @GREP@
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
INSTALL = @INSTALL@
@ -97,16 +110,23 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
@ -127,8 +147,7 @@ abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@ -159,6 +178,7 @@ libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
@ -177,13 +197,14 @@ target_os = @target_os@
target_vendor = @target_vendor@
toolexecdir = @toolexecdir@
toolexeclibdir = @toolexeclibdir@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
DISTCLEANFILES = ffitarget.h
EXTRA_DIST = ffi.h.in ffi_common.h
includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
nodist_includes_HEADERS = ffi.h ffitarget.h
nodist_includes_HEADERS = ffi.h ffitarget.h
all: all-am
.SUFFIXES:
@ -191,14 +212,14 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign include/Makefile
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign include/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@ -216,6 +237,7 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
ffi.h: $(top_builddir)/config.status $(srcdir)/ffi.h.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
@ -227,65 +249,72 @@ clean-libtool:
install-nodist_includesHEADERS: $(nodist_includes_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(includesdir)" || $(MKDIR_P) "$(DESTDIR)$(includesdir)"
@list='$(nodist_includes_HEADERS)'; for p in $$list; do \
@list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(nodist_includesHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includesdir)/$$f'"; \
$(nodist_includesHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includesdir)/$$f"; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includesdir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(includesdir)" || exit $$?; \
done
uninstall-nodist_includesHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(nodist_includes_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(includesdir)/$$f'"; \
rm -f "$(DESTDIR)$(includesdir)/$$f"; \
done
@list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(includesdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(includesdir)" && rm -f $$files
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
$(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_FILES) $(LISP)
tags=; \
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@ -306,13 +335,17 @@ distdir: $(DISTFILES)
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@ -343,6 +376,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@ -362,6 +396,8 @@ dvi-am:
html: html-am
html-am:
info: info-am
info-am:
@ -370,18 +406,28 @@ install-data-am: install-nodist_includesHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
@ -417,6 +463,7 @@ uninstall-am: uninstall-nodist_includesHEADERS
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-nodist_includesHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -57,9 +57,7 @@ extern "C" {
#endif
/* Specify which architecture libffi is configured for. */
#ifndef @TARGET@
#define @TARGET@
#endif
/* ---- System configuration information --------------------------------- */
@ -67,6 +65,10 @@ extern "C" {
#ifndef LIBFFI_ASM
#ifdef _MSC_VER
#define __attribute__(X)
#endif
#include <stddef.h>
#include <limits.h>
@ -254,7 +256,11 @@ typedef struct {
ffi_cif *cif;
void (*fun)(ffi_cif*,void*,void**,void*);
void *user_data;
#ifdef __GNUC__
} ffi_closure __attribute__((aligned (8)));
#else
} ffi_closure;
#endif
void *ffi_closure_alloc (size_t size, void **code);
void ffi_closure_free (void *);

View File

@ -18,7 +18,10 @@ extern "C" {
/* Do not move this. Some versions of AIX are very picky about where
this is positioned. */
#ifdef __GNUC__
/* mingw64 defines this already in malloc.h. */
#ifndef alloca
# define alloca __builtin_alloca
#endif
# define MAYBE_UNUSED __attribute__((__unused__))
#else
# define MAYBE_UNUSED
@ -29,7 +32,11 @@ extern "C" {
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
# ifdef _MSC_VER
# define alloca _alloca
# else
char *alloca ();
# endif
# endif
# endif
# endif
@ -77,6 +84,22 @@ typedef struct
} extended_cif;
/* Terse sized type definitions. */
#if defined(_MSC_VER) || defined(__sgi)
typedef unsigned char UINT8;
typedef signed char SINT8;
typedef unsigned short UINT16;
typedef signed short SINT16;
typedef unsigned int UINT32;
typedef signed int SINT32;
# ifdef _MSC_VER
typedef unsigned __int64 UINT64;
typedef signed __int64 SINT64;
# else
# include <inttypes.h>
typedef uint64_t UINT64;
typedef int64_t SINT64;
# endif
#else
typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
typedef signed int SINT8 __attribute__((__mode__(__QI__)));
typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
@ -85,6 +108,7 @@ typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
typedef signed int SINT32 __attribute__((__mode__(__SI__)));
typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
typedef signed int SINT64 __attribute__((__mode__(__DI__)));
#endif
typedef float FLOAT32;

View File

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

View File

@ -0,0 +1,29 @@
# This file is used to maintain libtool version info for libffi. See
# the libtool manual to understand the meaning of the fields. This is
# a separate file so that version updates don't involve re-running
# automake.
#
# Here are a set of rules to help you update your library version
# information:
#
# 1. Start with version information of `0:0:0' for each libtool library.
#
# 2. Update the version information only immediately before a public
# release of your software. More frequent updates are unnecessary,
# and only guarantee that the current interface number gets larger
# faster.
#
# 3. If the library source code has changed at all since the last
# update, then increment revision (`c:r:a' becomes `c:r+1:a').
#
# 4. If any interfaces have been added, removed, or changed since the
# last update, increment current, and set revision to 0.
#
# 5. If any interfaces have been added since the last public release,
# then increment age.
#
# 6. If any interfaces have been removed since the last public
# release, then set age to 0.
#
# CURRENT:REVISION:AGE
5:10:0

8406
Modules/_ctypes/libffi/ltmain.sh Executable file

File diff suppressed because it is too large Load Diff

7360
Modules/_ctypes/libffi/m4/libtool.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

368
Modules/_ctypes/libffi/m4/ltoptions.m4 vendored Normal file
View File

@ -0,0 +1,368 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
# ------------------------------------------
m4_define([_LT_MANGLE_OPTION],
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
# ---------------------------------------
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
# saved as a flag.
m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
[m4_warning([Unknown $1 option `$2'])])[]dnl
])
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
# ------------------------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
m4_define([_LT_IF_OPTION],
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
# -------------------------------------------------------
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
# are set.
m4_define([_LT_UNLESS_OPTIONS],
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
[m4_define([$0_found])])])[]dnl
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
])[]dnl
])
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
# ----------------------------------------
# OPTION-LIST is a space-separated list of Libtool options associated
# with MACRO-NAME. If any OPTION has a matching handler declared with
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
# the unknown option and exit.
m4_defun([_LT_SET_OPTIONS],
[# Set options
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
[_LT_SET_OPTION([$1], _LT_Option)])
m4_if([$1],[LT_INIT],[
dnl
dnl Simply set some default values (i.e off) if boolean options were not
dnl specified:
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
])
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
])
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
dnl `shared' nor `disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
[_LT_ENABLE_FAST_INSTALL])
])
])# _LT_SET_OPTIONS
## --------------------------------- ##
## Macros to handle LT_INIT options. ##
## --------------------------------- ##
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
# -----------------------------------------
m4_define([_LT_MANGLE_DEFUN],
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
# -----------------------------------------------
m4_define([LT_OPTION_DEFINE],
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
])# LT_OPTION_DEFINE
# dlopen
# ------
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
])
AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
# win32-dll
# ---------
# Declare package support for building win32 dll's.
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
esac
test -z "$AS" && AS=as
_LT_DECL([], [AS], [0], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
# implement the --enable-shared flag, and supports the `shared' and
# `disable-shared' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
_LT_DECL([build_libtool_libs], [enable_shared], [0],
[Whether or not to build shared libraries])
])# _LT_ENABLE_SHARED
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
# Old names:
AC_DEFUN([AC_ENABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
])
AC_DEFUN([AC_DISABLE_SHARED],
[_LT_SET_OPTION([LT_INIT], [disable-shared])
])
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
# implement the --enable-static flag, and support the `static' and
# `disable-static' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
_LT_DECL([build_old_libs], [enable_static], [0],
[Whether or not to build static libraries])
])# _LT_ENABLE_STATIC
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
# Old names:
AC_DEFUN([AC_ENABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
])
AC_DEFUN([AC_DISABLE_STATIC],
[_LT_SET_OPTION([LT_INIT], [disable-static])
])
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
# implement the --enable-fast-install flag, and support the `fast-install'
# and `disable-fast-install' LT_INIT options.
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
for pkg in $enableval; do
IFS="$lt_save_ifs"
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS="$lt_save_ifs"
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
_LT_DECL([fast_install], [enable_fast_install], [0],
[Whether or not to optimize for fast installation])dnl
])# _LT_ENABLE_FAST_INSTALL
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
# Old names:
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
the `disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
# LT_INIT options.
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[pic_mode="$withval"],
[pic_mode=default])
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
# Old name:
AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
put the `pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
## ----------------- ##
## LTDL_INIT Options ##
## ----------------- ##
m4_define([_LTDL_MODE], [])
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
[m4_define([_LTDL_MODE], [nonrecursive])])
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
[m4_define([_LTDL_MODE], [recursive])])
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
[m4_define([_LTDL_MODE], [subproject])])
m4_define([_LTDL_TYPE], [])
LT_OPTION_DEFINE([LTDL_INIT], [installable],
[m4_define([_LTDL_TYPE], [installable])])
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
[m4_define([_LTDL_TYPE], [convenience])])

123
Modules/_ctypes/libffi/m4/ltsugar.m4 vendored Normal file
View File

@ -0,0 +1,123 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 6 ltsugar.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
# lt_join(SEP, ARG1, [ARG2...])
# -----------------------------
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
# associated separator.
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
# versions in m4sugar had bugs.
m4_define([lt_join],
[m4_if([$#], [1], [],
[$#], [2], [[$2]],
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
m4_define([_lt_join],
[m4_if([$#$2], [2], [],
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
# lt_car(LIST)
# lt_cdr(LIST)
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
# Autoconf-2.59 which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
[$#], 1, [],
[m4_dquote(m4_shift($@))])])
m4_define([lt_unquote], $1)
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
# than defined and empty).
#
# This macro is needed until we can rely on Autoconf 2.62, since earlier
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
m4_define([lt_append],
[m4_define([$1],
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
# ----------------------------------------------------------
# Produce a SEP delimited list of all paired combinations of elements of
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
# has the form PREFIXmINFIXSUFFIXn.
# Needed until we can rely on m4_combine added in Autoconf 2.62.
m4_define([lt_combine],
[m4_if(m4_eval([$# > 3]), [1],
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
[[m4_foreach([_Lt_prefix], [$2],
[m4_foreach([_Lt_suffix],
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
# -----------------------------------------------------------------------
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
m4_define([lt_if_append_uniq],
[m4_ifdef([$1],
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
[lt_append([$1], [$2], [$3])$4],
[$5])],
[lt_append([$1], [$2], [$3])$4])])
# lt_dict_add(DICT, KEY, VALUE)
# -----------------------------
m4_define([lt_dict_add],
[m4_define([$1($2)], [$3])])
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
# --------------------------------------------
m4_define([lt_dict_add_subkey],
[m4_define([$1($2:$3)], [$4])])
# lt_dict_fetch(DICT, KEY, [SUBKEY])
# ----------------------------------
m4_define([lt_dict_fetch],
[m4_ifval([$3],
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
# -----------------------------------------------------------------
m4_define([lt_if_dict_fetch],
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
[$5],
[$6])])
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
# --------------------------------------------------------------
m4_define([lt_dict_filter],
[m4_if([$5], [], [],
[lt_join(m4_quote(m4_default([$4], [[, ]])),
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
])

23
Modules/_ctypes/libffi/m4/ltversion.m4 vendored Normal file
View File

@ -0,0 +1,23 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# Generated from ltversion.in.
# serial 3012 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.2.6])
m4_define([LT_PACKAGE_REVISION], [1.3012])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.2.6'
macro_revision='1.3012'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])

View File

@ -0,0 +1,92 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 4 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
# using a macro with the same name in our local m4/libtool.m4 it'll
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
# and doesn't know about Autoconf macros at all.)
#
# So we provide this file, which has a silly filename so it's always
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
# we give up compatibility with versions before 1.7, at which point
# we need to keep only those names which we still refer to.
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
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_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
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([_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([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
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([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])

View File

@ -0,0 +1,8 @@
## Process this with automake to create Makefile.in
AUTOMAKE_OPTIONS=foreign
EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3
man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3

View File

@ -0,0 +1,448 @@
# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = man
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/fficonfig.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
man3dir = $(mandir)/man3
am__installdirs = "$(DESTDIR)$(man3dir)"
NROFF = nroff
MANS = $(man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TARGET = @TARGET@
TARGETDIR = @TARGETDIR@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
toolexecdir = @toolexecdir@
toolexeclibdir = @toolexeclibdir@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3
man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign man/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-man3: $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man3dir)" || $(MKDIR_P) "$(DESTDIR)$(man3dir)"
@list=''; test -n "$(man3dir)" || exit 0; \
{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.3[a-z]*$$/p'; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \
done; }
uninstall-man3:
@$(NORMAL_UNINSTALL)
@list=''; test -n "$(man3dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
sed -n '/\.3[a-z]*$$/p'; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
test -z "$$files" || { \
echo " ( cd '$(DESTDIR)$(man3dir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(man3dir)" && rm -f $$files; }
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
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'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(MANS)
installdirs:
for dir in "$(DESTDIR)$(man3dir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-man
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man: install-man3
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-man
uninstall-man: uninstall-man3
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-man3 \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
uninstall uninstall-am uninstall-man uninstall-man3
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,31 @@
.Dd February 15, 2008
.Dt FFI 3
.Sh NAME
.Nm FFI
.Nd Foreign Function Interface
.Sh LIBRARY
libffi, -lffi
.Sh SYNOPSIS
.In ffi.h
.Ft ffi_status
.Fo ffi_prep_cif
.Fa "ffi_cif *cif"
.Fa "ffi_abi abi"
.Fa "unsigned int nargs"
.Fa "ffi_type *rtype"
.Fa "ffi_type **atypes"
.Fc
.Ft void
.Fo ffi_call
.Fa "ffi_cif *cif"
.Fa "void (*fn)(void)"
.Fa "void *rvalue"
.Fa "void **avalue"
.Fc
.Sh DESCRIPTION
The foreign function interface provides a mechanism by which a function can
generate a call to another function at runtime without requiring knowledge of
the called function's interface at compile time.
.Sh SEE ALSO
.Xr ffi_prep_cif 3 ,
.Xr ffi_call 3

View File

@ -0,0 +1,103 @@
.Dd February 15, 2008
.Dt ffi_call 3
.Sh NAME
.Nm ffi_call
.Nd Invoke a foreign function.
.Sh SYNOPSIS
.In ffi.h
.Ft void
.Fo ffi_call
.Fa "ffi_cif *cif"
.Fa "void (*fn)(void)"
.Fa "void *rvalue"
.Fa "void **avalue"
.Fc
.Sh DESCRIPTION
The
.Nm ffi_call
function provides a simple mechanism for invoking a function without
requiring knowledge of the function's interface at compile time.
.Fa fn
is called with the values retrieved from the pointers in the
.Fa avalue
array. The return value from
.Fa fn
is placed in storage pointed to by
.Fa rvalue .
.Fa cif
contains information describing the data types, sizes and alignments of the
arguments to and return value from
.Fa fn ,
and must be initialized with
.Nm ffi_prep_cif
before it is used with
.Nm ffi_call .
.Pp
.Fa rvalue
must point to storage that is sizeof(ffi_arg) or larger for non-floating point
types. For smaller-sized return value types, the
.Nm ffi_arg
or
.Nm ffi_sarg
integral type must be used to hold
the return value.
.Sh EXAMPLES
.Bd -literal
#include <ffi.h>
#include <stdio.h>
unsigned char
foo(unsigned int, float);
int
main(int argc, const char **argv)
{
ffi_cif cif;
ffi_type *arg_types[2];
void *arg_values[2];
ffi_status status;
// Because the return value from foo() is smaller than sizeof(long), it
// must be passed as ffi_arg or ffi_sarg.
ffi_arg result;
// Specify the data type of each argument. Available types are defined
// in <ffi/ffi.h>.
arg_types[0] = &ffi_type_uint;
arg_types[1] = &ffi_type_float;
// Prepare the ffi_cif structure.
if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI,
2, &ffi_type_uint8, arg_types)) != FFI_OK)
{
// Handle the ffi_status error.
}
// Specify the values of each argument.
unsigned int arg1 = 42;
float arg2 = 5.1;
arg_values[0] = &arg1;
arg_values[1] = &arg2;
// Invoke the function.
ffi_call(&cif, FFI_FN(foo), &result, arg_values);
// The ffi_arg 'result' now contains the unsigned char returned from foo(),
// which can be accessed by a typecast.
printf("result is %hhu", (unsigned char)result);
return 0;
}
// The target function.
unsigned char
foo(unsigned int x, float y)
{
unsigned char result = x - y;
return result;
}
.Ed
.Sh SEE ALSO
.Xr ffi 3 ,
.Xr ffi_prep_cif 3

View File

@ -0,0 +1,66 @@
.Dd February 15, 2008
.Dt ffi_prep_cif 3
.Sh NAME
.Nm ffi_prep_cif
.Nd Prepare a
.Nm ffi_cif
structure for use with
.Nm ffi_call
.
.Sh SYNOPSIS
.In ffi.h
.Ft ffi_status
.Fo ffi_prep_cif
.Fa "ffi_cif *cif"
.Fa "ffi_abi abi"
.Fa "unsigned int nargs"
.Fa "ffi_type *rtype"
.Fa "ffi_type **atypes"
.Fc
.Sh DESCRIPTION
The
.Nm ffi_prep_cif
function prepares a
.Nm ffi_cif
structure for use with
.Nm ffi_call
.
.Fa abi
specifies a set of calling conventions to use.
.Fa atypes
is an array of
.Fa nargs
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.
.Sh RETURN VALUES
Upon successful completion,
.Nm ffi_prep_cif
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

201
Modules/_ctypes/libffi/mdate-sh Executable file
View File

@ -0,0 +1,201 @@
#!/bin/sh
# Get modification time of a file or directory and pretty-print it.
scriptversion=2005-06-29.22
# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005 Free Software
# Foundation, Inc.
# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
#
# 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 2, 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.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case $1 in
'')
echo "$0: No file. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: mdate-sh [--help] [--version] FILE
Pretty-print the modification time of FILE.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "mdate-sh $scriptversion"
exit $?
;;
esac
# Prevent date giving response in another language.
LANG=C
export LANG
LC_ALL=C
export LC_ALL
LC_TIME=C
export LC_TIME
# GNU ls changes its time format in response to the TIME_STYLE
# variable. Since we cannot assume `unset' works, revert this
# variable to its documented default.
if test "${TIME_STYLE+set}" = set; then
TIME_STYLE=posix-long-iso
export TIME_STYLE
fi
save_arg1=$1
# Find out how to get the extended ls output of a file or directory.
if ls -L /dev/null 1>/dev/null 2>&1; then
ls_command='ls -L -l -d'
else
ls_command='ls -l -d'
fi
# A `ls -l' line looks as follows on OS/2.
# drwxrwx--- 0 Aug 11 2001 foo
# This differs from Unix, which adds ownership information.
# drwxrwx--- 2 root root 4096 Aug 11 2001 foo
#
# 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
# 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
# the extended ls output of the root directory to decide how many
# words should be skipped to get the date.
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
set x`ls -l -d /`
# Find which argument is the month.
month=
command=
until test $month
do
shift
# Add another shift to the command.
command="$command shift;"
case $1 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
Apr) month=April; nummonth=4;;
May) month=May; nummonth=5;;
Jun) month=June; nummonth=6;;
Jul) month=July; nummonth=7;;
Aug) month=August; nummonth=8;;
Sep) month=September; nummonth=9;;
Oct) month=October; nummonth=10;;
Nov) month=November; nummonth=11;;
Dec) month=December; nummonth=12;;
esac
done
# Get the extended ls output of the file or directory.
set dummy x`eval "$ls_command \"\$save_arg1\""`
# Remove all preceding arguments
eval $command
# Because of the dummy argument above, month is in $2.
#
# On a POSIX system, we should have
#
# $# = 5
# $1 = file size
# $2 = month
# $3 = day
# $4 = year or time
# $5 = filename
#
# On Darwin 7.7.0 and 7.6.0, we have
#
# $# = 4
# $1 = day
# $2 = month
# $3 = year or time
# $4 = filename
# Get the month.
case $2 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
Apr) month=April; nummonth=4;;
May) month=May; nummonth=5;;
Jun) month=June; nummonth=6;;
Jul) month=July; nummonth=7;;
Aug) month=August; nummonth=8;;
Sep) month=September; nummonth=9;;
Oct) month=October; nummonth=10;;
Nov) month=November; nummonth=11;;
Dec) month=December; nummonth=12;;
esac
case $3 in
???*) day=$1;;
*) day=$3; shift;;
esac
# Here we have to deal with the problem that the ls output gives either
# the time of day or the year.
case $3 in
*:*) set `date`; eval year=\$$#
case $2 in
Jan) nummonthtod=1;;
Feb) nummonthtod=2;;
Mar) nummonthtod=3;;
Apr) nummonthtod=4;;
May) nummonthtod=5;;
Jun) nummonthtod=6;;
Jul) nummonthtod=7;;
Aug) nummonthtod=8;;
Sep) nummonthtod=9;;
Oct) nummonthtod=10;;
Nov) nummonthtod=11;;
Dec) nummonthtod=12;;
esac
# For the first six month of the year the time notation can also
# be used for files modified in the last year.
if (expr $nummonth \> $nummonthtod) > /dev/null;
then
year=`expr $year - 1`
fi;;
*) year=$3;;
esac
# The result.
echo $day $month $year
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -1,9 +1,9 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2004-09-07.08
scriptversion=2005-06-08.21
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
@ -19,8 +19,8 @@ scriptversion=2004-09-07.08
# 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., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@ -87,12 +87,12 @@ Supported PROGRAM values:
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>."
exit 0
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit 0
exit $?
;;
-*)
@ -288,11 +288,18 @@ WARNING: \`$1' is $msg. You should only need it if
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
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
# ... 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
;;

View File

@ -67,11 +67,19 @@
#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
|| defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
|| defined(__ARM_ARCH_6ZK__)
|| defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
|| defined(__ARM_ARCH_6M__)
# undef __ARM_ARCH__
# define __ARM_ARCH__ 6
#endif
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
|| defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
|| defined(__ARM_ARCH_7EM__)
# undef __ARM_ARCH__
# define __ARM_ARCH__ 7
#endif
#if __ARM_ARCH__ >= 5
# define call_reg(x) blx x
#elif defined (__ARM_ARCH_4T__)
@ -189,7 +197,7 @@ ARM_FUNC_START ffi_call_SYSV
@ return INT
cmp r3, #FFI_TYPE_INT
#ifdef __SOFTFP__
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
cmpne r3, #FFI_TYPE_FLOAT
#endif
streq r0, [r2]
@ -197,12 +205,12 @@ ARM_FUNC_START ffi_call_SYSV
@ return INT64
cmp r3, #FFI_TYPE_SINT64
#ifdef __SOFTFP__
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
cmpne r3, #FFI_TYPE_DOUBLE
#endif
stmeqia r2, {r0, r1}
#ifndef __SOFTFP__
#if !defined(__SOFTFP__) && !defined(__ARM_EABI__)
beq LSYM(Lepilogue)
@ return FLOAT
@ -245,21 +253,21 @@ ARM_FUNC_START ffi_closure_SYSV
beq .Lretint
cmp r0, #FFI_TYPE_FLOAT
#ifdef __SOFTFP__
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
beq .Lretint
#else
beq .Lretfloat
#endif
cmp r0, #FFI_TYPE_DOUBLE
#ifdef __SOFTFP__
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
beq .Lretlonglong
#else
beq .Lretdouble
#endif
cmp r0, #FFI_TYPE_LONGDOUBLE
#ifdef __SOFTFP__
#if defined(__SOFTFP__) || defined(__ARM_EABI__)
beq .Lretlonglong
#else
beq .Lretlongdouble
@ -278,7 +286,7 @@ ARM_FUNC_START ffi_closure_SYSV
ldr r1, [sp, #4]
b .Lclosure_epilogue
#ifndef __SOFTFP__
#if !defined(__SOFTFP__) && !defined(__ARM_EABI__)
.Lretfloat:
ldfs f0, [sp]
b .Lclosure_epilogue

View File

@ -0,0 +1,421 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
AVR32 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>
#include <unistd.h>
#include <asm/unistd.h>
/* #define DEBUG */
extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
unsigned int, unsigned int, unsigned int*, unsigned int,
void (*fn)(void));
extern void ffi_closure_SYSV (ffi_closure *);
unsigned int pass_struct_on_stack(ffi_type *type)
{
if(type->type != FFI_TYPE_STRUCT)
return 0;
if(type->alignment < type->size &&
!(type->size == 4 || type->size == 8) &&
!(type->size == 8 && type->alignment >= 4))
return 1;
if(type->size == 3 || type->size == 5 || type->size == 6 ||
type->size == 7)
return 1;
return 0;
}
/* ffi_prep_args is called by the assembly routine once stack space
* has been allocated for the function's arguments
*
* This is annoyingly complex since we need to keep track of used
* registers.
*/
void ffi_prep_args(char *stack, extended_cif *ecif)
{
unsigned int i;
void **p_argv;
ffi_type **p_arg;
char *reg_base = stack;
char *stack_base = stack + 20;
unsigned int stack_offset = 0;
unsigned int reg_mask = 0;
p_argv = ecif->avalue;
/* If cif->flags is struct then we know it's not passed in registers */
if(ecif->cif->flags == FFI_TYPE_STRUCT)
{
*(void**)reg_base = ecif->rvalue;
reg_mask |= 1;
}
for(i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs;
i++, p_arg++)
{
size_t z = (*p_arg)->size;
int alignment = (*p_arg)->alignment;
int type = (*p_arg)->type;
char *addr = 0;
if(z % 4 != 0)
z += (4 - z % 4);
if(reg_mask != 0x1f)
{
if(pass_struct_on_stack(*p_arg))
{
addr = stack_base + stack_offset;
stack_offset += z;
}
else if(z == sizeof(int))
{
char index = 0;
while((reg_mask >> index) & 1)
index++;
addr = reg_base + (index * 4);
reg_mask |= (1 << index);
}
else if(z == 2 * sizeof(int))
{
if(!((reg_mask >> 1) & 1))
{
addr = reg_base + 4;
reg_mask |= (3 << 1);
}
else if(!((reg_mask >> 3) & 1))
{
addr = reg_base + 12;
reg_mask |= (3 << 3);
}
}
}
if(!addr)
{
addr = stack_base + stack_offset;
stack_offset += z;
}
if(type == FFI_TYPE_STRUCT && (*p_arg)->elements[1] == NULL)
type = (*p_arg)->elements[0]->type;
switch(type)
{
case FFI_TYPE_UINT8:
*(unsigned int *)addr = (unsigned int)*(UINT8 *)(*p_argv);
break;
case FFI_TYPE_SINT8:
*(signed int *)addr = (signed int)*(SINT8 *)(*p_argv);
break;
case FFI_TYPE_UINT16:
*(unsigned int *)addr = (unsigned int)*(UINT16 *)(*p_argv);
break;
case FFI_TYPE_SINT16:
*(signed int *)addr = (signed int)*(SINT16 *)(*p_argv);
break;
default:
memcpy(addr, *p_argv, z);
}
p_argv++;
}
#ifdef DEBUG
/* Debugging */
for(i = 0; i < 5; i++)
{
if((reg_mask & (1 << i)) == 0)
printf("r%d: (unused)\n", 12 - i);
else
printf("r%d: 0x%08x\n", 12 - i, ((unsigned int*)reg_base)[i]);
}
for(i = 0; i < stack_offset / 4; i++)
{
printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack_base)[i]);
}
#endif
}
/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
/* Round the stack up to a multiple of 8 bytes. This isn't needed
* everywhere, but it is on some platforms, and it doesn't harm
* anything when it isn't needed. */
cif->bytes = (cif->bytes + 7) & ~7;
/* Flag to indicate that he return value is in fact a struct */
cif->rstruct_flag = 0;
/* Set the return type flag */
switch(cif->rtype->type)
{
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
cif->flags = (unsigned)FFI_TYPE_UINT8;
break;
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
cif->flags = (unsigned)FFI_TYPE_UINT16;
break;
case FFI_TYPE_FLOAT:
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
case FFI_TYPE_POINTER:
cif->flags = (unsigned)FFI_TYPE_UINT32;
break;
case FFI_TYPE_DOUBLE:
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
cif->flags = (unsigned)FFI_TYPE_UINT64;
break;
case FFI_TYPE_STRUCT:
cif->rstruct_flag = 1;
if(!pass_struct_on_stack(cif->rtype))
{
if(cif->rtype->size <= 1)
cif->flags = (unsigned)FFI_TYPE_UINT8;
else if(cif->rtype->size <= 2)
cif->flags = (unsigned)FFI_TYPE_UINT16;
else if(cif->rtype->size <= 4)
cif->flags = (unsigned)FFI_TYPE_UINT32;
else if(cif->rtype->size <= 8)
cif->flags = (unsigned)FFI_TYPE_UINT64;
else
cif->flags = (unsigned)cif->rtype->type;
}
else
cif->flags = (unsigned)cif->rtype->type;
break;
default:
cif->flags = (unsigned)cif->rtype->type;
break;
}
return FFI_OK;
}
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
extended_cif ecif;
unsigned int size = 0, i = 0;
ffi_type **p_arg;
ecif.cif = cif;
ecif.avalue = avalue;
for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
size += (*p_arg)->size + (4 - (*p_arg)->size % 4);
/* If the return value is a struct and we don't have a return value
* address then we need to make one */
/* If cif->flags is struct then it's not suitable for registers */
if((rvalue == NULL) && (cif->flags == 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, size, cif->flags,
ecif.rvalue, cif->rstruct_flag, fn);
break;
default:
FFI_ASSERT(0);
break;
}
}
static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
void **avalue, ffi_cif *cif)
{
register unsigned int i, reg_mask = 0;
register void **p_argv;
register ffi_type **p_arg;
register char *reg_base = stack;
register char *stack_base = stack + 20;
register unsigned int stack_offset = 0;
#ifdef DEBUG
/* Debugging */
for(i = 0; i < cif->nargs + 7; i++)
{
printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack)[i]);
}
#endif
/* If cif->flags is struct then we know it's not passed in registers */
if(cif->flags == FFI_TYPE_STRUCT)
{
*rvalue = *(void **)reg_base;
reg_mask |= 1;
}
p_argv = avalue;
for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
{
size_t z = (*p_arg)->size;
int alignment = (*p_arg)->alignment;
*p_argv = 0;
if(z % 4 != 0)
z += (4 - z % 4);
if(reg_mask != 0x1f)
{
if(pass_struct_on_stack(*p_arg))
{
*p_argv = (void*)stack_base + stack_offset;
stack_offset += z;
}
else if(z <= sizeof(int))
{
char index = 0;
while((reg_mask >> index) & 1)
index++;
*p_argv = (void*)reg_base + (index * 4);
reg_mask |= (1 << index);
}
else if(z == 2 * sizeof(int))
{
if(!((reg_mask >> 1) & 1))
{
*p_argv = (void*)reg_base + 4;
reg_mask |= (3 << 1);
}
else if(!((reg_mask >> 3) & 1))
{
*p_argv = (void*)reg_base + 12;
reg_mask |= (3 << 3);
}
}
}
if(!*p_argv)
{
*p_argv = (void*)stack_base + stack_offset;
stack_offset += z;
}
if((*p_arg)->type != FFI_TYPE_STRUCT ||
(*p_arg)->elements[1] == NULL)
{
if(alignment == 1)
**(unsigned int**)p_argv <<= 24;
else if(alignment == 2)
**(unsigned int**)p_argv <<= 16;
}
p_argv++;
}
#ifdef DEBUG
/* Debugging */
for(i = 0; i < cif->nargs; i++)
{
printf("sp+%d: 0x%08x\n", i*4, *(((unsigned int**)avalue)[i]));
}
#endif
}
/* This function is jumped to by the trampoline */
unsigned int ffi_closure_SYSV_inner(ffi_closure *closure, void **respp,
void *args)
{
ffi_cif *cif;
void **arg_area;
unsigned int i, size = 0;
ffi_type **p_arg;
cif = closure->cif;
for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
size += (*p_arg)->size + (4 - (*p_arg)->size % 4);
arg_area = (void **)alloca(size);
/* 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);
(closure->fun)(cif, *respp, 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)
{
FFI_ASSERT(cif->abi == FFI_SYSV);
unsigned char *__tramp = (unsigned char*)(&closure->tramp[0]);
unsigned int __fun = (unsigned int)(&ffi_closure_SYSV);
unsigned int __ctx = (unsigned int)(codeloc);
unsigned int __rstruct_flag = (unsigned int)(cif->rstruct_flag);
unsigned int __inner = (unsigned int)(&ffi_closure_SYSV_inner);
*(unsigned int*) &__tramp[0] = 0xebcd1f00; /* pushm r8-r12 */
*(unsigned int*) &__tramp[4] = 0xfefc0010; /* ld.w r12, pc[16] */
*(unsigned int*) &__tramp[8] = 0xfefb0010; /* ld.w r11, pc[16] */
*(unsigned int*) &__tramp[12] = 0xfefa0010; /* ld.w r10, pc[16] */
*(unsigned int*) &__tramp[16] = 0xfeff0010; /* ld.w pc, pc[16] */
*(unsigned int*) &__tramp[20] = __ctx;
*(unsigned int*) &__tramp[24] = __rstruct_flag;
*(unsigned int*) &__tramp[28] = __inner;
*(unsigned int*) &__tramp[32] = __fun;
syscall(__NR_cacheflush, 0, (&__tramp[0]), 36);
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
return FFI_OK;
}

View File

@ -0,0 +1,50 @@
/* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
Target configuration macros for AVR32.
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_DEFAULT_ABI = FFI_SYSV,
FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
} ffi_abi;
#endif
#define FFI_EXTRA_CIF_FIELDS unsigned int rstruct_flag
/* Definitions for closures */
#define FFI_CLOSURES 1
#define FFI_TRAMPOLINE_SIZE 36
#define FFI_NATIVE_RAW_API 0
#endif

View File

@ -0,0 +1,208 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
AVR32 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>
/* r12: ffi_prep_args
* r11: &ecif
* r10: size
* r9: cif->flags
* r8: ecif.rvalue
* sp+0: cif->rstruct_flag
* sp+4: fn */
.text
.align 1
.globl ffi_call_SYSV
.type ffi_call_SYSV, @function
ffi_call_SYSV:
stm --sp, r0,r1,lr
stm --sp, r8-r12
mov r0, sp
/* Make room for all of the new args. */
sub sp, r10
/* Pad to make way for potential skipped registers */
sub sp, 20
/* Call ffi_prep_args(stack, &ecif). */
/* r11 already set */
mov r1, r12
mov r12, sp
icall r1
/* Save new argument size */
mov r1, r12
/* Move first 5 parameters in registers. */
ldm sp++, r8-r12
/* call (fn) (...). */
ld.w r1, r0[36]
icall r1
/* Remove the space we pushed for the args. */
mov sp, r0
/* Load r1 with the rstruct flag. */
ld.w r1, sp[32]
/* Load r9 with the return type code. */
ld.w r9, sp[12]
/* Load r8 with the return value pointer. */
ld.w r8, sp[16]
/* If the return value pointer is NULL, assume no return value. */
cp.w r8, 0
breq .Lend
/* Check if return type is actually a struct */
cp.w r1, 0
breq 1f
/* Return 8bit */
cp.w r9, FFI_TYPE_UINT8
breq .Lstore8
/* Return 16bit */
cp.w r9, FFI_TYPE_UINT16
breq .Lstore16
1:
/* Return 32bit */
cp.w r9, FFI_TYPE_UINT32
breq .Lstore32
cp.w r9, FFI_TYPE_UINT16
breq .Lstore32
cp.w r9, FFI_TYPE_UINT8
breq .Lstore32
/* Return 64bit */
cp.w r9, FFI_TYPE_UINT64
breq .Lstore64
/* Didn't match anything */
bral .Lend
.Lstore64:
st.w r8[0], r11
st.w r8[4], r10
bral .Lend
.Lstore32:
st.w r8[0], r12
bral .Lend
.Lstore16:
st.h r8[0], r12
bral .Lend
.Lstore8:
st.b r8[0], r12
bral .Lend
.Lend:
sub sp, -20
ldm sp++, r0,r1,pc
.size ffi_call_SYSV, . - ffi_call_SYSV
/* r12: __ctx
* r11: __rstruct_flag
* r10: __inner */
.align 1
.globl ffi_closure_SYSV
.type ffi_closure_SYSV, @function
ffi_closure_SYSV:
stm --sp, r0,lr
mov r0, r11
mov r8, r10
sub r10, sp, -8
sub sp, 12
st.w sp[8], sp
sub r11, sp, -8
icall r8
/* Check if return type is actually a struct */
cp.w r0, 0
breq 1f
/* Return 8bit */
cp.w r12, FFI_TYPE_UINT8
breq .Lget8
/* Return 16bit */
cp.w r12, FFI_TYPE_UINT16
breq .Lget16
1:
/* Return 32bit */
cp.w r12, FFI_TYPE_UINT32
breq .Lget32
cp.w r12, FFI_TYPE_UINT16
breq .Lget32
cp.w r12, FFI_TYPE_UINT8
breq .Lget32
/* Return 64bit */
cp.w r12, FFI_TYPE_UINT64
breq .Lget64
/* Didn't match anything */
bral .Lclend
.Lget64:
ld.w r11, sp[0]
ld.w r10, sp[4]
bral .Lclend
.Lget32:
ld.w r12, sp[0]
bral .Lclend
.Lget16:
ld.uh r12, sp[0]
bral .Lclend
.Lget8:
ld.ub r12, sp[0]
bral .Lclend
.Lclend:
sub sp, -12
ldm sp++, r0,lr
sub sp, -20
mov pc, lr
.size ffi_closure_SYSV, . - ffi_closure_SYSV
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits
#endif

View File

@ -0,0 +1,633 @@
/* -----------------------------------------------------------------------
closures.c - Copyright (c) 2007, 2009 Red Hat, Inc.
Copyright (C) 2007, 2009 Free Software Foundation, Inc
Code to allocate and deallocate memory for closures.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#if defined __linux__ && !defined _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#include <ffi.h>
#include <ffi_common.h>
#ifndef FFI_MMAP_EXEC_WRIT
# if __gnu_linux__
/* This macro indicates it may be forbidden to map anonymous memory
with both write and execute permission. Code compiled when this
option is defined will attempt to map such pages once, but if it
fails, it falls back to creating a temporary file in a writable and
executable filesystem and mapping pages from it into separate
locations in the virtual memory space, one location writable and
another executable. */
# define FFI_MMAP_EXEC_WRIT 1
# define HAVE_MNTENT 1
# endif
# if defined(X86_WIN32) || defined(X86_WIN64)
/* Windows systems may have Data Execution Protection (DEP) enabled,
which requires the use of VirtualMalloc/VirtualFree to alloc/free
executable memory. */
# define FFI_MMAP_EXEC_WRIT 1
# endif
#endif
#if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX
# ifdef __linux__
/* When defined to 1 check for SELinux and if SELinux is active,
don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that
might cause audit messages. */
# define FFI_MMAP_EXEC_SELINUX 1
# endif
#endif
#if FFI_CLOSURES
# if FFI_MMAP_EXEC_WRIT
#define USE_LOCKS 1
#define USE_DL_PREFIX 1
#ifdef __GNUC__
#ifndef USE_BUILTIN_FFS
#define USE_BUILTIN_FFS 1
#endif
#endif
/* We need to use mmap, not sbrk. */
#define HAVE_MORECORE 0
/* We could, in theory, support mremap, but it wouldn't buy us anything. */
#define HAVE_MREMAP 0
/* We have no use for this, so save some code and data. */
#define NO_MALLINFO 1
/* We need all allocations to be in regular segments, otherwise we
lose track of the corresponding code address. */
#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
/* Don't allocate more than a page unless needed. */
#define DEFAULT_GRANULARITY ((size_t)malloc_getpagesize)
#if FFI_CLOSURE_TEST
/* Don't release single pages, to avoid a worst-case scenario of
continuously allocating and releasing single pages, but release
pairs of pages, which should do just as well given that allocations
are likely to be small. */
#define DEFAULT_TRIM_THRESHOLD ((size_t)malloc_getpagesize)
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <string.h>
#include <stdio.h>
#if !defined(X86_WIN32) && !defined(X86_WIN64)
#ifdef HAVE_MNTENT
#include <mntent.h>
#endif /* HAVE_MNTENT */
#include <sys/param.h>
#include <pthread.h>
/* We don't want sys/mman.h to be included after we redefine mmap and
dlmunmap. */
#include <sys/mman.h>
#define LACKS_SYS_MMAN_H 1
#if FFI_MMAP_EXEC_SELINUX
#include <sys/statfs.h>
#include <stdlib.h>
static int selinux_enabled = -1;
static int
selinux_enabled_check (void)
{
struct statfs sfs;
FILE *f;
char *buf = NULL;
size_t len = 0;
if (statfs ("/selinux", &sfs) >= 0
&& (unsigned int) sfs.f_type == 0xf97cff8cU)
return 1;
f = fopen ("/proc/mounts", "r");
if (f == NULL)
return 0;
while (getline (&buf, &len, f) >= 0)
{
char *p = strchr (buf, ' ');
if (p == NULL)
break;
p = strchr (p + 1, ' ');
if (p == NULL)
break;
if (strncmp (p + 1, "selinuxfs ", 10) != 0)
{
free (buf);
fclose (f);
return 1;
}
}
free (buf);
fclose (f);
return 0;
}
#define is_selinux_enabled() (selinux_enabled >= 0 ? selinux_enabled \
: (selinux_enabled = selinux_enabled_check ()))
#else
#define is_selinux_enabled() 0
#endif /* !FFI_MMAP_EXEC_SELINUX */
#elif defined (__CYGWIN__)
#include <sys/mman.h>
/* Cygwin is Linux-like, but not quite that Linux-like. */
#define is_selinux_enabled() 0
#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
/* Declare all functions defined in dlmalloc.c as static. */
static void *dlmalloc(size_t);
static void dlfree(void*);
static void *dlcalloc(size_t, size_t) MAYBE_UNUSED;
static void *dlrealloc(void *, size_t) MAYBE_UNUSED;
static void *dlmemalign(size_t, size_t) MAYBE_UNUSED;
static void *dlvalloc(size_t) MAYBE_UNUSED;
static int dlmallopt(int, int) MAYBE_UNUSED;
static size_t dlmalloc_footprint(void) MAYBE_UNUSED;
static size_t dlmalloc_max_footprint(void) MAYBE_UNUSED;
static void** dlindependent_calloc(size_t, size_t, void**) MAYBE_UNUSED;
static void** dlindependent_comalloc(size_t, size_t*, void**) MAYBE_UNUSED;
static void *dlpvalloc(size_t) MAYBE_UNUSED;
static int dlmalloc_trim(size_t) MAYBE_UNUSED;
static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
static void dlmalloc_stats(void) MAYBE_UNUSED;
#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
/* Use these for mmap and munmap within dlmalloc.c. */
static void *dlmmap(void *, size_t, int, int, int, off_t);
static int dlmunmap(void *, size_t);
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
#define mmap dlmmap
#define munmap dlmunmap
#include "dlmalloc.c"
#undef mmap
#undef munmap
#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
#if FFI_MMAP_EXEC_SELINUX
/* A mutex used to synchronize access to *exec* variables in this file. */
static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
/* A file descriptor of a temporary file from which we'll map
executable pages. */
static int execfd = -1;
/* The amount of space already allocated from the temporary file. */
static size_t execsize = 0;
/* Open a temporary file name, and immediately unlink it. */
static int
open_temp_exec_file_name (char *name)
{
int fd = mkstemp (name);
if (fd != -1)
unlink (name);
return fd;
}
/* Open a temporary file in the named directory. */
static int
open_temp_exec_file_dir (const char *dir)
{
static const char suffix[] = "/ffiXXXXXX";
int lendir = strlen (dir);
char *tempname = __builtin_alloca (lendir + sizeof (suffix));
if (!tempname)
return -1;
memcpy (tempname, dir, lendir);
memcpy (tempname + lendir, suffix, sizeof (suffix));
return open_temp_exec_file_name (tempname);
}
/* Open a temporary file in the directory in the named environment
variable. */
static int
open_temp_exec_file_env (const char *envvar)
{
const char *value = getenv (envvar);
if (!value)
return -1;
return open_temp_exec_file_dir (value);
}
#ifdef HAVE_MNTENT
/* Open a temporary file in an executable and writable mount point
listed in the mounts file. Subsequent calls with the same mounts
keep searching for mount points in the same file. Providing NULL
as the mounts file closes the file. */
static int
open_temp_exec_file_mnt (const char *mounts)
{
static const char *last_mounts;
static FILE *last_mntent;
if (mounts != last_mounts)
{
if (last_mntent)
endmntent (last_mntent);
last_mounts = mounts;
if (mounts)
last_mntent = setmntent (mounts, "r");
else
last_mntent = NULL;
}
if (!last_mntent)
return -1;
for (;;)
{
int fd;
struct mntent mnt;
char buf[MAXPATHLEN * 3];
if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)))
return -1;
if (hasmntopt (&mnt, "ro")
|| hasmntopt (&mnt, "noexec")
|| access (mnt.mnt_dir, W_OK))
continue;
fd = open_temp_exec_file_dir (mnt.mnt_dir);
if (fd != -1)
return fd;
}
}
#endif /* HAVE_MNTENT */
/* Instructions to look for a location to hold a temporary file that
can be mapped in for execution. */
static struct
{
int (*func)(const char *);
const char *arg;
int repeat;
} open_temp_exec_file_opts[] = {
{ open_temp_exec_file_env, "TMPDIR", 0 },
{ open_temp_exec_file_dir, "/tmp", 0 },
{ open_temp_exec_file_dir, "/var/tmp", 0 },
{ open_temp_exec_file_dir, "/dev/shm", 0 },
{ open_temp_exec_file_env, "HOME", 0 },
#ifdef HAVE_MNTENT
{ open_temp_exec_file_mnt, "/etc/mtab", 1 },
{ open_temp_exec_file_mnt, "/proc/mounts", 1 },
#endif /* HAVE_MNTENT */
};
/* Current index into open_temp_exec_file_opts. */
static int open_temp_exec_file_opts_idx = 0;
/* Reset a current multi-call func, then advances to the next entry.
If we're at the last, go back to the first and return nonzero,
otherwise return zero. */
static int
open_temp_exec_file_opts_next (void)
{
if (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func (NULL);
open_temp_exec_file_opts_idx++;
if (open_temp_exec_file_opts_idx
== (sizeof (open_temp_exec_file_opts)
/ sizeof (*open_temp_exec_file_opts)))
{
open_temp_exec_file_opts_idx = 0;
return 1;
}
return 0;
}
/* Return a file descriptor of a temporary zero-sized file in a
writable and exexutable filesystem. */
static int
open_temp_exec_file (void)
{
int fd;
do
{
fd = open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func
(open_temp_exec_file_opts[open_temp_exec_file_opts_idx].arg);
if (!open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat
|| fd == -1)
{
if (open_temp_exec_file_opts_next ())
break;
}
}
while (fd == -1);
return fd;
}
/* Map in a chunk of memory from the temporary exec file into separate
locations in the virtual memory address space, one writable and one
executable. Returns the address of the writable portion, after
storing an offset to the corresponding executable portion at the
last word of the requested chunk. */
static void *
dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset)
{
void *ptr;
if (execfd == -1)
{
open_temp_exec_file_opts_idx = 0;
retry_open:
execfd = open_temp_exec_file ();
if (execfd == -1)
return MFAIL;
}
offset = execsize;
if (ftruncate (execfd, offset + length))
return MFAIL;
flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS);
flags |= MAP_SHARED;
ptr = mmap (NULL, length, (prot & ~PROT_WRITE) | PROT_EXEC,
flags, execfd, offset);
if (ptr == MFAIL)
{
if (!offset)
{
close (execfd);
goto retry_open;
}
ftruncate (execfd, offset);
return MFAIL;
}
else if (!offset
&& open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
open_temp_exec_file_opts_next ();
start = mmap (start, length, prot, flags, execfd, offset);
if (start == MFAIL)
{
munmap (ptr, length);
ftruncate (execfd, offset);
return start;
}
mmap_exec_offset ((char *)start, length) = (char*)ptr - (char*)start;
execsize += length;
return start;
}
/* Map in a writable and executable chunk of memory if possible.
Failing that, fall back to dlmmap_locked. */
static void *
dlmmap (void *start, size_t length, int prot,
int flags, int fd, off_t offset)
{
void *ptr;
assert (start == NULL && length % malloc_getpagesize == 0
&& prot == (PROT_READ | PROT_WRITE)
&& flags == (MAP_PRIVATE | MAP_ANONYMOUS)
&& fd == -1 && offset == 0);
#if FFI_CLOSURE_TEST
printf ("mapping in %zi\n", length);
#endif
if (execfd == -1 && !is_selinux_enabled ())
{
ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
if (ptr != MFAIL || (errno != EPERM && errno != EACCES))
/* Cool, no need to mess with separate segments. */
return ptr;
/* If MREMAP_DUP is ever introduced and implemented, try mmap
with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with
MREMAP_DUP and prot at this point. */
}
if (execsize == 0 || execfd == -1)
{
pthread_mutex_lock (&open_temp_exec_file_mutex);
ptr = dlmmap_locked (start, length, prot, flags, offset);
pthread_mutex_unlock (&open_temp_exec_file_mutex);
return ptr;
}
return dlmmap_locked (start, length, prot, flags, offset);
}
#else
static void *
dlmmap (void *start, size_t length, int prot,
int flags, int fd, off_t offset)
{
assert (start == NULL && length % malloc_getpagesize == 0
&& prot == (PROT_READ | PROT_WRITE)
&& flags == (MAP_PRIVATE | MAP_ANONYMOUS)
&& fd == -1 && offset == 0);
#if FFI_CLOSURE_TEST
printf ("mapping in %zi\n", length);
#endif
return mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
}
#endif
/* Release memory at the given address, as well as the corresponding
executable page if it's separate. */
static int
dlmunmap (void *start, size_t length)
{
/* We don't bother decreasing execsize or truncating the file, since
we can't quite tell whether we're unmapping the end of the file.
We don't expect frequent deallocation anyway. If we did, we
could locate pages in the file by writing to the pages being
deallocated and checking that the file contents change.
Yuck. */
msegmentptr seg = segment_holding (gm, start);
void *code;
#if FFI_CLOSURE_TEST
printf ("unmapping %zi\n", length);
#endif
if (seg && (code = add_segment_exec_offset (start, seg)) != start)
{
int ret = munmap (code, length);
if (ret)
return ret;
}
return munmap (start, length);
}
#if FFI_CLOSURE_FREE_CODE
/* Return segment holding given code address. */
static msegmentptr
segment_holding_code (mstate m, char* addr)
{
msegmentptr sp = &m->seg;
for (;;) {
if (addr >= add_segment_exec_offset (sp->base, sp)
&& addr < add_segment_exec_offset (sp->base, sp) + sp->size)
return sp;
if ((sp = sp->next) == 0)
return 0;
}
}
#endif
#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
/* Allocate a chunk of memory with the given size. Returns a pointer
to the writable address, and sets *CODE to the executable
corresponding virtual address. */
void *
ffi_closure_alloc (size_t size, void **code)
{
void *ptr;
if (!code)
return NULL;
ptr = dlmalloc (size);
if (ptr)
{
msegmentptr seg = segment_holding (gm, ptr);
*code = add_segment_exec_offset (ptr, seg);
}
return ptr;
}
/* Release a chunk of memory allocated with ffi_closure_alloc. If
FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
writable or the executable address given. Otherwise, only the
writable address can be provided here. */
void
ffi_closure_free (void *ptr)
{
#if FFI_CLOSURE_FREE_CODE
msegmentptr seg = segment_holding_code (gm, ptr);
if (seg)
ptr = sub_segment_exec_offset (ptr, seg);
#endif
dlfree (ptr);
}
#if FFI_CLOSURE_TEST
/* Do some internal sanity testing to make sure allocation and
deallocation of pages are working as intended. */
int main ()
{
void *p[3];
#define GET(idx, len) do { p[idx] = dlmalloc (len); printf ("allocated %zi for p[%i]\n", (len), (idx)); } while (0)
#define PUT(idx) do { printf ("freeing p[%i]\n", (idx)); dlfree (p[idx]); } while (0)
GET (0, malloc_getpagesize / 2);
GET (1, 2 * malloc_getpagesize - 64 * sizeof (void*));
PUT (1);
GET (1, 2 * malloc_getpagesize);
GET (2, malloc_getpagesize / 2);
PUT (1);
PUT (0);
PUT (2);
return 0;
}
#endif /* FFI_CLOSURE_TEST */
# else /* ! FFI_MMAP_EXEC_WRIT */
/* On many systems, memory returned by malloc is writable and
executable, so just use it. */
#include <stdlib.h>
void *
ffi_closure_alloc (size_t size, void **code)
{
if (!code)
return NULL;
return *code = malloc (size);
}
void
ffi_closure_free (void *ptr)
{
free (ptr);
}
# endif /* ! FFI_MMAP_EXEC_WRIT */
#endif /* FFI_CLOSURES */

View File

@ -1,25 +0,0 @@
/*
* This file is for MacOSX only. Dispatch to the right architecture include
* file based on the current archictecture (instead of relying on a symlink
* created by configure). This makes is possible to build a univeral binary
* of ctypes in one go.
*/
#if defined(__i386__)
#ifndef X86_DARWIN
#define X86_DARWIN
#endif
#undef POWERPC_DARWIN
#include "../src/x86/ffitarget.h"
#elif defined(__ppc__)
#ifndef POWERPC_DARWIN
#define POWERPC_DARWIN
#endif
#undef X86_DARWIN
#include "../src/powerpc/ffitarget.h"
#endif

View File

@ -0,0 +1,59 @@
/* -----------------------------------------------------------------------
debug.c - Copyright (c) 1996 Red Hat, 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.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
#include <stdio.h>
/* General debugging routines */
void ffi_stop_here(void)
{
/* This function is only useful for debugging purposes.
Place a breakpoint on ffi_stop_here to be notified of
significant events. */
}
/* This function should only be called via the FFI_ASSERT() macro */
void ffi_assert(char *expr, char *file, int line)
{
fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
ffi_stop_here();
abort();
}
/* Perform a sanity check on an ffi_type structure */
void ffi_type_test(ffi_type *a, char *file, int line)
{
FFI_ASSERT_AT(a != NULL, file, line);
FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line);
FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line);
FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line);
FFI_ASSERT_AT(a->type != FFI_TYPE_STRUCT || a->elements != NULL, file, line);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (C) 2004 Anthony Green
Copyright (C) 2007 Free Software Foundation, Inc.
Copyright (C) 2007 Free Software Foundation, Inc.
Copyright (C) 2008 Red Hat, Inc.
FR-V Foreign Function Interface

View File

@ -0,0 +1,356 @@
/* -----------------------------------------------------------------------
java_raw_api.c - Copyright (c) 1999, 2007, 2008 Red Hat, Inc.
Cloned from raw_api.c
Raw_api.c author: Kresten Krab Thorup <krab@gnu.org>
Java_raw_api.c author: Hans-J. Boehm <hboehm@hpl.hp.com>
$Id $
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.
----------------------------------------------------------------------- */
/* This defines a Java- and 64-bit specific variant of the raw API. */
/* It assumes that "raw" argument blocks look like Java stacks on a */
/* 64-bit machine. Arguments that can be stored in a single stack */
/* stack slots (longs, doubles) occupy 128 bits, but only the first */
/* 64 bits are actually used. */
#include <ffi.h>
#include <ffi_common.h>
#include <stdlib.h>
#if !defined(NO_JAVA_RAW_API) && !defined(FFI_NO_RAW_API)
size_t
ffi_java_raw_size (ffi_cif *cif)
{
size_t result = 0;
int i;
ffi_type **at = cif->arg_types;
for (i = cif->nargs-1; i >= 0; i--, at++)
{
switch((*at) -> type) {
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_DOUBLE:
result += 2 * FFI_SIZEOF_JAVA_RAW;
break;
case FFI_TYPE_STRUCT:
/* No structure parameters in Java. */
abort();
default:
result += FFI_SIZEOF_JAVA_RAW;
}
}
return result;
}
void
ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args)
{
unsigned i;
ffi_type **tp = cif->arg_types;
#if WORDS_BIGENDIAN
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
switch ((*tp)->type)
{
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
*args = (void*) ((char*)(raw++) + 3);
break;
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT16:
*args = (void*) ((char*)(raw++) + 2);
break;
#if FFI_SIZEOF_JAVA_RAW == 8
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_DOUBLE:
*args = (void *)raw;
raw += 2;
break;
#endif
case FFI_TYPE_POINTER:
*args = (void*) &(raw++)->ptr;
break;
default:
*args = raw;
raw +=
ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw);
}
}
#else /* WORDS_BIGENDIAN */
#if !PDP
/* then assume little endian */
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
#if FFI_SIZEOF_JAVA_RAW == 8
switch((*tp)->type) {
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_DOUBLE:
*args = (void*) raw;
raw += 2;
break;
default:
*args = (void*) raw++;
}
#else /* FFI_SIZEOF_JAVA_RAW != 8 */
*args = (void*) raw;
raw +=
ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw);
#endif /* FFI_SIZEOF_JAVA_RAW == 8 */
}
#else
#error "pdp endian not supported"
#endif /* ! PDP */
#endif /* WORDS_BIGENDIAN */
}
void
ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw)
{
unsigned i;
ffi_type **tp = cif->arg_types;
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
switch ((*tp)->type)
{
case FFI_TYPE_UINT8:
#if WORDS_BIGENDIAN
*(UINT32*)(raw++) = *(UINT8*) (*args);
#else
(raw++)->uint = *(UINT8*) (*args);
#endif
break;
case FFI_TYPE_SINT8:
#if WORDS_BIGENDIAN
*(SINT32*)(raw++) = *(SINT8*) (*args);
#else
(raw++)->sint = *(SINT8*) (*args);
#endif
break;
case FFI_TYPE_UINT16:
#if WORDS_BIGENDIAN
*(UINT32*)(raw++) = *(UINT16*) (*args);
#else
(raw++)->uint = *(UINT16*) (*args);
#endif
break;
case FFI_TYPE_SINT16:
#if WORDS_BIGENDIAN
*(SINT32*)(raw++) = *(SINT16*) (*args);
#else
(raw++)->sint = *(SINT16*) (*args);
#endif
break;
case FFI_TYPE_UINT32:
#if WORDS_BIGENDIAN
*(UINT32*)(raw++) = *(UINT32*) (*args);
#else
(raw++)->uint = *(UINT32*) (*args);
#endif
break;
case FFI_TYPE_SINT32:
#if WORDS_BIGENDIAN
*(SINT32*)(raw++) = *(SINT32*) (*args);
#else
(raw++)->sint = *(SINT32*) (*args);
#endif
break;
case FFI_TYPE_FLOAT:
(raw++)->flt = *(FLOAT32*) (*args);
break;
#if FFI_SIZEOF_JAVA_RAW == 8
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_DOUBLE:
raw->uint = *(UINT64*) (*args);
raw += 2;
break;
#endif
case FFI_TYPE_POINTER:
(raw++)->ptr = **(void***) args;
break;
default:
#if FFI_SIZEOF_JAVA_RAW == 8
FFI_ASSERT(0); /* Should have covered all cases */
#else
memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
raw +=
ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw);
#endif
}
}
}
#if !FFI_NATIVE_RAW_API
static void
ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue)
{
#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8
switch (cif->rtype->type)
{
case FFI_TYPE_UINT8:
case FFI_TYPE_UINT16:
case FFI_TYPE_UINT32:
*(UINT64 *)rvalue <<= 32;
break;
case FFI_TYPE_SINT8:
case FFI_TYPE_SINT16:
case FFI_TYPE_SINT32:
case FFI_TYPE_INT:
#if FFI_SIZEOF_JAVA_RAW == 4
case FFI_TYPE_POINTER:
#endif
*(SINT64 *)rvalue <<= 32;
break;
default:
break;
}
#endif
}
static void
ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue)
{
#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8
switch (cif->rtype->type)
{
case FFI_TYPE_UINT8:
case FFI_TYPE_UINT16:
case FFI_TYPE_UINT32:
*(UINT64 *)rvalue >>= 32;
break;
case FFI_TYPE_SINT8:
case FFI_TYPE_SINT16:
case FFI_TYPE_SINT32:
case FFI_TYPE_INT:
*(SINT64 *)rvalue >>= 32;
break;
default:
break;
}
#endif
}
/* This is a generic definition of ffi_raw_call, to be used if the
* native system does not provide a machine-specific implementation.
* Having this, allows code to be written for the raw API, without
* the need for system-specific code to handle input in that format;
* these following couple of functions will handle the translation forth
* and back automatically. */
void ffi_java_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue,
ffi_java_raw *raw)
{
void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
ffi_java_raw_to_ptrarray (cif, raw, avalue);
ffi_call (cif, fn, rvalue, avalue);
ffi_java_rvalue_to_raw (cif, rvalue);
}
#if FFI_CLOSURES /* base system provides closures */
static void
ffi_java_translate_args (ffi_cif *cif, void *rvalue,
void **avalue, void *user_data)
{
ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif));
ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
ffi_java_ptrarray_to_raw (cif, avalue, raw);
(*cl->fun) (cif, rvalue, raw, cl->user_data);
ffi_java_raw_to_rvalue (cif, rvalue);
}
ffi_status
ffi_prep_java_raw_closure_loc (ffi_java_raw_closure* cl,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
void *user_data,
void *codeloc)
{
ffi_status status;
status = ffi_prep_closure_loc ((ffi_closure*) cl,
cif,
&ffi_java_translate_args,
codeloc,
codeloc);
if (status == FFI_OK)
{
cl->fun = fun;
cl->user_data = user_data;
}
return status;
}
/* Again, here is the generic version of ffi_prep_raw_closure, which
* will install an intermediate "hub" for translation of arguments from
* the pointer-array format, to the raw format */
ffi_status
ffi_prep_java_raw_closure (ffi_java_raw_closure* cl,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
void *user_data)
{
return ffi_prep_java_raw_closure_loc (cl, cif, fun, user_data, cl);
}
#endif /* FFI_CLOSURES */
#endif /* !FFI_NATIVE_RAW_API */
#endif /* !FFI_NO_RAW_API */

View File

@ -99,7 +99,7 @@ static void ffi_prep_args(char *stack,
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i; i--, p_arg++)
for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; i++, p_arg++)
{
size_t z;
unsigned int a;
@ -123,9 +123,25 @@ static void ffi_prep_args(char *stack,
/* The size of a pointer depends on the ABI */
if (type == FFI_TYPE_POINTER)
type =
(ecif->cif->abi == FFI_N64) ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
type = (ecif->cif->abi == FFI_N64
|| ecif->cif->abi == FFI_N64_SOFT_FLOAT)
? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
if (i < 8 && (ecif->cif->abi == FFI_N32_SOFT_FLOAT
|| ecif->cif->abi == FFI_N64_SOFT_FLOAT))
{
switch (type)
{
case FFI_TYPE_FLOAT:
type = FFI_TYPE_UINT32;
break;
case FFI_TYPE_DOUBLE:
type = FFI_TYPE_UINT64;
break;
default:
break;
}
}
switch (type)
{
case FFI_TYPE_SINT8:
@ -205,13 +221,17 @@ static void ffi_prep_args(char *stack,
definitions and generates the appropriate flags. */
static unsigned
calc_n32_struct_flags(ffi_type *arg, unsigned *loc, unsigned *arg_reg)
calc_n32_struct_flags(int soft_float, ffi_type *arg,
unsigned *loc, unsigned *arg_reg)
{
unsigned flags = 0;
unsigned index = 0;
ffi_type *e;
if (soft_float)
return 0;
while ((e = arg->elements[index]))
{
/* Align this object. */
@ -236,7 +256,7 @@ calc_n32_struct_flags(ffi_type *arg, unsigned *loc, unsigned *arg_reg)
}
static unsigned
calc_n32_return_struct_flags(ffi_type *arg)
calc_n32_return_struct_flags(int soft_float, ffi_type *arg)
{
unsigned flags = 0;
unsigned small = FFI_TYPE_SMALLSTRUCT;
@ -256,6 +276,7 @@ calc_n32_return_struct_flags(ffi_type *arg)
small = FFI_TYPE_SMALLSTRUCT2;
e = arg->elements[0];
if (e->type == FFI_TYPE_DOUBLE)
flags = FFI_TYPE_DOUBLE;
else if (e->type == FFI_TYPE_FLOAT)
@ -276,6 +297,8 @@ calc_n32_return_struct_flags(ffi_type *arg)
floats! This must be passed the old way. */
return small;
}
if (soft_float)
flags += FFI_TYPE_STRUCT_SOFT;
}
else
if (!flags)
@ -382,16 +405,19 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
#ifdef FFI_MIPS_N32
/* Set the flags necessary for N32 processing */
{
int type;
unsigned arg_reg = 0;
unsigned loc = 0;
unsigned count = (cif->nargs < 8) ? cif->nargs : 8;
unsigned index = 0;
unsigned struct_flags = 0;
int soft_float = (cif->abi == FFI_N32_SOFT_FLOAT
|| cif->abi == FFI_N64_SOFT_FLOAT);
if (cif->rtype->type == FFI_TYPE_STRUCT)
{
struct_flags = calc_n32_return_struct_flags(cif->rtype);
struct_flags = calc_n32_return_struct_flags(soft_float, cif->rtype);
if (struct_flags == 0)
{
@ -411,7 +437,22 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
while (count-- > 0 && arg_reg < 8)
{
switch ((cif->arg_types)[index]->type)
type = (cif->arg_types)[index]->type;
if (soft_float)
{
switch (type)
{
case FFI_TYPE_FLOAT:
type = FFI_TYPE_UINT32;
break;
case FFI_TYPE_DOUBLE:
type = FFI_TYPE_UINT64;
break;
default:
break;
}
}
switch (type)
{
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
@ -423,17 +464,25 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
/* Align it. */
arg_reg = ALIGN(arg_reg, 2);
/* Treat it as two adjacent doubles. */
cif->flags +=
(FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
arg_reg++;
cif->flags +=
(FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
arg_reg++;
if (soft_float)
{
arg_reg += 2;
}
else
{
cif->flags +=
(FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
arg_reg++;
cif->flags +=
(FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
arg_reg++;
}
break;
case FFI_TYPE_STRUCT:
loc = arg_reg * FFI_SIZEOF_ARG;
cif->flags += calc_n32_struct_flags((cif->arg_types)[index],
cif->flags += calc_n32_struct_flags(soft_float,
(cif->arg_types)[index],
&loc, &arg_reg);
break;
@ -469,17 +518,43 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
case FFI_TYPE_VOID:
/* Do nothing, 'cause FFI_TYPE_VOID is 0 */
break;
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
case FFI_TYPE_POINTER:
if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32)
cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
else
cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
break;
case FFI_TYPE_FLOAT:
if (soft_float)
{
cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
break;
}
/* else fall through */
case FFI_TYPE_DOUBLE:
if (soft_float)
cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
else
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
break;
case FFI_TYPE_LONGDOUBLE:
/* Long double is returned as if it were a struct containing
two doubles. */
cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
cif->flags += (FFI_TYPE_DOUBLE + (FFI_TYPE_DOUBLE << FFI_FLAG_BITS))
<< (4 + (FFI_FLAG_BITS * 8));
if (soft_float)
{
cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
cif->flags += FFI_TYPE_SMALLSTRUCT2 << (4 + (FFI_FLAG_BITS * 8));
}
else
{
cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
cif->flags += (FFI_TYPE_DOUBLE
+ (FFI_TYPE_DOUBLE << FFI_FLAG_BITS))
<< (4 + (FFI_FLAG_BITS * 8));
}
break;
default:
cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
@ -499,7 +574,7 @@ extern int ffi_call_O32(void (*)(char *, extended_cif *, int, int),
/* Low level routine for calling N32 functions */
extern int ffi_call_N32(void (*)(char *, extended_cif *, int, int),
extended_cif *, unsigned,
unsigned, unsigned *, void (*)(void));
unsigned, void *, void (*)(void));
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
@ -529,10 +604,13 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
#ifdef FFI_MIPS_N32
case FFI_N32:
case FFI_N32_SOFT_FLOAT:
case FFI_N64:
case FFI_N64_SOFT_FLOAT:
{
int copy_rvalue = 0;
void *rvalue_copy = ecif.rvalue;
int copy_offset = 0;
char *rvalue_copy = ecif.rvalue;
if (cif->rtype->type == FFI_TYPE_STRUCT && cif->rtype->size < 16)
{
/* For structures smaller than 16 bytes we clobber memory
@ -541,10 +619,20 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
rvalue_copy = alloca(16);
copy_rvalue = 1;
}
else if (cif->rtype->type == FFI_TYPE_FLOAT
&& (cif->abi == FFI_N64_SOFT_FLOAT
|| cif->abi == FFI_N32_SOFT_FLOAT))
{
rvalue_copy = alloca (8);
copy_rvalue = 1;
#if defined(__MIPSEB__) || defined(_MIPSEB)
copy_offset = 4;
#endif
}
ffi_call_N32(ffi_prep_args, &ecif, cif->bytes,
cif->flags, rvalue_copy, fn);
if (copy_rvalue)
memcpy(ecif.rvalue, rvalue_copy, cif->rtype->size);
memcpy(ecif.rvalue, rvalue_copy + copy_offset, cif->rtype->size);
}
break;
#endif
@ -684,9 +772,10 @@ ffi_closure_mips_inner_O32 (ffi_closure *closure,
{
if (i < 2 && !seen_int &&
(arg_types[i]->type == FFI_TYPE_FLOAT ||
arg_types[i]->type == FFI_TYPE_DOUBLE))
arg_types[i]->type == FFI_TYPE_DOUBLE ||
arg_types[i]->type == FFI_TYPE_LONGDOUBLE))
{
#ifdef __MIPSEB__
#if defined(__MIPSEB__) || defined(_MIPSEB)
if (arg_types[i]->type == FFI_TYPE_FLOAT)
avaluep[i] = ((char *) &fpr[i]) + sizeof (float);
else
@ -755,7 +844,7 @@ ffi_closure_mips_inner_O32 (ffi_closure *closure,
static void
copy_struct_N32(char *target, unsigned offset, ffi_abi abi, ffi_type *type,
int argn, unsigned arg_offset, ffi_arg *ar,
ffi_arg *fpr)
ffi_arg *fpr, int soft_float)
{
ffi_type **elt_typep = type->elements;
while(*elt_typep)
@ -777,7 +866,7 @@ copy_struct_N32(char *target, unsigned offset, ffi_abi abi, ffi_type *type,
tp = target + offset;
if (elt_type->type == FFI_TYPE_DOUBLE)
if (elt_type->type == FFI_TYPE_DOUBLE && !soft_float)
*(double *)tp = *(double *)fpp;
else
memcpy(tp, argp + arg_offset, elt_type->size);
@ -815,8 +904,12 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
ffi_arg *avalue;
ffi_type **arg_types;
int i, avn, argn;
int soft_float;
ffi_arg *argp;
cif = closure->cif;
soft_float = cif->abi == FFI_N64_SOFT_FLOAT
|| cif->abi == FFI_N32_SOFT_FLOAT;
avalue = alloca (cif->nargs * sizeof (ffi_arg));
avaluep = alloca (cif->nargs * sizeof (ffi_arg));
@ -839,10 +932,16 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
while (i < avn)
{
if (arg_types[i]->type == FFI_TYPE_FLOAT
|| arg_types[i]->type == FFI_TYPE_DOUBLE)
|| arg_types[i]->type == FFI_TYPE_DOUBLE
|| arg_types[i]->type == FFI_TYPE_LONGDOUBLE)
{
ffi_arg *argp = argn >= 8 ? ar + argn : fpr + argn;
#ifdef __MIPSEB__
argp = (argn >= 8 || soft_float) ? ar + argn : fpr + argn;
if ((arg_types[i]->type == FFI_TYPE_LONGDOUBLE) && ((unsigned)argp & (arg_types[i]->alignment-1)))
{
argp=(ffi_arg*)ALIGN(argp,arg_types[i]->alignment);
argn++;
}
#if defined(__MIPSEB__) || defined(_MIPSEB)
if (arg_types[i]->type == FFI_TYPE_FLOAT && argn < 8)
avaluep[i] = ((char *) argp) + sizeof (float);
else
@ -856,11 +955,15 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
if (arg_types[i]->alignment > sizeof(ffi_arg))
argn = ALIGN(argn, arg_types[i]->alignment / sizeof(ffi_arg));
ffi_arg *argp = ar + argn;
argp = ar + argn;
/* The size of a pointer depends on the ABI */
if (type == FFI_TYPE_POINTER)
type = (cif->abi == FFI_N64) ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
type = (cif->abi == FFI_N64 || cif->abi == FFI_N64_SOFT_FLOAT)
? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
if (soft_float && type == FFI_TYPE_FLOAT)
type = FFI_TYPE_UINT32;
switch (type)
{
@ -901,7 +1004,7 @@ ffi_closure_mips_inner_N32 (ffi_closure *closure,
it was passed in registers. */
avaluep[i] = alloca(arg_types[i]->size);
copy_struct_N32(avaluep[i], 0, cif->abi, arg_types[i],
argn, 0, ar, fpr);
argn, 0, ar, fpr, soft_float);
break;
}

View File

@ -28,7 +28,10 @@
#define LIBFFI_TARGET_H
#ifdef linux
#include <asm/sgidefs.h>
# include <asm/sgidefs.h>
#else
# include <sgidefs.h>
#endif
# ifndef _ABIN32
# define _ABIN32 _MIPS_SIM_NABI32
# endif
@ -38,7 +41,6 @@
# ifndef _ABIO32
# define _ABIO32 _MIPS_SIM_ABI32
# endif
#endif
#if !defined(_MIPS_SIM)
-- something is very wrong --
@ -95,6 +97,15 @@
#define FFI_TYPE_STRUCT_DF 189
#define FFI_TYPE_STRUCT_SMALL 93
#define FFI_TYPE_STRUCT_SMALL2 109
/* and for n32 soft float, add 16 * 2^4 */
#define FFI_TYPE_STRUCT_D_SOFT 317
#define FFI_TYPE_STRUCT_F_SOFT 301
#define FFI_TYPE_STRUCT_DD_SOFT 509
#define FFI_TYPE_STRUCT_FF_SOFT 429
#define FFI_TYPE_STRUCT_FD_SOFT 493
#define FFI_TYPE_STRUCT_DF_SOFT 445
#define FFI_TYPE_STRUCT_SOFT 16
#endif
#ifdef LIBFFI_ASM
@ -145,7 +156,8 @@
# endif /* _MIPS_SIM==_ABI64 */
#endif /* !FFI_MIPS_O32 */
#else /* !LIBFFI_ASM */
#ifdef FFI_MIPS_O32
# ifdef __GNUC__
# ifdef FFI_MIPS_O32
/* O32 stack frames have 32bit integer args */
typedef unsigned int ffi_arg __attribute__((__mode__(__SI__)));
typedef signed int ffi_sarg __attribute__((__mode__(__SI__)));
@ -153,7 +165,18 @@ typedef signed int ffi_sarg __attribute__((__mode__(__SI__)));
/* N32 and N64 frames have 64bit integer args */
typedef unsigned int ffi_arg __attribute__((__mode__(__DI__)));
typedef signed int ffi_sarg __attribute__((__mode__(__DI__)));
#endif
# endif
# else
# ifdef FFI_MIPS_O32
/* O32 stack frames have 32bit integer args */
typedef __uint32_t ffi_arg;
typedef __int32_t ffi_sarg;
# else
/* N32 and N64 frames have 64bit integer args */
typedef __uint64_t ffi_arg;
typedef __int64_t ffi_sarg;
# endif
# endif /* __GNUC__ */
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
@ -161,6 +184,8 @@ typedef enum ffi_abi {
FFI_N32,
FFI_N64,
FFI_O32_SOFT_FLOAT,
FFI_N32_SOFT_FLOAT,
FFI_N64_SOFT_FLOAT,
#ifdef FFI_MIPS_O32
#ifdef __mips_soft_float
@ -170,9 +195,17 @@ typedef enum ffi_abi {
#endif
#else
# if _MIPS_SIM==_ABI64
# ifdef __mips_soft_float
FFI_DEFAULT_ABI = FFI_N64_SOFT_FLOAT,
# else
FFI_DEFAULT_ABI = FFI_N64,
# endif
# else
# ifdef __mips_soft_float
FFI_DEFAULT_ABI = FFI_N32_SOFT_FLOAT,
# else
FFI_DEFAULT_ABI = FFI_N32,
# endif
# endif
#endif

View File

@ -14,14 +14,14 @@
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.
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
@ -40,7 +40,9 @@
#define SIZEOF_FRAME ( 8 * FFI_SIZEOF_ARG )
#ifdef linux
.abicalls
#endif
.text
.align 2
.globl ffi_call_N32
@ -217,8 +219,10 @@ callit:
# Shift the return type flag over
SRL t6, 8*FFI_FLAG_BITS
beq t6, FFI_TYPE_SINT32, retint
bne t6, FFI_TYPE_INT, retfloat
retint:
jal t9
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
REG_S v0, 0(t4)
@ -277,12 +281,58 @@ retstruct_d_f:
b epilogue
retstruct_f_d:
bne t6, FFI_TYPE_STRUCT_FD, retstruct_small
bne t6, FFI_TYPE_STRUCT_FD, retstruct_d_soft
jal t9
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
s.s $f0, 0(t4)
s.d $f2, 8(t4)
b epilogue
retstruct_d_soft:
bne t6, FFI_TYPE_STRUCT_D_SOFT, retstruct_f_soft
jal t9
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
sd v0, 0(t4)
b epilogue
retstruct_f_soft:
bne t6, FFI_TYPE_STRUCT_F_SOFT, retstruct_d_d_soft
jal t9
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
sw v0, 0(t4)
b epilogue
retstruct_d_d_soft:
bne t6, FFI_TYPE_STRUCT_DD_SOFT, retstruct_f_f_soft
jal t9
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
sd v0, 0(t4)
sd v1, 8(t4)
b epilogue
retstruct_f_f_soft:
bne t6, FFI_TYPE_STRUCT_FF_SOFT, retstruct_d_f_soft
jal t9
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
sw v0, 0(t4)
sw v1, 4(t4)
b epilogue
retstruct_d_f_soft:
bne t6, FFI_TYPE_STRUCT_DF_SOFT, retstruct_f_d_soft
jal t9
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
sd v0, 0(t4)
sw v1, 8(t4)
b epilogue
retstruct_f_d_soft:
bne t6, FFI_TYPE_STRUCT_FD_SOFT, retstruct_small
jal t9
REG_L t4, 4*FFI_SIZEOF_ARG($fp)
sw v0, 0(t4)
sd v1, 8(t4)
b epilogue
retstruct_small:
bne t6, FFI_TYPE_STRUCT_SMALL, retstruct_small2
@ -413,6 +463,11 @@ ffi_closure_N32:
jalr t9
# Return flags are in v0
bne v0, FFI_TYPE_SINT32, cls_retint
lw v0, V0_OFF2($sp)
b cls_epilogue
cls_retint:
bne v0, FFI_TYPE_INT, cls_retfloat
REG_L v0, V0_OFF2($sp)
b cls_epilogue
@ -474,6 +529,7 @@ cls_epilogue:
.LFE2:
.end ffi_closure_N32
#ifdef linux
.section .eh_frame,"aw",@progbits
.Lframe1:
.4byte .LECIE1-.LSCIE1 # length
@ -530,5 +586,6 @@ cls_epilogue:
.uleb128 (SIZEOF_FRAME2 - RA_OFF2)/4
.align EH_FRAME_ALIGN
.LEFDE3:
#endif /* linux */
#endif

View File

@ -14,14 +14,14 @@
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.
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

View File

@ -492,6 +492,13 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
avalue[i] = (void *)(stack - slot);
break;
#ifdef PA_HPUX
case FFI_TYPE_LONGDOUBLE:
/* Long doubles are treated like a big structure. */
avalue[i] = (void *) *(stack - slot);
break;
#endif
case FFI_TYPE_STRUCT:
/* Structs smaller or equal than 4 bytes are passed in one
register. Structs smaller or equal 8 bytes are passed in two

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
aix.S - Copyright (c) 2002 Free Software Foundation, Inc.
aix.S - Copyright (c) 2002,2009 Free Software Foundation, Inc.
based on darwin.S by John Hornkvist
PowerPC Assembly glue.
@ -86,9 +86,13 @@
#define L(x) x
.file "aix.S"
.toc
.csect .text[PR]
.align 2
.globl ffi_prep_args
/* void ffi_call_AIX(extended_cif *ecif, unsigned long bytes,
* unsigned int flags, unsigned int *rvalue,
* void (*fn)(),
* void (*prep_args)(extended_cif*, unsigned *const));
* r3=ecif, r4=bytes, r5=flags, r6=rvalue, r7=fn, r8=prep_args
*/
.csect .text[PR]
.align 2
@ -96,61 +100,151 @@
.globl .ffi_call_AIX
.csect ffi_call_AIX[DS]
ffi_call_AIX:
#ifdef __64BIT__
.llong .ffi_call_AIX, TOC[tc0], 0
.csect .text[PR]
.ffi_call_AIX:
/* Save registers we use. */
mflr r0
std r28,-32(r1)
std r29,-24(r1)
std r30,-16(r1)
std r31, -8(r1)
std r0, 16(r1)
mr r28, r1 /* our AP. */
stdux r1, r1, r4
/* Save arguments over call... */
mr r31, r5 /* flags, */
mr r30, r6 /* rvalue, */
mr r29, r7 /* function address. */
std r2, 40(r1)
/* Call ffi_prep_args. */
mr r4, r1
bl .ffi_prep_args
/* Now do the call. */
ld r0, 0(r29)
ld r2, 8(r29)
ld r11, 16(r29)
/* Set up cr1 with bits 4-7 of the flags. */
mtcrf 0x40, r31
mtctr r0
/* Load all those argument registers. */
// We have set up a nice stack frame, just load it into registers.
ld r3, 40+(1*8)(r1)
ld r4, 40+(2*8)(r1)
ld r5, 40+(3*8)(r1)
ld r6, 40+(4*8)(r1)
nop
ld r7, 40+(5*8)(r1)
ld r8, 40+(6*8)(r1)
ld r9, 40+(7*8)(r1)
ld r10,40+(8*8)(r1)
L1:
/* Load all the FP registers. */
bf 6,L2 // 2f + 0x18
lfd f1,-32-(13*8)(r28)
lfd f2,-32-(12*8)(r28)
lfd f3,-32-(11*8)(r28)
lfd f4,-32-(10*8)(r28)
nop
lfd f5,-32-(9*8)(r28)
lfd f6,-32-(8*8)(r28)
lfd f7,-32-(7*8)(r28)
lfd f8,-32-(6*8)(r28)
nop
lfd f9,-32-(5*8)(r28)
lfd f10,-32-(4*8)(r28)
lfd f11,-32-(3*8)(r28)
lfd f12,-32-(2*8)(r28)
nop
lfd f13,-32-(1*8)(r28)
L2:
/* Make the call. */
bctrl
ld r2, 40(r1)
/* Now, deal with the return value. */
mtcrf 0x01, r31
bt 30, L(done_return_value)
bt 29, L(fp_return_value)
std r3, 0(r30)
/* Fall through... */
L(done_return_value):
/* Restore the registers we used and return. */
mr r1, r28
ld r0, 16(r28)
ld r28, -32(r1)
mtlr r0
ld r29, -24(r1)
ld r30, -16(r1)
ld r31, -8(r1)
blr
L(fp_return_value):
bf 28, L(float_return_value)
stfd f1, 0(r30)
bf 31, L(done_return_value)
stfd f2, 8(r30)
b L(done_return_value)
L(float_return_value):
stfs f1, 0(r30)
b L(done_return_value)
#else /* ! __64BIT__ */
.long .ffi_call_AIX, TOC[tc0], 0
.csect .text[PR]
.ffi_call_AIX:
mr r12,r8 // We only need r12 until the call, so it doesn't have to be saved...
/* Save the old stack pointer as AP. */
mr r8,r1
/* Allocate the stack space we need. */
stwux r1,r1,r4
/* Save registers we use. */
mflr r9
mflr r0
stw r28,-16(r8)
stw r29,-12(r8)
stw r30, -8(r8)
stw r31, -4(r8)
stw r28,-16(r1)
stw r29,-12(r1)
stw r30, -8(r1)
stw r31, -4(r1)
stw r9, 8(r8)
stw r2, 20(r1)
stw r0, 8(r1)
mr r28, r1 /* out AP. */
stwux r1, r1, r4
/* Save arguments over call... */
mr r31,r5 /* flags, */
mr r30,r6 /* rvalue, */
mr r29,r7 /* function address, */
mr r28,r8 /* our AP. */
mr r31, r5 /* flags, */
mr r30, r6 /* rvalue, */
mr r29, r7 /* function address, */
stw r2, 20(r1)
/* Call ffi_prep_args. */
mr r4,r1
li r9,0
lwz r2,4(r12)
lwz r12,0(r12)
mtctr r12 // r12 holds address of _ffi_prep_args
bctrl
lwz r2,20(r1)
mr r4, r1
bl .ffi_prep_args
/* Now do the call. */
lwz r12,0(r29)
lwz r0, 0(r29)
lwz r2, 4(r29)
lwz r11, 8(r29)
/* Set up cr1 with bits 4-7 of the flags. */
mtcrf 0x40,r31
stw r2,20(r1)
mtctr r12
lwz r2,4(r29)
mtcrf 0x40, r31
mtctr r0
/* Load all those argument registers. */
// We have set up a nice stack frame, just load it into registers.
lwz r3, 20+(1*4)(r1)
lwz r4, 20+(2*4)(r1)
lwz r5, 20+(3*4)(r1)
lwz r6, 20+(4*4)(r1)
lwz r3, 20+(1*4)(r1)
lwz r4, 20+(2*4)(r1)
lwz r5, 20+(3*4)(r1)
lwz r6, 20+(4*4)(r1)
nop
lwz r7, 20+(5*4)(r1)
lwz r8, 20+(6*4)(r1)
lwz r9, 20+(7*4)(r1)
lwz r10,20+(8*4)(r1)
lwz r7, 20+(5*4)(r1)
lwz r8, 20+(6*4)(r1)
lwz r9, 20+(7*4)(r1)
lwz r10,20+(8*4)(r1)
L1:
/* Load all the FP registers. */
@ -165,47 +259,48 @@ L1:
lfd f7,-16-(7*8)(r28)
lfd f8,-16-(6*8)(r28)
nop
lfd f9,-16-(5*8)(r28)
lfd f10,-16-(4*8)(r28)
lfd f11,-16-(3*8)(r28)
lfd f12,-16-(2*8)(r28)
lfd f9,-16-(5*8)(r28)
lfd f10,-16-(4*8)(r28)
lfd f11,-16-(3*8)(r28)
lfd f12,-16-(2*8)(r28)
nop
lfd f13,-16-(1*8)(r28)
lfd f13,-16-(1*8)(r28)
L2:
/* Make the call. */
bctrl
lwz r2,20(r1)
lwz r2, 20(r1)
/* Now, deal with the return value. */
mtcrf 0x01,r31
mtcrf 0x01, r31
bt 30,L(done_return_value)
bt 29,L(fp_return_value)
stw r3,0(r30)
bf 28,L(done_return_value)
stw r4,4(r30)
bt 30, L(done_return_value)
bt 29, L(fp_return_value)
stw r3, 0(r30)
bf 28, L(done_return_value)
stw r4, 4(r30)
/* Fall through... */
L(done_return_value):
/* Restore the registers we used and return. */
lwz r9, 8(r28)
lwz r31, -4(r28)
mtlr r9
lwz r30, -8(r28)
lwz r29,-12(r28)
lwz r28,-16(r28)
lwz r1,0(r1)
mr r1, r28
lwz r0, 8(r28)
lwz r28,-16(r1)
mtlr r0
lwz r29,-12(r1)
lwz r30, -8(r1)
lwz r31, -4(r1)
blr
L(fp_return_value):
bf 28,L(float_return_value)
stfd f1,0(r30)
bf 28, L(float_return_value)
stfd f1, 0(r30)
b L(done_return_value)
L(float_return_value):
stfs f1,0(r30)
stfs f1, 0(r30)
b L(done_return_value)
#endif
.long 0
.byte 0,0,0,1,128,4,0,0
//END(ffi_call_AIX)
@ -216,7 +311,11 @@ L(float_return_value):
.globl .ffi_call_DARWIN
.csect ffi_call_DARWIN[DS]
ffi_call_DARWIN:
#ifdef __64BIT__
.llong .ffi_call_DARWIN, TOC[tc0], 0
#else
.long .ffi_call_DARWIN, TOC[tc0], 0
#endif
.csect .text[PR]
.ffi_call_DARWIN:
blr

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
aix_closure.S - Copyright (c) 2002 2003 Free Software Foundation, Inc.
aix_closure.S - Copyright (c) 2002, 2003, 2009 Free Software Foundation, Inc.
based on darwin_closure.S
PowerPC Assembly glue.
@ -94,65 +94,66 @@ LC..60:
.globl ffi_closure_ASM
.globl .ffi_closure_ASM
.csect ffi_closure_ASM[DS]
ffi_closure_ASM:
.long .ffi_closure_ASM, TOC[tc0], 0
#ifdef __64BIT__
.llong .ffi_closure_ASM, TOC[tc0], 0
.csect .text[PR]
.ffi_closure_ASM:
mflr r0 /* extract return address */
stw r0, 8(r1) /* save the return address */
/* 24 Bytes (Linkage Area) */
/* 32 Bytes (params) */
/* 104 Bytes (13*8 from FPR) */
/* 8 Bytes (result) */
/* 168 Bytes */
stwu r1,-176(r1) /* skip over caller save area
keep stack aligned to 16 */
/* we want to build up an area for the parameters passed */
/* in registers (both floating point and integer) */
/* we store gpr 3 to gpr 10 (aligned to 4)
in the parents outgoing area */
stw r3, 200(r1)
stw r4, 204(r1)
stw r5, 208(r1)
stw r6, 212(r1)
stw r7, 216(r1)
stw r8, 220(r1)
stw r9, 224(r1)
stw r10, 228(r1)
std r3, 48+(0*8)(r1)
std r4, 48+(1*8)(r1)
std r5, 48+(2*8)(r1)
std r6, 48+(3*8)(r1)
mflr r0
std r7, 48+(4*8)(r1)
std r8, 48+(5*8)(r1)
std r9, 48+(6*8)(r1)
std r10, 48+(7*8)(r1)
std r0, 16(r1) /* save the return address */
/* 48 Bytes (Linkage Area) */
/* 64 Bytes (params) */
/* 16 Bytes (result) */
/* 104 Bytes (13*8 from FPR) */
/* 8 Bytes (alignment) */
/* 240 Bytes */
stdu r1, -240(r1) /* skip over caller save area
keep stack aligned to 16 */
/* next save fpr 1 to fpr 13 (aligned to 8) */
stfd f1, 56(r1)
stfd f2, 64(r1)
stfd f3, 72(r1)
stfd f4, 80(r1)
stfd f5, 88(r1)
stfd f6, 96(r1)
stfd f7, 104(r1)
stfd f8, 112(r1)
stfd f9, 120(r1)
stfd f10, 128(r1)
stfd f11, 136(r1)
stfd f12, 144(r1)
stfd f13, 152(r1)
stfd f1, 128+(0*8)(r1)
stfd f2, 128+(1*8)(r1)
stfd f3, 128+(2*8)(r1)
stfd f4, 128+(3*8)(r1)
stfd f5, 128+(4*8)(r1)
stfd f6, 128+(5*8)(r1)
stfd f7, 128+(6*8)(r1)
stfd f8, 128+(7*8)(r1)
stfd f9, 128+(8*8)(r1)
stfd f10, 128+(9*8)(r1)
stfd f11, 128+(10*8)(r1)
stfd f12, 128+(11*8)(r1)
stfd f13, 128+(12*8)(r1)
/* set up registers for the routine that actually does the work */
/* get the context pointer from the trampoline */
mr r3,r11
mr r3, r11
/* now load up the pointer to the result storage */
addi r4,r1,160
addi r4, r1, 112
/* now load up the pointer to the saved gpr registers */
addi r5,r1,200
addi r5, r1, 288
/* now load up the pointer to the saved fpr registers */
addi r6,r1,56
addi r6, r1, 128
/* make the call */
bl .ffi_closure_helper_DARWIN
@ -164,84 +165,279 @@ ffi_closure_ASM:
/* look up the proper starting point in table */
/* by using return type as offset */
addi r5,r1,160 /* get pointer to results area */
lwz r4,LC..60(2) /* get address of jump table */
slwi r3,r3,2 /* now multiply return type by 4 */
lwzx r3,r4,r3 /* get the contents of that table value */
add r3,r3,r4 /* add contents of table to table address */
mtctr r3
ld r4, LC..60(2) /* get address of jump table */
sldi r3, r3, 4 /* now multiply return type by 16 */
ld r0, 240+16(r1) /* load return address */
add r3, r3, r4 /* add contents of table to table address */
mtctr r3
bctr /* jump to it */
/* Each fragment must be exactly 16 bytes long (4 instructions).
Align to 16 byte boundary for cache and dispatch efficiency. */
.align 4
L..60:
.long L..44-L..60 /* FFI_TYPE_VOID */
.long L..50-L..60 /* FFI_TYPE_INT */
.long L..47-L..60 /* FFI_TYPE_FLOAT */
.long L..46-L..60 /* FFI_TYPE_DOUBLE */
.long L..46-L..60 /* FFI_TYPE_LONGDOUBLE */
.long L..56-L..60 /* FFI_TYPE_UINT8 */
.long L..55-L..60 /* FFI_TYPE_SINT8 */
.long L..58-L..60 /* FFI_TYPE_UINT16 */
.long L..57-L..60 /* FFI_TYPE_SINT16 */
.long L..50-L..60 /* FFI_TYPE_UINT32 */
.long L..50-L..60 /* FFI_TYPE_SINT32 */
.long L..48-L..60 /* FFI_TYPE_UINT64 */
.long L..48-L..60 /* FFI_TYPE_SINT64 */
.long L..44-L..60 /* FFI_TYPE_STRUCT */
.long L..50-L..60 /* FFI_TYPE_POINTER */
/* case FFI_TYPE_VOID */
mtlr r0
addi r1, r1, 240
blr
nop
/* case double */
L..46:
lfd f1,0(r5)
b L..44
/* case float */
L..47:
lfs f1,0(r5)
b L..44
/* case long long */
L..48:
lwz r3,0(r5)
lwz r4,4(r5)
b L..44
/* case default / int32 / pointer */
L..50:
lwz r3,0(r5)
b L..44
/* case signed int8 */
L..55:
addi r5,r5,3
lbz r3,0(r5)
slwi r3,r3,24
srawi r3,r3,24
b L..44
/* case unsigned int8 */
L..56:
addi r5,r5,3
lbz r3,0(r5)
b L..44
/* case signed int16 */
L..57:
addi r5,r5,2
lhz r3,0(r5)
extsh r3,r3
b L..44
/* case unsigned int16 */
L..58:
addi r5,r5,2
lhz r3,0(r5)
/* case void / done */
L..44:
addi r1,r1,176 /* restore stack pointer */
lwz r0,8(r1) /* get return address */
mtlr r0 /* reset link register */
/* case FFI_TYPE_INT */
lwa r3, 112+4(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_FLOAT */
lfs f1, 112+0(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_DOUBLE */
lfd f1, 112+0(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_LONGDOUBLE */
lfd f1, 112+0(r1)
mtlr r0
lfd f2, 112+8(r1)
b L..finish
/* case FFI_TYPE_UINT8 */
lbz r3, 112+7(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_SINT8 */
lbz r3, 112+7(r1)
mtlr r0
extsb r3, r3
b L..finish
/* case FFI_TYPE_UINT16 */
lhz r3, 112+6(r1)
mtlr r0
L..finish:
addi r1, r1, 240
blr
/* case FFI_TYPE_SINT16 */
lha r3, 112+6(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_UINT32 */
lwz r3, 112+4(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_SINT32 */
lwa r3, 112+4(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_UINT64 */
ld r3, 112+0(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_SINT64 */
ld r3, 112+0(r1)
mtlr r0
addi r1, r1, 240
blr
/* case FFI_TYPE_STRUCT */
mtlr r0
addi r1, r1, 240
blr
nop
/* case FFI_TYPE_POINTER */
ld r3, 112+0(r1)
mtlr r0
addi r1, r1, 240
blr
#else /* ! __64BIT__ */
.long .ffi_closure_ASM, TOC[tc0], 0
.csect .text[PR]
.ffi_closure_ASM:
/* we want to build up an area for the parameters passed */
/* in registers (both floating point and integer) */
/* we store gpr 3 to gpr 10 (aligned to 4)
in the parents outgoing area */
stw r3, 24+(0*4)(r1)
stw r4, 24+(1*4)(r1)
stw r5, 24+(2*4)(r1)
stw r6, 24+(3*4)(r1)
mflr r0
stw r7, 24+(4*4)(r1)
stw r8, 24+(5*4)(r1)
stw r9, 24+(6*4)(r1)
stw r10, 24+(7*4)(r1)
stw r0, 8(r1)
/* 24 Bytes (Linkage Area) */
/* 32 Bytes (params) */
/* 16 Bytes (result) */
/* 104 Bytes (13*8 from FPR) */
/* 176 Bytes */
stwu r1, -176(r1) /* skip over caller save area
keep stack aligned to 16 */
/* next save fpr 1 to fpr 13 (aligned to 8) */
stfd f1, 72+(0*8)(r1)
stfd f2, 72+(1*8)(r1)
stfd f3, 72+(2*8)(r1)
stfd f4, 72+(3*8)(r1)
stfd f5, 72+(4*8)(r1)
stfd f6, 72+(5*8)(r1)
stfd f7, 72+(6*8)(r1)
stfd f8, 72+(7*8)(r1)
stfd f9, 72+(8*8)(r1)
stfd f10, 72+(9*8)(r1)
stfd f11, 72+(10*8)(r1)
stfd f12, 72+(11*8)(r1)
stfd f13, 72+(12*8)(r1)
/* set up registers for the routine that actually does the work */
/* get the context pointer from the trampoline */
mr r3, r11
/* now load up the pointer to the result storage */
addi r4, r1, 56
/* now load up the pointer to the saved gpr registers */
addi r5, r1, 200
/* now load up the pointer to the saved fpr registers */
addi r6, r1, 72
/* make the call */
bl .ffi_closure_helper_DARWIN
nop
/* now r3 contains the return type */
/* so use it to look up in a table */
/* so we know how to deal with each type */
/* look up the proper starting point in table */
/* by using return type as offset */
lwz r4, LC..60(2) /* get address of jump table */
slwi r3, r3, 4 /* now multiply return type by 4 */
lwz r0, 176+8(r1) /* load return address */
add r3, r3, r4 /* add contents of table to table address */
mtctr r3
bctr /* jump to it */
/* Each fragment must be exactly 16 bytes long (4 instructions).
Align to 16 byte boundary for cache and dispatch efficiency. */
.align 4
L..60:
/* case FFI_TYPE_VOID */
mtlr r0
addi r1, r1, 176
blr
nop
/* case FFI_TYPE_INT */
lwz r3, 56+0(r1)
mtlr r0
addi r1, r1, 176
blr
/* case FFI_TYPE_FLOAT */
lfs f1, 56+0(r1)
mtlr r0
addi r1, r1, 176
blr
/* case FFI_TYPE_DOUBLE */
lfd f1, 56+0(r1)
mtlr r0
addi r1, r1, 176
blr
/* case FFI_TYPE_LONGDOUBLE */
lfd f1, 56+0(r1)
mtlr r0
lfd f2, 56+8(r1)
b L..finish
/* case FFI_TYPE_UINT8 */
lbz r3, 56+3(r1)
mtlr r0
addi r1, r1, 176
blr
/* case FFI_TYPE_SINT8 */
lbz r3, 56+3(r1)
mtlr r0
extsb r3, r3
b L..finish
/* case FFI_TYPE_UINT16 */
lhz r3, 56+2(r1)
mtlr r0
addi r1, r1, 176
blr
/* case FFI_TYPE_SINT16 */
lha r3, 56+2(r1)
mtlr r0
addi r1, r1, 176
blr
/* case FFI_TYPE_UINT32 */
lwz r3, 56+0(r1)
mtlr r0
addi r1, r1, 176
blr
/* case FFI_TYPE_SINT32 */
lwz r3, 56+0(r1)
mtlr r0
addi r1, r1, 176
blr
/* case FFI_TYPE_UINT64 */
lwz r3, 56+0(r1)
mtlr r0
lwz r4, 56+4(r1)
b L..finish
/* case FFI_TYPE_SINT64 */
lwz r3, 56+0(r1)
mtlr r0
lwz r4, 56+4(r1)
b L..finish
/* case FFI_TYPE_STRUCT */
mtlr r0
addi r1, r1, 176
blr
nop
/* case FFI_TYPE_POINTER */
lwz r3, 56+0(r1)
mtlr r0
L..finish:
addi r1, r1, 176
blr
#endif
/* END(ffi_closure_ASM) */

View File

@ -1,6 +1,6 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Geoffrey Keating
Copyright (C) 2007 Free Software Foundation, Inc
Copyright (C) 2007, 2008 Free Software Foundation, Inc
Copyright (C) 2008 Red Hat, Inc
PowerPC Foreign Function Interface
@ -43,6 +43,11 @@ enum {
FLAG_RETURNS_64BITS = 1 << (31-28),
FLAG_RETURNS_128BITS = 1 << (31-27), /* cr6 */
FLAG_SYSV_SMST_R4 = 1 << (31-26), /* use r4 for FFI_SYSV 8 byte
structs. */
FLAG_SYSV_SMST_R3 = 1 << (31-25), /* use r3 for FFI_SYSV 4 byte
structs. */
/* Bits (31-24) through (31-19) store shift value for SMST */
FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
@ -180,6 +185,7 @@ ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
{
*next_arg.f = (float) double_tmp;
next_arg.u += 1;
intarg_count++;
}
else
*fpr_base.d++ = double_tmp;
@ -680,15 +686,15 @@ ffi_prep_cif_machdep (ffi_cif *cif)
The same applies for the structs returned in r3/r4. */
if (size <= 4)
{
flags |= 1 << (31 - FFI_SYSV_TYPE_SMALL_STRUCT - 1);
flags |= 8 * (4 - size) << 4;
flags |= FLAG_SYSV_SMST_R3;
flags |= 8 * (4 - size) << 8;
break;
}
/* These structs are returned in r3 and r4. See above. */
if (size <= 8)
{
flags |= 1 << (31 - FFI_SYSV_TYPE_SMALL_STRUCT - 2);
flags |= 8 * (8 - size) << 4;
flags |= FLAG_SYSV_SMST_R3 | FLAG_SYSV_SMST_R4;
flags |= 8 * (8 - size) << 8;
break;
}
}
@ -1144,6 +1150,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
pst++;
avalue[i] = pst;
pst += 2;
ng = 8;
}
break;
@ -1217,6 +1224,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
{
avalue[i] = pst;
pst += 4;
ng = 8;
}
break;
}
@ -1249,10 +1257,15 @@ ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
/* Tell ffi_closure_SYSV how to perform return type promotions.
Because the FFI_SYSV ABI returns the structures <= 8 bytes in r3/r4
we have to tell ffi_closure_SYSV how to treat them. */
we have to tell ffi_closure_SYSV how to treat them. We combine the base
type FFI_SYSV_TYPE_SMALL_STRUCT - 1 with the size of the struct.
So a one byte struct gets the return type 16. Return type 1 to 15 are
already used and we never have a struct with size zero. That is the reason
for the subtraction of 1. See the comment in ffitarget.h about ordering.
*/
if (cif->abi == FFI_SYSV && cif->rtype->type == FFI_TYPE_STRUCT
&& size <= 8)
return FFI_SYSV_TYPE_SMALL_STRUCT + size;
return (FFI_SYSV_TYPE_SMALL_STRUCT - 1) + size;
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
else if (cif->rtype->type == FFI_TYPE_LONGDOUBLE
&& cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)

View File

@ -3,7 +3,7 @@
Copyright (C) 1998 Geoffrey Keating
Copyright (C) 2001 John Hornkvist
Copyright (C) 2002, 2006, 2007 Free Software Foundation, Inc.
Copyright (C) 2002, 2006, 2007, 2009 Free Software Foundation, Inc.
FFI support for Darwin and AIX.
@ -32,7 +32,7 @@
#include <stdlib.h>
extern void ffi_closure_ASM(void);
extern void ffi_closure_ASM (void);
enum {
/* The assembly depends on these exact flags. */
@ -80,34 +80,37 @@ enum { ASM_NEEDS_REGISTERS = 4 };
*/
void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
void
ffi_prep_args (extended_cif *ecif, unsigned long *const stack)
{
const unsigned bytes = ecif->cif->bytes;
const unsigned flags = ecif->cif->flags;
const unsigned nargs = ecif->cif->nargs;
const ffi_abi abi = ecif->cif->abi;
/* 'stacktop' points at the previous backchain pointer. */
unsigned *const stacktop = stack + (bytes / sizeof(unsigned));
unsigned long *const stacktop = stack + (bytes / sizeof(unsigned long));
/* 'fpr_base' points at the space for fpr1, and grows upwards as
we use FPR registers. */
double *fpr_base = (double*) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS;
double *fpr_base = (double *) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS;
int fparg_count = 0;
/* 'next_arg' grows up as we put parameters in it. */
unsigned *next_arg = stack + 6; /* 6 reserved positions. */
unsigned long *next_arg = stack + 6; /* 6 reserved positions. */
int i = ecif->cif->nargs;
int i;
double double_tmp;
void **p_argv = ecif->avalue;
unsigned gprvalue;
unsigned long gprvalue;
ffi_type** ptr = ecif->cif->arg_types;
char *dest_cpy;
unsigned size_al = 0;
/* Check that everything starts aligned properly. */
FFI_ASSERT(((unsigned)(char *)stack & 0xF) == 0);
FFI_ASSERT(((unsigned)(char *)stacktop & 0xF) == 0);
FFI_ASSERT(((unsigned) (char *) stack & 0xF) == 0);
FFI_ASSERT(((unsigned) (char *) stacktop & 0xF) == 0);
FFI_ASSERT((bytes & 0xF) == 0);
/* Deal with return values that are actually pass-by-reference.
@ -115,12 +118,10 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
Return values are referenced by r3, so r4 is the first parameter. */
if (flags & FLAG_RETVAL_REFERENCE)
*next_arg++ = (unsigned)(char *)ecif->rvalue;
*next_arg++ = (unsigned long) (char *) ecif->rvalue;
/* Now for the arguments. */
for (;
i > 0;
i--, ptr++, p_argv++)
for (i = nargs; i > 0; i--, ptr++, p_argv++)
{
switch ((*ptr)->type)
{
@ -128,7 +129,7 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
purpose registers are filled, the corresponding GPRs that match
the size of the floating-point parameter are skipped. */
case FFI_TYPE_FLOAT:
double_tmp = *(float *)*p_argv;
double_tmp = *(float *) *p_argv;
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
*(double *)next_arg = double_tmp;
else
@ -139,12 +140,16 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
break;
case FFI_TYPE_DOUBLE:
double_tmp = *(double *)*p_argv;
double_tmp = *(double *) *p_argv;
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
*(double *)next_arg = double_tmp;
else
*fpr_base++ = double_tmp;
#ifdef POWERPC64
next_arg++;
#else
next_arg += 2;
#endif
fparg_count++;
FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
break;
@ -152,42 +157,71 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
double_tmp = ((double *)*p_argv)[0];
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
*(double *)next_arg = double_tmp;
#ifdef POWERPC64
if (fparg_count < NUM_FPR_ARG_REGISTERS)
*(long double *) fpr_base++ = *(long double *) *p_argv;
else
*(long double *) next_arg = *(long double *) *p_argv;
next_arg += 2;
fparg_count += 2;
#else
double_tmp = ((double *) *p_argv)[0];
if (fparg_count < NUM_FPR_ARG_REGISTERS)
*fpr_base++ = double_tmp;
else
*(double *) next_arg = double_tmp;
next_arg += 2;
fparg_count++;
double_tmp = ((double *)*p_argv)[1];
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
*(double *)next_arg = double_tmp;
else
double_tmp = ((double *) *p_argv)[1];
if (fparg_count < NUM_FPR_ARG_REGISTERS)
*fpr_base++ = double_tmp;
else
*(double *) next_arg = double_tmp;
next_arg += 2;
fparg_count++;
#endif
FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
break;
#endif
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
*(long long *)next_arg = *(long long *)*p_argv;
next_arg+=2;
#ifdef POWERPC64
gprvalue = *(long long *) *p_argv;
goto putgpr;
#else
*(long long *) next_arg = *(long long *) *p_argv;
next_arg += 2;
#endif
break;
case FFI_TYPE_POINTER:
gprvalue = *(unsigned long *) *p_argv;
goto putgpr;
case FFI_TYPE_UINT8:
gprvalue = *(unsigned char *)*p_argv;
gprvalue = *(unsigned char *) *p_argv;
goto putgpr;
case FFI_TYPE_SINT8:
gprvalue = *(signed char *)*p_argv;
gprvalue = *(signed char *) *p_argv;
goto putgpr;
case FFI_TYPE_UINT16:
gprvalue = *(unsigned short *)*p_argv;
gprvalue = *(unsigned short *) *p_argv;
goto putgpr;
case FFI_TYPE_SINT16:
gprvalue = *(signed short *)*p_argv;
gprvalue = *(signed short *) *p_argv;
goto putgpr;
case FFI_TYPE_STRUCT:
#ifdef POWERPC64
dest_cpy = (char *) next_arg;
size_al = (*ptr)->size;
if ((*ptr)->elements[0]->type == 3)
size_al = ALIGN((*ptr)->size, 8);
if (size_al < 3 && abi == FFI_DARWIN)
dest_cpy += 4 - size_al;
memcpy ((char *) dest_cpy, (char *) *p_argv, size_al);
next_arg += (size_al + 7) / 8;
#else
dest_cpy = (char *) next_arg;
/* Structures that match the basic modes (QI 1 byte, HI 2 bytes,
@ -195,22 +229,24 @@ void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
Structures with 3 byte in size are padded upwards. */
size_al = (*ptr)->size;
/* If the first member of the struct is a double, then align
the struct to double-word.
Type 3 is defined in include/ffi.h. #define FFI_TYPE_DOUBLE 3. */
if ((*ptr)->elements[0]->type == 3)
the struct to double-word. */
if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE)
size_al = ALIGN((*ptr)->size, 8);
if (size_al < 3 && ecif->cif->abi == FFI_DARWIN)
if (size_al < 3 && abi == FFI_DARWIN)
dest_cpy += 4 - size_al;
memcpy((char *)dest_cpy, (char *)*p_argv, size_al);
memcpy((char *) dest_cpy, (char *) *p_argv, size_al);
next_arg += (size_al + 3) / 4;
#endif
break;
case FFI_TYPE_INT:
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
case FFI_TYPE_POINTER:
gprvalue = *(unsigned *)*p_argv;
gprvalue = *(signed int *) *p_argv;
goto putgpr;
case FFI_TYPE_UINT32:
gprvalue = *(unsigned int *) *p_argv;
putgpr:
*next_arg++ = gprvalue;
break;
@ -268,8 +304,44 @@ darwin_adjust_aggregate_sizes (ffi_type *s)
/* Do not add additional tail padding. */
}
/* Adjust the size of S to be correct for AIX.
Word-align double unless it is the first member of a structure. */
static void
aix_adjust_aggregate_sizes (ffi_type *s)
{
int i;
if (s->type != FFI_TYPE_STRUCT)
return;
s->size = 0;
for (i = 0; s->elements[i] != NULL; i++)
{
ffi_type *p;
int align;
p = s->elements[i];
aix_adjust_aggregate_sizes (p);
align = p->alignment;
if (i != 0 && p->type == FFI_TYPE_DOUBLE)
align = 4;
s->size = ALIGN(s->size, align) + p->size;
}
s->size = ALIGN(s->size, s->alignment);
if (s->elements[0]->type == FFI_TYPE_UINT64
|| s->elements[0]->type == FFI_TYPE_SINT64
|| s->elements[0]->type == FFI_TYPE_DOUBLE
|| s->elements[0]->alignment == 8)
s->alignment = s->alignment > 8 ? s->alignment : 8;
/* Do not add additional tail padding. */
}
/* Perform machine dependent cif processing. */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
ffi_status
ffi_prep_cif_machdep (ffi_cif *cif)
{
/* All this is for the DARWIN ABI. */
int i;
@ -290,6 +362,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
darwin_adjust_aggregate_sizes (cif->arg_types[i]);
}
if (cif->abi == FFI_AIX)
{
aix_adjust_aggregate_sizes (cif->rtype);
for (i = 0; i < cif->nargs; i++)
aix_adjust_aggregate_sizes (cif->arg_types[i]);
}
/* Space for the frame pointer, callee's LR, CR, etc, and for
the asm's temp regs. */
@ -324,6 +403,9 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
#ifdef POWERPC64
case FFI_TYPE_POINTER:
#endif
flags |= FLAG_RETURNS_64BITS;
break;
@ -387,11 +469,14 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
case FFI_TYPE_STRUCT:
size_al = (*ptr)->size;
/* If the first member of the struct is a double, then align
the struct to double-word.
Type 3 is defined in include/ffi.h. #define FFI_TYPE_DOUBLE 3. */
if ((*ptr)->elements[0]->type == 3)
the struct to double-word. */
if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE)
size_al = ALIGN((*ptr)->size, 8);
#ifdef POWERPC64
intarg_count += (size_al + 7) / 8;
#else
intarg_count += (size_al + 3) / 4;
#endif
break;
default:
@ -410,8 +495,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
bytes += NUM_FPR_ARG_REGISTERS * sizeof(double);
/* Stack space. */
#ifdef POWERPC64
if ((intarg_count + fparg_count) > NUM_GPR_ARG_REGISTERS)
bytes += (intarg_count + fparg_count) * sizeof(long);
#else
if ((intarg_count + 2 * fparg_count) > NUM_GPR_ARG_REGISTERS)
bytes += (intarg_count + 2 * fparg_count) * sizeof(long);
#endif
else
bytes += NUM_GPR_ARG_REGISTERS * sizeof(long);
@ -424,12 +514,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
return FFI_OK;
}
extern void ffi_call_AIX(extended_cif *, unsigned, unsigned, unsigned *,
extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *,
void (*fn)(void), void (*fn2)(void));
extern void ffi_call_DARWIN(extended_cif *, unsigned, unsigned, unsigned *,
extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *,
void (*fn)(void), void (*fn2)(void));
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
void
ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
extended_cif ecif;
@ -442,7 +533,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
ecif.rvalue = alloca(cif->rtype->size);
ecif.rvalue = alloca (cif->rtype->size);
}
else
ecif.rvalue = rvalue;
@ -450,11 +541,11 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
switch (cif->abi)
{
case FFI_AIX:
ffi_call_AIX(&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn,
ffi_call_AIX(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn,
ffi_prep_args);
break;
case FFI_DARWIN:
ffi_call_DARWIN(&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn,
ffi_call_DARWIN(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn,
ffi_prep_args);
break;
default:
@ -617,8 +708,9 @@ typedef union
double d;
} ffi_dblfl;
int ffi_closure_helper_DARWIN (ffi_closure*, void*,
unsigned long*, ffi_dblfl*);
int
ffi_closure_helper_DARWIN (ffi_closure *, void *,
unsigned long *, ffi_dblfl *);
/* Basically the trampoline invokes ffi_closure_ASM, and on
entry, r11 holds the address of the closure.
@ -627,8 +719,9 @@ int ffi_closure_helper_DARWIN (ffi_closure*, void*,
up space for a return value, ffi_closure_ASM invokes the
following helper function to do most of the work. */
int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
unsigned long * pgr, ffi_dblfl * pfr)
int
ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
unsigned long *pgr, ffi_dblfl *pfr)
{
/* rvalue is the pointer to space for return value in closure assembly
pgr is the pointer to where r3-r10 are stored in ffi_closure_ASM
@ -645,18 +738,12 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
void ** avalue;
ffi_type ** arg_types;
long i, avn;
long nf; /* number of floating registers already used. */
long ng; /* number of general registers already used. */
ffi_cif * cif;
double temp;
ffi_dblfl * end_pfr = pfr + NUM_FPR_ARG_REGISTERS;
unsigned size_al;
union ldu temp_ld;
cif = closure->cif;
avalue = alloca(cif->nargs * sizeof(void *));
nf = 0;
ng = 0;
avalue = alloca (cif->nargs * sizeof(void *));
/* Copy the caller's structure return value address so that the closure
returns the data directly to the caller. */
@ -664,7 +751,6 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
{
rvalue = (void *) *pgr;
pgr++;
ng++;
}
i = 0;
@ -678,58 +764,82 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
{
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
#ifdef POWERPC64
avalue[i] = (char *) pgr + 7;
#else
avalue[i] = (char *) pgr + 3;
ng++;
#endif
pgr++;
break;
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
#ifdef POWERPC64
avalue[i] = (char *) pgr + 6;
#else
avalue[i] = (char *) pgr + 2;
ng++;
#endif
pgr++;
break;
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
#ifdef POWERPC64
avalue[i] = (char *) pgr + 4;
#else
case FFI_TYPE_POINTER:
avalue[i] = pgr;
ng++;
#endif
pgr++;
break;
case FFI_TYPE_STRUCT:
#ifdef POWERPC64
size_al = arg_types[i]->size;
if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
size_al = ALIGN (arg_types[i]->size, 8);
if (size_al < 3 && cif->abi == FFI_DARWIN)
avalue[i] = (void *) pgr + 8 - size_al;
else
avalue[i] = (void *) pgr;
pgr += (size_al + 7) / 8;
#else
/* Structures that match the basic modes (QI 1 byte, HI 2 bytes,
SI 4 bytes) are aligned as if they were those modes. */
size_al = arg_types[i]->size;
/* If the first member of the struct is a double, then align
the struct to double-word.
Type 3 is defined in include/ffi.h. #define FFI_TYPE_DOUBLE 3. */
if (arg_types[i]->elements[0]->type == 3)
the struct to double-word. */
if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
size_al = ALIGN(arg_types[i]->size, 8);
if (size_al < 3 && cif->abi == FFI_DARWIN)
avalue[i] = (void*) pgr + 4 - size_al;
else
avalue[i] = (void*) pgr;
ng += (size_al + 3) / 4;
pgr += (size_al + 3) / 4;
#endif
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
#ifdef POWERPC64
case FFI_TYPE_POINTER:
avalue[i] = pgr;
pgr++;
break;
#else
/* Long long ints are passed in two gpr's. */
avalue[i] = pgr;
ng += 2;
pgr += 2;
break;
#endif
case FFI_TYPE_FLOAT:
/* A float value consumes a GPR.
There are 13 64bit floating point registers. */
if (nf < NUM_FPR_ARG_REGISTERS)
if (pfr < end_pfr)
{
temp = pfr->d;
pfr->f = (float)temp;
double temp = pfr->d;
pfr->f = (float) temp;
avalue[i] = pfr;
pfr++;
}
@ -737,15 +847,13 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
{
avalue[i] = pgr;
}
nf++;
ng++;
pgr++;
break;
case FFI_TYPE_DOUBLE:
/* A double value consumes two GPRs.
There are 13 64bit floating point registers. */
if (nf < NUM_FPR_ARG_REGISTERS)
if (pfr < end_pfr)
{
avalue[i] = pfr;
pfr++;
@ -754,17 +862,36 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
{
avalue[i] = pgr;
}
nf++;
ng += 2;
#ifdef POWERPC64
pgr++;
#else
pgr += 2;
#endif
break;
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#ifdef POWERPC64
if (pfr + 1 < end_pfr)
{
avalue[i] = pfr;
pfr += 2;
}
else
{
if (pfr < end_pfr)
{
*pgr = *(unsigned long *) pfr;
pfr++;
}
avalue[i] = pgr;
}
pgr += 2;
#else /* POWERPC64 */
/* A long double value consumes four GPRs and two FPRs.
There are 13 64bit floating point registers. */
if (nf < NUM_FPR_ARG_REGISTERS - 1)
if (pfr + 1 < end_pfr)
{
avalue[i] = pfr;
pfr += 2;
@ -772,19 +899,20 @@ int ffi_closure_helper_DARWIN (ffi_closure* closure, void * rvalue,
/* Here we have the situation where one part of the long double
is stored in fpr13 and the other part is already on the stack.
We use a union to pass the long double to avalue[i]. */
else if (nf == NUM_FPR_ARG_REGISTERS - 1)
else if (pfr + 1 == end_pfr)
{
union ldu temp_ld;
memcpy (&temp_ld.lb[0], pfr, sizeof(ldbits));
memcpy (&temp_ld.lb[1], pgr + 2, sizeof(ldbits));
avalue[i] = &temp_ld.ld;
pfr++;
}
else
{
avalue[i] = pgr;
}
nf += 2;
ng += 4;
pgr += 4;
#endif /* POWERPC64 */
break;
#endif
default:

View File

@ -1,6 +1,6 @@
/* -----------------------------------------------------------------*-C-*-
ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
Copyright (C) 2007 Free Software Foundation, Inc
Copyright (C) 2007, 2008 Free Software Foundation, Inc
Target configuration macros for PowerPC.
Permission is hereby granted, free of charge, to any person obtaining
@ -30,7 +30,11 @@
/* ---- System specific configurations ----------------------------------- */
#if defined (POWERPC) && defined (__powerpc64__)
#if defined (POWERPC) && defined (__powerpc64__) /* linux64 */
#define POWERPC64
#elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin */
#define POWERPC64
#elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */
#define POWERPC64
#endif
@ -78,6 +82,8 @@ typedef enum ffi_abi {
FFI_SYSV,
FFI_GCC_SYSV,
FFI_LINUX64,
FFI_LINUX,
FFI_LINUX_SOFT_FLOAT,
FFI_DEFAULT_ABI = FFI_SYSV,
#endif
@ -96,7 +102,9 @@ typedef enum ffi_abi {
/* Needed for soft-float long-double-128 support. */
#define FFI_TYPE_UINT128 (FFI_TYPE_LAST + 1)
/* Needed for FFI_SYSV small structure returns. */
/* Needed for FFI_SYSV small structure returns.
We use two flag bits, (FLAG_SYSV_SMST_R3, FLAG_SYSV_SMST_R4) which are
defined in ffi.c, to determine the exact return type and its size. */
#define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 2)
#if defined(POWERPC64) || defined(POWERPC_AIX)

View File

@ -136,29 +136,18 @@ L(float_return_value):
b L(done_return_value)
L(small_struct_return_value):
mtcrf 0x10,%r31 /* cr3 */
bt- 15,L(smst_one_register)
mtcrf 0x08,%r31 /* cr4 */
bt- 16,L(smst_two_register)
b L(done_return_value)
L(smst_one_register):
rlwinm %r5,%r31,5+23,32-5,31 /* Extract the value to shift. */
slw %r3,%r3,%r5
stw %r3,0(%r30)
b L(done_return_value)
L(smst_two_register):
rlwinm %r5,%r31,5+23,32-5,31 /* Extract the value to shift. */
cmpwi %r5,0
subfic %r9,%r5,32
slw %r29,%r3,%r5
srw %r9,%r4,%r9
beq- L(smst_8byte)
or %r3,%r9,%r29
slw %r4,%r4,%r5
L(smst_8byte):
stw %r3,0(%r30)
stw %r4,4(%r30)
extrwi %r6,%r31,2,19 /* number of bytes padding = shift/8 */
mtcrf 0x02,%r31 /* copy flags to cr[24:27] (cr6) */
extrwi %r5,%r31,5,19 /* r5 <- number of bits of padding */
subfic %r6,%r6,4 /* r6 <- number of useful bytes in r3 */
bf- 25,L(done_return_value) /* struct in r3 ? if not, done. */
/* smst_one_register: */
slw %r3,%r3,%r5 /* Left-justify value in r3 */
mtxer %r6 /* move byte count to XER ... */
stswx %r3,0,%r30 /* ... and store that many bytes */
bf+ 26,L(done_return_value) /* struct in r3:r4 ? */
add %r6,%r6,%r30 /* adjust pointer */
stswi %r4,%r6,4 /* store last four bytes */
b L(done_return_value)
.LFE1:

View File

@ -0,0 +1,254 @@
/* -----------------------------------------------------------------------
raw_api.c - Copyright (c) 1999, 2008 Red Hat, Inc.
Author: Kresten Krab Thorup <krab@gnu.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.
----------------------------------------------------------------------- */
/* This file defines generic functions for use with the raw api. */
#include <ffi.h>
#include <ffi_common.h>
#if !FFI_NO_RAW_API
size_t
ffi_raw_size (ffi_cif *cif)
{
size_t result = 0;
int i;
ffi_type **at = cif->arg_types;
for (i = cif->nargs-1; i >= 0; i--, at++)
{
#if !FFI_NO_STRUCTS
if ((*at)->type == FFI_TYPE_STRUCT)
result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG);
else
#endif
result += ALIGN ((*at)->size, FFI_SIZEOF_ARG);
}
return result;
}
void
ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args)
{
unsigned i;
ffi_type **tp = cif->arg_types;
#if WORDS_BIGENDIAN
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
switch ((*tp)->type)
{
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
*args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 1);
break;
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT16:
*args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 2);
break;
#if FFI_SIZEOF_ARG >= 4
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
*args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 4);
break;
#endif
#if !FFI_NO_STRUCTS
case FFI_TYPE_STRUCT:
*args = (raw++)->ptr;
break;
#endif
case FFI_TYPE_POINTER:
*args = (void*) &(raw++)->ptr;
break;
default:
*args = raw;
raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
}
}
#else /* WORDS_BIGENDIAN */
#if !PDP
/* then assume little endian */
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
#if !FFI_NO_STRUCTS
if ((*tp)->type == FFI_TYPE_STRUCT)
{
*args = (raw++)->ptr;
}
else
#endif
{
*args = (void*) raw;
raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*);
}
}
#else
#error "pdp endian not supported"
#endif /* ! PDP */
#endif /* WORDS_BIGENDIAN */
}
void
ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw)
{
unsigned i;
ffi_type **tp = cif->arg_types;
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
switch ((*tp)->type)
{
case FFI_TYPE_UINT8:
(raw++)->uint = *(UINT8*) (*args);
break;
case FFI_TYPE_SINT8:
(raw++)->sint = *(SINT8*) (*args);
break;
case FFI_TYPE_UINT16:
(raw++)->uint = *(UINT16*) (*args);
break;
case FFI_TYPE_SINT16:
(raw++)->sint = *(SINT16*) (*args);
break;
#if FFI_SIZEOF_ARG >= 4
case FFI_TYPE_UINT32:
(raw++)->uint = *(UINT32*) (*args);
break;
case FFI_TYPE_SINT32:
(raw++)->sint = *(SINT32*) (*args);
break;
#endif
#if !FFI_NO_STRUCTS
case FFI_TYPE_STRUCT:
(raw++)->ptr = *args;
break;
#endif
case FFI_TYPE_POINTER:
(raw++)->ptr = **(void***) args;
break;
default:
memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
}
}
}
#if !FFI_NATIVE_RAW_API
/* This is a generic definition of ffi_raw_call, to be used if the
* native system does not provide a machine-specific implementation.
* Having this, allows code to be written for the raw API, without
* the need for system-specific code to handle input in that format;
* these following couple of functions will handle the translation forth
* and back automatically. */
void ffi_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *raw)
{
void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
ffi_raw_to_ptrarray (cif, raw, avalue);
ffi_call (cif, fn, rvalue, avalue);
}
#if FFI_CLOSURES /* base system provides closures */
static void
ffi_translate_args (ffi_cif *cif, void *rvalue,
void **avalue, void *user_data)
{
ffi_raw *raw = (ffi_raw*)alloca (ffi_raw_size (cif));
ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
ffi_ptrarray_to_raw (cif, avalue, raw);
(*cl->fun) (cif, rvalue, raw, cl->user_data);
}
ffi_status
ffi_prep_raw_closure_loc (ffi_raw_closure* cl,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data,
void *codeloc)
{
ffi_status status;
status = ffi_prep_closure_loc ((ffi_closure*) cl,
cif,
&ffi_translate_args,
codeloc,
codeloc);
if (status == FFI_OK)
{
cl->fun = fun;
cl->user_data = user_data;
}
return status;
}
#endif /* FFI_CLOSURES */
#endif /* !FFI_NATIVE_RAW_API */
#if FFI_CLOSURES
/* Again, here is the generic version of ffi_prep_raw_closure, which
* will install an intermediate "hub" for translation of arguments from
* the pointer-array format, to the raw format */
ffi_status
ffi_prep_raw_closure (ffi_raw_closure* cl,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data)
{
return ffi_prep_raw_closure_loc (cl, cif, fun, user_data, cl);
}
#endif /* FFI_CLOSURES */
#endif /* !FFI_NO_RAW_API */

View File

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2000 Software AG
Copyright (c) 2008 Red Hat, Inc.
S390 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007 Kaz Kojima
ffi.c - Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Kaz Kojima
Copyright (c) 2008 Red Hat, Inc.
SuperH Foreign Function Interface
@ -461,7 +461,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
void *codeloc)
{
unsigned int *tramp;
unsigned short insn;
unsigned int insn;
FFI_ASSERT (cif->abi == FFI_GCC_SYSV);

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2002, 2003, 2004, 2006 Kaz Kojima
sysv.S - Copyright (c) 2002, 2003, 2004, 2006, 2008 Kaz Kojima
SuperH Foreign Function Interface
@ -14,14 +14,14 @@
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.
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
@ -702,6 +702,10 @@ L_case_v:
.ffi_closure_SYSV_end:
.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits
#endif
.section ".eh_frame","aw",@progbits
__FRAME_BEGIN__:
.4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2003, 2004 Kaz Kojima
ffi.c - Copyright (c) 2003, 2004, 2006, 2007 Kaz Kojima
Copyright (c) 2008 Anthony Green
SuperH SHmedia Foreign Function Interface
@ -56,9 +56,7 @@ return_type (ffi_type *arg)
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
/*@-exportheader@*/
void ffi_prep_args(char *stack, extended_cif *ecif)
/*@=exportheader@*/
{
register unsigned int i;
register unsigned int avn;
@ -162,6 +160,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
int n, m;
int greg;
int freg;
int fpair = -1;
greg = (return_type (cif->rtype) == FFI_TYPE_STRUCT ? 1 : 0);
freg = 0;
@ -177,7 +176,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
cif->bytes += sizeof (UINT64) - sizeof (float);
if (freg >= NFREGARG - 1)
continue;
freg++;
if (fpair < 0)
{
fpair = freg;
freg += 2;
}
else
fpair = -1;
cif->flags2 += ((cif->arg_types)[i]->type) << (2 * j++);
break;
@ -186,7 +191,6 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
continue;
if ((freg + 1) < NFREGARG)
{
freg = (freg + 1) & ~1;
freg += 2;
cif->flags2 += ((cif->arg_types)[i]->type) << (2 * j++);
}
@ -264,9 +268,7 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif,
else if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
/*@-sysunrecog@*/
ecif.rvalue = alloca(cif->rtype->size);
/*@=sysunrecog@*/
}
else
ecif.rvalue = rvalue;
@ -274,10 +276,8 @@ void ffi_call(/*@dependent@*/ ffi_cif *cif,
switch (cif->abi)
{
case FFI_SYSV:
/*@-usedef@*/
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes,
cif->flags, cif->flags2, ecif.rvalue, fn);
/*@=usedef@*/
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, cif->flags2,
ecif.rvalue, fn);
break;
default:
FFI_ASSERT(0);
@ -294,10 +294,11 @@ extern void ffi_closure_SYSV (void);
extern void __ic_invalidate (void *line);
ffi_status
ffi_prep_closure (ffi_closure *closure,
ffi_cif *cif,
void (*fun)(ffi_cif*, void*, void**, void*),
void *user_data)
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;
@ -321,8 +322,8 @@ ffi_prep_closure (ffi_closure *closure,
tramp[2] = 0xcc000010 | (((UINT32) ffi_closure_SYSV) >> 16) << 10;
tramp[3] = 0xc8000010 | (((UINT32) ffi_closure_SYSV) & 0xffff) << 10;
tramp[4] = 0x6bf10600;
tramp[5] = 0xcc000010 | (((UINT32) closure) >> 16) << 10;
tramp[6] = 0xc8000010 | (((UINT32) closure) & 0xffff) << 10;
tramp[5] = 0xcc000010 | (((UINT32) codeloc) >> 16) << 10;
tramp[6] = 0xc8000010 | (((UINT32) codeloc) & 0xffff) << 10;
tramp[7] = 0x4401fff0;
closure->cif = cif;
@ -330,7 +331,8 @@ ffi_prep_closure (ffi_closure *closure,
closure->user_data = user_data;
/* Flush the icache. */
asm volatile ("ocbwb %0,0; synco; icbi %0,0; synci" : : "r" (tramp));
asm volatile ("ocbwb %0,0; synco; icbi %1,0; synci" : : "r" (tramp),
"r"(codeloc));
return FFI_OK;
}
@ -352,6 +354,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, UINT64 *rvalue,
int i, avn;
int greg, freg;
ffi_cif *cif;
int fpair = -1;
cif = closure->cif;
avalue = alloca (cif->nargs * sizeof (void *));
@ -360,7 +363,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure, UINT64 *rvalue,
returns the data directly to the caller. */
if (return_type (cif->rtype) == FFI_TYPE_STRUCT)
{
rvalue = *pgr;
rvalue = (UINT64 *) *pgr;
greg = 1;
}
else
@ -404,11 +407,24 @@ ffi_closure_helper_SYSV (ffi_closure *closure, UINT64 *rvalue,
if ((*p_arg)->type == FFI_TYPE_FLOAT)
{
if (freg < NFREGARG - 1)
{
if (fpair >= 0)
{
avalue[i] = (UINT32 *) pfr + fpair;
fpair = -1;
}
else
{
#ifdef __LITTLE_ENDIAN__
avalue[i] = (UINT32 *) pfr + (1 ^ freg++);
fpair = freg;
avalue[i] = (UINT32 *) pfr + (1 ^ freg);
#else
avalue[i] = (UINT32 *) pfr + freg++;
fpair = 1 ^ freg;
avalue[i] = (UINT32 *) pfr + freg;
#endif
freg += 2;
}
}
else
#ifdef __LITTLE_ENDIAN__
avalue[i] = pgr + greg;
@ -430,7 +446,6 @@ ffi_closure_helper_SYSV (ffi_closure *closure, UINT64 *rvalue,
avalue[i] = pgr + greg;
else
{
freg = (freg + 1) & ~1;
avalue[i] = pfr + (freg >> 1);
freg += 2;
}

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2003, 2004 Kaz Kojima
sysv.S - Copyright (c) 2003, 2004, 2006, 2008 Kaz Kojima
SuperH SHmedia Foreign Function Interface
@ -14,14 +14,15 @@
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.
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
@ -85,6 +86,7 @@ ENTRY(ffi_call_SYSV)
addi r15, 64, r22
movi 0, r0
movi 0, r1
movi -1, r23
pt/l 1f, tr1
bnei/l r29, FFI_TYPE_STRUCT, tr1
@ -107,9 +109,6 @@ ENTRY(ffi_call_SYSV)
.L_pass_d:
addi r0, 1, r0
addi r1, 1, r1
andi r1, ~1, r1
pt/l 3f, tr0
movi 12, r20
bge/l r1, r20, tr0
@ -159,13 +158,23 @@ ENTRY(ffi_call_SYSV)
addi.l r15, 8, r15
3:
pt/l .L_pass, tr0
addi r1, 1, r1
blink tr0, r63
.L_pop_f:
pt/l .L_pop_f_tbl, tr1
pt/l 5f, tr2
gettr tr1, r20
bge/l r23, r63, tr2
add r1, r63, r23
shlli r1, 3, r21
addi r1, 2, r1
add r20, r21, r20
ptabs/l r20, tr1
blink tr1, r63
5:
addi r23, 1, r21
movi -1, r23
shlli r21, 3, r21
add r20, r21, r20
ptabs/l r20, tr1
blink tr1, r63
@ -430,6 +439,10 @@ ENTRY(ffi_closure_SYSV)
.ffi_closure_SYSV_end:
.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
#if defined __ELF__ && defined __linux__
.section .note.GNU-stack,"",@progbits
#endif
.section ".eh_frame","aw",@progbits
__FRAME_BEGIN__:
.4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */

View File

@ -308,14 +308,24 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
cif->flags = FFI_TYPE_STRUCT;
break;
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
if (cif->abi == FFI_V9)
cif->flags = FFI_TYPE_INT;
else
cif->flags = cif->rtype->type;
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
if (cif->abi != FFI_V9)
{
cif->flags = FFI_TYPE_SINT64;
break;
}
/* FALLTHROUGH */
if (cif->abi == FFI_V9)
cif->flags = FFI_TYPE_INT;
else
cif->flags = FFI_TYPE_SINT64;
break;
default:
cif->flags = FFI_TYPE_INT;
break;
@ -589,6 +599,11 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure,
/* Right-justify. */
argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
/* Align on a 16-byte boundary. */
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
if (arg_types[i]->type == FFI_TYPE_LONGDOUBLE && (argn % 2) != 0)
argn++;
#endif
if (i < fp_slot_max
&& (arg_types[i]->type == FFI_TYPE_FLOAT
|| arg_types[i]->type == FFI_TYPE_DOUBLE

View File

@ -73,21 +73,63 @@ _ffi_call_v8:
be,a done
st %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_SINT64
be longlong
cmp %i3, FFI_TYPE_DOUBLE
bne done
nop
st %f0, [%i4+0]
st %f1, [%i4+4]
be,a double
st %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_SINT8
be,a sint8
sll %o0, 24, %o0 ! (delay)
cmp %i3, FFI_TYPE_UINT8
be,a uint8
sll %o0, 24, %o0 ! (delay)
cmp %i3, FFI_TYPE_SINT16
be,a sint16
sll %o0, 16, %o0 ! (delay)
cmp %i3, FFI_TYPE_UINT16
be,a uint16
sll %o0, 16, %o0 ! (delay)
cmp %i3, FFI_TYPE_SINT64
be,a longlong
st %o0, [%i4+0] ! (delay)
done:
ret
restore
longlong:
double:
st %f1, [%i4+4]
ret
restore
sint8:
sra %o0, 24, %o0
st %o0, [%i4+0]
ret
restore
uint8:
srl %o0, 24, %o0
st %o0, [%i4+0]
ret
restore
sint16:
sra %o0, 16, %o0
st %o0, [%i4+0]
ret
restore
uint16:
srl %o0, 16, %o0
st %o0, [%i4+0]
ret
restore
longlong:
st %o1, [%i4+4]
ret
restore
@ -148,7 +190,8 @@ ffi_closure_v8:
be done1
cmp %o0, FFI_TYPE_INT
be integer
be done1
ld [%fp-8], %i0
cmp %o0, FFI_TYPE_FLOAT
be,a done1
@ -166,13 +209,11 @@ ffi_closure_v8:
cmp %o0, FFI_TYPE_STRUCT
be done2
! FFI_TYPE_SINT64
! FFI_TYPE_UINT64
ld [%fp-4], %i1
cmp %o0, FFI_TYPE_SINT64
be,a done1
ldd [%fp-8], %i0
integer:
ld [%fp-8], %i0
done1:
jmp %i7+8
restore

View File

@ -0,0 +1,77 @@
/* -----------------------------------------------------------------------
types.c - Copyright (c) 1996, 1998 Red Hat, Inc.
Predefined ffi_types needed by libffi.
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.
----------------------------------------------------------------------- */
/* Hide the basic type definitions from the header file, so that we
can redefine them here as "const". */
#define LIBFFI_HIDE_BASIC_TYPES
#include <ffi.h>
#include <ffi_common.h>
/* Type definitions */
#define FFI_TYPEDEF(name, type, id) \
struct struct_align_##name { \
char c; \
type x; \
}; \
const ffi_type ffi_type_##name = { \
sizeof(type), \
offsetof(struct struct_align_##name, x), \
id, NULL \
}
/* Size and alignment are fake here. They must not be 0. */
const ffi_type ffi_type_void = {
1, 1, FFI_TYPE_VOID, NULL
};
FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8);
FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8);
FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16);
FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16);
FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32);
FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32);
FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64);
FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64);
FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER);
FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT);
FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE);
#ifdef __alpha__
/* Even if we're not configured to default to 128-bit long double,
maintain binary compatibility, as -mlong-double-128 can be used
at any time. */
/* Validate the hard-coded number below. */
# if defined(__LONG_DOUBLE_128__) && FFI_TYPE_LONGDOUBLE != 4
# error FFI_TYPE_LONGDOUBLE out of date
# endif
const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
#elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
#endif

View File

@ -15,15 +15,16 @@
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.
----------------------------------------------------------------------- */
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 __x86_64__

View File

@ -3,7 +3,7 @@
Copyright (c) 2002 Ranjit Mathew
Copyright (c) 2002 Bo Thorsen
Copyright (c) 2002 Roger Sayle
Copyright (C) 2008 Free Software Foundation, Inc.
Copyright (C) 2008 Free Software Foundation, Inc.
x86 Foreign Function Interface
@ -28,7 +28,11 @@
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#ifndef __x86_64__
#if !defined(__x86_64__) || defined(_WIN64)
#ifdef _WIN64
#include <windows.h>
#endif
#include <ffi.h>
#include <ffi_common.h>
@ -47,10 +51,15 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
argp = stack;
if (ecif->cif->flags == FFI_TYPE_STRUCT)
if (ecif->cif->flags == FFI_TYPE_STRUCT
#ifdef X86_WIN64
&& (ecif->cif->rtype->size != 1 && ecif->cif->rtype->size != 2
&& ecif->cif->rtype->size != 4 && ecif->cif->rtype->size != 8)
#endif
)
{
*(void **) argp = ecif->rvalue;
argp += 4;
argp += sizeof(void*);
}
p_argv = ecif->avalue;
@ -62,53 +71,75 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
size_t z;
/* Align if necessary */
if ((sizeof(int) - 1) & (unsigned) argp)
argp = (char *) ALIGN(argp, sizeof(int));
if ((sizeof(void*) - 1) & (size_t) argp)
argp = (char *) ALIGN(argp, sizeof(void*));
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_SINT32:
*(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
break;
case FFI_TYPE_UINT32:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
break;
case FFI_TYPE_STRUCT:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
break;
default:
FFI_ASSERT(0);
}
}
#ifdef X86_WIN64
if (z > sizeof(ffi_arg)
|| ((*p_arg)->type == FFI_TYPE_STRUCT
&& (z != 1 && z != 2 && z != 4 && z != 8))
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
|| ((*p_arg)->type == FFI_TYPE_LONGDOUBLE)
#endif
)
{
z = sizeof(ffi_arg);
*(void **)argp = *p_argv;
}
else if ((*p_arg)->type == FFI_TYPE_FLOAT)
{
memcpy(argp, *p_argv, z);
}
else
{
memcpy(argp, *p_argv, z);
}
#endif
if (z < sizeof(ffi_arg))
{
z = sizeof(ffi_arg);
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(ffi_sarg *) argp = (ffi_sarg)*(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
*(ffi_arg *) argp = (ffi_arg)*(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
*(ffi_sarg *) argp = (ffi_sarg)*(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
*(ffi_arg *) argp = (ffi_arg)*(UINT16 *)(* p_argv);
break;
case FFI_TYPE_SINT32:
*(ffi_sarg *) argp = (ffi_sarg)*(SINT32 *)(* p_argv);
break;
case FFI_TYPE_UINT32:
*(ffi_arg *) argp = (ffi_arg)*(UINT32 *)(* p_argv);
break;
case FFI_TYPE_STRUCT:
*(ffi_arg *) argp = *(ffi_arg *)(* p_argv);
break;
default:
FFI_ASSERT(0);
}
}
else
{
memcpy(argp, *p_argv, z);
}
p_argv++;
#ifdef X86_WIN64
argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
#else
argp += z;
#endif
}
return;
@ -124,21 +155,32 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
#ifdef X86
case FFI_TYPE_STRUCT:
#endif
#if defined(X86) || defined(X86_DARWIN)
#if defined(X86) || defined (X86_WIN32) || defined(X86_FREEBSD) || defined(X86_DARWIN) || defined(X86_WIN64)
case FFI_TYPE_UINT8:
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT8:
case FFI_TYPE_SINT16:
#endif
#ifdef X86_WIN64
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
#endif
case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
#ifndef X86_WIN64
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
#endif
cif->flags = (unsigned) cif->rtype->type;
break;
case FFI_TYPE_UINT64:
#ifdef X86_WIN64
case FFI_TYPE_POINTER:
#endif
cif->flags = FFI_TYPE_SINT64;
break;
@ -154,7 +196,11 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
}
else if (cif->rtype->size == 4)
{
#ifdef X86_WIN64
cif->flags = FFI_TYPE_SMALL_STRUCT_4B;
#else
cif->flags = FFI_TYPE_INT; /* same as int type */
#endif
}
else if (cif->rtype->size == 8)
{
@ -163,12 +209,23 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
else
{
cif->flags = FFI_TYPE_STRUCT;
#ifdef X86_WIN64
// allocate space for return value pointer
cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG);
#endif
}
break;
#endif
default:
#ifdef X86_WIN64
cif->flags = FFI_TYPE_SINT64;
break;
case FFI_TYPE_INT:
cif->flags = FFI_TYPE_SINT32;
#else
cif->flags = FFI_TYPE_INT;
#endif
break;
}
@ -176,17 +233,38 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
cif->bytes = (cif->bytes + 15) & ~0xF;
#endif
#ifdef X86_WIN64
{
unsigned int i;
ffi_type **ptr;
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
{
if (((*ptr)->alignment - 1) & cif->bytes)
cif->bytes = ALIGN(cif->bytes, (*ptr)->alignment);
cif->bytes += ALIGN((*ptr)->size, FFI_SIZEOF_ARG);
}
}
// ensure space for storing four registers
cif->bytes += 4 * sizeof(ffi_arg);
#endif
return FFI_OK;
}
extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned *, void (*fn)(void));
unsigned, unsigned, unsigned *, void (*fn)(void));
#ifdef X86_WIN32
extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned *, void (*fn)(void));
unsigned, unsigned, unsigned *, void (*fn)(void));
#endif /* X86_WIN32 */
#ifdef X86_WIN64
extern int
ffi_call_win64(void (*)(char *, extended_cif *), extended_cif *,
unsigned, unsigned, unsigned *, void (*fn)(void));
#endif
void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
@ -195,30 +273,66 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
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 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))
#ifdef X86_WIN64
if (rvalue == NULL
&& cif->flags == FFI_TYPE_STRUCT
&& cif->rtype->size != 1 && cif->rtype->size != 2
&& cif->rtype->size != 4 && cif->rtype->size != 8)
{
ecif.rvalue = alloca((cif->rtype->size + 0xF) & ~0xF);
}
#else
if (rvalue == NULL
&& cif->flags == FFI_TYPE_STRUCT)
{
ecif.rvalue = alloca(cif->rtype->size);
}
#endif
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
#ifdef X86_WIN64
case FFI_WIN64:
{
// Make copies of all struct arguments
// NOTE: not sure if responsibility should be here or in caller
unsigned int i;
for (i=0; i < cif->nargs;i++) {
size_t size = cif->arg_types[i]->size;
if ((cif->arg_types[i]->type == FFI_TYPE_STRUCT
&& (size != 1 && size != 2 && size != 4 && size != 8))
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|| cif->arg_types[i]->type == FFI_TYPE_LONGDOUBLE
#endif
)
{
void *local = alloca(size);
memcpy(local, avalue[i], size);
avalue[i] = local;
}
}
ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
}
break;
#else
case FFI_SYSV:
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
fn);
fn);
break;
#ifdef X86_WIN32
case FFI_STDCALL:
ffi_call_STDCALL(ffi_prep_args, &ecif, cif->bytes, cif->flags,
ecif.rvalue, fn);
ecif.rvalue, fn);
break;
#endif /* X86_WIN32 */
#endif /* X86_WIN64 */
default:
FFI_ASSERT(0);
break;
@ -229,7 +343,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
/** private members **/
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
void** args, ffi_cif* cif);
void** args, ffi_cif* cif);
void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *)
__attribute__ ((regparm(1)));
unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *)
@ -240,9 +354,42 @@ void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *)
void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *)
__attribute__ ((regparm(1)));
#endif
#ifdef X86_WIN64
void FFI_HIDDEN ffi_closure_win64 (ffi_closure *);
#endif
/* This function is jumped to by the trampoline */
#ifdef X86_WIN64
void * FFI_HIDDEN
ffi_closure_win64_inner (ffi_closure *closure, void *args) {
ffi_cif *cif;
void **arg_area;
void *result;
void *resp = &result;
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 change RESP to point to the
* structure return address. */
ffi_prep_incoming_args_SYSV(args, &resp, arg_area, cif);
(closure->fun) (cif, resp, arg_area, closure->user_data);
/* The result is returned in rax. This does the right thing for
result types except for floats; we have to 'mov xmm0, rax' in the
caller to correct this.
TODO: structure sizes of 3 5 6 7 are returned by reference, too!!!
*/
return cif->rtype->size > sizeof(void *) ? resp : *(void **)resp;
}
#else
unsigned int FFI_HIDDEN
ffi_closure_SYSV_inner (closure, respp, args)
ffi_closure *closure;
@ -259,7 +406,7 @@ ffi_closure_SYSV_inner (closure, respp, args)
/* 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
* a structure, it will change RESP to point to the
* structure return address. */
ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif);
@ -268,10 +415,11 @@ ffi_closure_SYSV_inner (closure, respp, args)
return cif->flags;
}
#endif /* !X86_WIN64 */
static void
ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
ffi_cif *cif)
ffi_cif *cif)
{
register unsigned int i;
register void **p_argv;
@ -280,10 +428,20 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
argp = stack;
#ifdef X86_WIN64
if (cif->rtype->size > sizeof(ffi_arg)
|| (cif->flags == FFI_TYPE_STRUCT
&& (cif->rtype->size != 1 && cif->rtype->size != 2
&& cif->rtype->size != 4 && cif->rtype->size != 8))) {
*rvalue = *(void **) argp;
argp += sizeof(void *);
}
#else
if ( cif->flags == FFI_TYPE_STRUCT ) {
*rvalue = *(void **) argp;
argp += 4;
argp += sizeof(void *);
}
#endif
p_argv = avalue;
@ -292,30 +450,65 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
size_t z;
/* Align if necessary */
if ((sizeof(int) - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, sizeof(int));
if ((sizeof(void*) - 1) & (size_t) argp) {
argp = (char *) ALIGN(argp, sizeof(void*));
}
z = (*p_arg)->size;
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) argp;
#ifdef X86_WIN64
if ((*p_arg)->size > sizeof(ffi_arg)
|| ((*p_arg)->type == FFI_TYPE_STRUCT
&& ((*p_arg)->size != 1 && (*p_arg)->size != 2
&& (*p_arg)->size != 4 && (*p_arg)->size != 8)))
{
z = sizeof(void *);
*p_argv = *(void **)argp;
}
else
#endif
{
z = (*p_arg)->size;
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) argp;
}
p_argv++;
#ifdef X86_WIN64
argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
#else
argp += z;
#endif
}
return;
}
#define FFI_INIT_TRAMPOLINE_WIN64(TRAMP,FUN,CTX,MASK) \
{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
void* __fun = (void*)(FUN); \
void* __ctx = (void*)(CTX); \
*(unsigned char*) &__tramp[0] = 0x41; \
*(unsigned char*) &__tramp[1] = 0xbb; \
*(unsigned int*) &__tramp[2] = MASK; /* mov $mask, %r11 */ \
*(unsigned char*) &__tramp[6] = 0x48; \
*(unsigned char*) &__tramp[7] = 0xb8; \
*(void**) &__tramp[8] = __ctx; /* mov __ctx, %rax */ \
*(unsigned char *) &__tramp[16] = 0x49; \
*(unsigned char *) &__tramp[17] = 0xba; \
*(void**) &__tramp[18] = __fun; /* mov __fun, %r10 */ \
*(unsigned char *) &__tramp[26] = 0x41; \
*(unsigned char *) &__tramp[27] = 0xff; \
*(unsigned char *) &__tramp[28] = 0xe2; /* jmp %r10 */ \
}
/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */
#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \
unsigned int __dis = __fun - (__ctx + 10); \
unsigned int __dis = __fun - (__ctx + 10); \
*(unsigned char*) &__tramp[0] = 0xb8; \
*(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
*(unsigned char *) &__tramp[5] = 0xe9; \
@ -340,11 +533,23 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
ffi_status
ffi_prep_closure_loc (ffi_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data,
void *codeloc)
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data,
void *codeloc)
{
#ifdef X86_WIN64
#define ISFLOAT(IDX) (cif->arg_types[IDX]->type == FFI_TYPE_FLOAT || cif->arg_types[IDX]->type == FFI_TYPE_DOUBLE)
#define FLAG(IDX) (cif->nargs>(IDX)&&ISFLOAT(IDX)?(1<<(IDX)):0)
if (cif->abi == FFI_WIN64)
{
int mask = FLAG(0)|FLAG(1)|FLAG(2)|FLAG(3);
FFI_INIT_TRAMPOLINE_WIN64 (&closure->tramp[0],
&ffi_closure_win64,
codeloc, mask);
/* make sure we can execute here */
}
#else
if (cif->abi == FFI_SYSV)
{
FFI_INIT_TRAMPOLINE (&closure->tramp[0],
@ -358,7 +563,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
&ffi_closure_STDCALL,
(void*)codeloc, cif->bytes);
}
#endif
#endif /* X86_WIN32 */
#endif /* !X86_WIN64 */
else
{
return FFI_BAD_ABI;
@ -377,10 +583,10 @@ ffi_prep_closure_loc (ffi_closure* closure,
ffi_status
ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data,
void *codeloc)
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data,
void *codeloc)
{
int i;
@ -401,7 +607,7 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
codeloc);
codeloc);
closure->cif = cif;
closure->user_data = user_data;
@ -423,12 +629,12 @@ ffi_prep_args_raw(char *stack, extended_cif *ecif)
extern void
ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *, unsigned,
unsigned, unsigned *, void (*fn)(void));
unsigned, unsigned *, void (*fn)(void));
#ifdef X86_WIN32
extern void
ffi_call_STDCALL(void (*)(char *, extended_cif *), extended_cif *, unsigned,
unsigned, unsigned *, void (*fn)(void));
unsigned, unsigned *, void (*fn)(void));
#endif /* X86_WIN32 */
void
@ -440,8 +646,8 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
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 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))
@ -456,12 +662,12 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
{
case FFI_SYSV:
ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
ecif.rvalue, fn);
ecif.rvalue, fn);
break;
#ifdef X86_WIN32
case FFI_STDCALL:
ffi_call_STDCALL(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
ecif.rvalue, fn);
ecif.rvalue, fn);
break;
#endif /* X86_WIN32 */
default:
@ -472,4 +678,5 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
#endif
#endif /* __x86_64__ */
#endif /* !__x86_64__ || X86_WIN64 */

View File

@ -1,6 +1,6 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
Copyright (c) 2008 Red Hat, Inc.
ffi64.c - Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
Copyright (c) 2008 Red Hat, Inc.
x86-64 Foreign Function Interface
@ -145,13 +145,35 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_POINTER:
if (byte_offset + type->size <= 4)
classes[0] = X86_64_INTEGERSI_CLASS;
else
classes[0] = X86_64_INTEGER_CLASS;
return 1;
{
int size = byte_offset + type->size;
if (size <= 4)
{
classes[0] = X86_64_INTEGERSI_CLASS;
return 1;
}
else if (size <= 8)
{
classes[0] = X86_64_INTEGER_CLASS;
return 1;
}
else if (size <= 12)
{
classes[0] = X86_64_INTEGER_CLASS;
classes[1] = X86_64_INTEGERSI_CLASS;
return 2;
}
else if (size <= 16)
{
classes[0] = classes[1] = X86_64_INTEGERSI_CLASS;
return 2;
}
else
FFI_ASSERT (0);
}
case FFI_TYPE_FLOAT:
if (byte_offset == 0)
if (!(byte_offset % 8))
classes[0] = X86_64_SSESF_CLASS;
else
classes[0] = X86_64_SSE_CLASS;
@ -171,13 +193,21 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
int i;
enum x86_64_reg_class subclasses[MAX_CLASSES];
/* If the struct is larger than 16 bytes, pass it on the stack. */
if (type->size > 16)
/* If the struct is larger than 32 bytes, pass it on the stack. */
if (type->size > 32)
return 0;
for (i = 0; i < words; i++)
classes[i] = X86_64_NO_CLASS;
/* Zero sized arrays or structures are NO_CLASS. We return 0 to
signalize memory class, so handle it as special case. */
if (!words)
{
classes[0] = X86_64_NO_CLASS;
return 1;
}
/* Merge the fields of structure. */
for (ptr = type->elements; *ptr != NULL; ptr++)
{
@ -198,6 +228,20 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
byte_offset += (*ptr)->size;
}
if (words > 2)
{
/* When size > 16 bytes, if the first one isn't
X86_64_SSE_CLASS or any other ones aren't
X86_64_SSEUP_CLASS, everything should be passed in
memory. */
if (classes[0] != X86_64_SSE_CLASS)
return 0;
for (i = 1; i < words; i++)
if (classes[i] != X86_64_SSEUP_CLASS)
return 0;
}
/* Final merger cleanup. */
for (i = 0; i < words; i++)
{
@ -207,15 +251,25 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
return 0;
/* The X86_64_SSEUP_CLASS should be always preceded by
X86_64_SSE_CLASS. */
X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */
if (classes[i] == X86_64_SSEUP_CLASS
&& (i == 0 || classes[i - 1] != X86_64_SSE_CLASS))
classes[i] = X86_64_SSE_CLASS;
&& classes[i - 1] != X86_64_SSE_CLASS
&& classes[i - 1] != X86_64_SSEUP_CLASS)
{
/* The first one should never be X86_64_SSEUP_CLASS. */
FFI_ASSERT (i != 0);
classes[i] = X86_64_SSE_CLASS;
}
/* X86_64_X87UP_CLASS should be preceded by X86_64_X87_CLASS. */
/* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
everything should be passed in memory. */
if (classes[i] == X86_64_X87UP_CLASS
&& (i == 0 || classes[i - 1] != X86_64_X87_CLASS))
classes[i] = X86_64_SSE_CLASS;
&& (classes[i - 1] != X86_64_X87_CLASS))
{
/* The first one should never be X86_64_X87UP_CLASS. */
FFI_ASSERT (i != 0);
return 0;
}
}
return words;
}
@ -528,10 +582,10 @@ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
argp += arg_types[i]->size;
}
/* If the argument is in a single register, or two consecutive
registers, then we can use that address directly. */
integer registers, then we can use that address directly. */
else if (n == 1
|| (n == 2
&& SSE_CLASS_P (classes[0]) == SSE_CLASS_P (classes[1])))
|| (n == 2 && !(SSE_CLASS_P (classes[0])
|| SSE_CLASS_P (classes[1]))))
{
/* The argument is in a single register. */
if (SSE_CLASS_P (classes[0]))

View File

@ -36,11 +36,26 @@
#define X86
#endif
#ifdef X86_WIN64
#define FFI_SIZEOF_ARG 8
#define USE_BUILTIN_FFS 0 // not yet implemented in mingw-64
#endif
/* ---- Generic type definitions ----------------------------------------- */
#ifndef LIBFFI_ASM
#ifdef X86_WIN64
#ifdef _MSC_VER
typedef unsigned __int64 ffi_arg;
typedef __int64 ffi_sarg;
#else
typedef unsigned long long ffi_arg;
typedef long long ffi_sarg;
#endif
#else
typedef unsigned long ffi_arg;
typedef signed long ffi_sarg;
#endif
typedef enum ffi_abi {
FFI_FIRST_ABI = 0,
@ -53,6 +68,11 @@ typedef enum ffi_abi {
FFI_DEFAULT_ABI = FFI_SYSV,
#endif
#ifdef X86_WIN64
FFI_WIN64,
FFI_DEFAULT_ABI = FFI_WIN64,
#else
/* ---- Intel x86 and AMD x86-64 - */
#if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__))
FFI_SYSV,
@ -63,6 +83,7 @@ typedef enum ffi_abi {
FFI_DEFAULT_ABI = FFI_UNIX64,
#endif
#endif
#endif /* X86_WIN64 */
FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
} ffi_abi;
@ -73,6 +94,7 @@ typedef enum ffi_abi {
#define FFI_CLOSURES 1
#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
#define FFI_TRAMPOLINE_SIZE 24
@ -81,10 +103,18 @@ typedef enum ffi_abi {
#ifdef X86_WIN32
#define FFI_TRAMPOLINE_SIZE 13
#else
#ifdef X86_WIN64
#define FFI_TRAMPOLINE_SIZE 29
#define FFI_NATIVE_RAW_API 0
#define FFI_NO_RAW_API 1
#else
#define FFI_TRAMPOLINE_SIZE 10
#endif
#endif
#ifndef X86_WIN64
#define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
#endif
#endif
#endif

View File

@ -242,9 +242,20 @@ ffi_closure_SYSV:
#if !FFI_NO_RAW_API
/* Precalculate for e.g. the Solaris 10/x86 assembler. */
#if FFI_TRAMPOLINE_SIZE == 10
#define RAW_CLOSURE_CIF_OFFSET 12
#define RAW_CLOSURE_FUN_OFFSET 16
#define RAW_CLOSURE_USER_DATA_OFFSET 20
#elif FFI_TRAMPOLINE_SIZE == 24
#define RAW_CLOSURE_CIF_OFFSET 24
#define RAW_CLOSURE_FUN_OFFSET 28
#define RAW_CLOSURE_USER_DATA_OFFSET 32
#else
#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
#endif
#define CIF_FLAGS_OFFSET 20
.align 4
@ -343,10 +354,12 @@ ffi_closure_raw_SYSV:
.long .LEFDE1-.LASFDE1 /* FDE Length */
.LASFDE1:
.long .LASFDE1-.Lframe1 /* FDE CIE offset */
#ifdef __PIC__
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
.long .LFB1-. /* FDE initial location */
#elif defined __PIC__
.long .LFB1@rel
#else
.long .LFB1 /* FDE initial location */
.long .LFB1
#endif
.long .LFE1-.LFB1 /* FDE address range */
#ifdef __PIC__
@ -368,8 +381,10 @@ ffi_closure_raw_SYSV:
.long .LEFDE2-.LASFDE2 /* FDE Length */
.LASFDE2:
.long .LASFDE2-.Lframe1 /* FDE CIE offset */
#ifdef __PIC__
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
.long .LFB2-. /* FDE initial location */
#elif defined __PIC__
.long .LFB2@rel
#else
.long .LFB2
#endif
@ -402,8 +417,10 @@ ffi_closure_raw_SYSV:
.long .LEFDE3-.LASFDE3 /* FDE Length */
.LASFDE3:
.long .LASFDE3-.Lframe1 /* FDE CIE offset */
#ifdef __PIC__
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
.long .LFB3-. /* FDE initial location */
#elif defined __PIC__
.long .LFB3@rel
#else
.long .LFB3
#endif

View File

@ -89,7 +89,6 @@ ffi_call_unix64:
addq %r11, %r10
jmp *%r10
.section .rodata
.Lstore_table:
.long .Lst_void-.Lstore_table /* FFI_TYPE_VOID */
.long .Lst_sint32-.Lstore_table /* FFI_TYPE_INT */
@ -107,7 +106,6 @@ ffi_call_unix64:
.long .Lst_struct-.Lstore_table /* FFI_TYPE_STRUCT */
.long .Lst_int64-.Lstore_table /* FFI_TYPE_POINTER */
.text
.align 2
.Lst_void:
ret
@ -240,7 +238,6 @@ ffi_closure_unix64:
addq %r11, %r10
jmp *%r10
.section .rodata
.Lload_table:
.long .Lld_void-.Lload_table /* FFI_TYPE_VOID */
.long .Lld_int32-.Lload_table /* FFI_TYPE_INT */
@ -258,7 +255,6 @@ ffi_closure_unix64:
.long .Lld_struct-.Lload_table /* FFI_TYPE_STRUCT */
.long .Lld_int64-.Lload_table /* FFI_TYPE_POINTER */
.text
.align 2
.Lld_void:
ret
@ -351,7 +347,11 @@ ffi_closure_unix64:
.long .LEFDE1-.LASFDE1 /* FDE Length */
.LASFDE1:
.long .LASFDE1-.Lframe1 /* FDE CIE offset */
#if HAVE_AS_X86_PCREL
.long .LUW0-. /* FDE initial location */
#else
.long .LUW0@rel
#endif
.long .LUW4-.LUW0 /* FDE address range */
.uleb128 0x0 /* Augmentation size */
@ -389,7 +389,11 @@ ffi_closure_unix64:
.long .LEFDE3-.LASFDE3 /* FDE Length */
.LASFDE3:
.long .LASFDE3-.Lframe1 /* FDE CIE offset */
#if HAVE_AS_X86_PCREL
.long .LUW5-. /* FDE initial location */
#else
.long .LUW5@rel
#endif
.long .LUW9-.LUW5 /* FDE address range */
.uleb128 0x0 /* Augmentation size */

View File

@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
win32.S - Copyright (c) 1996, 1998, 2001, 2002 Red Hat, Inc.
win32.S - Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
Copyright (c) 2001 John Beniton
Copyright (c) 2002 Ranjit Mathew
@ -17,32 +17,33 @@
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.
----------------------------------------------------------------------- */
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
.globl ffi_prep_args
.text
# This assumes we are using gas.
.balign 16
.globl _ffi_call_SYSV
.globl _ffi_call_SYSV
.def _ffi_call_SYSV; .scl 2; .type 32; .endef
_ffi_call_SYSV:
.LFB1:
pushl %ebp
.LCFI0:
movl %esp,%ebp
.LCFI1:
# Make room for all of the new args.
movl 16(%ebp),%ecx
subl %ecx,%esp
@ -62,100 +63,137 @@ _ffi_call_SYSV:
call *28(%ebp)
# Remove the space we pushed for the args
movl 16(%ebp),%ecx
addl %ecx,%esp
# Load %ecx with the return type code
movl 20(%ebp),%ecx
# If the return value pointer is NULL, assume no return value.
cmpl $0,24(%ebp)
jne retint
jne 0f
# Even if there is no space for the return value, we are
# obliged to handle floating-point values.
cmpl $FFI_TYPE_FLOAT,%ecx
jne noretval
jne .Lnoretval
fstp %st(0)
jmp epilogue
retint:
cmpl $FFI_TYPE_INT,%ecx
jne retfloat
jmp .Lepilogue
0:
call 1f
# Do not insert anything here between the call and the jump table.
.Lstore_table:
.long .Lnoretval /* FFI_TYPE_VOID */
.long .Lretint /* FFI_TYPE_INT */
.long .Lretfloat /* FFI_TYPE_FLOAT */
.long .Lretdouble /* FFI_TYPE_DOUBLE */
.long .Lretlongdouble /* FFI_TYPE_LONGDOUBLE */
.long .Lretuint8 /* FFI_TYPE_UINT8 */
.long .Lretsint8 /* FFI_TYPE_SINT8 */
.long .Lretuint16 /* FFI_TYPE_UINT16 */
.long .Lretsint16 /* FFI_TYPE_SINT16 */
.long .Lretint /* FFI_TYPE_UINT32 */
.long .Lretint /* FFI_TYPE_SINT32 */
.long .Lretint64 /* FFI_TYPE_UINT64 */
.long .Lretint64 /* FFI_TYPE_SINT64 */
.long .Lretstruct /* FFI_TYPE_STRUCT */
.long .Lretint /* FFI_TYPE_POINTER */
.long .Lretstruct1b /* FFI_TYPE_SMALL_STRUCT_1B */
.long .Lretstruct2b /* FFI_TYPE_SMALL_STRUCT_2B */
.long .Lretstruct4b /* FFI_TYPE_SMALL_STRUCT_4B */
1:
add %ecx, %ecx
add %ecx, %ecx
add (%esp),%ecx
add $4, %esp
jmp *(%ecx)
/* Sign/zero extend as appropriate. */
.Lretsint8:
movsbl %al, %eax
jmp .Lretint
.Lretsint16:
movswl %ax, %eax
jmp .Lretint
.Lretuint8:
movzbl %al, %eax
jmp .Lretint
.Lretuint16:
movzwl %ax, %eax
jmp .Lretint
.Lretint:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
jmp epilogue
jmp .Lepilogue
retfloat:
cmpl $FFI_TYPE_FLOAT,%ecx
jne retdouble
.Lretfloat:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstps (%ecx)
jmp epilogue
jmp .Lepilogue
retdouble:
cmpl $FFI_TYPE_DOUBLE,%ecx
jne retlongdouble
.Lretdouble:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstpl (%ecx)
jmp epilogue
jmp .Lepilogue
retlongdouble:
cmpl $FFI_TYPE_LONGDOUBLE,%ecx
jne retint64
.Lretlongdouble:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstpt (%ecx)
jmp epilogue
jmp .Lepilogue
retint64:
cmpl $FFI_TYPE_SINT64,%ecx
jne retstruct1b
.Lretint64:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
movl %edx,4(%ecx)
retstruct1b:
cmpl $FFI_TYPE_SINT8,%ecx
jne retstruct2b
jmp .Lepilogue
.Lretstruct1b:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movb %al,0(%ecx)
jmp epilogue
jmp .Lepilogue
retstruct2b:
cmpl $FFI_TYPE_SINT16,%ecx
jne retstruct
.Lretstruct2b:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movw %ax,0(%ecx)
jmp epilogue
retstruct:
jmp .Lepilogue
.Lretstruct4b:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
jmp .Lepilogue
.Lretstruct:
# Nothing to do!
noretval:
epilogue:
.Lnoretval:
.Lepilogue:
movl %ebp,%esp
popl %ebp
ret
.ffi_call_SYSV_end:
.LFE1:
# This assumes we are using gas.
.balign 16
.globl _ffi_call_STDCALL
.globl _ffi_call_STDCALL
.def _ffi_call_STDCALL; .scl 2; .type 32; .endef
_ffi_call_STDCALL:
.LFB2:
pushl %ebp
.LCFI2:
movl %esp,%ebp
.LCFI3:
# Make room for all of the new args.
movl 16(%ebp),%ecx
subl %ecx,%esp
@ -182,103 +220,133 @@ _ffi_call_STDCALL:
# If the return value pointer is NULL, assume no return value.
cmpl $0,24(%ebp)
jne sc_retint
jne 0f
# Even if there is no space for the return value, we are
# obliged to handle floating-point values.
cmpl $FFI_TYPE_FLOAT,%ecx
jne sc_noretval
jne .Lsc_noretval
fstp %st(0)
jmp sc_epilogue
jmp .Lsc_epilogue
sc_retint:
cmpl $FFI_TYPE_INT,%ecx
jne sc_retfloat
0:
call 1f
# Do not insert anything here between the call and the jump table.
.Lsc_store_table:
.long .Lsc_noretval /* FFI_TYPE_VOID */
.long .Lsc_retint /* FFI_TYPE_INT */
.long .Lsc_retfloat /* FFI_TYPE_FLOAT */
.long .Lsc_retdouble /* FFI_TYPE_DOUBLE */
.long .Lsc_retlongdouble /* FFI_TYPE_LONGDOUBLE */
.long .Lsc_retuint8 /* FFI_TYPE_UINT8 */
.long .Lsc_retsint8 /* FFI_TYPE_SINT8 */
.long .Lsc_retuint16 /* FFI_TYPE_UINT16 */
.long .Lsc_retsint16 /* FFI_TYPE_SINT16 */
.long .Lsc_retint /* FFI_TYPE_UINT32 */
.long .Lsc_retint /* FFI_TYPE_SINT32 */
.long .Lsc_retint64 /* FFI_TYPE_UINT64 */
.long .Lsc_retint64 /* FFI_TYPE_SINT64 */
.long .Lsc_retstruct /* FFI_TYPE_STRUCT */
.long .Lsc_retint /* FFI_TYPE_POINTER */
.long .Lsc_retstruct1b /* FFI_TYPE_SMALL_STRUCT_1B */
.long .Lsc_retstruct2b /* FFI_TYPE_SMALL_STRUCT_2B */
.long .Lsc_retstruct4b /* FFI_TYPE_SMALL_STRUCT_4B */
1:
add %ecx, %ecx
add %ecx, %ecx
add (%esp),%ecx
add $4, %esp
jmp *(%ecx)
/* Sign/zero extend as appropriate. */
.Lsc_retsint8:
movsbl %al, %eax
jmp .Lsc_retint
.Lsc_retsint16:
movswl %ax, %eax
jmp .Lsc_retint
.Lsc_retuint8:
movzbl %al, %eax
jmp .Lsc_retint
.Lsc_retuint16:
movzwl %ax, %eax
jmp .Lsc_retint
.Lsc_retint:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
jmp sc_epilogue
jmp .Lsc_epilogue
sc_retfloat:
cmpl $FFI_TYPE_FLOAT,%ecx
jne sc_retdouble
.Lsc_retfloat:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstps (%ecx)
jmp sc_epilogue
jmp .Lsc_epilogue
sc_retdouble:
cmpl $FFI_TYPE_DOUBLE,%ecx
jne sc_retlongdouble
.Lsc_retdouble:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstpl (%ecx)
jmp sc_epilogue
jmp .Lsc_epilogue
sc_retlongdouble:
cmpl $FFI_TYPE_LONGDOUBLE,%ecx
jne sc_retint64
.Lsc_retlongdouble:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstpt (%ecx)
jmp sc_epilogue
jmp .Lsc_epilogue
sc_retint64:
cmpl $FFI_TYPE_SINT64,%ecx
jne sc_retstruct1b
.Lsc_retint64:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
movl %edx,4(%ecx)
jmp .Lsc_epilogue
sc_retstruct1b:
cmpl $FFI_TYPE_SINT8,%ecx
jne sc_retstruct2b
.Lsc_retstruct1b:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movb %al,0(%ecx)
jmp sc_epilogue
jmp .Lsc_epilogue
sc_retstruct2b:
cmpl $FFI_TYPE_SINT16,%ecx
jne sc_retstruct
.Lsc_retstruct2b:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movw %ax,0(%ecx)
jmp sc_epilogue
jmp .Lsc_epilogue
sc_retstruct:
.Lsc_retstruct4b:
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
jmp .Lsc_epilogue
.Lsc_retstruct:
# Nothing to do!
sc_noretval:
sc_epilogue:
.Lsc_noretval:
.Lsc_epilogue:
movl %ebp,%esp
popl %ebp
ret
.ffi_call_STDCALL_end:
.LFE2:
.globl _ffi_closure_STDCALL
_ffi_closure_STDCALL:
pushl %ebp
movl %esp, %ebp
subl $40, %esp
leal -24(%ebp), %edx
movl %edx, -12(%ebp) /* resp */
leal 12(%ebp), %edx /* account for stub return address on stack */
movl %edx, 4(%esp) /* args */
leal -12(%ebp), %edx
movl %edx, (%esp) /* &resp */
call _ffi_closure_SYSV_inner
movl -12(%ebp), %ecx
jmp .Lcls_return_result
.ffi_closure_STDCALL_end:
.globl _ffi_closure_SYSV
# This assumes we are using gas.
.balign 16
.globl _ffi_closure_SYSV
.def _ffi_closure_SYSV; .scl 2; .type 32; .endef
_ffi_closure_SYSV:
.LFB3:
pushl %ebp
.LCFI4:
movl %esp, %ebp
.LCFI5:
subl $40, %esp
leal -24(%ebp), %edx
movl %edx, -12(%ebp) /* resp */
@ -288,48 +356,100 @@ _ffi_closure_SYSV:
movl %edx, (%esp) /* &resp */
call _ffi_closure_SYSV_inner
movl -12(%ebp), %ecx
.Lcls_return_result:
cmpl $FFI_TYPE_INT, %eax
je .Lcls_retint
cmpl $FFI_TYPE_FLOAT, %eax
je .Lcls_retfloat
cmpl $FFI_TYPE_DOUBLE, %eax
je .Lcls_retdouble
cmpl $FFI_TYPE_LONGDOUBLE, %eax
je .Lcls_retldouble
cmpl $FFI_TYPE_SINT64, %eax
je .Lcls_retllong
cmpl $FFI_TYPE_SINT8, %eax /* 1-byte struct */
je .Lcls_retstruct1
cmpl $FFI_TYPE_SINT16, %eax /* 2-bytes struct */
je .Lcls_retstruct2
.Lcls_epilogue:
movl %ebp, %esp
popl %ebp
ret
0:
call 1f
# Do not insert anything here between the call and the jump table.
.Lcls_store_table:
.long .Lcls_noretval /* FFI_TYPE_VOID */
.long .Lcls_retint /* FFI_TYPE_INT */
.long .Lcls_retfloat /* FFI_TYPE_FLOAT */
.long .Lcls_retdouble /* FFI_TYPE_DOUBLE */
.long .Lcls_retldouble /* FFI_TYPE_LONGDOUBLE */
.long .Lcls_retuint8 /* FFI_TYPE_UINT8 */
.long .Lcls_retsint8 /* FFI_TYPE_SINT8 */
.long .Lcls_retuint16 /* FFI_TYPE_UINT16 */
.long .Lcls_retsint16 /* FFI_TYPE_SINT16 */
.long .Lcls_retint /* FFI_TYPE_UINT32 */
.long .Lcls_retint /* FFI_TYPE_SINT32 */
.long .Lcls_retllong /* FFI_TYPE_UINT64 */
.long .Lcls_retllong /* FFI_TYPE_SINT64 */
.long .Lcls_retstruct /* FFI_TYPE_STRUCT */
.long .Lcls_retint /* FFI_TYPE_POINTER */
.long .Lcls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
.long .Lcls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
.long .Lcls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
1:
add %eax, %eax
add %eax, %eax
add (%esp),%eax
add $4, %esp
jmp *(%eax)
/* Sign/zero extend as appropriate. */
.Lcls_retsint8:
movsbl (%ecx), %eax
jmp .Lcls_epilogue
.Lcls_retsint16:
movswl (%ecx), %eax
jmp .Lcls_epilogue
.Lcls_retuint8:
movzbl (%ecx), %eax
jmp .Lcls_epilogue
.Lcls_retuint16:
movzwl (%ecx), %eax
jmp .Lcls_epilogue
.Lcls_retint:
movl (%ecx), %eax
jmp .Lcls_epilogue
.Lcls_retfloat:
flds (%ecx)
jmp .Lcls_epilogue
.Lcls_retdouble:
fldl (%ecx)
jmp .Lcls_epilogue
.Lcls_retldouble:
fldt (%ecx)
jmp .Lcls_epilogue
.Lcls_retllong:
movl (%ecx), %eax
movl 4(%ecx), %edx
jmp .Lcls_epilogue
.Lcls_retstruct1:
movsbl (%ecx), %eax
jmp .Lcls_epilogue
.Lcls_retstruct2:
movswl (%ecx), %eax
jmp .Lcls_epilogue
.Lcls_retstruct4:
movl (%ecx), %eax
jmp .Lcls_epilogue
.Lcls_retstruct:
# Caller expects us to pop struct return value pointer hidden arg.
movl %ebp, %esp
popl %ebp
ret $0x4
.Lcls_noretval:
.Lcls_epilogue:
movl %ebp, %esp
popl %ebp
ret
.ffi_closure_SYSV_end:
.LFE3:
#if !FFI_NO_RAW_API
@ -338,12 +458,18 @@ _ffi_closure_SYSV:
#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
#define CIF_FLAGS_OFFSET 20
.balign 16
.globl _ffi_closure_raw_SYSV
# This assumes we are using gas.
.balign 16
.globl _ffi_closure_raw_SYSV
.def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef
_ffi_closure_raw_SYSV:
.LFB4:
pushl %ebp
.LCFI6:
movl %esp, %ebp
.LCFI7:
pushl %esi
.LCFI8:
subl $36, %esp
movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
@ -355,37 +481,397 @@ _ffi_closure_raw_SYSV:
movl %esi, (%esp) /* cif */
call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
cmpl $FFI_TYPE_INT, %eax
je .Lrcls_retint
cmpl $FFI_TYPE_FLOAT, %eax
je .Lrcls_retfloat
cmpl $FFI_TYPE_DOUBLE, %eax
je .Lrcls_retdouble
cmpl $FFI_TYPE_LONGDOUBLE, %eax
je .Lrcls_retldouble
cmpl $FFI_TYPE_SINT64, %eax
je .Lrcls_retllong
0:
call 1f
# Do not insert anything here between the call and the jump table.
.Lrcls_store_table:
.long .Lrcls_noretval /* FFI_TYPE_VOID */
.long .Lrcls_retint /* FFI_TYPE_INT */
.long .Lrcls_retfloat /* FFI_TYPE_FLOAT */
.long .Lrcls_retdouble /* FFI_TYPE_DOUBLE */
.long .Lrcls_retldouble /* FFI_TYPE_LONGDOUBLE */
.long .Lrcls_retuint8 /* FFI_TYPE_UINT8 */
.long .Lrcls_retsint8 /* FFI_TYPE_SINT8 */
.long .Lrcls_retuint16 /* FFI_TYPE_UINT16 */
.long .Lrcls_retsint16 /* FFI_TYPE_SINT16 */
.long .Lrcls_retint /* FFI_TYPE_UINT32 */
.long .Lrcls_retint /* FFI_TYPE_SINT32 */
.long .Lrcls_retllong /* FFI_TYPE_UINT64 */
.long .Lrcls_retllong /* FFI_TYPE_SINT64 */
.long .Lrcls_retstruct /* FFI_TYPE_STRUCT */
.long .Lrcls_retint /* FFI_TYPE_POINTER */
.long .Lrcls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
.long .Lrcls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
.long .Lrcls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
1:
add %eax, %eax
add %eax, %eax
add (%esp),%eax
add $4, %esp
jmp *(%eax)
/* Sign/zero extend as appropriate. */
.Lrcls_retsint8:
movsbl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retsint16:
movswl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retuint8:
movzbl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retuint16:
movzwl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retint:
movl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retfloat:
flds -24(%ebp)
jmp .Lrcls_epilogue
.Lrcls_retdouble:
fldl -24(%ebp)
jmp .Lrcls_epilogue
.Lrcls_retldouble:
fldt -24(%ebp)
jmp .Lrcls_epilogue
.Lrcls_retllong:
movl -24(%ebp), %eax
movl -20(%ebp), %edx
jmp .Lrcls_epilogue
.Lrcls_retstruct1:
movsbl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retstruct2:
movswl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retstruct4:
movl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retstruct:
# Nothing to do!
.Lrcls_noretval:
.Lrcls_epilogue:
addl $36, %esp
popl %esi
popl %ebp
ret
.Lrcls_retint:
movl -24(%ebp), %eax
jmp .Lrcls_epilogue
.Lrcls_retfloat:
flds -24(%ebp)
jmp .Lrcls_epilogue
.Lrcls_retdouble:
fldl -24(%ebp)
jmp .Lrcls_epilogue
.Lrcls_retldouble:
fldt -24(%ebp)
jmp .Lrcls_epilogue
.Lrcls_retllong:
movl -24(%ebp), %eax
movl -20(%ebp), %edx
jmp .Lrcls_epilogue
.ffi_closure_raw_SYSV_end:
.LFE4:
#endif /* !FFI_NO_RAW_API */
# This assumes we are using gas.
.balign 16
.globl _ffi_closure_STDCALL
.def _ffi_closure_STDCALL; .scl 2; .type 32; .endef
_ffi_closure_STDCALL:
.LFB5:
pushl %ebp
.LCFI9:
movl %esp, %ebp
.LCFI10:
subl $40, %esp
leal -24(%ebp), %edx
movl %edx, -12(%ebp) /* resp */
leal 12(%ebp), %edx /* account for stub return address on stack */
movl %edx, 4(%esp) /* args */
leal -12(%ebp), %edx
movl %edx, (%esp) /* &resp */
call _ffi_closure_SYSV_inner
movl -12(%ebp), %ecx
0:
call 1f
# Do not insert anything here between the call and the jump table.
.Lscls_store_table:
.long .Lscls_noretval /* FFI_TYPE_VOID */
.long .Lscls_retint /* FFI_TYPE_INT */
.long .Lscls_retfloat /* FFI_TYPE_FLOAT */
.long .Lscls_retdouble /* FFI_TYPE_DOUBLE */
.long .Lscls_retldouble /* FFI_TYPE_LONGDOUBLE */
.long .Lscls_retuint8 /* FFI_TYPE_UINT8 */
.long .Lscls_retsint8 /* FFI_TYPE_SINT8 */
.long .Lscls_retuint16 /* FFI_TYPE_UINT16 */
.long .Lscls_retsint16 /* FFI_TYPE_SINT16 */
.long .Lscls_retint /* FFI_TYPE_UINT32 */
.long .Lscls_retint /* FFI_TYPE_SINT32 */
.long .Lscls_retllong /* FFI_TYPE_UINT64 */
.long .Lscls_retllong /* FFI_TYPE_SINT64 */
.long .Lscls_retstruct /* FFI_TYPE_STRUCT */
.long .Lscls_retint /* FFI_TYPE_POINTER */
.long .Lscls_retstruct1 /* FFI_TYPE_SMALL_STRUCT_1B */
.long .Lscls_retstruct2 /* FFI_TYPE_SMALL_STRUCT_2B */
.long .Lscls_retstruct4 /* FFI_TYPE_SMALL_STRUCT_4B */
1:
add %eax, %eax
add %eax, %eax
add (%esp),%eax
add $4, %esp
jmp *(%eax)
/* Sign/zero extend as appropriate. */
.Lscls_retsint8:
movsbl (%ecx), %eax
jmp .Lscls_epilogue
.Lscls_retsint16:
movswl (%ecx), %eax
jmp .Lscls_epilogue
.Lscls_retuint8:
movzbl (%ecx), %eax
jmp .Lscls_epilogue
.Lscls_retuint16:
movzwl (%ecx), %eax
jmp .Lscls_epilogue
.Lscls_retint:
movl (%ecx), %eax
jmp .Lscls_epilogue
.Lscls_retfloat:
flds (%ecx)
jmp .Lscls_epilogue
.Lscls_retdouble:
fldl (%ecx)
jmp .Lscls_epilogue
.Lscls_retldouble:
fldt (%ecx)
jmp .Lscls_epilogue
.Lscls_retllong:
movl (%ecx), %eax
movl 4(%ecx), %edx
jmp .Lscls_epilogue
.Lscls_retstruct1:
movsbl (%ecx), %eax
jmp .Lscls_epilogue
.Lscls_retstruct2:
movswl (%ecx), %eax
jmp .Lscls_epilogue
.Lscls_retstruct4:
movl (%ecx), %eax
jmp .Lscls_epilogue
.Lscls_retstruct:
# Nothing to do!
.Lscls_noretval:
.Lscls_epilogue:
movl %ebp, %esp
popl %ebp
ret
.ffi_closure_STDCALL_end:
.LFE5:
.section .eh_frame,"w"
.Lframe1:
.LSCIE1:
.long .LECIE1-.LASCIE1 /* Length of Common Information Entry */
.LASCIE1:
.long 0x0 /* CIE Identifier Tag */
.byte 0x1 /* CIE Version */
#ifdef __PIC__
.ascii "zR\0" /* CIE Augmentation */
#else
.ascii "\0" /* CIE Augmentation */
#endif
.byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
.byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
.byte 0x8 /* CIE RA Column */
#ifdef __PIC__
.byte 0x1 /* .uleb128 0x1; Augmentation size */
.byte 0x1b /* FDE Encoding (pcrel sdata4) */
#endif
.byte 0xc /* DW_CFA_def_cfa CFA = r4 + 4 = 4(%esp) */
.byte 0x4 /* .uleb128 0x4 */
.byte 0x4 /* .uleb128 0x4 */
.byte 0x88 /* DW_CFA_offset, column 0x8 %eip at CFA + 1 * -4 */
.byte 0x1 /* .uleb128 0x1 */
.align 4
.LECIE1:
.LSFDE1:
.long .LEFDE1-.LASFDE1 /* FDE Length */
.LASFDE1:
.long .LASFDE1-.Lframe1 /* FDE CIE offset */
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
.long .LFB1-. /* FDE initial location */
#else
.long .LFB1
#endif
.long .LFE1-.LFB1 /* FDE address range */
#ifdef __PIC__
.byte 0x0 /* .uleb128 0x0; Augmentation size */
#endif
/* DW_CFA_xxx CFI instructions go here. */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI0-.LFB1
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
.byte 0x8 /* .uleb128 0x8 */
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
.byte 0x2 /* .uleb128 0x2 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI1-.LCFI0
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
.byte 0x5 /* .uleb128 0x5 */
/* End of DW_CFA_xxx CFI instructions. */
.align 4
.LEFDE1:
.LSFDE2:
.long .LEFDE2-.LASFDE2 /* FDE Length */
.LASFDE2:
.long .LASFDE2-.Lframe1 /* FDE CIE offset */
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
.long .LFB2-. /* FDE initial location */
#else
.long .LFB2
#endif
.long .LFE2-.LFB2 /* FDE address range */
#ifdef __PIC__
.byte 0x0 /* .uleb128 0x0; Augmentation size */
#endif
/* DW_CFA_xxx CFI instructions go here. */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI2-.LFB2
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
.byte 0x8 /* .uleb128 0x8 */
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
.byte 0x2 /* .uleb128 0x2 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI3-.LCFI2
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
.byte 0x5 /* .uleb128 0x5 */
/* End of DW_CFA_xxx CFI instructions. */
.align 4
.LEFDE2:
.LSFDE3:
.long .LEFDE3-.LASFDE3 /* FDE Length */
.LASFDE3:
.long .LASFDE3-.Lframe1 /* FDE CIE offset */
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
.long .LFB3-. /* FDE initial location */
#else
.long .LFB3
#endif
.long .LFE3-.LFB3 /* FDE address range */
#ifdef __PIC__
.byte 0x0 /* .uleb128 0x0; Augmentation size */
#endif
/* DW_CFA_xxx CFI instructions go here. */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI4-.LFB3
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
.byte 0x8 /* .uleb128 0x8 */
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
.byte 0x2 /* .uleb128 0x2 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI5-.LCFI4
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
.byte 0x5 /* .uleb128 0x5 */
/* End of DW_CFA_xxx CFI instructions. */
.align 4
.LEFDE3:
#if !FFI_NO_RAW_API
.LSFDE4:
.long .LEFDE4-.LASFDE4 /* FDE Length */
.LASFDE4:
.long .LASFDE4-.Lframe1 /* FDE CIE offset */
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
.long .LFB4-. /* FDE initial location */
#else
.long .LFB4
#endif
.long .LFE4-.LFB4 /* FDE address range */
#ifdef __PIC__
.byte 0x0 /* .uleb128 0x0; Augmentation size */
#endif
/* DW_CFA_xxx CFI instructions go here. */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI6-.LFB4
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
.byte 0x8 /* .uleb128 0x8 */
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
.byte 0x2 /* .uleb128 0x2 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI7-.LCFI6
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
.byte 0x5 /* .uleb128 0x5 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI8-.LCFI7
.byte 0x86 /* DW_CFA_offset, column 0x6 %esi at CFA + 3 * -4 */
.byte 0x3 /* .uleb128 0x3 */
/* End of DW_CFA_xxx CFI instructions. */
.align 4
.LEFDE4:
#endif /* !FFI_NO_RAW_API */
.LSFDE5:
.long .LEFDE5-.LASFDE5 /* FDE Length */
.LASFDE5:
.long .LASFDE5-.Lframe1 /* FDE CIE offset */
#if defined __PIC__ && defined HAVE_AS_X86_PCREL
.long .LFB5-. /* FDE initial location */
#else
.long .LFB5
#endif
.long .LFE5-.LFB5 /* FDE address range */
#ifdef __PIC__
.byte 0x0 /* .uleb128 0x0; Augmentation size */
#endif
/* DW_CFA_xxx CFI instructions go here. */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI9-.LFB5
.byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
.byte 0x8 /* .uleb128 0x8 */
.byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
.byte 0x2 /* .uleb128 0x2 */
.byte 0x4 /* DW_CFA_advance_loc4 */
.long .LCFI10-.LCFI9
.byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
.byte 0x5 /* .uleb128 0x5 */
/* End of DW_CFA_xxx CFI instructions. */
.align 4
.LEFDE5:

View File

@ -0,0 +1,460 @@
#define LIBFFI_ASM
#include <fficonfig.h>
#include <ffi.h>
/* Constants for ffi_call_win64 */
#define STACK 0
#define PREP_ARGS_FN 32
#define ECIF 40
#define CIF_BYTES 48
#define CIF_FLAGS 56
#define RVALUE 64
#define FN 72
/* ffi_call_win64 (void (*prep_args_fn)(char *, extended_cif *),
extended_cif *ecif, unsigned bytes, unsigned flags,
unsigned *rvalue, void (*fn)());
*/
#ifdef _MSC_VER
PUBLIC ffi_call_win64
EXTRN __chkstk:NEAR
EXTRN ffi_closure_win64_inner:NEAR
_TEXT SEGMENT
;;; ffi_closure_win64 will be called with these registers set:
;;; rax points to 'closure'
;;; r11 contains a bit mask that specifies which of the
;;; first four parameters are float or double
;;;
;;; It must move the parameters passed in registers to their stack location,
;;; call ffi_closure_win64_inner for the actual work, then return the result.
;;;
ffi_closure_win64 PROC FRAME
;; copy register arguments onto stack
test r11, 1
jne first_is_float
mov QWORD PTR [rsp+8], rcx
jmp second
first_is_float:
movlpd QWORD PTR [rsp+8], xmm0
second:
test r11, 2
jne second_is_float
mov QWORD PTR [rsp+16], rdx
jmp third
second_is_float:
movlpd QWORD PTR [rsp+16], xmm1
third:
test r11, 4
jne third_is_float
mov QWORD PTR [rsp+24], r8
jmp fourth
third_is_float:
movlpd QWORD PTR [rsp+24], xmm2
fourth:
test r11, 8
jne fourth_is_float
mov QWORD PTR [rsp+32], r9
jmp done
fourth_is_float:
movlpd QWORD PTR [rsp+32], xmm3
done:
.ALLOCSTACK 40
sub rsp, 40
.ENDPROLOG
mov rcx, rax ; context is first parameter
mov rdx, rsp ; stack is second parameter
add rdx, 48 ; point to start of arguments
mov rax, ffi_closure_win64_inner
call rax ; call the real closure function
add rsp, 40
movd xmm0, rax ; If the closure returned a float,
; ffi_closure_win64_inner wrote it to rax
ret 0
ffi_closure_win64 ENDP
ffi_call_win64 PROC FRAME
;; copy registers onto stack
mov QWORD PTR [rsp+32], r9
mov QWORD PTR [rsp+24], r8
mov QWORD PTR [rsp+16], rdx
mov QWORD PTR [rsp+8], rcx
.PUSHREG rbp
push rbp
.ALLOCSTACK 48
sub rsp, 48 ; 00000030H
.SETFRAME rbp, 32
lea rbp, QWORD PTR [rsp+32]
.ENDPROLOG
mov eax, DWORD PTR CIF_BYTES[rbp]
add rax, 15
and rax, -16
call __chkstk
sub rsp, rax
lea rax, QWORD PTR [rsp+32]
mov QWORD PTR STACK[rbp], rax
mov rdx, QWORD PTR ECIF[rbp]
mov rcx, QWORD PTR STACK[rbp]
call QWORD PTR PREP_ARGS_FN[rbp]
mov rsp, QWORD PTR STACK[rbp]
movlpd xmm3, QWORD PTR [rsp+24]
movd r9, xmm3
movlpd xmm2, QWORD PTR [rsp+16]
movd r8, xmm2
movlpd xmm1, QWORD PTR [rsp+8]
movd rdx, xmm1
movlpd xmm0, QWORD PTR [rsp]
movd rcx, xmm0
call QWORD PTR FN[rbp]
ret_struct4b$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_4B
jne ret_struct2b$
mov rcx, QWORD PTR RVALUE[rbp]
mov DWORD PTR [rcx], eax
jmp ret_void$
ret_struct2b$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_2B
jne ret_struct1b$
mov rcx, QWORD PTR RVALUE[rbp]
mov WORD PTR [rcx], ax
jmp ret_void$
ret_struct1b$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_1B
jne ret_uint8$
mov rcx, QWORD PTR RVALUE[rbp]
mov BYTE PTR [rcx], al
jmp ret_void$
ret_uint8$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT8
jne ret_sint8$
mov rcx, QWORD PTR RVALUE[rbp]
movzx rax, al
mov QWORD PTR [rcx], rax
jmp ret_void$
ret_sint8$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT8
jne ret_uint16$
mov rcx, QWORD PTR RVALUE[rbp]
movsx rax, al
mov QWORD PTR [rcx], rax
jmp ret_void$
ret_uint16$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT16
jne ret_sint16$
mov rcx, QWORD PTR RVALUE[rbp]
movzx rax, ax
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_sint16$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT16
jne ret_uint32$
mov rcx, QWORD PTR RVALUE[rbp]
movsx rax, ax
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_uint32$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT32
jne ret_sint32$
mov rcx, QWORD PTR RVALUE[rbp]
mov eax, eax
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_sint32$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32
jne ret_float$
mov rcx, QWORD PTR RVALUE[rbp]
cdqe
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_float$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_FLOAT
jne SHORT ret_double$
mov rax, QWORD PTR RVALUE[rbp]
movss DWORD PTR [rax], xmm0
jmp SHORT ret_void$
ret_double$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE
jne SHORT ret_sint64$
mov rax, QWORD PTR RVALUE[rbp]
movlpd QWORD PTR [rax], xmm0
jmp SHORT ret_void$
ret_sint64$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64
jne ret_void$
mov rcx, QWORD PTR RVALUE[rbp]
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_void$:
xor rax, rax
lea rsp, QWORD PTR [rbp+16]
pop rbp
ret 0
ffi_call_win64 ENDP
_TEXT ENDS
END
#else
.text
.extern _ffi_closure_win64_inner
# ffi_closure_win64 will be called with these registers set:
# rax points to 'closure'
# r11 contains a bit mask that specifies which of the
# first four parameters are float or double
#
# It must move the parameters passed in registers to their stack location,
# call ffi_closure_win64_inner for the actual work, then return the result.
#
.balign 16
.globl _ffi_closure_win64
_ffi_closure_win64:
# copy register arguments onto stack
test $1,%r11
jne .Lfirst_is_float
mov %rcx, 8(%rsp)
jmp .Lsecond
.Lfirst_is_float:
movlpd %xmm0, 8(%rsp)
.Lsecond:
test $2, %r11
jne .Lsecond_is_float
mov %rdx, 16(%rsp)
jmp .Lthird
.Lsecond_is_float:
movlpd %xmm1, 16(%rsp)
.Lthird:
test $4, %r11
jne .Lthird_is_float
mov %r8,24(%rsp)
jmp .Lfourth
.Lthird_is_float:
movlpd %xmm2, 24(%rsp)
.Lfourth:
test $8, %r11
jne .Lfourth_is_float
mov %r9, 32(%rsp)
jmp .Ldone
.Lfourth_is_float:
movlpd %xmm3, 32(%rsp)
.Ldone:
#.ALLOCSTACK 40
sub $40, %rsp
#.ENDPROLOG
mov %rax, %rcx # context is first parameter
mov %rsp, %rdx # stack is second parameter
add $48, %rdx # point to start of arguments
mov $_ffi_closure_win64_inner, %rax
callq *%rax # call the real closure function
add $40, %rsp
movq %rax, %xmm0 # If the closure returned a float,
# ffi_closure_win64_inner wrote it to rax
retq
.ffi_closure_win64_end:
.balign 16
.globl _ffi_call_win64
_ffi_call_win64:
# copy registers onto stack
mov %r9,32(%rsp)
mov %r8,24(%rsp)
mov %rdx,16(%rsp)
mov %rcx,8(%rsp)
#.PUSHREG rbp
push %rbp
#.ALLOCSTACK 48
sub $48,%rsp
#.SETFRAME rbp, 32
lea 32(%rsp),%rbp
#.ENDPROLOG
mov CIF_BYTES(%rbp),%eax
add $15, %rax
and $-16, %rax
cmpq $0x1000, %rax
jb Lch_done
Lch_probe:
subq $0x1000,%rsp
orl $0x0, (%rsp)
subq $0x1000,%rax
cmpq $0x1000,%rax
ja Lch_probe
Lch_done:
subq %rax, %rsp
orl $0x0, (%rsp)
lea 32(%rsp), %rax
mov %rax, STACK(%rbp)
mov ECIF(%rbp), %rdx
mov STACK(%rbp), %rcx
callq *PREP_ARGS_FN(%rbp)
mov STACK(%rbp), %rsp
movlpd 24(%rsp), %xmm3
movd %xmm3, %r9
movlpd 16(%rsp), %xmm2
movd %xmm2, %r8
movlpd 8(%rsp), %xmm1
movd %xmm1, %rdx
movlpd (%rsp), %xmm0
movd %xmm0, %rcx
callq *FN(%rbp)
.Lret_struct4b:
cmpl $FFI_TYPE_SMALL_STRUCT_4B, CIF_FLAGS(%rbp)
jne .Lret_struct2b
mov RVALUE(%rbp), %rcx
mov %eax, (%rcx)
jmp .Lret_void
.Lret_struct2b:
cmpl $FFI_TYPE_SMALL_STRUCT_2B, CIF_FLAGS(%rbp)
jne .Lret_struct1b
mov RVALUE(%rbp), %rcx
mov %ax, (%rcx)
jmp .Lret_void
.Lret_struct1b:
cmpl $FFI_TYPE_SMALL_STRUCT_1B, CIF_FLAGS(%rbp)
jne .Lret_uint8
mov RVALUE(%rbp), %rcx
mov %al, (%rcx)
jmp .Lret_void
.Lret_uint8:
cmpl $FFI_TYPE_UINT8, CIF_FLAGS(%rbp)
jne .Lret_sint8
mov RVALUE(%rbp), %rcx
movzbq %al, %rax
movq %rax, (%rcx)
jmp .Lret_void
.Lret_sint8:
cmpl $FFI_TYPE_SINT8, CIF_FLAGS(%rbp)
jne .Lret_uint16
mov RVALUE(%rbp), %rcx
movsbq %al, %rax
movq %rax, (%rcx)
jmp .Lret_void
.Lret_uint16:
cmpl $FFI_TYPE_UINT16, CIF_FLAGS(%rbp)
jne .Lret_sint16
mov RVALUE(%rbp), %rcx
movzwq %ax, %rax
movq %rax, (%rcx)
jmp .Lret_void
.Lret_sint16:
cmpl $FFI_TYPE_SINT16, CIF_FLAGS(%rbp)
jne .Lret_uint32
mov RVALUE(%rbp), %rcx
movswq %ax, %rax
movq %rax, (%rcx)
jmp .Lret_void
.Lret_uint32:
cmpl $FFI_TYPE_UINT32, CIF_FLAGS(%rbp)
jne .Lret_sint32
mov RVALUE(%rbp), %rcx
movl %eax, %eax
movq %rax, (%rcx)
jmp .Lret_void
.Lret_sint32:
cmpl $FFI_TYPE_SINT32, CIF_FLAGS(%rbp)
jne .Lret_float
mov RVALUE(%rbp), %rcx
cltq
movq %rax, (%rcx)
jmp .Lret_void
.Lret_float:
cmpl $FFI_TYPE_FLOAT, CIF_FLAGS(%rbp)
jne .Lret_double
mov RVALUE(%rbp), %rax
movss %xmm0, (%rax)
jmp .Lret_void
.Lret_double:
cmpl $FFI_TYPE_DOUBLE, CIF_FLAGS(%rbp)
jne .Lret_sint64
mov RVALUE(%rbp), %rax
movlpd %xmm0, (%rax)
jmp .Lret_void
.Lret_sint64:
cmpl $FFI_TYPE_SINT64, CIF_FLAGS(%rbp)
jne .Lret_void
mov RVALUE(%rbp), %rcx
mov %rax, (%rcx)
jmp .Lret_void
.Lret_void:
xor %rax, %rax
lea 16(%rbp), %rsp
pop %rbp
retq
.ffi_call_win64_end:
#endif /* !_MSC_VER */

View File

@ -0,0 +1,80 @@
## Process this file with automake to produce Makefile.in.
AUTOMAKE_OPTIONS = foreign dejagnu
# Setup the testing framework, if you have one
EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \
echo $(top_builddir)/../expect/expect ; \
else echo expect ; fi`
RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
echo $(top_srcdir)/../dejagnu/runtest ; \
else echo runtest; fi`
AM_RUNTESTFLAGS =
CLEANFILES = *.exe core* *.log *.sum
EXTRA_DIST = libffi.special/special.exp \
libffi.special/unwindtest_ffi_call.cc libffi.special/unwindtest.cc \
libffi.special/ffitestcxx.h config/default.exp lib/target-libpath.exp \
lib/libffi-dg.exp lib/wrapper.exp libffi.call/float.c \
libffi.call/cls_multi_schar.c libffi.call/float3.c \
libffi.call/cls_3_1byte.c libffi.call/stret_large2.c \
libffi.call/cls_5_1_byte.c libffi.call/stret_medium.c \
libffi.call/promotion.c libffi.call/cls_dbls_struct.c \
libffi.call/nested_struct.c libffi.call/closure_fn1.c \
libffi.call/cls_4_1byte.c libffi.call/cls_float.c \
libffi.call/cls_2byte.c libffi.call/closure_fn4.c \
libffi.call/return_fl2.c libffi.call/nested_struct7.c \
libffi.call/cls_uint.c libffi.call/cls_align_sint64.c \
libffi.call/float1.c libffi.call/cls_19byte.c \
libffi.call/nested_struct1.c libffi.call/cls_4byte.c \
libffi.call/return_fl1.c libffi.call/cls_align_pointer.c \
libffi.call/nested_struct4.c libffi.call/nested_struct3.c \
libffi.call/struct7.c libffi.call/nested_struct9.c \
libffi.call/cls_sshort.c libffi.call/cls_ulonglong.c \
libffi.call/cls_pointer_stack.c libffi.call/cls_multi_uchar.c \
libffi.call/testclosure.c libffi.call/cls_3byte1.c \
libffi.call/struct6.c libffi.call/return_uc.c libffi.call/return_ll1.c \
libffi.call/cls_ushort.c libffi.call/stret_medium2.c \
libffi.call/cls_multi_ushortchar.c libffi.call/return_dbl2.c \
libffi.call/closure_loc_fn0.c libffi.call/return_sc.c \
libffi.call/nested_struct8.c libffi.call/cls_7_1_byte.c \
libffi.call/return_ll.c libffi.call/cls_pointer.c \
libffi.call/err_bad_abi.c libffi.call/return_dbl1.c \
libffi.call/call.exp libffi.call/ffitest.h libffi.call/strlen.c \
libffi.call/return_sl.c libffi.call/cls_1_1byte.c \
libffi.call/struct1.c libffi.call/cls_64byte.c libffi.call/return_ul.c \
libffi.call/cls_double.c libffi.call/many_win32.c \
libffi.call/cls_16byte.c libffi.call/cls_align_double.c \
libffi.call/cls_align_uint16.c libffi.call/cls_9byte1.c \
libffi.call/cls_multi_sshortchar.c libffi.call/cls_multi_ushort.c \
libffi.call/closure_stdcall.c libffi.call/return_fl.c \
libffi.call/strlen_win32.c libffi.call/return_ldl.c \
libffi.call/cls_align_float.c libffi.call/struct3.c \
libffi.call/cls_uchar.c libffi.call/cls_sint.c libffi.call/float2.c \
libffi.call/cls_align_longdouble_split.c \
libffi.call/cls_longdouble_va.c libffi.call/cls_multi_sshort.c \
libffi.call/stret_large.c libffi.call/cls_align_sint16.c \
libffi.call/nested_struct6.c libffi.call/cls_5byte.c \
libffi.call/return_dbl.c libffi.call/cls_20byte.c \
libffi.call/cls_8byte.c libffi.call/pyobjc-tc.c \
libffi.call/cls_24byte.c libffi.call/cls_align_longdouble_split2.c \
libffi.call/cls_6_1_byte.c libffi.call/cls_schar.c \
libffi.call/cls_18byte.c libffi.call/closure_fn3.c \
libffi.call/err_bad_typedef.c libffi.call/closure_fn2.c \
libffi.call/struct2.c libffi.call/cls_3byte2.c \
libffi.call/cls_align_longdouble.c libffi.call/cls_20byte1.c \
libffi.call/return_fl3.c libffi.call/cls_align_uint32.c \
libffi.call/problem1.c libffi.call/float4.c \
libffi.call/cls_align_uint64.c libffi.call/struct9.c \
libffi.call/closure_fn5.c libffi.call/cls_align_sint32.c \
libffi.call/closure_fn0.c libffi.call/closure_fn6.c \
libffi.call/struct4.c libffi.call/nested_struct2.c \
libffi.call/cls_6byte.c libffi.call/cls_7byte.c libffi.call/many.c \
libffi.call/struct8.c libffi.call/negint.c libffi.call/struct5.c \
libffi.call/cls_12byte.c libffi.call/cls_double_va.c \
libffi.call/cls_longdouble.c libffi.call/cls_9byte2.c \
libffi.call/nested_struct10.c libffi.call/nested_struct5.c \
libffi.call/huge_struct.c

View File

@ -0,0 +1,482 @@
# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/fficonfig.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
DEJATOOL = $(PACKAGE)
RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AM_RUNTESTFLAGS =
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASDEPMODE = @CCASDEPMODE@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
TARGET = @TARGET@
TARGETDIR = @TARGETDIR@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
toolexecdir = @toolexecdir@
toolexeclibdir = @toolexeclibdir@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign dejagnu
# Setup the testing framework, if you have one
EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \
echo $(top_builddir)/../expect/expect ; \
else echo expect ; fi`
RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
echo $(top_srcdir)/../dejagnu/runtest ; \
else echo runtest; fi`
CLEANFILES = *.exe core* *.log *.sum
EXTRA_DIST = libffi.special/special.exp \
libffi.special/unwindtest_ffi_call.cc libffi.special/unwindtest.cc \
libffi.special/ffitestcxx.h config/default.exp lib/target-libpath.exp \
lib/libffi-dg.exp lib/wrapper.exp libffi.call/float.c \
libffi.call/cls_multi_schar.c libffi.call/float3.c \
libffi.call/cls_3_1byte.c libffi.call/stret_large2.c \
libffi.call/cls_5_1_byte.c libffi.call/stret_medium.c \
libffi.call/promotion.c libffi.call/cls_dbls_struct.c \
libffi.call/nested_struct.c libffi.call/closure_fn1.c \
libffi.call/cls_4_1byte.c libffi.call/cls_float.c \
libffi.call/cls_2byte.c libffi.call/closure_fn4.c \
libffi.call/return_fl2.c libffi.call/nested_struct7.c \
libffi.call/cls_uint.c libffi.call/cls_align_sint64.c \
libffi.call/float1.c libffi.call/cls_19byte.c \
libffi.call/nested_struct1.c libffi.call/cls_4byte.c \
libffi.call/return_fl1.c libffi.call/cls_align_pointer.c \
libffi.call/nested_struct4.c libffi.call/nested_struct3.c \
libffi.call/struct7.c libffi.call/nested_struct9.c \
libffi.call/cls_sshort.c libffi.call/cls_ulonglong.c \
libffi.call/cls_pointer_stack.c libffi.call/cls_multi_uchar.c \
libffi.call/testclosure.c libffi.call/cls_3byte1.c \
libffi.call/struct6.c libffi.call/return_uc.c libffi.call/return_ll1.c \
libffi.call/cls_ushort.c libffi.call/stret_medium2.c \
libffi.call/cls_multi_ushortchar.c libffi.call/return_dbl2.c \
libffi.call/closure_loc_fn0.c libffi.call/return_sc.c \
libffi.call/nested_struct8.c libffi.call/cls_7_1_byte.c \
libffi.call/return_ll.c libffi.call/cls_pointer.c \
libffi.call/err_bad_abi.c libffi.call/return_dbl1.c \
libffi.call/call.exp libffi.call/ffitest.h libffi.call/strlen.c \
libffi.call/return_sl.c libffi.call/cls_1_1byte.c \
libffi.call/struct1.c libffi.call/cls_64byte.c libffi.call/return_ul.c \
libffi.call/cls_double.c libffi.call/many_win32.c \
libffi.call/cls_16byte.c libffi.call/cls_align_double.c \
libffi.call/cls_align_uint16.c libffi.call/cls_9byte1.c \
libffi.call/cls_multi_sshortchar.c libffi.call/cls_multi_ushort.c \
libffi.call/closure_stdcall.c libffi.call/return_fl.c \
libffi.call/strlen_win32.c libffi.call/return_ldl.c \
libffi.call/cls_align_float.c libffi.call/struct3.c \
libffi.call/cls_uchar.c libffi.call/cls_sint.c libffi.call/float2.c \
libffi.call/cls_align_longdouble_split.c \
libffi.call/cls_longdouble_va.c libffi.call/cls_multi_sshort.c \
libffi.call/stret_large.c libffi.call/cls_align_sint16.c \
libffi.call/nested_struct6.c libffi.call/cls_5byte.c \
libffi.call/return_dbl.c libffi.call/cls_20byte.c \
libffi.call/cls_8byte.c libffi.call/pyobjc-tc.c \
libffi.call/cls_24byte.c libffi.call/cls_align_longdouble_split2.c \
libffi.call/cls_6_1_byte.c libffi.call/cls_schar.c \
libffi.call/cls_18byte.c libffi.call/closure_fn3.c \
libffi.call/err_bad_typedef.c libffi.call/closure_fn2.c \
libffi.call/struct2.c libffi.call/cls_3byte2.c \
libffi.call/cls_align_longdouble.c libffi.call/cls_20byte1.c \
libffi.call/return_fl3.c libffi.call/cls_align_uint32.c \
libffi.call/problem1.c libffi.call/float4.c \
libffi.call/cls_align_uint64.c libffi.call/struct9.c \
libffi.call/closure_fn5.c libffi.call/cls_align_sint32.c \
libffi.call/closure_fn0.c libffi.call/closure_fn6.c \
libffi.call/struct4.c libffi.call/nested_struct2.c \
libffi.call/cls_6byte.c libffi.call/cls_7byte.c libffi.call/many.c \
libffi.call/struct8.c libffi.call/negint.c libffi.call/struct5.c \
libffi.call/cls_12byte.c libffi.call/cls_double_va.c \
libffi.call/cls_longdouble.c libffi.call/cls_9byte2.c \
libffi.call/nested_struct10.c libffi.call/nested_struct5.c \
libffi.call/huge_struct.c
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign testsuite/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
check-DEJAGNU: site.exp
srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
EXPECT=$(EXPECT); export EXPECT; \
runtest=$(RUNTEST); \
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
then :; else exit_status=1; fi; \
done; \
else echo "WARNING: could not find \`runtest'" 1>&2; :;\
fi; \
exit $$exit_status
site.exp: Makefile
@echo 'Making a new site.exp file...'
@echo '## these variables are automatically generated by make ##' >site.tmp
@echo '# Do not edit here. If you wish to override these values' >>site.tmp
@echo '# edit the last section' >>site.tmp
@echo 'set srcdir $(srcdir)' >>site.tmp
@echo "set objdir `pwd`" >>site.tmp
@echo 'set build_alias "$(build_alias)"' >>site.tmp
@echo 'set build_triplet $(build_triplet)' >>site.tmp
@echo 'set host_alias "$(host_alias)"' >>site.tmp
@echo 'set host_triplet $(host_triplet)' >>site.tmp
@echo 'set target_alias "$(target_alias)"' >>site.tmp
@echo 'set target_triplet $(target_triplet)' >>site.tmp
@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
@test ! -f site.exp || \
sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
@-rm -f site.bak
@test ! -f site.exp || mv site.exp site.bak
@mv site.tmp site.exp
distclean-DEJAGNU:
-rm -f site.exp site.bak
-l='$(DEJATOOL)'; for tool in $$l; do \
rm -f $$tool.sum $$tool.log; \
done
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-DEJAGNU distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: check-am install-am install-strip
.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \
clean-libtool distclean distclean-DEJAGNU distclean-generic \
distclean-libtool distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1 @@
load_lib "standard.exp"

View File

@ -0,0 +1,300 @@
# Copyright (C) 2003, 2005, 2008, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
proc load_gcc_lib { filename } {
global srcdir
load_file $srcdir/lib/$filename
}
load_lib dg.exp
load_lib libgloss.exp
load_gcc_lib target-libpath.exp
load_gcc_lib wrapper.exp
# Define libffi callbacks for dg.exp.
proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } {
# To get all \n in dg-output test strings to match printf output
# in a system that outputs it as \015\012 (i.e. not just \012), we
# need to change all \n into \r?\n. As there is no dejagnu flag
# or hook to do that, we simply change the text being tested.
# Unfortunately, we have to know that the variable is called
# dg-output-text and lives in the caller of libffi-dg-test, which
# is two calls up. Overriding proc dg-output would be longer and
# would necessarily have the same assumption.
upvar 2 dg-output-text output_match
if { [llength $output_match] > 1 } {
regsub -all "\n" [lindex $output_match 1] "\r?\n" x
set output_match [lreplace $output_match 1 1 $x]
}
# Set up the compiler flags, based on what we're going to do.
set options [list]
switch $do_what {
"compile" {
set compile_type "assembly"
set output_file "[file rootname [file tail $prog]].s"
}
"link" {
set compile_type "executable"
set output_file "[file rootname [file tail $prog]].exe"
# The following line is needed for targets like the i960 where
# the default output file is b.out. Sigh.
}
"run" {
set compile_type "executable"
# FIXME: "./" is to cope with "." not being in $PATH.
# Should this be handled elsewhere?
# YES.
set output_file "./[file rootname [file tail $prog]].exe"
# This is the only place where we care if an executable was
# created or not. If it was, dg.exp will try to run it.
remote_file build delete $output_file;
}
default {
perror "$do_what: not a valid dg-do keyword"
return ""
}
}
if { $extra_tool_flags != "" } {
lappend options "additional_flags=$extra_tool_flags"
}
set comp_output [libffi_target_compile "$prog" "$output_file" "$compile_type" $options];
return [list $comp_output $output_file]
}
proc libffi-dg-test { prog do_what extra_tool_flags } {
return [libffi-dg-test-1 target_compile $prog $do_what $extra_tool_flags]
}
proc libffi-init { args } {
global gluefile wrap_flags;
global srcdir
global blddirffi
global objdir
global TOOL_OPTIONS
global tool
global libffi_include
global libffi_link_flags
global tool_root_dir
global ld_library_path
set blddirffi [pwd]/..
verbose "libffi $blddirffi"
set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
if {$gccdir != ""} {
set gccdir [file dirname $gccdir]
}
verbose "gccdir $gccdir"
set ld_library_path "."
append ld_library_path ":${gccdir}"
set compiler "${gccdir}/xgcc"
if { [is_remote host] == 0 && [which $compiler] != 0 } {
foreach i "[exec $compiler --print-multi-lib]" {
set mldir ""
regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
set mldir [string trimright $mldir "\;@"]
if { "$mldir" == "." } {
continue
}
if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
append ld_library_path ":${gccdir}/${mldir}"
}
}
}
# add the library path for libffi.
append ld_library_path ":${blddirffi}/.libs"
verbose "ld_library_path: $ld_library_path"
# Point to the Libffi headers in libffi.
set libffi_include "${blddirffi}/include"
verbose "libffi_include $libffi_include"
set libffi_dir "${blddirffi}/.libs"
verbose "libffi_dir $libffi_dir"
if { $libffi_dir != "" } {
set libffi_dir [file dirname ${libffi_dir}]
set libffi_link_flags "-L${libffi_dir}/.libs"
}
set_ld_library_path_env_vars
libffi_maybe_build_wrapper "${objdir}/testglue.o"
}
proc libffi_exit { } {
global gluefile;
if [info exists gluefile] {
file_on_build delete $gluefile;
unset gluefile;
}
}
proc libffi_target_compile { source dest type options } {
global gluefile wrap_flags;
global srcdir
global blddirffi
global TOOL_OPTIONS
global libffi_link_flags
global libffi_include
global target_triplet
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
lappend options "libs=${gluefile}"
lappend options "ldflags=$wrap_flags"
}
# TOOL_OPTIONS must come first, so that it doesn't override testcase
# specific options.
if [info exists TOOL_OPTIONS] {
lappend options [concat "additional_flags=$TOOL_OPTIONS" $options];
}
# search for ffi_mips.h in srcdir, too
lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.."
lappend options "additional_flags=${libffi_link_flags}"
# Darwin needs a stack execution allowed flag.
if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"]
|| [istarget "*-*-darwin2*"] } {
lappend options "additional_flags=-Wl,-allow_stack_execute"
}
# If you're building the compiler with --prefix set to a place
# where it's not yet installed, then the linker won't be able to
# find the libgcc used by libffi.dylib. We could pass the
# -dylib_file option, but that's complicated, and it's much easier
# to just make the linker find libgcc using -L options.
if { [string match "*-*-darwin*" $target_triplet] } {
lappend options "libs= -shared-libgcc"
}
if { [string match "*-*-openbsd*" $target_triplet] } {
lappend options "libs= -lpthread"
}
lappend options "libs= -lffi"
verbose "options: $options"
return [target_compile $source $dest $type $options]
}
# Utility routines.
#
# search_for -- looks for a string match in a file
#
proc search_for { file pattern } {
set fd [open $file r]
while { [gets $fd cur_line]>=0 } {
if [string match "*$pattern*" $cur_line] then {
close $fd
return 1
}
}
close $fd
return 0
}
# Modified dg-runtest that can cycle through a list of optimization options
# as c-torture does.
proc libffi-dg-runtest { testcases default-extra-flags } {
global runtests
foreach test $testcases {
# If we're only testing specific files and this isn't one of
# them, skip it.
if ![runtest_file_p $runtests $test] {
continue
}
# Look for a loop within the source code - if we don't find one,
# don't pass -funroll[-all]-loops.
global torture_with_loops torture_without_loops
if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
set option_list $torture_with_loops
} else {
set option_list $torture_without_loops
}
set nshort [file tail [file dirname $test]]/[file tail $test]
foreach flags $option_list {
verbose "Testing $nshort, $flags" 1
dg-test $test $flags ${default-extra-flags}
}
}
}
# Like check_conditional_xfail, but callable from a dg test.
proc dg-xfail-if { args } {
set args [lreplace $args 0 0]
set selector "target [join [lindex $args 1]]"
if { [dg-process-target $selector] == "S" } {
global compiler_conditional_xfail_data
set compiler_conditional_xfail_data $args
}
}
# We need to make sure that additional_files and additional_sources
# are both cleared out after every test. It is not enough to clear
# them out *before* the next test run because gcc-target-compile gets
# run directly from some .exp files (outside of any test). (Those
# uses should eventually be eliminated.)
# Because the DG framework doesn't provide a hook that is run at the
# end of a test, we must replace dg-test with a wrapper.
if { [info procs saved-dg-test] == [list] } {
rename dg-test saved-dg-test
proc dg-test { args } {
global additional_files
global additional_sources
global errorInfo
if { [ catch { eval saved-dg-test $args } errmsg ] } {
set saved_info $errorInfo
set additional_files ""
set additional_sources ""
error $errmsg $saved_info
}
set additional_files ""
set additional_sources ""
}
}
# Local Variables:
# tcl-indent-level:4
# End:

View File

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

View File

@ -0,0 +1,45 @@
# Copyright (C) 2004, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# This file contains GCC-specifics for status wrappers for test programs.
# ${tool}_maybe_build_wrapper -- Build wrapper object if the target
# needs it. FILENAME is the path to the wrapper file. If there are
# additional arguments, they are command-line options to provide to
# the compiler when compiling FILENAME.
proc ${tool}_maybe_build_wrapper { filename args } {
global gluefile wrap_flags
if { [target_info needs_status_wrapper] != "" \
&& [target_info needs_status_wrapper] != "0" \
&& ![info exists gluefile] } {
set saved_wrap_compile_flags [target_info wrap_compile_flags]
set flags [join $args " "]
# The wrapper code may contain code that gcc objects on. This
# became true for dejagnu-1.4.4. The set of warnings and code
# that gcc objects on may change, so just make sure -w is always
# passed to turn off all warnings.
set_currtarget_info wrap_compile_flags \
"$saved_wrap_compile_flags -w $flags"
set result [build_wrapper $filename]
set_currtarget_info wrap_compile_flags "$saved_wrap_compile_flags"
if { $result != "" } {
set gluefile [lindex $result 0]
set wrap_flags [lindex $result 1]
}
}
}

View File

@ -0,0 +1,36 @@
# Copyright (C) 2003, 2006, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
# libffi testsuite that uses the 'dg.exp' driver.
load_lib libffi-dg.exp
dg-init
libffi-init
global srcdir subdir
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O0 -W -Wall" ""
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2" ""
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O3" ""
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-Os" ""
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-O2 -fomit-frame-pointer" ""
dg-finish
# Local Variables:
# tcl-indent-level:4
# End:

View File

@ -0,0 +1,89 @@
/* Area: closure_call
Purpose: Check multiple values passing from different type.
Also, exceed the limit of gpr and fpr registers on PowerPC
Darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030828 */
/* { dg-do run } */
#include "ffitest.h"
static void
closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) +
(int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] +
(int)(*(signed short *)args[4]) +
(int)(*(unsigned long long *)args[5]) +
(int)*(int *)args[6] + (int)(*(int *)args[7]) +
(int)(*(double *)args[8]) + (int)*(int *)args[9] +
(int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
(int)*(int *)args[12] + (int)(*(int *)args[13]) +
(int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
(int)*(unsigned long long *)args[0], (int)(*(int *)args[1]),
(int)(*(unsigned long long *)args[2]),
(int)*(int *)args[3], (int)(*(signed short *)args[4]),
(int)(*(unsigned long long *)args[5]),
(int)*(int *)args[6], (int)(*(int *)args[7]),
(int)(*(double *)args[8]), (int)*(int *)args[9],
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
(int)*(int *)args[12], (int)(*(int *)args[13]),
(int)(*(int *)args[14]),*(int *)args[15],
(int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
}
typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long,
int, signed short, unsigned long long, int,
int, double, int, int, float, int, int,
int, int);
int main (void)
{
ffi_cif cif;
void * code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int res;
cl_arg_types[0] = &ffi_type_uint64;
cl_arg_types[1] = &ffi_type_sint;
cl_arg_types[2] = &ffi_type_uint64;
cl_arg_types[3] = &ffi_type_sint;
cl_arg_types[4] = &ffi_type_sshort;
cl_arg_types[5] = &ffi_type_uint64;
cl_arg_types[6] = &ffi_type_sint;
cl_arg_types[7] = &ffi_type_sint;
cl_arg_types[8] = &ffi_type_double;
cl_arg_types[9] = &ffi_type_sint;
cl_arg_types[10] = &ffi_type_sint;
cl_arg_types[11] = &ffi_type_float;
cl_arg_types[12] = &ffi_type_sint;
cl_arg_types[13] = &ffi_type_sint;
cl_arg_types[14] = &ffi_type_sint;
cl_arg_types[15] = &ffi_type_sint;
cl_arg_types[16] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
(void *) 3 /* userdata */, code) == FFI_OK);
res = (*((closure_test_type0)code))
(1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13,
19, 21, 1);
/* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 680" } */
exit(0);
}

View File

@ -0,0 +1,81 @@
/* Area: closure_call.
Purpose: Check multiple values passing from different type.
Also, exceed the limit of gpr and fpr registers on PowerPC
Darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030828 */
/* { dg-do run } */
#include "ffitest.h"
static void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(float *)args[0] +(int)(*(float *)args[1]) +
(int)(*(float *)args[2]) + (int)*(float *)args[3] +
(int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) +
(int)*(float *)args[6] + (int)(*(int *)args[7]) +
(int)(*(double*)args[8]) + (int)*(int *)args[9] +
(int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
(int)*(int *)args[12] + (int)(*(int *)args[13]) +
(int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
(int)*(float *)args[0], (int)(*(float *)args[1]),
(int)(*(float *)args[2]), (int)*(float *)args[3],
(int)(*(signed short *)args[4]), (int)(*(float *)args[5]),
(int)*(float *)args[6], (int)(*(int *)args[7]),
(int)(*(double *)args[8]), (int)*(int *)args[9],
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
(int)*(int *)args[12], (int)(*(int *)args[13]),
(int)(*(int *)args[14]), *(int *)args[15],
(int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
}
typedef int (*closure_test_type1)(float, float, float, float, signed short,
float, float, int, double, int, int, float,
int, int, int, int);
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int res;
cl_arg_types[0] = &ffi_type_float;
cl_arg_types[1] = &ffi_type_float;
cl_arg_types[2] = &ffi_type_float;
cl_arg_types[3] = &ffi_type_float;
cl_arg_types[4] = &ffi_type_sshort;
cl_arg_types[5] = &ffi_type_float;
cl_arg_types[6] = &ffi_type_float;
cl_arg_types[7] = &ffi_type_sint;
cl_arg_types[8] = &ffi_type_double;
cl_arg_types[9] = &ffi_type_sint;
cl_arg_types[10] = &ffi_type_sint;
cl_arg_types[11] = &ffi_type_float;
cl_arg_types[12] = &ffi_type_sint;
cl_arg_types[13] = &ffi_type_sint;
cl_arg_types[14] = &ffi_type_sint;
cl_arg_types[15] = &ffi_type_sint;
cl_arg_types[16] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1,
(void *) 3 /* userdata */, code) == FFI_OK);
res = (*((closure_test_type1)code))
(1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13,
19, 21, 1);
/* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 255" } */
exit(0);
}

View File

@ -0,0 +1,81 @@
/* Area: closure_call
Purpose: Check multiple values passing from different type.
Also, exceed the limit of gpr and fpr registers on PowerPC
Darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030828 */
/* { dg-do run } */
#include "ffitest.h"
static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(double *)args[0] +(int)(*(double *)args[1]) +
(int)(*(double *)args[2]) + (int)*(double *)args[3] +
(int)(*(signed short *)args[4]) + (int)(*(double *)args[5]) +
(int)*(double *)args[6] + (int)(*(int *)args[7]) +
(int)(*(double *)args[8]) + (int)*(int *)args[9] +
(int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
(int)*(int *)args[12] + (int)(*(float *)args[13]) +
(int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
(int)*(double *)args[0], (int)(*(double *)args[1]),
(int)(*(double *)args[2]), (int)*(double *)args[3],
(int)(*(signed short *)args[4]), (int)(*(double *)args[5]),
(int)*(double *)args[6], (int)(*(int *)args[7]),
(int)(*(double*)args[8]), (int)*(int *)args[9],
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
(int)*(int *)args[12], (int)(*(float *)args[13]),
(int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata,
(int)*(ffi_arg *)resp);
}
typedef int (*closure_test_type2)(double, double, double, double, signed short,
double, double, int, double, int, int, float,
int, float, int, int);
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int res;
cl_arg_types[0] = &ffi_type_double;
cl_arg_types[1] = &ffi_type_double;
cl_arg_types[2] = &ffi_type_double;
cl_arg_types[3] = &ffi_type_double;
cl_arg_types[4] = &ffi_type_sshort;
cl_arg_types[5] = &ffi_type_double;
cl_arg_types[6] = &ffi_type_double;
cl_arg_types[7] = &ffi_type_sint;
cl_arg_types[8] = &ffi_type_double;
cl_arg_types[9] = &ffi_type_sint;
cl_arg_types[10] = &ffi_type_sint;
cl_arg_types[11] = &ffi_type_float;
cl_arg_types[12] = &ffi_type_sint;
cl_arg_types[13] = &ffi_type_float;
cl_arg_types[14] = &ffi_type_sint;
cl_arg_types[15] = &ffi_type_sint;
cl_arg_types[16] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn2,
(void *) 3 /* userdata */, code) == FFI_OK);
res = (*((closure_test_type2)code))
(1, 2, 3, 4, 127, 5, 6, 8, 9, 10, 11, 12.0, 13,
19.0, 21, 1);
/* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 255" } */
exit(0);
}

View File

@ -0,0 +1,82 @@
/* Area: closure_call
Purpose: Check multiple values passing from different type.
Also, exceed the limit of gpr and fpr registers on PowerPC
Darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030828 */
/* { dg-do run } */
#include "ffitest.h"
static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(float *)args[0] +(int)(*(float *)args[1]) +
(int)(*(float *)args[2]) + (int)*(float *)args[3] +
(int)(*(float *)args[4]) + (int)(*(float *)args[5]) +
(int)*(float *)args[6] + (int)(*(float *)args[7]) +
(int)(*(double *)args[8]) + (int)*(int *)args[9] +
(int)(*(float *)args[10]) + (int)(*(float *)args[11]) +
(int)*(int *)args[12] + (int)(*(float *)args[13]) +
(int)(*(float *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
(int)*(float *)args[0], (int)(*(float *)args[1]),
(int)(*(float *)args[2]), (int)*(float *)args[3],
(int)(*(float *)args[4]), (int)(*(float *)args[5]),
(int)*(float *)args[6], (int)(*(float *)args[7]),
(int)(*(double *)args[8]), (int)*(int *)args[9],
(int)(*(float *)args[10]), (int)(*(float *)args[11]),
(int)*(int *)args[12], (int)(*(float *)args[13]),
(int)(*(float *)args[14]), *(int *)args[15], (int)(intptr_t)userdata,
(int)*(ffi_arg *)resp);
}
typedef int (*closure_test_type3)(float, float, float, float, float, float,
float, float, double, int, float, float, int,
float, float, int);
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int res;
cl_arg_types[0] = &ffi_type_float;
cl_arg_types[1] = &ffi_type_float;
cl_arg_types[2] = &ffi_type_float;
cl_arg_types[3] = &ffi_type_float;
cl_arg_types[4] = &ffi_type_float;
cl_arg_types[5] = &ffi_type_float;
cl_arg_types[6] = &ffi_type_float;
cl_arg_types[7] = &ffi_type_float;
cl_arg_types[8] = &ffi_type_double;
cl_arg_types[9] = &ffi_type_sint;
cl_arg_types[10] = &ffi_type_float;
cl_arg_types[11] = &ffi_type_float;
cl_arg_types[12] = &ffi_type_sint;
cl_arg_types[13] = &ffi_type_float;
cl_arg_types[14] = &ffi_type_float;
cl_arg_types[15] = &ffi_type_sint;
cl_arg_types[16] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn3,
(void *) 3 /* userdata */, code) == FFI_OK);
res = (*((closure_test_type3)code))
(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9, 10, 11.11, 12.0, 13,
19.19, 21.21, 1);
/* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 19 21 1 3: 135" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 135" } */
exit(0);
}

View File

@ -0,0 +1,89 @@
/* Area: closure_call
Purpose: Check multiple long long values passing.
Also, exceed the limit of gpr and fpr registers on PowerPC
Darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20031026 */
/* { dg-do run } */
#include "ffitest.h"
static void
closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] +
(int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] +
(int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] +
(int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] +
(int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] +
(int)*(unsigned long long *)args[10] +
(int)*(unsigned long long *)args[11] +
(int)*(unsigned long long *)args[12] +
(int)*(unsigned long long *)args[13] +
(int)*(unsigned long long *)args[14] +
*(int *)args[15] + (intptr_t)userdata;
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
(int)*(unsigned long long *)args[0],
(int)*(unsigned long long *)args[1],
(int)*(unsigned long long *)args[2],
(int)*(unsigned long long *)args[3],
(int)*(unsigned long long *)args[4],
(int)*(unsigned long long *)args[5],
(int)*(unsigned long long *)args[6],
(int)*(unsigned long long *)args[7],
(int)*(unsigned long long *)args[8],
(int)*(unsigned long long *)args[9],
(int)*(unsigned long long *)args[10],
(int)*(unsigned long long *)args[11],
(int)*(unsigned long long *)args[12],
(int)*(unsigned long long *)args[13],
(int)*(unsigned long long *)args[14],
*(int *)args[15],
(int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
}
typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, int);
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int i, res;
for (i = 0; i < 15; i++) {
cl_arg_types[i] = &ffi_type_uint64;
}
cl_arg_types[15] = &ffi_type_sint;
cl_arg_types[16] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
(void *) 3 /* userdata */, code) == FFI_OK);
res = (*((closure_test_type0)code))
(1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11LL, 12LL,
13LL, 19LL, 21LL, 1);
/* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 680" } */
exit(0);
}

View File

@ -0,0 +1,92 @@
/* Area: closure_call
Purpose: Check multiple long long values passing.
Exceed the limit of gpr registers on PowerPC
Darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20031026 */
/* { dg-do run } */
#include "ffitest.h"
static void
closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] +
(int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] +
(int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] +
(int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] +
(int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] +
(int)*(int *)args[10] +
(int)*(unsigned long long *)args[11] +
(int)*(unsigned long long *)args[12] +
(int)*(unsigned long long *)args[13] +
(int)*(unsigned long long *)args[14] +
*(int *)args[15] + (intptr_t)userdata;
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
(int)*(unsigned long long *)args[0],
(int)*(unsigned long long *)args[1],
(int)*(unsigned long long *)args[2],
(int)*(unsigned long long *)args[3],
(int)*(unsigned long long *)args[4],
(int)*(unsigned long long *)args[5],
(int)*(unsigned long long *)args[6],
(int)*(unsigned long long *)args[7],
(int)*(unsigned long long *)args[8],
(int)*(unsigned long long *)args[9],
(int)*(int *)args[10],
(int)*(unsigned long long *)args[11],
(int)*(unsigned long long *)args[12],
(int)*(unsigned long long *)args[13],
(int)*(unsigned long long *)args[14],
*(int *)args[15],
(int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
}
typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, unsigned long long,
int, unsigned long long,
unsigned long long, unsigned long long,
unsigned long long, int);
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int i, res;
for (i = 0; i < 10; i++) {
cl_arg_types[i] = &ffi_type_uint64;
}
cl_arg_types[10] = &ffi_type_sint;
for (i = 11; i < 15; i++) {
cl_arg_types[i] = &ffi_type_uint64;
}
cl_arg_types[15] = &ffi_type_sint;
cl_arg_types[16] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn5,
(void *) 3 /* userdata */, code) == FFI_OK);
res = (*((closure_test_type0)code))
(1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11, 12LL,
13LL, 19LL, 21LL, 1);
/* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 680" } */
exit(0);
}

View File

@ -0,0 +1,90 @@
/* Area: closure_call
Purpose: Check multiple values passing from different type.
Also, exceed the limit of gpr and fpr registers on PowerPC.
Limitations: none.
PR: PR23404
Originator: <andreast@gcc.gnu.org> 20050830 */
/* { dg-do run } */
#include "ffitest.h"
static void
closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(unsigned long long *)args[0] +
(int)(*(unsigned long long *)args[1]) +
(int)(*(unsigned long long *)args[2]) +
(int)*(unsigned long long *)args[3] +
(int)(*(int *)args[4]) + (int)(*(double *)args[5]) +
(int)*(double *)args[6] + (int)(*(float *)args[7]) +
(int)(*(double *)args[8]) + (int)*(double *)args[9] +
(int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
(int)*(int *)args[12] + (int)(*(int *)args[13]) +
(int)(*(double *)args[14]) + (int)*(double *)args[15] +
(intptr_t)userdata;
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
(int)*(unsigned long long *)args[0],
(int)(*(unsigned long long *)args[1]),
(int)(*(unsigned long long *)args[2]),
(int)*(unsigned long long *)args[3],
(int)(*(int *)args[4]), (int)(*(double *)args[5]),
(int)*(double *)args[6], (int)(*(float *)args[7]),
(int)(*(double *)args[8]), (int)*(double *)args[9],
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
(int)*(int *)args[12], (int)(*(int *)args[13]),
(int)(*(double *)args[14]), (int)(*(double *)args[15]),
(int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
}
typedef int (*closure_test_type0)(unsigned long long,
unsigned long long,
unsigned long long,
unsigned long long,
int, double, double, float, double, double,
int, float, int, int, double, double);
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int res;
cl_arg_types[0] = &ffi_type_uint64;
cl_arg_types[1] = &ffi_type_uint64;
cl_arg_types[2] = &ffi_type_uint64;
cl_arg_types[3] = &ffi_type_uint64;
cl_arg_types[4] = &ffi_type_sint;
cl_arg_types[5] = &ffi_type_double;
cl_arg_types[6] = &ffi_type_double;
cl_arg_types[7] = &ffi_type_float;
cl_arg_types[8] = &ffi_type_double;
cl_arg_types[9] = &ffi_type_double;
cl_arg_types[10] = &ffi_type_sint;
cl_arg_types[11] = &ffi_type_float;
cl_arg_types[12] = &ffi_type_sint;
cl_arg_types[13] = &ffi_type_sint;
cl_arg_types[14] = &ffi_type_double;
cl_arg_types[15] = &ffi_type_double;
cl_arg_types[16] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
(void *) 3 /* userdata */, code) == FFI_OK);
res = (*((closure_test_type0)code))
(1, 2, 3, 4, 127, 429., 7., 8., 9.5, 10., 11, 12., 13,
19, 21., 1.);
/* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 680" } */
exit(0);
}

View File

@ -0,0 +1,95 @@
/* Area: closure_call
Purpose: Check multiple values passing from different type.
Also, exceed the limit of gpr and fpr registers on PowerPC
Darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030828 */
/* { dg-do run } */
#include "ffitest.h"
static void
closure_loc_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) +
(int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] +
(int)(*(signed short *)args[4]) +
(int)(*(unsigned long long *)args[5]) +
(int)*(int *)args[6] + (int)(*(int *)args[7]) +
(int)(*(double *)args[8]) + (int)*(int *)args[9] +
(int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
(int)*(int *)args[12] + (int)(*(int *)args[13]) +
(int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
(int)*(unsigned long long *)args[0], (int)(*(int *)args[1]),
(int)(*(unsigned long long *)args[2]),
(int)*(int *)args[3], (int)(*(signed short *)args[4]),
(int)(*(unsigned long long *)args[5]),
(int)*(int *)args[6], (int)(*(int *)args[7]),
(int)(*(double *)args[8]), (int)*(int *)args[9],
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
(int)*(int *)args[12], (int)(*(int *)args[13]),
(int)(*(int *)args[14]),*(int *)args[15],
(int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
}
typedef int (*closure_loc_test_type0)(unsigned long long, int, unsigned long long,
int, signed short, unsigned long long, int,
int, double, int, int, float, int, int,
int, int);
int main (void)
{
ffi_cif cif;
ffi_closure *pcl;
ffi_type * cl_arg_types[17];
int res;
void *codeloc;
cl_arg_types[0] = &ffi_type_uint64;
cl_arg_types[1] = &ffi_type_sint;
cl_arg_types[2] = &ffi_type_uint64;
cl_arg_types[3] = &ffi_type_sint;
cl_arg_types[4] = &ffi_type_sshort;
cl_arg_types[5] = &ffi_type_uint64;
cl_arg_types[6] = &ffi_type_sint;
cl_arg_types[7] = &ffi_type_sint;
cl_arg_types[8] = &ffi_type_double;
cl_arg_types[9] = &ffi_type_sint;
cl_arg_types[10] = &ffi_type_sint;
cl_arg_types[11] = &ffi_type_float;
cl_arg_types[12] = &ffi_type_sint;
cl_arg_types[13] = &ffi_type_sint;
cl_arg_types[14] = &ffi_type_sint;
cl_arg_types[15] = &ffi_type_sint;
cl_arg_types[16] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
pcl = ffi_closure_alloc(sizeof(ffi_closure), &codeloc);
CHECK(pcl != NULL);
CHECK(codeloc != NULL);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_loc_test_fn0,
(void *) 3 /* userdata */, codeloc) == FFI_OK);
CHECK(memcmp(pcl, codeloc, sizeof(*pcl)) == 0);
res = (*((closure_loc_test_type0)codeloc))
(1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13,
19, 21, 1);
/* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 680" } */
exit(0);
}

View File

@ -0,0 +1,64 @@
/* Area: closure_call (stdcall convention)
Purpose: Check handling when caller expects stdcall callee
Limitations: none.
PR: none.
Originator: <twalljava@dev.java.net> */
/* { dg-do run { target i?86-*-cygwin* i?86-*-mingw* } } */
#include "ffitest.h"
static void
closure_test_stdcall(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata)
{
*(ffi_arg*)resp =
(int)*(int *)args[0] + (int)(*(int *)args[1])
+ (int)(*(int *)args[2]) + (int)(*(int *)args[3])
+ (int)(intptr_t)userdata;
printf("%d %d %d %d: %d\n",
(int)*(int *)args[0], (int)(*(int *)args[1]),
(int)(*(int *)args[2]), (int)(*(int *)args[3]),
(int)*(ffi_arg *)resp);
}
typedef int (__stdcall *closure_test_type0)(int, int, int, int);
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int res;
void* sp_pre;
void* sp_post;
char buf[1024];
cl_arg_types[0] = &ffi_type_uint;
cl_arg_types[1] = &ffi_type_uint;
cl_arg_types[2] = &ffi_type_uint;
cl_arg_types[3] = &ffi_type_uint;
cl_arg_types[4] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 4,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_stdcall,
(void *) 3 /* userdata */, code) == FFI_OK);
asm volatile (" movl %%esp,%0" : "=g" (sp_pre));
res = (*(closure_test_type0)code)(0, 1, 2, 3);
asm volatile (" movl %%esp,%0" : "=g" (sp_post));
/* { dg-output "0 1 2 3: 9" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 9" } */
sprintf(buf, "mismatch: pre=%p vs post=%p", sp_pre, sp_post);
printf("stack pointer %s\n", (sp_pre == sp_post ? "match" : buf));
/* { dg-output "\nstack pointer match" } */
exit(0);
}

View File

@ -0,0 +1,94 @@
/* Area: ffi_call, closure_call
Purpose: Check structure passing with different structure size.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030828 */
/* { dg-do run } */
#include "ffitest.h"
typedef struct cls_struct_12byte {
int a;
int b;
int c;
} cls_struct_12byte;
cls_struct_12byte cls_struct_12byte_fn(struct cls_struct_12byte b1,
struct cls_struct_12byte b2)
{
struct cls_struct_12byte result;
result.a = b1.a + b2.a;
result.b = b1.b + b2.b;
result.c = b1.c + b2.c;
printf("%d %d %d %d %d %d: %d %d %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c,
result.a, result.b, result.c);
return result;
}
static void cls_struct_12byte_gn(ffi_cif* cif __UNUSED__, void* resp,
void** args , void* userdata __UNUSED__)
{
struct cls_struct_12byte b1, b2;
b1 = *(struct cls_struct_12byte*)(args[0]);
b2 = *(struct cls_struct_12byte*)(args[1]);
*(cls_struct_12byte*)resp = cls_struct_12byte_fn(b1, b2);
}
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5];
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
cls_struct_type.elements = cls_struct_fields;
struct cls_struct_12byte h_dbl = { 7, 4, 9 };
struct cls_struct_12byte j_dbl = { 1, 5, 3 };
struct cls_struct_12byte res_dbl;
cls_struct_fields[0] = &ffi_type_sint;
cls_struct_fields[1] = &ffi_type_sint;
cls_struct_fields[2] = &ffi_type_sint;
cls_struct_fields[3] = NULL;
dbl_arg_types[0] = &cls_struct_type;
dbl_arg_types[1] = &cls_struct_type;
dbl_arg_types[2] = NULL;
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
dbl_arg_types) == FFI_OK);
args_dbl[0] = &h_dbl;
args_dbl[1] = &j_dbl;
args_dbl[2] = NULL;
ffi_call(&cif, FFI_FN(cls_struct_12byte_fn), &res_dbl, args_dbl);
/* { dg-output "7 4 9 1 5 3: 8 9 12" } */
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 8 9 12" } */
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_12byte_gn, NULL, code) == FFI_OK);
res_dbl.a = 0;
res_dbl.b = 0;
res_dbl.c = 0;
res_dbl = ((cls_struct_12byte(*)(cls_struct_12byte, cls_struct_12byte))(code))(h_dbl, j_dbl);
/* { dg-output "\n7 4 9 1 5 3: 8 9 12" } */
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 8 9 12" } */
exit(0);
}

View File

@ -0,0 +1,95 @@
/* Area: ffi_call, closure_call
Purpose: Check structure passing with different structure size.
Depending on the ABI. Check overlapping.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030828 */
/* { dg-do run } */
#include "ffitest.h"
typedef struct cls_struct_16byte {
int a;
double b;
int c;
} cls_struct_16byte;
cls_struct_16byte cls_struct_16byte_fn(struct cls_struct_16byte b1,
struct cls_struct_16byte b2)
{
struct cls_struct_16byte result;
result.a = b1.a + b2.a;
result.b = b1.b + b2.b;
result.c = b1.c + b2.c;
printf("%d %g %d %d %g %d: %d %g %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c,
result.a, result.b, result.c);
return result;
}
static void cls_struct_16byte_gn(ffi_cif* cif __UNUSED__, void* resp,
void** args, void* userdata __UNUSED__)
{
struct cls_struct_16byte b1, b2;
b1 = *(struct cls_struct_16byte*)(args[0]);
b2 = *(struct cls_struct_16byte*)(args[1]);
*(cls_struct_16byte*)resp = cls_struct_16byte_fn(b1, b2);
}
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5];
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
cls_struct_type.elements = cls_struct_fields;
struct cls_struct_16byte h_dbl = { 7, 8.0, 9 };
struct cls_struct_16byte j_dbl = { 1, 9.0, 3 };
struct cls_struct_16byte res_dbl;
cls_struct_fields[0] = &ffi_type_sint;
cls_struct_fields[1] = &ffi_type_double;
cls_struct_fields[2] = &ffi_type_sint;
cls_struct_fields[3] = NULL;
dbl_arg_types[0] = &cls_struct_type;
dbl_arg_types[1] = &cls_struct_type;
dbl_arg_types[2] = NULL;
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
dbl_arg_types) == FFI_OK);
args_dbl[0] = &h_dbl;
args_dbl[1] = &j_dbl;
args_dbl[2] = NULL;
ffi_call(&cif, FFI_FN(cls_struct_16byte_fn), &res_dbl, args_dbl);
/* { dg-output "7 8 9 1 9 3: 8 17 12" } */
printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 8 17 12" } */
res_dbl.a = 0;
res_dbl.b = 0.0;
res_dbl.c = 0;
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_16byte_gn, NULL, code) == FFI_OK);
res_dbl = ((cls_struct_16byte(*)(cls_struct_16byte, cls_struct_16byte))(code))(h_dbl, j_dbl);
/* { dg-output "\n7 8 9 1 9 3: 8 17 12" } */
printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 8 17 12" } */
exit(0);
}

View File

@ -0,0 +1,96 @@
/* Area: ffi_call, closure_call
Purpose: Check structure passing with different structure size.
Depending on the ABI. Double alignment check on darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030915 */
/* { dg-do run } */
#include "ffitest.h"
typedef struct cls_struct_18byte {
double a;
unsigned char b;
unsigned char c;
double d;
} cls_struct_18byte;
cls_struct_18byte cls_struct_18byte_fn(struct cls_struct_18byte a1,
struct cls_struct_18byte a2)
{
struct cls_struct_18byte result;
result.a = a1.a + a2.a;
result.b = a1.b + a2.b;
result.c = a1.c + a2.c;
result.d = a1.d + a2.d;
printf("%g %d %d %g %g %d %d %g: %g %d %d %g\n", a1.a, a1.b, a1.c, a1.d,
a2.a, a2.b, a2.c, a2.d,
result.a, result.b, result.c, result.d);
return result;
}
static void
cls_struct_18byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata __UNUSED__)
{
struct cls_struct_18byte a1, a2;
a1 = *(struct cls_struct_18byte*)(args[0]);
a2 = *(struct cls_struct_18byte*)(args[1]);
*(cls_struct_18byte*)resp = cls_struct_18byte_fn(a1, a2);
}
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type;
ffi_type* dbl_arg_types[3];
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
cls_struct_type.elements = cls_struct_fields;
struct cls_struct_18byte g_dbl = { 1.0, 127, 126, 3.0 };
struct cls_struct_18byte f_dbl = { 4.0, 125, 124, 5.0 };
struct cls_struct_18byte res_dbl;
cls_struct_fields[0] = &ffi_type_double;
cls_struct_fields[1] = &ffi_type_uchar;
cls_struct_fields[2] = &ffi_type_uchar;
cls_struct_fields[3] = &ffi_type_double;
cls_struct_fields[4] = NULL;
dbl_arg_types[0] = &cls_struct_type;
dbl_arg_types[1] = &cls_struct_type;
dbl_arg_types[2] = NULL;
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
dbl_arg_types) == FFI_OK);
args_dbl[0] = &g_dbl;
args_dbl[1] = &f_dbl;
args_dbl[2] = NULL;
ffi_call(&cif, FFI_FN(cls_struct_18byte_fn), &res_dbl, args_dbl);
/* { dg-output "1 127 126 3 4 125 124 5: 5 252 250 8" } */
printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 5 252 250 8" } */
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_18byte_gn, NULL, code) == FFI_OK);
res_dbl = ((cls_struct_18byte(*)(cls_struct_18byte, cls_struct_18byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n1 127 126 3 4 125 124 5: 5 252 250 8" } */
printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 5 252 250 8" } */
exit(0);
}

View File

@ -0,0 +1,102 @@
/* Area: ffi_call, closure_call
Purpose: Check structure passing with different structure size.
Depending on the ABI. Double alignment check on darwin.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030915 */
/* { dg-do run } */
#include "ffitest.h"
typedef struct cls_struct_19byte {
double a;
unsigned char b;
unsigned char c;
double d;
unsigned char e;
} cls_struct_19byte;
cls_struct_19byte cls_struct_19byte_fn(struct cls_struct_19byte a1,
struct cls_struct_19byte a2)
{
struct cls_struct_19byte result;
result.a = a1.a + a2.a;
result.b = a1.b + a2.b;
result.c = a1.c + a2.c;
result.d = a1.d + a2.d;
result.e = a1.e + a2.e;
printf("%g %d %d %g %d %g %d %d %g %d: %g %d %d %g %d\n",
a1.a, a1.b, a1.c, a1.d, a1.e,
a2.a, a2.b, a2.c, a2.d, a2.e,
result.a, result.b, result.c, result.d, result.e);
return result;
}
static void
cls_struct_19byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata __UNUSED__)
{
struct cls_struct_19byte a1, a2;
a1 = *(struct cls_struct_19byte*)(args[0]);
a2 = *(struct cls_struct_19byte*)(args[1]);
*(cls_struct_19byte*)resp = cls_struct_19byte_fn(a1, a2);
}
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[6];
ffi_type cls_struct_type;
ffi_type* dbl_arg_types[3];
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
cls_struct_type.elements = cls_struct_fields;
struct cls_struct_19byte g_dbl = { 1.0, 127, 126, 3.0, 120 };
struct cls_struct_19byte f_dbl = { 4.0, 125, 124, 5.0, 119 };
struct cls_struct_19byte res_dbl;
cls_struct_fields[0] = &ffi_type_double;
cls_struct_fields[1] = &ffi_type_uchar;
cls_struct_fields[2] = &ffi_type_uchar;
cls_struct_fields[3] = &ffi_type_double;
cls_struct_fields[4] = &ffi_type_uchar;
cls_struct_fields[5] = NULL;
dbl_arg_types[0] = &cls_struct_type;
dbl_arg_types[1] = &cls_struct_type;
dbl_arg_types[2] = NULL;
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
dbl_arg_types) == FFI_OK);
args_dbl[0] = &g_dbl;
args_dbl[1] = &f_dbl;
args_dbl[2] = NULL;
ffi_call(&cif, FFI_FN(cls_struct_19byte_fn), &res_dbl, args_dbl);
/* { dg-output "1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */
printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e);
/* { dg-output "\nres: 5 252 250 8 239" } */
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_19byte_gn, NULL, code) == FFI_OK);
res_dbl = ((cls_struct_19byte(*)(cls_struct_19byte, cls_struct_19byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */
printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e);
/* { dg-output "\nres: 5 252 250 8 239" } */
exit(0);
}

View File

@ -0,0 +1,89 @@
/* Area: ffi_call, closure_call
Purpose: Check structure passing with different structure size.
Especially with small structures which may fit in one
register. Depending on the ABI.
Limitations: none.
PR: none.
Originator: <andreast@gcc.gnu.org> 20030902 */
/* { dg-do run } */
#include "ffitest.h"
typedef struct cls_struct_1_1byte {
unsigned char a;
} cls_struct_1_1byte;
cls_struct_1_1byte cls_struct_1_1byte_fn(struct cls_struct_1_1byte a1,
struct cls_struct_1_1byte a2)
{
struct cls_struct_1_1byte result;
result.a = a1.a + a2.a;
printf("%d %d: %d\n", a1.a, a2.a, result.a);
return result;
}
static void
cls_struct_1_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
void* userdata __UNUSED__)
{
struct cls_struct_1_1byte a1, a2;
a1 = *(struct cls_struct_1_1byte*)(args[0]);
a2 = *(struct cls_struct_1_1byte*)(args[1]);
*(cls_struct_1_1byte*)resp = cls_struct_1_1byte_fn(a1, a2);
}
int main (void)
{
ffi_cif cif;
void *code;
ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[2];
ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5];
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
cls_struct_type.elements = cls_struct_fields;
struct cls_struct_1_1byte g_dbl = { 12 };
struct cls_struct_1_1byte f_dbl = { 178 };
struct cls_struct_1_1byte res_dbl;
cls_struct_fields[0] = &ffi_type_uchar;
cls_struct_fields[1] = NULL;
dbl_arg_types[0] = &cls_struct_type;
dbl_arg_types[1] = &cls_struct_type;
dbl_arg_types[2] = NULL;
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
dbl_arg_types) == FFI_OK);
args_dbl[0] = &g_dbl;
args_dbl[1] = &f_dbl;
args_dbl[2] = NULL;
ffi_call(&cif, FFI_FN(cls_struct_1_1byte_fn), &res_dbl, args_dbl);
/* { dg-output "12 178: 190" } */
printf("res: %d\n", res_dbl.a);
/* { dg-output "\nres: 190" } */
CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_1_1byte_gn, NULL, code) == FFI_OK);
res_dbl = ((cls_struct_1_1byte(*)(cls_struct_1_1byte, cls_struct_1_1byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 178: 190" } */
printf("res: %d\n", res_dbl.a);
/* { dg-output "\nres: 190" } */
exit(0);
}

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