Commit 5196736e by Andreas Jaeger Committed by Andreas Tobler

acinclude.m4: Add AC_FUNC_MMAP_BLACKLIST.

2003-11-21  Andreas Jaeger  <aj@suse.de>
	    Andreas Tobler  <a.tobler@schweiz.ch>

	* acinclude.m4: Add AC_FUNC_MMAP_BLACKLIST.
	* configure.in: Call AC_FUNC_MMAP_BLACKLIST.
	* Makefile.in: Rebuilt.
	* aclocal.m4: Likewise.
	* configure: Likewise.
	* fficonfig.h.in: Likewise.
	* testsuite/lib/libffi-dg.exp: Add include dir.
	* testsuite/libffi.call/ffitest.h: Add MMAP definitions.
	* testsuite/libffi.special/ffitestcxx.h: Likewise.
	* testsuite/libffi.call/closure_fn0.c: Use MMAP functionality
	for ffi_closure if available.
	* testsuite/libffi.call/closure_fn1.c: Likewise.
	* testsuite/libffi.call/closure_fn2.c: Likewise.
	* testsuite/libffi.call/closure_fn3.c: Likewise.
	* testsuite/libffi.call/closure_fn4.c: Likewise.
	* testsuite/libffi.call/closure_fn5.c: Likewise.
	* testsuite/libffi.call/cls_12byte.c: Likewise.
	* testsuite/libffi.call/cls_16byte.c: Likewise.
	* testsuite/libffi.call/cls_18byte.c: Likewise.
	* testsuite/libffi.call/cls_19byte.c: Likewise.
	* testsuite/libffi.call/cls_1_1byte.c: Likewise.
	* testsuite/libffi.call/cls_20byte.c: Likewise.
	* testsuite/libffi.call/cls_20byte1.c: Likewise.
	* testsuite/libffi.call/cls_24byte.c: Likewise.
	* testsuite/libffi.call/cls_2byte.c: Likewise.
	* testsuite/libffi.call/cls_3_1byte.c: Likewise.
	* testsuite/libffi.call/cls_3byte1.c: Likewise.
	* testsuite/libffi.call/cls_3byte2.c: Likewise.
	* testsuite/libffi.call/cls_4_1byte.c: Likewise.
	* testsuite/libffi.call/cls_4byte.c: Likewise.
	* testsuite/libffi.call/cls_5byte.c: Likewise.
	* testsuite/libffi.call/cls_64byte.c: Likewise.
	* testsuite/libffi.call/cls_6byte.c: Likewise.
	* testsuite/libffi.call/cls_7byte.c: Likewise.
	* testsuite/libffi.call/cls_8byte.c: Likewise.
	* testsuite/libffi.call/cls_9byte1.c: Likewise.
	* testsuite/libffi.call/cls_9byte2.c: Likewise.
	* testsuite/libffi.call/cls_double.c: Likewise.
	* testsuite/libffi.call/cls_float.c: Likewise.
	* testsuite/libffi.call/cls_schar.c: Likewise.
	* testsuite/libffi.call/cls_sint.c: Likewise.
	* testsuite/libffi.call/cls_sshort.c: Likewise.
	* testsuite/libffi.call/cls_uchar.c: Likewise.
	* testsuite/libffi.call/cls_uint.c: Likewise.
	* testsuite/libffi.call/cls_ulonglong.c: Likewise.
	* testsuite/libffi.call/cls_ushort.c: Likewise.
	* testsuite/libffi.call/nested_struct.c: Likewise.
	* testsuite/libffi.call/nested_struct1.c: Likewise.
	* testsuite/libffi.call/nested_struct2.c: Likewise.
	* testsuite/libffi.call/nested_struct3.c: Likewise.
	* testsuite/libffi.call/problem1.c: Likewise.
	* testsuite/libffi.special/unwindtest.cc: Likewise.

Co-Authored-By: Andreas Tobler <a.tobler@schweiz.ch>

From-SVN: r73800
parent 4e074baf
2003-11-21 Andreas Jaeger <aj@suse.de>
Andreas Tobler <a.tobler@schweiz.ch>
* acinclude.m4: Add AC_FUNC_MMAP_BLACKLIST.
* configure.in: Call AC_FUNC_MMAP_BLACKLIST.
* Makefile.in: Rebuilt.
* aclocal.m4: Likewise.
* configure: Likewise.
* fficonfig.h.in: Likewise.
* testsuite/lib/libffi-dg.exp: Add include dir.
* testsuite/libffi.call/ffitest.h: Add MMAP definitions.
* testsuite/libffi.special/ffitestcxx.h: Likewise.
* testsuite/libffi.call/closure_fn0.c: Use MMAP functionality
for ffi_closure if available.
* testsuite/libffi.call/closure_fn1.c: Likewise.
* testsuite/libffi.call/closure_fn2.c: Likewise.
* testsuite/libffi.call/closure_fn3.c: Likewise.
* testsuite/libffi.call/closure_fn4.c: Likewise.
* testsuite/libffi.call/closure_fn5.c: Likewise.
* testsuite/libffi.call/cls_12byte.c: Likewise.
* testsuite/libffi.call/cls_16byte.c: Likewise.
* testsuite/libffi.call/cls_18byte.c: Likewise.
* testsuite/libffi.call/cls_19byte.c: Likewise.
* testsuite/libffi.call/cls_1_1byte.c: Likewise.
* testsuite/libffi.call/cls_20byte.c: Likewise.
* testsuite/libffi.call/cls_20byte1.c: Likewise.
* testsuite/libffi.call/cls_24byte.c: Likewise.
* testsuite/libffi.call/cls_2byte.c: Likewise.
* testsuite/libffi.call/cls_3_1byte.c: Likewise.
* testsuite/libffi.call/cls_3byte1.c: Likewise.
* testsuite/libffi.call/cls_3byte2.c: Likewise.
* testsuite/libffi.call/cls_4_1byte.c: Likewise.
* testsuite/libffi.call/cls_4byte.c: Likewise.
* testsuite/libffi.call/cls_5byte.c: Likewise.
* testsuite/libffi.call/cls_64byte.c: Likewise.
* testsuite/libffi.call/cls_6byte.c: Likewise.
* testsuite/libffi.call/cls_7byte.c: Likewise.
* testsuite/libffi.call/cls_8byte.c: Likewise.
* testsuite/libffi.call/cls_9byte1.c: Likewise.
* testsuite/libffi.call/cls_9byte2.c: Likewise.
* testsuite/libffi.call/cls_double.c: Likewise.
* testsuite/libffi.call/cls_float.c: Likewise.
* testsuite/libffi.call/cls_schar.c: Likewise.
* testsuite/libffi.call/cls_sint.c: Likewise.
* testsuite/libffi.call/cls_sshort.c: Likewise.
* testsuite/libffi.call/cls_uchar.c: Likewise.
* testsuite/libffi.call/cls_uint.c: Likewise.
* testsuite/libffi.call/cls_ulonglong.c: Likewise.
* testsuite/libffi.call/cls_ushort.c: Likewise.
* testsuite/libffi.call/nested_struct.c: Likewise.
* testsuite/libffi.call/nested_struct1.c: Likewise.
* testsuite/libffi.call/nested_struct2.c: Likewise.
* testsuite/libffi.call/nested_struct3.c: Likewise.
* testsuite/libffi.call/problem1.c: Likewise.
* testsuite/libffi.special/unwindtest.cc: Likewise.
2003-11-20 Andreas Tobler <a.tobler@schweiz.ch> 2003-11-20 Andreas Tobler <a.tobler@schweiz.ch>
* testsuite/lib/libffi-dg.exp: Make the -lgcc_s conditional. * testsuite/lib/libffi-dg.exp: Make the -lgcc_s conditional.
......
...@@ -8,4 +8,93 @@ AC_DEFUN([AM_PROG_LIBTOOL],) ...@@ -8,4 +8,93 @@ AC_DEFUN([AM_PROG_LIBTOOL],)
AC_SUBST(LIBTOOL) AC_SUBST(LIBTOOL)
]) ])
# mmap(2) blacklisting. Some platforms provide the mmap library routine
# but don't support all of the features we need from it.
AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
[if test $ac_cv_header_sys_mman_h != yes \
|| test $ac_cv_func_mmap != yes; then
ac_cv_func_mmap_file=no
ac_cv_func_mmap_dev_zero=no
ac_cv_func_mmap_anon=no
else
AC_CACHE_CHECK([whether read-only mmap of a plain file works],
ac_cv_func_mmap_file,
[# Add a system to this blacklist if
# mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
# memory area containing the same data that you'd get if you applied
# read() to the same fd. The only system known to have a problem here
# is VMS, where text files have record structure.
case "$host_os" in
vms* | ultrix*)
ac_cv_func_mmap_file=no ;;
*)
ac_cv_func_mmap_file=yes;;
esac])
AC_CACHE_CHECK([whether mmap from /dev/zero works],
ac_cv_func_mmap_dev_zero,
[# Add a system to this blacklist if it has mmap() but /dev/zero
# does not exist, or if mmapping /dev/zero does not give anonymous
# zeroed pages with both the following properties:
# 1. If you map N consecutive pages in with one call, and then
# unmap any subset of those pages, the pages that were not
# explicitly unmapped remain accessible.
# 2. If you map two adjacent blocks of memory and then unmap them
# both at once, they must both go away.
# Systems known to be in this category are Windows (all variants),
# VMS, and Darwin.
case "$host_os" in
vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
ac_cv_func_mmap_dev_zero=no ;;
*)
ac_cv_func_mmap_dev_zero=yes;;
esac])
# Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
],
[int n = MAP_ANONYMOUS;],
ac_cv_decl_map_anon=yes,
ac_cv_decl_map_anon=no)])
if test $ac_cv_decl_map_anon = no; then
ac_cv_func_mmap_anon=no
else
AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
ac_cv_func_mmap_anon,
[# Add a system to this blacklist if it has mmap() and MAP_ANON or
# MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
# doesn't give anonymous zeroed pages with the same properties listed
# above for use of /dev/zero.
# Systems known to be in this category are Windows, VMS, and SCO Unix.
case "$host_os" in
vms* | cygwin* | pe | mingw* | sco* | udk* )
ac_cv_func_mmap_anon=no ;;
*)
ac_cv_func_mmap_anon=yes;;
esac])
fi
fi
if test $ac_cv_func_mmap_file = yes; then
AC_DEFINE(HAVE_MMAP_FILE, 1,
[Define if read-only mmap of a plain file works.])
fi
if test $ac_cv_func_mmap_dev_zero = yes; then
AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
[Define if mmap of /dev/zero works.])
fi
if test $ac_cv_func_mmap_anon = yes; then
AC_DEFINE(HAVE_MMAP_ANON, 1,
[Define if mmap with MAP_ANON(YMOUS) works.])
fi
])
sinclude(../config/accross.m4) sinclude(../config/accross.m4)
dnl aclocal.m4 generated automatically by aclocal 1.4-p5 dnl aclocal.m4 generated automatically by aclocal 1.4
dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it, dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved. dnl with or without modifications, as long as this notice is preserved.
...@@ -20,11 +20,100 @@ AC_DEFUN([AM_PROG_LIBTOOL],) ...@@ -20,11 +20,100 @@ AC_DEFUN([AM_PROG_LIBTOOL],)
AC_SUBST(LIBTOOL) AC_SUBST(LIBTOOL)
]) ])
# mmap(2) blacklisting. Some platforms provide the mmap library routine
# but don't support all of the features we need from it.
AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
[if test $ac_cv_header_sys_mman_h != yes \
|| test $ac_cv_func_mmap != yes; then
ac_cv_func_mmap_file=no
ac_cv_func_mmap_dev_zero=no
ac_cv_func_mmap_anon=no
else
AC_CACHE_CHECK([whether read-only mmap of a plain file works],
ac_cv_func_mmap_file,
[# Add a system to this blacklist if
# mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
# memory area containing the same data that you'd get if you applied
# read() to the same fd. The only system known to have a problem here
# is VMS, where text files have record structure.
case "$host_os" in
vms* | ultrix*)
ac_cv_func_mmap_file=no ;;
*)
ac_cv_func_mmap_file=yes;;
esac])
AC_CACHE_CHECK([whether mmap from /dev/zero works],
ac_cv_func_mmap_dev_zero,
[# Add a system to this blacklist if it has mmap() but /dev/zero
# does not exist, or if mmapping /dev/zero does not give anonymous
# zeroed pages with both the following properties:
# 1. If you map N consecutive pages in with one call, and then
# unmap any subset of those pages, the pages that were not
# explicitly unmapped remain accessible.
# 2. If you map two adjacent blocks of memory and then unmap them
# both at once, they must both go away.
# Systems known to be in this category are Windows (all variants),
# VMS, and Darwin.
case "$host_os" in
vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
ac_cv_func_mmap_dev_zero=no ;;
*)
ac_cv_func_mmap_dev_zero=yes;;
esac])
# Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
],
[int n = MAP_ANONYMOUS;],
ac_cv_decl_map_anon=yes,
ac_cv_decl_map_anon=no)])
if test $ac_cv_decl_map_anon = no; then
ac_cv_func_mmap_anon=no
else
AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
ac_cv_func_mmap_anon,
[# Add a system to this blacklist if it has mmap() and MAP_ANON or
# MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
# doesn't give anonymous zeroed pages with the same properties listed
# above for use of /dev/zero.
# Systems known to be in this category are Windows, VMS, and SCO Unix.
case "$host_os" in
vms* | cygwin* | pe | mingw* | sco* | udk* )
ac_cv_func_mmap_anon=no ;;
*)
ac_cv_func_mmap_anon=yes;;
esac])
fi
fi
if test $ac_cv_func_mmap_file = yes; then
AC_DEFINE(HAVE_MMAP_FILE, 1,
[Define if read-only mmap of a plain file works.])
fi
if test $ac_cv_func_mmap_dev_zero = yes; then
AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
[Define if mmap of /dev/zero works.])
fi
if test $ac_cv_func_mmap_anon = yes; then
AC_DEFINE(HAVE_MMAP_ANON, 1,
[Define if mmap with MAP_ANON(YMOUS) works.])
fi
])
sinclude(../config/accross.m4) sinclude(../config/accross.m4)
# Like AC_CONFIG_HEADER, but automatically create stamp file. # Like AC_CONFIG_HEADER, but automatically create stamp file.
AC_DEFUN([AM_CONFIG_HEADER], AC_DEFUN(AM_CONFIG_HEADER,
[AC_PREREQ([2.12]) [AC_PREREQ([2.12])
AC_CONFIG_HEADER([$1]) AC_CONFIG_HEADER([$1])
dnl When config.status generates a header, we must update the stamp-h file. dnl When config.status generates a header, we must update the stamp-h file.
...@@ -54,7 +143,7 @@ changequote([,]))]) ...@@ -54,7 +143,7 @@ changequote([,]))])
dnl Usage: dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define]) dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN([AM_INIT_AUTOMAKE], AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AC_PROG_INSTALL]) [AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1] PACKAGE=[$1]
AC_SUBST(PACKAGE) AC_SUBST(PACKAGE)
...@@ -82,7 +171,7 @@ AC_REQUIRE([AC_PROG_MAKE_SET])]) ...@@ -82,7 +171,7 @@ AC_REQUIRE([AC_PROG_MAKE_SET])])
# Check to make sure that the build environment is sane. # Check to make sure that the build environment is sane.
# #
AC_DEFUN([AM_SANITY_CHECK], AC_DEFUN(AM_SANITY_CHECK,
[AC_MSG_CHECKING([whether build environment is sane]) [AC_MSG_CHECKING([whether build environment is sane])
# Just in case # Just in case
sleep 1 sleep 1
...@@ -123,7 +212,7 @@ AC_MSG_RESULT(yes)]) ...@@ -123,7 +212,7 @@ AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version. dnl The program must properly implement --version.
AC_DEFUN([AM_MISSING_PROG], AC_DEFUN(AM_MISSING_PROG,
[AC_MSG_CHECKING(for working $2) [AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if # Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected. # an executable is not found, even if stderr is redirected.
...@@ -142,7 +231,7 @@ AC_SUBST($1)]) ...@@ -142,7 +231,7 @@ AC_SUBST($1)])
# serial 1 # serial 1
AC_DEFUN([AM_MAINTAINER_MODE], AC_DEFUN(AM_MAINTAINER_MODE,
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode is disabled by default dnl maintainer-mode is disabled by default
AC_ARG_ENABLE(maintainer-mode, AC_ARG_ENABLE(maintainer-mode,
...@@ -159,7 +248,7 @@ AC_DEFUN([AM_MAINTAINER_MODE], ...@@ -159,7 +248,7 @@ AC_DEFUN([AM_MAINTAINER_MODE],
# Define a conditional. # Define a conditional.
AC_DEFUN([AM_CONDITIONAL], AC_DEFUN(AM_CONDITIONAL,
[AC_SUBST($1_TRUE) [AC_SUBST($1_TRUE)
AC_SUBST($1_FALSE) AC_SUBST($1_FALSE)
if $2; then if $2; then
......
...@@ -46,6 +46,8 @@ AC_PROG_CC ...@@ -46,6 +46,8 @@ AC_PROG_CC
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_FUNC_MMAP_BLACKLIST
dnl The -no-testsuite modules omit the test subdir. dnl The -no-testsuite modules omit the test subdir.
AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite) AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
......
...@@ -28,6 +28,15 @@ ...@@ -28,6 +28,15 @@
/* Define if you have the memcpy function. */ /* Define if you have the memcpy function. */
#undef HAVE_MEMCPY #undef HAVE_MEMCPY
/* Define if read-only mmap of a plain file works. */
#undef HAVE_MMAP_FILE
/* Define if mmap of /dev/zero works. */
#undef HAVE_MMAP_DEV_ZERO
/* Define if mmap with MAP_ANON(YMOUS) works. */
#undef HAVE_MMAP_ANON
/* The number of bytes in type double */ /* The number of bytes in type double */
#undef SIZEOF_DOUBLE #undef SIZEOF_DOUBLE
......
...@@ -162,7 +162,7 @@ proc libffi_target_compile { source dest type options } { ...@@ -162,7 +162,7 @@ proc libffi_target_compile { source dest type options } {
} }
# search for ffi_mips.h in srcdir, too # search for ffi_mips.h in srcdir, too
lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include" lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.."
lappend options "additional_flags=${libffi_link_flags}" lappend options "additional_flags=${libffi_link_flags}"
if { [string match "powerpc-*-darwin*" $target_triplet] } { if { [string match "powerpc-*-darwin*" $target_triplet] } {
......
...@@ -45,11 +45,19 @@ typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long, ...@@ -45,11 +45,19 @@ typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[17]; ffi_type * cl_arg_types[17];
int res; int res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_uint64; cl_arg_types[0] = &ffi_type_uint64;
cl_arg_types[1] = &ffi_type_uint; cl_arg_types[1] = &ffi_type_uint;
cl_arg_types[2] = &ffi_type_uint64; cl_arg_types[2] = &ffi_type_uint64;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */ /* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
#include "ffitest.h" #include "ffitest.h"
static void closure_test_fn1(ffi_cif* cif,void* resp,void** args, static void closure_test_fn1(ffi_cif* cif,void* resp,void** args,
void* userdata) void* userdata)
{ {
...@@ -40,11 +41,19 @@ typedef int (*closure_test_type1)(float, float, float, float, signed short, ...@@ -40,11 +41,19 @@ typedef int (*closure_test_type1)(float, float, float, float, signed short,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[17]; ffi_type * cl_arg_types[17];
int res; int res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_float; cl_arg_types[0] = &ffi_type_float;
cl_arg_types[1] = &ffi_type_float; cl_arg_types[1] = &ffi_type_float;
cl_arg_types[2] = &ffi_type_float; cl_arg_types[2] = &ffi_type_float;
......
...@@ -41,11 +41,19 @@ typedef int (*closure_test_type2)(double, double, double, double, signed short, ...@@ -41,11 +41,19 @@ typedef int (*closure_test_type2)(double, double, double, double, signed short,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[17]; ffi_type * cl_arg_types[17];
int res; int res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_double; cl_arg_types[0] = &ffi_type_double;
cl_arg_types[1] = &ffi_type_double; cl_arg_types[1] = &ffi_type_double;
cl_arg_types[2] = &ffi_type_double; cl_arg_types[2] = &ffi_type_double;
......
...@@ -42,11 +42,18 @@ typedef int (*closure_test_type3)(float, float, float, float, float, float, ...@@ -42,11 +42,18 @@ typedef int (*closure_test_type3)(float, float, float, float, float, float,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[17]; ffi_type * cl_arg_types[17];
int res; int res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_float; cl_arg_types[0] = &ffi_type_float;
cl_arg_types[1] = &ffi_type_float; cl_arg_types[1] = &ffi_type_float;
......
...@@ -59,11 +59,19 @@ typedef int (*closure_test_type0)(unsigned long long, unsigned long long, ...@@ -59,11 +59,19 @@ typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[17]; ffi_type * cl_arg_types[17];
int i, res; int i, res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
for (i = 0; i < 15; i++) { for (i = 0; i < 15; i++) {
cl_arg_types[i] = &ffi_type_uint64; cl_arg_types[i] = &ffi_type_uint64;
} }
......
...@@ -59,10 +59,17 @@ typedef int (*closure_test_type0)(unsigned long long, unsigned long long, ...@@ -59,10 +59,17 @@ typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[17]; ffi_type * cl_arg_types[17];
int i, res; int i, res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
cl_arg_types[i] = &ffi_type_uint64; cl_arg_types[i] = &ffi_type_uint64;
......
...@@ -41,13 +41,21 @@ static void cls_struct_12byte_gn(ffi_cif* cif, void* resp, void** args, void* us ...@@ -41,13 +41,21 @@ static void cls_struct_12byte_gn(ffi_cif* cif, void* resp, void** args, void* us
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -42,13 +42,21 @@ static void cls_struct_16byte_gn(ffi_cif* cif, void* resp, void** args, void* us ...@@ -42,13 +42,21 @@ static void cls_struct_16byte_gn(ffi_cif* cif, void* resp, void** args, void* us
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -46,13 +46,21 @@ cls_struct_18byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -46,13 +46,21 @@ cls_struct_18byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[3]; void* args_dbl[3];
ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[3]; ffi_type* dbl_arg_types[3];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -49,13 +49,21 @@ cls_struct_19byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -49,13 +49,21 @@ cls_struct_19byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[3]; void* args_dbl[3];
ffi_type* cls_struct_fields[6]; ffi_type* cls_struct_fields[6];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[3]; ffi_type* dbl_arg_types[3];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
...@@ -85,7 +93,7 @@ int main (void) ...@@ -85,7 +93,7 @@ int main (void)
ffi_call(&cif, FFI_FN(cls_struct_19byte_fn), &res_dbl, args_dbl); 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" } */ /* { 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, printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e); res_dbl.d, res_dbl.e);
/* { dg-output "\nres: 5 252 250 8 239" } */ /* { dg-output "\nres: 5 252 250 8 239" } */
......
...@@ -40,13 +40,21 @@ cls_struct_1_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -40,13 +40,21 @@ cls_struct_1_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[2]; ffi_type* cls_struct_fields[2];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -42,13 +42,21 @@ cls_struct_20byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -42,13 +42,21 @@ cls_struct_20byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -42,13 +42,21 @@ cls_struct_20byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -42,13 +42,21 @@ cls_struct_20byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[3]; void* args_dbl[3];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[3]; ffi_type* dbl_arg_types[3];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -53,13 +53,21 @@ cls_struct_24byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -53,13 +53,21 @@ cls_struct_24byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -42,13 +42,21 @@ cls_struct_2byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -42,13 +42,21 @@ cls_struct_2byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -46,13 +46,21 @@ cls_struct_3_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -46,13 +46,21 @@ cls_struct_3_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -42,13 +42,21 @@ cls_struct_3byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -42,13 +42,21 @@ cls_struct_3byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -42,13 +42,21 @@ cls_struct_3byte_gn1(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -42,13 +42,21 @@ cls_struct_3byte_gn1(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -48,13 +48,21 @@ cls_struct_4_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -48,13 +48,21 @@ cls_struct_4_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -42,13 +42,21 @@ cls_struct_4byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -42,13 +42,21 @@ cls_struct_4byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -45,13 +45,21 @@ cls_struct_5byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -45,13 +45,21 @@ cls_struct_5byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -58,13 +58,21 @@ cls_struct_64byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -58,13 +58,21 @@ cls_struct_64byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[9]; ffi_type* cls_struct_fields[9];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -47,13 +47,21 @@ cls_struct_6byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -47,13 +47,21 @@ cls_struct_6byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -47,13 +47,21 @@ cls_struct_7byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -47,13 +47,21 @@ cls_struct_7byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -41,13 +41,21 @@ cls_struct_8byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -41,13 +41,21 @@ cls_struct_8byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[4]; ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -43,13 +43,21 @@ static void cls_struct_9byte_gn(ffi_cif* cif, void* resp, void** args, ...@@ -43,13 +43,21 @@ static void cls_struct_9byte_gn(ffi_cif* cif, void* resp, void** args,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[3]; void* args_dbl[3];
ffi_type* cls_struct_fields[3]; ffi_type* cls_struct_fields[3];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[3]; ffi_type* dbl_arg_types[3];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -43,13 +43,21 @@ static void cls_struct_9byte_gn(ffi_cif* cif, void* resp, void** args, ...@@ -43,13 +43,21 @@ static void cls_struct_9byte_gn(ffi_cif* cif, void* resp, void** args,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[3]; void* args_dbl[3];
ffi_type* cls_struct_fields[3]; ffi_type* cls_struct_fields[3];
ffi_type cls_struct_type; ffi_type cls_struct_type;
ffi_type* dbl_arg_types[3]; ffi_type* dbl_arg_types[3];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -20,11 +20,19 @@ typedef double (*cls_ret_double)(double); ...@@ -20,11 +20,19 @@ typedef double (*cls_ret_double)(double);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
double res; double res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_double; cl_arg_types[0] = &ffi_type_double;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -21,11 +21,19 @@ typedef float (*cls_ret_float)(float); ...@@ -21,11 +21,19 @@ typedef float (*cls_ret_float)(float);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
float res; float res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_float; cl_arg_types[0] = &ffi_type_float;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -19,11 +19,19 @@ typedef signed char (*cls_ret_schar)(signed char); ...@@ -19,11 +19,19 @@ typedef signed char (*cls_ret_schar)(signed char);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
signed char res; signed char res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_schar; cl_arg_types[0] = &ffi_type_schar;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -19,11 +19,19 @@ typedef signed int (*cls_ret_sint)(signed int); ...@@ -19,11 +19,19 @@ typedef signed int (*cls_ret_sint)(signed int);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
signed int res; signed int res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_sint32; cl_arg_types[0] = &ffi_type_sint32;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -19,11 +19,19 @@ typedef signed short (*cls_ret_sshort)(signed short); ...@@ -19,11 +19,19 @@ typedef signed short (*cls_ret_sshort)(signed short);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
signed short res; signed short res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_sint16; cl_arg_types[0] = &ffi_type_sint16;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -19,11 +19,19 @@ typedef unsigned char (*cls_ret_uchar)(unsigned char); ...@@ -19,11 +19,19 @@ typedef unsigned char (*cls_ret_uchar)(unsigned char);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
unsigned char res; unsigned char res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_uchar; cl_arg_types[0] = &ffi_type_uchar;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -20,11 +20,19 @@ typedef unsigned int (*cls_ret_uint)(unsigned int); ...@@ -20,11 +20,19 @@ typedef unsigned int (*cls_ret_uint)(unsigned int);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
unsigned int res; unsigned int res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_uint32; cl_arg_types[0] = &ffi_type_uint32;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -20,11 +20,19 @@ typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long); ...@@ -20,11 +20,19 @@ typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
unsigned long long res; unsigned long long res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_uint64; cl_arg_types[0] = &ffi_type_uint64;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -20,11 +20,19 @@ typedef unsigned short (*cls_ret_ushort)(unsigned short); ...@@ -20,11 +20,19 @@ typedef unsigned short (*cls_ret_ushort)(unsigned short);
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[2]; ffi_type * cl_arg_types[2];
unsigned short res; unsigned short res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cl_arg_types[0] = &ffi_type_ushort; cl_arg_types[0] = &ffi_type_ushort;
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
...@@ -2,8 +2,77 @@ ...@@ -2,8 +2,77 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ffi.h> #include <ffi.h>
#include "fficonfig.h"
#define MAX_ARGS 256 #define MAX_ARGS 256
#define CHECK(x) !(x) ? abort() : 0 #define CHECK(x) !(x) ? abort() : 0
/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
file open. */
#ifdef HAVE_MMAP_ANON
# undef HAVE_MMAP_DEV_ZERO
# include <sys/mman.h>
# ifndef MAP_FAILED
# define MAP_FAILED -1
# endif
# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
# define MAP_ANONYMOUS MAP_ANON
# endif
# define USING_MMAP
#endif
#ifdef HAVE_MMAP_DEV_ZERO
# include <sys/mman.h>
# ifndef MAP_FAILED
# define MAP_FAILED -1
# endif
# define USING_MMAP
#endif
#ifdef USING_MMAP
static inline void *
allocate_mmap (size_t size)
{
void *page;
#if defined (HAVE_MMAP_DEV_ZERO)
static int dev_zero_fd = -1;
#endif
#ifdef HAVE_MMAP_DEV_ZERO
if (dev_zero_fd == -1)
{
dev_zero_fd = open ("/dev/zero", O_RDONLY);
if (dev_zero_fd == -1)
{
perror ("open /dev/zero: %m");
exit (1);
}
}
#endif
#ifdef HAVE_MMAP_ANON
page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#endif
#ifdef HAVE_MMAP_DEV_ZERO
page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE, dev_zero_fd, 0);
#endif
if (page == MAP_FAILED)
{
perror ("virtual memory exhausted");
exit (1);
}
return page;
}
#endif
...@@ -67,8 +67,10 @@ cls_struct_combined_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -67,8 +67,10 @@ cls_struct_combined_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields[5];
ffi_type* cls_struct_fields1[5]; ffi_type* cls_struct_fields1[5];
...@@ -76,6 +78,12 @@ int main (void) ...@@ -76,6 +78,12 @@ int main (void)
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -71,8 +71,10 @@ cls_struct_combined_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -71,8 +71,10 @@ cls_struct_combined_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[5]; void* args_dbl[5];
ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields[5];
ffi_type* cls_struct_fields1[5]; ffi_type* cls_struct_fields1[5];
...@@ -80,6 +82,12 @@ int main (void) ...@@ -80,6 +82,12 @@ int main (void)
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2; ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
ffi_type* dbl_arg_types[5]; ffi_type* dbl_arg_types[5];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -58,14 +58,22 @@ B_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -58,14 +58,22 @@ B_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[3]; void* args_dbl[3];
ffi_type* cls_struct_fields[3]; ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3]; ffi_type* cls_struct_fields1[3];
ffi_type cls_struct_type, cls_struct_type1; ffi_type cls_struct_type, cls_struct_type1;
ffi_type* dbl_arg_types[3]; ffi_type* dbl_arg_types[3];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -49,14 +49,22 @@ B_gn(ffi_cif* cif, void* resp, void** args, void* userdata) ...@@ -49,14 +49,22 @@ B_gn(ffi_cif* cif, void* resp, void** args, void* userdata)
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
void* args_dbl[3]; void* args_dbl[3];
ffi_type* cls_struct_fields[3]; ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3]; ffi_type* cls_struct_fields1[3];
ffi_type cls_struct_type, cls_struct_type1; ffi_type cls_struct_type, cls_struct_type1;
ffi_type* dbl_arg_types[3]; ffi_type* dbl_arg_types[3];
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
cls_struct_type.size = 0; cls_struct_type.size = 0;
cls_struct_type.alignment = 0; cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT; cls_struct_type.type = FFI_TYPE_STRUCT;
......
...@@ -29,61 +29,69 @@ my_ffi_struct callee(struct my_ffi_struct a1, struct my_ffi_struct a2) ...@@ -29,61 +29,69 @@ my_ffi_struct callee(struct my_ffi_struct a1, struct my_ffi_struct a2)
void stub(ffi_cif* cif, void* resp, void** args, void* userdata) void stub(ffi_cif* cif, void* resp, void** args, void* userdata)
{ {
struct my_ffi_struct a1; struct my_ffi_struct a1;
struct my_ffi_struct a2; struct my_ffi_struct a2;
a1 = *(struct my_ffi_struct*)(args[0]); a1 = *(struct my_ffi_struct*)(args[0]);
a2 = *(struct my_ffi_struct*)(args[1]); a2 = *(struct my_ffi_struct*)(args[1]);
*(my_ffi_struct *)resp = callee(a1, a2); *(my_ffi_struct *)resp = callee(a1, a2);
} }
int main(void) int main(void)
{ {
ffi_type* my_ffi_struct_fields[4]; ffi_type* my_ffi_struct_fields[4];
ffi_type my_ffi_struct_type; ffi_type my_ffi_struct_type;
ffi_cif cif; ffi_cif cif;
static ffi_closure cl; #ifndef USING_MMAP
ffi_closure *pcl = &cl; static ffi_closure cl;
void* args[4]; #endif
ffi_type* arg_types[3]; ffi_closure *pcl;
void* args[4];
struct my_ffi_struct g = { 1.0, 2.0, 3.0 }; ffi_type* arg_types[3];
struct my_ffi_struct f = { 1.0, 2.0, 3.0 };
struct my_ffi_struct res; #ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
my_ffi_struct_type.size = 0; #else
my_ffi_struct_type.alignment = 0; pcl = &cl;
my_ffi_struct_type.type = FFI_TYPE_STRUCT; #endif
my_ffi_struct_type.elements = my_ffi_struct_fields;
struct my_ffi_struct g = { 1.0, 2.0, 3.0 };
my_ffi_struct_fields[0] = &ffi_type_double; struct my_ffi_struct f = { 1.0, 2.0, 3.0 };
my_ffi_struct_fields[1] = &ffi_type_double; struct my_ffi_struct res;
my_ffi_struct_fields[2] = &ffi_type_double;
my_ffi_struct_fields[3] = NULL; my_ffi_struct_type.size = 0;
my_ffi_struct_type.alignment = 0;
arg_types[0] = &my_ffi_struct_type; my_ffi_struct_type.type = FFI_TYPE_STRUCT;
arg_types[1] = &my_ffi_struct_type; my_ffi_struct_type.elements = my_ffi_struct_fields;
arg_types[2] = NULL;
my_ffi_struct_fields[0] = &ffi_type_double;
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &my_ffi_struct_type, my_ffi_struct_fields[1] = &ffi_type_double;
arg_types) == FFI_OK); my_ffi_struct_fields[2] = &ffi_type_double;
my_ffi_struct_fields[3] = NULL;
args[0] = &g;
args[1] = &f; arg_types[0] = &my_ffi_struct_type;
args[2] = NULL; arg_types[1] = &my_ffi_struct_type;
ffi_call(&cif, FFI_FN(callee), &res, args); arg_types[2] = NULL;
/* { dg-output "1 2 3 1 2 3: 2 4 6" } */
printf("res: %g %g %g\n", res.a, res.b, res.c); CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &my_ffi_struct_type,
/* { dg-output "\nres: 2 4 6" } */ arg_types) == FFI_OK);
CHECK(ffi_prep_closure(pcl, &cif, stub, NULL) == FFI_OK); args[0] = &g;
args[1] = &f;
res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(pcl))(g, f); args[2] = NULL;
/* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */ ffi_call(&cif, FFI_FN(callee), &res, args);
printf("res: %g %g %g\n", res.a, res.b, res.c); /* { dg-output "1 2 3 1 2 3: 2 4 6" } */
/* { dg-output "\nres: 2 4 6" } */ printf("res: %g %g %g\n", res.a, res.b, res.c);
/* { dg-output "\nres: 2 4 6" } */
exit(0);;
CHECK(ffi_prep_closure(pcl, &cif, stub, NULL) == FFI_OK);
res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(pcl))(g, f);
/* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */
printf("res: %g %g %g\n", res.a, res.b, res.c);
/* { dg-output "\nres: 2 4 6" } */
exit(0);;
} }
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <ffi.h> #include <ffi.h>
#include "fficonfig.h"
#define MAX_ARGS 256 #define MAX_ARGS 256
#define CHECK(x) (!(x) ? abort() : (void)0) #define CHECK(x) (!(x) ? abort() : (void)0)
/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
file open. */
#ifdef HAVE_MMAP_ANON
# undef HAVE_MMAP_DEV_ZERO
# include <sys/mman.h>
# ifndef MAP_FAILED
# define MAP_FAILED -1
# endif
# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
# define MAP_ANONYMOUS MAP_ANON
# endif
# define USING_MMAP
#endif
#ifdef HAVE_MMAP_DEV_ZERO
# include <sys/mman.h>
# ifndef MAP_FAILED
# define MAP_FAILED -1
# endif
# define USING_MMAP
#endif
#ifdef USING_MMAP
static inline void *
allocate_mmap (size_t size)
{
void *page;
#if defined (HAVE_MMAP_DEV_ZERO)
static int dev_zero_fd = -1;
#endif
#ifdef HAVE_MMAP_DEV_ZERO
if (dev_zero_fd == -1)
{
dev_zero_fd = open ("/dev/zero", O_RDONLY);
if (dev_zero_fd == -1)
{
perror ("open /dev/zero: %m");
exit (1);
}
}
#endif
#ifdef HAVE_MMAP_ANON
page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
#endif
#ifdef HAVE_MMAP_DEV_ZERO
page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE, dev_zero_fd, 0);
#endif
if (page == MAP_FAILED)
{
perror ("virtual memory exhausted");
exit (1);
}
return page;
}
#endif
...@@ -49,10 +49,18 @@ typedef int (*closure_test_type1)(float, float, float, float, signed short, ...@@ -49,10 +49,18 @@ typedef int (*closure_test_type1)(float, float, float, float, signed short,
int main (void) int main (void)
{ {
ffi_cif cif; ffi_cif cif;
#ifndef USING_MMAP
static ffi_closure cl; static ffi_closure cl;
ffi_closure *pcl = &cl; #endif
ffi_closure *pcl;
ffi_type * cl_arg_types[17]; ffi_type * cl_arg_types[17];
int res; int res;
#ifdef USING_MMAP
pcl = allocate_mmap (sizeof(ffi_closure));
#else
pcl = &cl;
#endif
{ {
cl_arg_types[1] = NULL; cl_arg_types[1] = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment