summaryrefslogtreecommitdiff
path: root/libffi/testsuite
diff options
context:
space:
mode:
authorAndrew Haley <aph@gcc.gnu.org>2009-06-12 15:57:58 +0000
committerAndrew Haley <aph@gcc.gnu.org>2009-06-12 15:57:58 +0000
commit062b827975180b9b278666e5a08f6e55bb120010 (patch)
treeefc26880d57fcef907b242e65358738dc2e71d97 /libffi/testsuite
parente39a546c5d03b42256bd637ee0e287cb7107afdd (diff)
downloadgcc-062b827975180b9b278666e5a08f6e55bb120010.tar.gz
[multiple changes]
2009-06-12 Andrew Haley <aph@redhat.com> * ChangeLog.libffi: 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-12 Andrew Haley <aph@redhat.com> * Makefile.am: Remove info_TEXINFOS. From-SVN: r148433
Diffstat (limited to 'libffi/testsuite')
-rw-r--r--libffi/testsuite/Makefile.in2
-rw-r--r--libffi/testsuite/libffi.call/closure_fn0.c18
-rw-r--r--libffi/testsuite/libffi.call/closure_fn1.c18
-rw-r--r--libffi/testsuite/libffi.call/closure_fn2.c18
-rw-r--r--libffi/testsuite/libffi.call/closure_fn3.c18
-rw-r--r--libffi/testsuite/libffi.call/closure_fn4.c18
-rw-r--r--libffi/testsuite/libffi.call/closure_fn5.c17
-rw-r--r--libffi/testsuite/libffi.call/closure_fn6.c18
-rw-r--r--libffi/testsuite/libffi.call/closure_stdcall.c18
-rw-r--r--libffi/testsuite/libffi.call/cls_12byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_16byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_18byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_19byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_1_1byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_20byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_20byte1.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_24byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_2byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_3_1byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_3byte1.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_3byte2.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_4_1byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_4byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_5_1_byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_5byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_64byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_6_1_byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_6byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_7_1_byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_7byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_8byte.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_9byte1.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_9byte2.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_double.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_float.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_longdouble.c18
-rw-r--r--libffi/testsuite/libffi.call/cls_align_longdouble_split.c20
-rw-r--r--libffi/testsuite/libffi.call/cls_align_longdouble_split2.c23
-rw-r--r--libffi/testsuite/libffi.call/cls_align_pointer.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_sint16.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_sint32.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_sint64.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_uint16.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_uint32.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_align_uint64.c22
-rw-r--r--libffi/testsuite/libffi.call/cls_dbls_struct.c17
-rw-r--r--libffi/testsuite/libffi.call/cls_double.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_double_va.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_float.c17
-rw-r--r--libffi/testsuite/libffi.call/cls_longdouble.c20
-rw-r--r--libffi/testsuite/libffi.call/cls_longdouble_va.c19
-rw-r--r--libffi/testsuite/libffi.call/cls_multi_schar.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_multi_sshort.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_multi_sshortchar.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_multi_uchar.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_multi_ushort.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_multi_ushortchar.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_pointer.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_pointer_stack.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_schar.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_sint.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_sshort.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_uchar.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_uint.c16
-rw-r--r--libffi/testsuite/libffi.call/cls_ulonglong.c22
-rw-r--r--libffi/testsuite/libffi.call/cls_ushort.c16
-rw-r--r--libffi/testsuite/libffi.call/err_bad_abi.c14
-rw-r--r--libffi/testsuite/libffi.call/err_bad_typedef.c10
-rw-r--r--libffi/testsuite/libffi.call/float2.c3
-rw-r--r--libffi/testsuite/libffi.call/nested_struct.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct1.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct10.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct2.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct3.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct4.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct5.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct6.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct7.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct8.c16
-rw-r--r--libffi/testsuite/libffi.call/nested_struct9.c16
-rw-r--r--libffi/testsuite/libffi.call/problem1.c16
-rw-r--r--libffi/testsuite/libffi.call/return_ldl.c2
-rw-r--r--libffi/testsuite/libffi.call/stret_large.c16
-rw-r--r--libffi/testsuite/libffi.call/stret_large2.c16
-rw-r--r--libffi/testsuite/libffi.call/stret_medium.c16
-rw-r--r--libffi/testsuite/libffi.call/stret_medium2.c16
-rw-r--r--libffi/testsuite/libffi.special/unwindtest.cc26
87 files changed, 371 insertions, 1031 deletions
diff --git a/libffi/testsuite/Makefile.in b/libffi/testsuite/Makefile.in
index 03c75e58b10..c6dd213abd0 100644
--- a/libffi/testsuite/Makefile.in
+++ b/libffi/testsuite/Makefile.in
@@ -175,6 +175,8 @@ X86_FREEBSD_TRUE = @X86_FREEBSD_TRUE@
X86_TRUE = @X86_TRUE@
X86_WIN32_FALSE = @X86_WIN32_FALSE@
X86_WIN32_TRUE = @X86_WIN32_TRUE@
+X86_WIN64_FALSE = @X86_WIN64_FALSE@
+X86_WIN64_TRUE = @X86_WIN64_TRUE@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DSYMUTIL = @ac_ct_DSYMUTIL@
diff --git a/libffi/testsuite/libffi.call/closure_fn0.c b/libffi/testsuite/libffi.call/closure_fn0.c
index b42fc20316f..a579ff6c979 100644
--- a/libffi/testsuite/libffi.call/closure_fn0.c
+++ b/libffi/testsuite/libffi.call/closure_fn0.c
@@ -49,19 +49,11 @@ typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void * code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
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[1] = &ffi_type_sint;
cl_arg_types[2] = &ffi_type_uint64;
@@ -84,10 +76,10 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn0,
- (void *) 3 /* userdata */) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
+ (void *) 3 /* userdata */, code) == FFI_OK);
- res = (*((closure_test_type0)pcl))
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/closure_fn1.c b/libffi/testsuite/libffi.call/closure_fn1.c
index 82b9b1d6edb..91231738c13 100644
--- a/libffi/testsuite/libffi.call/closure_fn1.c
+++ b/libffi/testsuite/libffi.call/closure_fn1.c
@@ -41,19 +41,11 @@ typedef int (*closure_test_type1)(float, float, float, float, signed short,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
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[1] = &ffi_type_float;
cl_arg_types[2] = &ffi_type_float;
@@ -76,10 +68,10 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn1,
- (void *) 3 /* userdata */) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1,
+ (void *) 3 /* userdata */, code) == FFI_OK);
- res = (*((closure_test_type1)pcl))
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/closure_fn2.c b/libffi/testsuite/libffi.call/closure_fn2.c
index d0ba48e6736..08ff9d92274 100644
--- a/libffi/testsuite/libffi.call/closure_fn2.c
+++ b/libffi/testsuite/libffi.call/closure_fn2.c
@@ -41,19 +41,11 @@ typedef int (*closure_test_type2)(double, double, double, double, signed short,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
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[1] = &ffi_type_double;
cl_arg_types[2] = &ffi_type_double;
@@ -76,10 +68,10 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn2,
- (void *) 3 /* userdata */) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn2,
+ (void *) 3 /* userdata */, code) == FFI_OK);
- res = (*((closure_test_type2)pcl))
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/closure_fn3.c b/libffi/testsuite/libffi.call/closure_fn3.c
index be4062d8b6f..9b54d805c82 100644
--- a/libffi/testsuite/libffi.call/closure_fn3.c
+++ b/libffi/testsuite/libffi.call/closure_fn3.c
@@ -42,19 +42,11 @@ typedef int (*closure_test_type3)(float, float, float, float, float, float,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
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[1] = &ffi_type_float;
cl_arg_types[2] = &ffi_type_float;
@@ -77,10 +69,10 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn3,
- (void *) 3 /* userdata */) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn3,
+ (void *) 3 /* userdata */, code) == FFI_OK);
- res = (*((closure_test_type3)pcl))
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/closure_fn4.c b/libffi/testsuite/libffi.call/closure_fn4.c
index 9a70b992c70..d4a1530b065 100644
--- a/libffi/testsuite/libffi.call/closure_fn4.c
+++ b/libffi/testsuite/libffi.call/closure_fn4.c
@@ -60,19 +60,11 @@ typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int i, res;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
for (i = 0; i < 15; i++) {
cl_arg_types[i] = &ffi_type_uint64;
}
@@ -83,10 +75,10 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn0,
- (void *) 3 /* userdata */) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
+ (void *) 3 /* userdata */, code) == FFI_OK);
- res = (*((closure_test_type0)pcl))
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/closure_fn5.c b/libffi/testsuite/libffi.call/closure_fn5.c
index c12491e84b6..99074426c67 100644
--- a/libffi/testsuite/libffi.call/closure_fn5.c
+++ b/libffi/testsuite/libffi.call/closure_fn5.c
@@ -59,17 +59,10 @@ typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
int i, res;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
for (i = 0; i < 10; i++) {
cl_arg_types[i] = &ffi_type_uint64;
@@ -85,10 +78,10 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn5,
- (void *) 3 /* userdata */) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn5,
+ (void *) 3 /* userdata */, code) == FFI_OK);
- res = (*((closure_test_type0)pcl))
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/closure_fn6.c b/libffi/testsuite/libffi.call/closure_fn6.c
index 5d9389d1775..73c54fd6b16 100644
--- a/libffi/testsuite/libffi.call/closure_fn6.c
+++ b/libffi/testsuite/libffi.call/closure_fn6.c
@@ -50,19 +50,11 @@ typedef int (*closure_test_type0)(unsigned long long,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
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[1] = &ffi_type_uint64;
cl_arg_types[2] = &ffi_type_uint64;
@@ -85,10 +77,10 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn0,
- (void *) 3 /* userdata */) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
+ (void *) 3 /* userdata */, code) == FFI_OK);
- res = (*((closure_test_type0)pcl))
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/closure_stdcall.c b/libffi/testsuite/libffi.call/closure_stdcall.c
index 020b469af7a..6bfcc1fbb5b 100644
--- a/libffi/testsuite/libffi.call/closure_stdcall.c
+++ b/libffi/testsuite/libffi.call/closure_stdcall.c
@@ -28,22 +28,14 @@ typedef int (__stdcall *closure_test_type0)(int, int, int, int);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cl_arg_types[0] = &ffi_type_uint;
cl_arg_types[1] = &ffi_type_uint;
cl_arg_types[2] = &ffi_type_uint;
@@ -54,11 +46,11 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_STDCALL, 4,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_stdcall,
- (void *) 3 /* userdata */) == 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)pcl)(0, 1, 2, 3);
+ res = (*(closure_test_type0)code)(0, 1, 2, 3);
asm volatile (" movl %%esp,%0" : "=g" (sp_post));
/* { dg-output "0 1 2 3: 9" } */
diff --git a/libffi/testsuite/libffi.call/cls_12byte.c b/libffi/testsuite/libffi.call/cls_12byte.c
index 92530d5ff57..f0a334fa797 100644
--- a/libffi/testsuite/libffi.call/cls_12byte.c
+++ b/libffi/testsuite/libffi.call/cls_12byte.c
@@ -42,21 +42,13 @@ static void cls_struct_12byte_gn(ffi_cif* cif __UNUSED__, void* resp,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -87,13 +79,13 @@ int main (void)
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(pcl, &cif, cls_struct_12byte_gn, NULL) == FFI_OK);
+ 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))(pcl))(h_dbl, j_dbl);
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/cls_16byte.c b/libffi/testsuite/libffi.call/cls_16byte.c
index f3c314a8760..9b9292ab056 100644
--- a/libffi/testsuite/libffi.call/cls_16byte.c
+++ b/libffi/testsuite/libffi.call/cls_16byte.c
@@ -43,21 +43,13 @@ static void cls_struct_16byte_gn(ffi_cif* cif __UNUSED__, void* resp,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -92,9 +84,9 @@ int main (void)
res_dbl.b = 0.0;
res_dbl.c = 0;
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_16byte_gn, NULL) == FFI_OK);
+ 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))(pcl))(h_dbl, j_dbl);
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/cls_18byte.c b/libffi/testsuite/libffi.call/cls_18byte.c
index 90165804695..40c8c6d96a1 100644
--- a/libffi/testsuite/libffi.call/cls_18byte.c
+++ b/libffi/testsuite/libffi.call/cls_18byte.c
@@ -47,21 +47,13 @@ cls_struct_18byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -93,9 +85,9 @@ int main (void)
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(pcl, &cif, cls_struct_18byte_gn, NULL) == FFI_OK);
+ 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))(pcl))(g_dbl, f_dbl);
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/cls_19byte.c b/libffi/testsuite/libffi.call/cls_19byte.c
index 8af583467b1..aa6424818f7 100644
--- a/libffi/testsuite/libffi.call/cls_19byte.c
+++ b/libffi/testsuite/libffi.call/cls_19byte.c
@@ -50,21 +50,13 @@ cls_struct_19byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -98,9 +90,9 @@ int main (void)
res_dbl.d, res_dbl.e);
/* { dg-output "\nres: 5 252 250 8 239" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_19byte_gn, NULL) == FFI_OK);
+ 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))(pcl))(g_dbl, f_dbl);
+ 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);
diff --git a/libffi/testsuite/libffi.call/cls_1_1byte.c b/libffi/testsuite/libffi.call/cls_1_1byte.c
index 0fcc8c6d54c..b9402d678ad 100644
--- a/libffi/testsuite/libffi.call/cls_1_1byte.c
+++ b/libffi/testsuite/libffi.call/cls_1_1byte.c
@@ -43,21 +43,13 @@ cls_struct_1_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -86,9 +78,9 @@ int main (void)
printf("res: %d\n", res_dbl.a);
/* { dg-output "\nres: 190" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_1_1byte_gn, NULL) == FFI_OK);
+ 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))(pcl))(g_dbl, f_dbl);
+ 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" } */
diff --git a/libffi/testsuite/libffi.call/cls_20byte.c b/libffi/testsuite/libffi.call/cls_20byte.c
index fa5f81a88c8..80dd7ac931b 100644
--- a/libffi/testsuite/libffi.call/cls_20byte.c
+++ b/libffi/testsuite/libffi.call/cls_20byte.c
@@ -43,21 +43,13 @@ cls_struct_20byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -88,9 +80,9 @@ int main (void)
printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 5 7 10" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_20byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */
printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 5 7 10" } */
diff --git a/libffi/testsuite/libffi.call/cls_20byte1.c b/libffi/testsuite/libffi.call/cls_20byte1.c
index 072bafcafb5..50bcbbf831a 100644
--- a/libffi/testsuite/libffi.call/cls_20byte1.c
+++ b/libffi/testsuite/libffi.call/cls_20byte1.c
@@ -45,21 +45,13 @@ cls_struct_20byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[4];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -90,9 +82,9 @@ int main (void)
printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 5 7 10" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_20byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */
printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 5 7 10" } */
diff --git a/libffi/testsuite/libffi.call/cls_24byte.c b/libffi/testsuite/libffi.call/cls_24byte.c
index 22e169058c5..46a6eb4d31c 100644
--- a/libffi/testsuite/libffi.call/cls_24byte.c
+++ b/libffi/testsuite/libffi.call/cls_24byte.c
@@ -54,21 +54,13 @@ cls_struct_24byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -106,13 +98,13 @@ int main (void)
printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 22 15 17 25" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_24byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_24byte_gn, NULL, code) == FFI_OK);
res_dbl = ((cls_struct_24byte(*)(cls_struct_24byte,
cls_struct_24byte,
cls_struct_24byte,
cls_struct_24byte))
- (pcl))(e_dbl, f_dbl, g_dbl, h_dbl);
+ (code))(e_dbl, f_dbl, g_dbl, h_dbl);
/* { dg-output "\n9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */
printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 22 15 17 25" } */
diff --git a/libffi/testsuite/libffi.call/cls_2byte.c b/libffi/testsuite/libffi.call/cls_2byte.c
index 5b91a09a2cc..101e130a1fc 100644
--- a/libffi/testsuite/libffi.call/cls_2byte.c
+++ b/libffi/testsuite/libffi.call/cls_2byte.c
@@ -43,21 +43,13 @@ cls_struct_2byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -87,9 +79,9 @@ int main (void)
printf("res: %d %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 13 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_2byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_2byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_2byte(*)(cls_struct_2byte, cls_struct_2byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_2byte(*)(cls_struct_2byte, cls_struct_2byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 127 1 13: 13 140" } */
printf("res: %d %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 13 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_3_1byte.c b/libffi/testsuite/libffi.call/cls_3_1byte.c
index 93fe911d2da..fc780c30d6c 100644
--- a/libffi/testsuite/libffi.call/cls_3_1byte.c
+++ b/libffi/testsuite/libffi.call/cls_3_1byte.c
@@ -47,21 +47,13 @@ cls_struct_3_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -92,9 +84,9 @@ int main (void)
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 190 192 194" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_3_1byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3_1byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_3_1byte(*)(cls_struct_3_1byte, cls_struct_3_1byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_3_1byte(*)(cls_struct_3_1byte, cls_struct_3_1byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 13 14 178 179 180: 190 192 194" } */
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 190 192 194" } */
diff --git a/libffi/testsuite/libffi.call/cls_3byte1.c b/libffi/testsuite/libffi.call/cls_3byte1.c
index b7726917094..5705ce38798 100644
--- a/libffi/testsuite/libffi.call/cls_3byte1.c
+++ b/libffi/testsuite/libffi.call/cls_3byte1.c
@@ -43,21 +43,13 @@ cls_struct_3byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -87,9 +79,9 @@ int main (void)
printf("res: %d %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 13 134" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_3byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_3byte(*)(cls_struct_3byte, cls_struct_3byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_3byte(*)(cls_struct_3byte, cls_struct_3byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 119 1 15: 13 134" } */
printf("res: %d %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 13 134" } */
diff --git a/libffi/testsuite/libffi.call/cls_3byte2.c b/libffi/testsuite/libffi.call/cls_3byte2.c
index 51128cc18ef..01770a0750b 100644
--- a/libffi/testsuite/libffi.call/cls_3byte2.c
+++ b/libffi/testsuite/libffi.call/cls_3byte2.c
@@ -43,21 +43,13 @@ cls_struct_3byte_gn1(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -87,9 +79,9 @@ int main (void)
printf("res: %d %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 24 144" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_3byte_gn1, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn1, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_3byte_1(*)(cls_struct_3byte_1, cls_struct_3byte_1))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_3byte_1(*)(cls_struct_3byte_1, cls_struct_3byte_1))(code))(g_dbl, f_dbl);
/* { dg-output "\n15 125 9 19: 24 144" } */
printf("res: %d %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 24 144" } */
diff --git a/libffi/testsuite/libffi.call/cls_4_1byte.c b/libffi/testsuite/libffi.call/cls_4_1byte.c
index a378d194f42..f3806d7ba1c 100644
--- a/libffi/testsuite/libffi.call/cls_4_1byte.c
+++ b/libffi/testsuite/libffi.call/cls_4_1byte.c
@@ -49,21 +49,13 @@ cls_struct_4_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -95,9 +87,9 @@ int main (void)
printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 190 192 194 196" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_4_1byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4_1byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_4_1byte(*)(cls_struct_4_1byte, cls_struct_4_1byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_4_1byte(*)(cls_struct_4_1byte, cls_struct_4_1byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 13 14 15 178 179 180 181: 190 192 194 196" } */
printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 190 192 194 196" } */
diff --git a/libffi/testsuite/libffi.call/cls_4byte.c b/libffi/testsuite/libffi.call/cls_4byte.c
index b2c951dbeb5..a1aba3c09d5 100644
--- a/libffi/testsuite/libffi.call/cls_4byte.c
+++ b/libffi/testsuite/libffi.call/cls_4byte.c
@@ -43,21 +43,13 @@ cls_struct_4byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -87,9 +79,9 @@ int main (void)
printf("res: %d %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 139 248" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_4byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_4byte(*)(cls_struct_4byte, cls_struct_4byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_4byte(*)(cls_struct_4byte, cls_struct_4byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n127 120 12 128: 139 248" } */
printf("res: %d %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 139 248" } */
diff --git a/libffi/testsuite/libffi.call/cls_5_1_byte.c b/libffi/testsuite/libffi.call/cls_5_1_byte.c
index 40d2e64eec8..2ceba3ddb2d 100644
--- a/libffi/testsuite/libffi.call/cls_5_1_byte.c
+++ b/libffi/testsuite/libffi.call/cls_5_1_byte.c
@@ -51,21 +51,13 @@ cls_struct_5byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[6];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -105,9 +97,9 @@ int main (void)
res_dbl.d = 0;
res_dbl.e = 0;
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_5byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_5byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n127 120 1 3 4 12 128 9 3 4: 139 248 10 6 8" } */
printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e);
diff --git a/libffi/testsuite/libffi.call/cls_5byte.c b/libffi/testsuite/libffi.call/cls_5byte.c
index 0307e51f6b9..61d595c2bf0 100644
--- a/libffi/testsuite/libffi.call/cls_5byte.c
+++ b/libffi/testsuite/libffi.call/cls_5byte.c
@@ -46,21 +46,13 @@ cls_struct_5byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -95,9 +87,9 @@ int main (void)
res_dbl.b = 0;
res_dbl.c = 0;
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_5byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_5byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n127 120 1 12 128 9: 139 248 10" } */
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 139 248 10" } */
diff --git a/libffi/testsuite/libffi.call/cls_64byte.c b/libffi/testsuite/libffi.call/cls_64byte.c
index 1329c6f26ab..576ebe0cc2a 100644
--- a/libffi/testsuite/libffi.call/cls_64byte.c
+++ b/libffi/testsuite/libffi.call/cls_64byte.c
@@ -59,21 +59,13 @@ cls_struct_64byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[9];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -116,13 +108,13 @@ int main (void)
res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h);
/* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_64byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_64byte_gn, NULL, code) == FFI_OK);
res_dbl = ((cls_struct_64byte(*)(cls_struct_64byte,
cls_struct_64byte,
cls_struct_64byte,
cls_struct_64byte))
- (pcl))(e_dbl, f_dbl, g_dbl, h_dbl);
+ (code))(e_dbl, f_dbl, g_dbl, h_dbl);
/* { dg-output "\n22 15 17 25 6 13 19 18" } */
printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h);
diff --git a/libffi/testsuite/libffi.call/cls_6_1_byte.c b/libffi/testsuite/libffi.call/cls_6_1_byte.c
index 7ddb586ea1a..9f2eff68c1f 100644
--- a/libffi/testsuite/libffi.call/cls_6_1_byte.c
+++ b/libffi/testsuite/libffi.call/cls_6_1_byte.c
@@ -53,21 +53,13 @@ cls_struct_6byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[7];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -109,9 +101,9 @@ int main (void)
res_dbl.e = 0;
res_dbl.f = 0;
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_6byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n127 120 1 3 4 5 12 128 9 3 4 5: 139 248 10 6 8 10" } */
printf("res: %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e, res_dbl.f);
diff --git a/libffi/testsuite/libffi.call/cls_6byte.c b/libffi/testsuite/libffi.call/cls_6byte.c
index 24fd63baa37..73257b0989b 100644
--- a/libffi/testsuite/libffi.call/cls_6byte.c
+++ b/libffi/testsuite/libffi.call/cls_6byte.c
@@ -49,21 +49,13 @@ cls_struct_6byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -95,9 +87,9 @@ int main (void)
printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 139 248 10 255" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_6byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n127 120 1 128 12 128 9 127: 139 248 10 255" } */
printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 139 248 10 255" } */
diff --git a/libffi/testsuite/libffi.call/cls_7_1_byte.c b/libffi/testsuite/libffi.call/cls_7_1_byte.c
index 0cf1371a77a..50d09c9da72 100644
--- a/libffi/testsuite/libffi.call/cls_7_1_byte.c
+++ b/libffi/testsuite/libffi.call/cls_7_1_byte.c
@@ -55,21 +55,13 @@ cls_struct_7byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[8];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -113,9 +105,9 @@ int main (void)
res_dbl.f = 0;
res_dbl.g = 0;
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_7byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n127 120 1 3 4 5 6 12 128 9 3 4 5 6: 139 248 10 6 8 10 12" } */
printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
diff --git a/libffi/testsuite/libffi.call/cls_7byte.c b/libffi/testsuite/libffi.call/cls_7byte.c
index 77858625fa9..f5c00003153 100644
--- a/libffi/testsuite/libffi.call/cls_7byte.c
+++ b/libffi/testsuite/libffi.call/cls_7byte.c
@@ -48,21 +48,13 @@ cls_struct_7byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[5];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -94,9 +86,9 @@ int main (void)
printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 139 248 10 509" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_7byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n127 120 1 254 12 128 9 255: 139 248 10 509" } */
printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
/* { dg-output "\nres: 139 248 10 509" } */
diff --git a/libffi/testsuite/libffi.call/cls_8byte.c b/libffi/testsuite/libffi.call/cls_8byte.c
index 75326b8f70e..4aa99d12e41 100644
--- a/libffi/testsuite/libffi.call/cls_8byte.c
+++ b/libffi/testsuite/libffi.call/cls_8byte.c
@@ -42,21 +42,13 @@ cls_struct_8byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -85,9 +77,9 @@ int main (void)
/* { dg-output "1 2 4 5: 5 7" } */
printf("res: %d %g\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 5 7" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_8byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_8byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_8byte(*)(cls_struct_8byte, cls_struct_8byte))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_8byte(*)(cls_struct_8byte, cls_struct_8byte))(code))(g_dbl, f_dbl);
/* { dg-output "\n1 2 4 5: 5 7" } */
printf("res: %d %g\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 5 7" } */
diff --git a/libffi/testsuite/libffi.call/cls_9byte1.c b/libffi/testsuite/libffi.call/cls_9byte1.c
index 0b3de9daa93..cc5e9d6c4e9 100644
--- a/libffi/testsuite/libffi.call/cls_9byte1.c
+++ b/libffi/testsuite/libffi.call/cls_9byte1.c
@@ -43,21 +43,13 @@ static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[3];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -87,9 +79,9 @@ int main (void)
printf("res: %d %g\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 8 17" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_9byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(pcl))(h_dbl, j_dbl);
+ res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl);
/* { dg-output "\n7 8 1 9: 8 17" } */
printf("res: %d %g\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 8 17" } */
diff --git a/libffi/testsuite/libffi.call/cls_9byte2.c b/libffi/testsuite/libffi.call/cls_9byte2.c
index 8cafc8af6c8..5c0ba0d4b8d 100644
--- a/libffi/testsuite/libffi.call/cls_9byte2.c
+++ b/libffi/testsuite/libffi.call/cls_9byte2.c
@@ -43,21 +43,13 @@ static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[3];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -88,9 +80,9 @@ int main (void)
/* { dg-output "\nres: 8 17" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_9byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(pcl))(h_dbl, j_dbl);
+ res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl);
/* { dg-output "\n7 8 1 9: 8 17" } */
printf("res: %g %d\n", res_dbl.a, res_dbl.b);
/* { dg-output "\nres: 8 17" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_double.c b/libffi/testsuite/libffi.call/cls_align_double.c
index 5ba230154a4..22b94d5a09d 100644
--- a/libffi/testsuite/libffi.call/cls_align_double.c
+++ b/libffi/testsuite/libffi.call/cls_align_double.c
@@ -45,21 +45,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -90,9 +82,9 @@ int main (void)
printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_float.c b/libffi/testsuite/libffi.call/cls_align_float.c
index 996e1ab965b..62637f21d18 100644
--- a/libffi/testsuite/libffi.call/cls_align_float.c
+++ b/libffi/testsuite/libffi.call/cls_align_float.c
@@ -43,21 +43,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -88,9 +80,9 @@ int main (void)
printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_longdouble.c b/libffi/testsuite/libffi.call/cls_align_longdouble.c
index 74cddc3a7e8..af380603c99 100644
--- a/libffi/testsuite/libffi.call/cls_align_longdouble.c
+++ b/libffi/testsuite/libffi.call/cls_align_longdouble.c
@@ -4,7 +4,7 @@
PR: none.
Originator: <hos@tamanegi.org> 20031203 */
-/* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run } */
#include "ffitest.h"
@@ -44,21 +44,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -89,9 +81,9 @@ int main (void)
printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_longdouble_split.c b/libffi/testsuite/libffi.call/cls_align_longdouble_split.c
index b350b3df295..40326778aee 100644
--- a/libffi/testsuite/libffi.call/cls_align_longdouble_split.c
+++ b/libffi/testsuite/libffi.call/cls_align_longdouble_split.c
@@ -4,8 +4,10 @@
PR: none.
Originator: <hos@tamanegi.org> 20031203 */
-/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */
+/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
#include "ffitest.h"
@@ -78,21 +80,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[8];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -128,9 +122,9 @@ int main (void)
res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
/* { dg-output "\nres: 9 11 13 15 17 19 21" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */
printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b,
res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
diff --git a/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c b/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c
index 0e8be3febf0..ced41c0b00c 100644
--- a/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c
+++ b/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c
@@ -5,8 +5,10 @@
Originator: Blake Chaffin 6/18/2007
*/
-/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* } } */
/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */
+/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
#include "ffitest.h"
@@ -58,21 +60,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[8];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -108,9 +102,9 @@ int main (void)
res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
/* { dg-output "\nres: 9 11 13 15 17 19 21" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */
printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b,
res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
@@ -118,3 +112,6 @@ int main (void)
exit(0);
}
+
+
+
diff --git a/libffi/testsuite/libffi.call/cls_align_pointer.c b/libffi/testsuite/libffi.call/cls_align_pointer.c
index 9a79922f561..cbc4f953ff6 100644
--- a/libffi/testsuite/libffi.call/cls_align_pointer.c
+++ b/libffi/testsuite/libffi.call/cls_align_pointer.c
@@ -47,21 +47,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -92,9 +84,9 @@ int main (void)
printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_sint16.c b/libffi/testsuite/libffi.call/cls_align_sint16.c
index fe4fe092215..383ea41d5a6 100644
--- a/libffi/testsuite/libffi.call/cls_align_sint16.c
+++ b/libffi/testsuite/libffi.call/cls_align_sint16.c
@@ -43,21 +43,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -88,9 +80,9 @@ int main (void)
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_sint32.c b/libffi/testsuite/libffi.call/cls_align_sint32.c
index c059da80975..705d78cfa84 100644
--- a/libffi/testsuite/libffi.call/cls_align_sint32.c
+++ b/libffi/testsuite/libffi.call/cls_align_sint32.c
@@ -43,21 +43,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -88,9 +80,9 @@ int main (void)
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_sint64.c b/libffi/testsuite/libffi.call/cls_align_sint64.c
index f5e9746cab0..d8b73e95783 100644
--- a/libffi/testsuite/libffi.call/cls_align_sint64.c
+++ b/libffi/testsuite/libffi.call/cls_align_sint64.c
@@ -43,21 +43,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -88,9 +80,9 @@ int main (void)
printf("res: %d %lld %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %lld %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_uint16.c b/libffi/testsuite/libffi.call/cls_align_uint16.c
index c861bee344d..cb6b74821ea 100644
--- a/libffi/testsuite/libffi.call/cls_align_uint16.c
+++ b/libffi/testsuite/libffi.call/cls_align_uint16.c
@@ -43,21 +43,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -88,9 +80,9 @@ int main (void)
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_uint32.c b/libffi/testsuite/libffi.call/cls_align_uint32.c
index d680d8a9f8c..e453d3e5d9e 100644
--- a/libffi/testsuite/libffi.call/cls_align_uint32.c
+++ b/libffi/testsuite/libffi.call/cls_align_uint32.c
@@ -43,21 +43,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -88,9 +80,9 @@ int main (void)
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
diff --git a/libffi/testsuite/libffi.call/cls_align_uint64.c b/libffi/testsuite/libffi.call/cls_align_uint64.c
index 0737ba2305b..a3886f48962 100644
--- a/libffi/testsuite/libffi.call/cls_align_uint64.c
+++ b/libffi/testsuite/libffi.call/cls_align_uint64.c
@@ -23,7 +23,7 @@ cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
result.b = a1.b + a2.b;
result.c = a1.c + a2.c;
- printf("%d %lld %d %d %lld %d: %d %lld %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
+ printf("%d %llu %d %d %llu %d: %d %llu %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
return result;
}
@@ -44,21 +44,13 @@ cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ 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];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -86,14 +78,14 @@ int main (void)
ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
/* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
- printf("res: %d %lld %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ printf("res: %d %llu %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
- res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
/* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
- printf("res: %d %lld %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ printf("res: %d %llu %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
/* { dg-output "\nres: 13 14271 140" } */
exit(0);
diff --git a/libffi/testsuite/libffi.call/cls_dbls_struct.c b/libffi/testsuite/libffi.call/cls_dbls_struct.c
index c568381cf45..fcf48b79237 100644
--- a/libffi/testsuite/libffi.call/cls_dbls_struct.c
+++ b/libffi/testsuite/libffi.call/cls_dbls_struct.c
@@ -30,19 +30,10 @@ int main(int argc __UNUSED__, char** argv __UNUSED__)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
-
- ffi_closure* pcl;
+ void *code;
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type* cl_arg_types[1];
-#ifdef USING_MMAP
- pcl = allocate_mmap(sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
ffi_type ts1_type;
ffi_type* ts1_type_elements[4];
@@ -63,9 +54,9 @@ int main(int argc __UNUSED__, char** argv __UNUSED__)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_void, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK);
- ((void*(*)(Dbls))(pcl))(arg);
+ ((void*(*)(Dbls))(code))(arg);
/* { dg-output "1.0 2.0\n" { xfail x86_64-*-linux-* } } */
closure_test_fn(arg);
diff --git a/libffi/testsuite/libffi.call/cls_double.c b/libffi/testsuite/libffi.call/cls_double.c
index ee77adde6a0..84ad4cb7d92 100644
--- a/libffi/testsuite/libffi.call/cls_double.c
+++ b/libffi/testsuite/libffi.call/cls_double.c
@@ -20,19 +20,11 @@ typedef double (*cls_ret_double)(double);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
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[1] = NULL;
@@ -40,9 +32,9 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_double, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_double_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_double_fn, NULL, code) == FFI_OK);
- res = (*((cls_ret_double)pcl))(21474.789);
+ res = (*((cls_ret_double)code))(21474.789);
/* { dg-output "21474.789000: 21474.789000" } */
printf("res: %.6f\n", res);
/* { dg-output "\nres: 21474.789000" } */
diff --git a/libffi/testsuite/libffi.call/cls_double_va.c b/libffi/testsuite/libffi.call/cls_double_va.c
index 4d6d5b71c40..45ce9bd7c38 100644
--- a/libffi/testsuite/libffi.call/cls_double_va.c
+++ b/libffi/testsuite/libffi.call/cls_double_va.c
@@ -20,19 +20,11 @@ cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args[3];
ffi_type* arg_types[3];
-#ifdef USING_MMAP
- pcl = allocate_mmap(sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
char* format = "%.1f\n";
double doubleArg = 7;
ffi_arg res = 0;
@@ -53,9 +45,9 @@ int main (void)
printf("res: %d\n", (int) res);
// { dg-output "\nres: 4" }
- CHECK(ffi_prep_closure(pcl, &cif, cls_double_va_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, code) == FFI_OK);
- res = ((int(*)(char*, double))(pcl))(format, doubleArg);
+ res = ((int(*)(char*, double))(code))(format, doubleArg);
// { dg-output "\n7.0" }
printf("res: %d\n", (int) res);
// { dg-output "\nres: 4" }
diff --git a/libffi/testsuite/libffi.call/cls_float.c b/libffi/testsuite/libffi.call/cls_float.c
index 8bed628f823..0090fed9063 100644
--- a/libffi/testsuite/libffi.call/cls_float.c
+++ b/libffi/testsuite/libffi.call/cls_float.c
@@ -21,20 +21,11 @@ typedef float (*cls_ret_float)(float);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
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[1] = NULL;
@@ -42,8 +33,8 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_float, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_float_fn, NULL) == FFI_OK);
- res = ((((cls_ret_float)pcl)(-2122.12)));
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_float_fn, NULL, code) == FFI_OK);
+ res = ((((cls_ret_float)code)(-2122.12)));
/* { dg-output "\\-2122.12: \\-2122.12" } */
printf("res: %.6f\n", res);
/* { dg-output "\nres: \-2122.120117" } */
diff --git a/libffi/testsuite/libffi.call/cls_longdouble.c b/libffi/testsuite/libffi.call/cls_longdouble.c
index a0fafc9f3e8..2f50b368e7a 100644
--- a/libffi/testsuite/libffi.call/cls_longdouble.c
+++ b/libffi/testsuite/libffi.call/cls_longdouble.c
@@ -4,8 +4,10 @@
PR: none.
Originator: Blake Chaffin */
-/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
/* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */
+/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
#include "ffitest.h"
@@ -47,20 +49,12 @@ cls_ldouble_gn(ffi_cif* cif __UNUSED__, void* resp,
int main(void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure* pcl;
+ void* code;
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args[9];
ffi_type* arg_types[9];
long double res = 0;
-#ifdef USING_MMAP
- pcl = allocate_mmap(sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
long double arg1 = 1;
long double arg2 = 2;
long double arg3 = 3;
@@ -98,10 +92,10 @@ int main(void)
printf("res: %Lg\n", res);
/* { dg-output "\nres: 36" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_ldouble_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ldouble_gn, NULL, code) == FFI_OK);
res = ((long double(*)(long double, long double, long double, long double,
- long double, long double, long double, long double))(pcl))(arg1, arg2,
+ long double, long double, long double, long double))(code))(arg1, arg2,
arg3, arg4, arg5, arg6, arg7, arg8);
/* { dg-output "\n1 2 3 4 5 6 7 8: 36" } */
printf("res: %Lg\n", res);
diff --git a/libffi/testsuite/libffi.call/cls_longdouble_va.c b/libffi/testsuite/libffi.call/cls_longdouble_va.c
index c3599d7b789..0e910d5bd37 100644
--- a/libffi/testsuite/libffi.call/cls_longdouble_va.c
+++ b/libffi/testsuite/libffi.call/cls_longdouble_va.c
@@ -4,7 +4,8 @@
PR: none.
Originator: Blake Chaffin 6/6/2007 */
-/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+/* { dg-output "" { xfail x86_64-*-mingw* } } */
#include "ffitest.h"
static void
@@ -20,19 +21,11 @@ cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args[3];
ffi_type* arg_types[3];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
char* format = "%L.1f\n";
long double ldArg = 7;
ffi_arg res = 0;
@@ -53,9 +46,9 @@ int main (void)
printf("res: %d\n", (int) res);
// { dg-output "\nres: 4" { xfail i*86-*-linux-* x86_64-*-linux-* sh*-*-linux-* } }
- CHECK(ffi_prep_closure(pcl, &cif, cls_longdouble_va_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, code) == FFI_OK);
- res = ((int(*)(char*, long double))(pcl))(format, ldArg);
+ res = ((int(*)(char*, long double))(code))(format, ldArg);
// { dg-output "\n7.0" }
printf("res: %d\n", (int) res);
// { dg-output "\nres: 4" }
diff --git a/libffi/testsuite/libffi.call/cls_multi_schar.c b/libffi/testsuite/libffi.call/cls_multi_schar.c
index 713c3188d81..71df7b6516e 100644
--- a/libffi/testsuite/libffi.call/cls_multi_schar.c
+++ b/libffi/testsuite/libffi.call/cls_multi_schar.c
@@ -36,21 +36,13 @@ typedef signed char (*test_type)(signed char, signed char);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void * args_dbl[3];
ffi_type * cl_arg_types[3];
ffi_arg res_call;
signed char a, b, res_closure;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
a = 2;
b = 125;
@@ -71,9 +63,9 @@ int main (void)
printf("res: %d\n", (signed char)res_call);
/* { dg-output "\nres: 127" } */
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
- res_closure = (*((test_type)pcl))(2, 125);
+ res_closure = (*((test_type)code))(2, 125);
/* { dg-output "\n2 125: 127" } */
printf("res: %d\n", res_closure);
/* { dg-output "\nres: 127" } */
diff --git a/libffi/testsuite/libffi.call/cls_multi_sshort.c b/libffi/testsuite/libffi.call/cls_multi_sshort.c
index 852fdf73db7..4c391532667 100644
--- a/libffi/testsuite/libffi.call/cls_multi_sshort.c
+++ b/libffi/testsuite/libffi.call/cls_multi_sshort.c
@@ -36,21 +36,13 @@ typedef signed short (*test_type)(signed short, signed short);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void * args_dbl[3];
ffi_type * cl_arg_types[3];
ffi_arg res_call;
unsigned short a, b, res_closure;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
a = 2;
b = 32765;
@@ -71,9 +63,9 @@ int main (void)
printf("res: %d\n", (unsigned short)res_call);
/* { dg-output "\nres: 32767" } */
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
- res_closure = (*((test_type)pcl))(2, 32765);
+ res_closure = (*((test_type)code))(2, 32765);
/* { dg-output "\n2 32765: 32767" } */
printf("res: %d\n", res_closure);
/* { dg-output "\nres: 32767" } */
diff --git a/libffi/testsuite/libffi.call/cls_multi_sshortchar.c b/libffi/testsuite/libffi.call/cls_multi_sshortchar.c
index e4e92ef4480..1c3aeb5a66c 100644
--- a/libffi/testsuite/libffi.call/cls_multi_sshortchar.c
+++ b/libffi/testsuite/libffi.call/cls_multi_sshortchar.c
@@ -41,22 +41,14 @@ typedef signed short (*test_type)(signed char, signed short,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void * args_dbl[5];
ffi_type * cl_arg_types[5];
ffi_arg res_call;
signed char a, c;
signed short b, d, res_closure;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
a = 1;
b = 32765;
c = 127;
@@ -83,9 +75,9 @@ int main (void)
printf("res: %d\n", (signed short)res_call);
/* { dg-output "\nres: 32765" } */
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
- res_closure = (*((test_type)pcl))(1, 32765, 127, -128);
+ res_closure = (*((test_type)code))(1, 32765, 127, -128);
/* { dg-output "\n1 32765 127 -128: 32765" } */
printf("res: %d\n", res_closure);
/* { dg-output "\nres: 32765" } */
diff --git a/libffi/testsuite/libffi.call/cls_multi_uchar.c b/libffi/testsuite/libffi.call/cls_multi_uchar.c
index 2c84aef6134..009c02c72ba 100644
--- a/libffi/testsuite/libffi.call/cls_multi_uchar.c
+++ b/libffi/testsuite/libffi.call/cls_multi_uchar.c
@@ -47,21 +47,13 @@ void test_func(ffi_cif *cif __UNUSED__, void *rval __UNUSED__, void **avals,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void * args_dbl[5];
ffi_type * cl_arg_types[5];
ffi_arg res_call;
unsigned char a, b, c, d, res_closure;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
a = 1;
b = 2;
c = 127;
@@ -88,9 +80,9 @@ int main (void)
printf("res: %d\n", (unsigned char)res_call);
/* { dg-output "\nres: 255" } */
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
- res_closure = (*((test_type)pcl))(1, 2, 127, 125);
+ res_closure = (*((test_type)code))(1, 2, 127, 125);
/* { dg-output "\n1 2 127 125: 255" } */
printf("res: %d\n", res_closure);
/* { dg-output "\nres: 255" } */
diff --git a/libffi/testsuite/libffi.call/cls_multi_ushort.c b/libffi/testsuite/libffi.call/cls_multi_ushort.c
index 215fef832a8..dd10ca73468 100644
--- a/libffi/testsuite/libffi.call/cls_multi_ushort.c
+++ b/libffi/testsuite/libffi.call/cls_multi_ushort.c
@@ -36,21 +36,13 @@ typedef unsigned short (*test_type)(unsigned short, unsigned short);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void * args_dbl[3];
ffi_type * cl_arg_types[3];
ffi_arg res_call;
unsigned short a, b, res_closure;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
a = 2;
b = 32765;
@@ -71,9 +63,9 @@ int main (void)
printf("res: %d\n", (unsigned short)res_call);
/* { dg-output "\nres: 32767" } */
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
- res_closure = (*((test_type)pcl))(2, 32765);
+ res_closure = (*((test_type)code))(2, 32765);
/* { dg-output "\n2 32765: 32767" } */
printf("res: %d\n", res_closure);
/* { dg-output "\nres: 32767" } */
diff --git a/libffi/testsuite/libffi.call/cls_multi_ushortchar.c b/libffi/testsuite/libffi.call/cls_multi_ushortchar.c
index 1cde84abb5e..2588e97f987 100644
--- a/libffi/testsuite/libffi.call/cls_multi_ushortchar.c
+++ b/libffi/testsuite/libffi.call/cls_multi_ushortchar.c
@@ -41,22 +41,14 @@ typedef unsigned short (*test_type)(unsigned char, unsigned short,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void * args_dbl[5];
ffi_type * cl_arg_types[5];
ffi_arg res_call;
unsigned char a, c;
unsigned short b, d, res_closure;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
a = 1;
b = 2;
c = 127;
@@ -83,9 +75,9 @@ int main (void)
printf("res: %d\n", (unsigned short)res_call);
/* { dg-output "\nres: 258" } */
- CHECK(ffi_prep_closure(pcl, &cif, test_func_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
- res_closure = (*((test_type)pcl))(1, 2, 127, 128);
+ res_closure = (*((test_type)code))(1, 2, 127, 128);
/* { dg-output "\n1 2 127 128: 258" } */
printf("res: %d\n", res_closure);
/* { dg-output "\nres: 258" } */
diff --git a/libffi/testsuite/libffi.call/cls_pointer.c b/libffi/testsuite/libffi.call/cls_pointer.c
index ffc1f6a3544..34e4209640b 100644
--- a/libffi/testsuite/libffi.call/cls_pointer.c
+++ b/libffi/testsuite/libffi.call/cls_pointer.c
@@ -32,20 +32,12 @@ cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure* pcl;
+ void *code;
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args[3];
// ffi_type cls_pointer_type;
ffi_type* arg_types[3];
-#ifdef USING_MMAP
- pcl = allocate_mmap(sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
/* cls_pointer_type.size = sizeof(void*);
cls_pointer_type.alignment = 0;
cls_pointer_type.type = FFI_TYPE_POINTER;
@@ -71,9 +63,9 @@ int main (void)
printf("res: 0x%08x\n", (unsigned int) res);
/* { dg-output "\nres: 0x9be02467" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_pointer_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
- res = (ffi_arg)((void*(*)(void*, void*))(pcl))(arg1, arg2);
+ res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2);
/* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */
printf("res: 0x%08x\n", (unsigned int) res);
/* { dg-output "\nres: 0x9be02467" } */
diff --git a/libffi/testsuite/libffi.call/cls_pointer_stack.c b/libffi/testsuite/libffi.call/cls_pointer_stack.c
index c7ab55b37e5..dd59c6b2c7a 100644
--- a/libffi/testsuite/libffi.call/cls_pointer_stack.c
+++ b/libffi/testsuite/libffi.call/cls_pointer_stack.c
@@ -93,20 +93,12 @@ cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure* pcl;
+ void *code;
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args[3];
// ffi_type cls_pointer_type;
ffi_type* arg_types[3];
-#ifdef USING_MMAP
- pcl = allocate_mmap(sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
/* cls_pointer_type.size = sizeof(void*);
cls_pointer_type.alignment = 0;
cls_pointer_type.type = FFI_TYPE_POINTER;
@@ -135,9 +127,9 @@ int main (void)
// { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" }
// { dg-output "\nres: 0x8bf258bd" }
- CHECK(ffi_prep_closure(pcl, &cif, cls_pointer_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
- res = (ffi_arg)((void*(*)(void*, void*))(pcl))(arg1, arg2);
+ res = (ffi_arg)((void*(*)(void*, void*))(code))(arg1, arg2);
printf("res: 0x%08x\n", (unsigned int) res);
// { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" }
diff --git a/libffi/testsuite/libffi.call/cls_schar.c b/libffi/testsuite/libffi.call/cls_schar.c
index bb1f2c64f35..82986b172c3 100644
--- a/libffi/testsuite/libffi.call/cls_schar.c
+++ b/libffi/testsuite/libffi.call/cls_schar.c
@@ -21,19 +21,11 @@ typedef signed char (*cls_ret_schar)(signed char);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
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[1] = NULL;
@@ -41,9 +33,9 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_schar, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_schar_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_schar_fn, NULL, code) == FFI_OK);
- res = (*((cls_ret_schar)pcl))(127);
+ res = (*((cls_ret_schar)code))(127);
/* { dg-output "127: 127" } */
printf("res: %d\n", res);
/* { dg-output "\nres: 127" } */
diff --git a/libffi/testsuite/libffi.call/cls_sint.c b/libffi/testsuite/libffi.call/cls_sint.c
index cf21bf84417..c7e13b73a3b 100644
--- a/libffi/testsuite/libffi.call/cls_sint.c
+++ b/libffi/testsuite/libffi.call/cls_sint.c
@@ -19,19 +19,11 @@ typedef signed int (*cls_ret_sint)(signed int);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
signed int res;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cl_arg_types[0] = &ffi_type_sint;
cl_arg_types[1] = NULL;
@@ -39,9 +31,9 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_sint_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sint_fn, NULL, code) == FFI_OK);
- res = (*((cls_ret_sint)pcl))(65534);
+ res = (*((cls_ret_sint)code))(65534);
/* { dg-output "65534: 65534" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 65534" } */
diff --git a/libffi/testsuite/libffi.call/cls_sshort.c b/libffi/testsuite/libffi.call/cls_sshort.c
index 8d63413318d..846d57ed1ba 100644
--- a/libffi/testsuite/libffi.call/cls_sshort.c
+++ b/libffi/testsuite/libffi.call/cls_sshort.c
@@ -19,19 +19,11 @@ typedef signed short (*cls_ret_sshort)(signed short);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
signed short res;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cl_arg_types[0] = &ffi_type_sshort;
cl_arg_types[1] = NULL;
@@ -39,9 +31,9 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_sshort, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_sshort_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sshort_fn, NULL, code) == FFI_OK);
- res = (*((cls_ret_sshort)pcl))(255);
+ res = (*((cls_ret_sshort)code))(255);
/* { dg-output "255: 255" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 255" } */
diff --git a/libffi/testsuite/libffi.call/cls_uchar.c b/libffi/testsuite/libffi.call/cls_uchar.c
index ea78ce5840a..c1317e795fd 100644
--- a/libffi/testsuite/libffi.call/cls_uchar.c
+++ b/libffi/testsuite/libffi.call/cls_uchar.c
@@ -19,19 +19,11 @@ typedef unsigned char (*cls_ret_uchar)(unsigned char);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
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[1] = NULL;
@@ -39,9 +31,9 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uchar, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_uchar_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uchar_fn, NULL, code) == FFI_OK);
- res = (*((cls_ret_uchar)pcl))(127);
+ res = (*((cls_ret_uchar)code))(127);
/* { dg-output "127: 127" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 127" } */
diff --git a/libffi/testsuite/libffi.call/cls_uint.c b/libffi/testsuite/libffi.call/cls_uint.c
index e31e41aacf2..885cff5c314 100644
--- a/libffi/testsuite/libffi.call/cls_uint.c
+++ b/libffi/testsuite/libffi.call/cls_uint.c
@@ -20,19 +20,11 @@ typedef unsigned int (*cls_ret_uint)(unsigned int);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
unsigned int res;
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cl_arg_types[0] = &ffi_type_uint;
cl_arg_types[1] = NULL;
@@ -40,9 +32,9 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_uint_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uint_fn, NULL, code) == FFI_OK);
- res = (*((cls_ret_uint)pcl))(2147483647);
+ res = (*((cls_ret_uint)code))(2147483647);
/* { dg-output "2147483647: 2147483647" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 2147483647" } */
diff --git a/libffi/testsuite/libffi.call/cls_ulonglong.c b/libffi/testsuite/libffi.call/cls_ulonglong.c
index 1cc0a389332..ed891e35a2b 100644
--- a/libffi/testsuite/libffi.call/cls_ulonglong.c
+++ b/libffi/testsuite/libffi.call/cls_ulonglong.c
@@ -20,34 +20,26 @@ typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
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[1] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint64, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_ulonglong_fn, NULL) == FFI_OK);
- res = (*((cls_ret_ulonglong)pcl))(214LL);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ulonglong_fn, NULL, code) == FFI_OK);
+ res = (*((cls_ret_ulonglong)code))(214LL);
/* { dg-output "214: 214" } */
- printf("res: %lld\n", res);
+ printf("res: %llu\n", res);
/* { dg-output "\nres: 214" } */
- res = (*((cls_ret_ulonglong)pcl))(9223372035854775808LL);
+ res = (*((cls_ret_ulonglong)code))(9223372035854775808LL);
/* { dg-output "\n9223372035854775808: 9223372035854775808" } */
- printf("res: %lld\n", res);
+ printf("res: %llu\n", res);
/* { dg-output "\nres: 9223372035854775808" } */
exit(0);
diff --git a/libffi/testsuite/libffi.call/cls_ushort.c b/libffi/testsuite/libffi.call/cls_ushort.c
index 81f984862a3..a00100e07f8 100644
--- a/libffi/testsuite/libffi.call/cls_ushort.c
+++ b/libffi/testsuite/libffi.call/cls_ushort.c
@@ -20,19 +20,11 @@ typedef unsigned short (*cls_ret_ushort)(unsigned short);
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[2];
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[1] = NULL;
@@ -40,9 +32,9 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_ushort, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, cls_ret_ushort_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ushort_fn, NULL, code) == FFI_OK);
- res = (*((cls_ret_ushort)pcl))(65535);
+ res = (*((cls_ret_ushort)code))(65535);
/* { dg-output "65535: 65535" } */
printf("res: %d\n",res);
/* { dg-output "\nres: 65535" } */
diff --git a/libffi/testsuite/libffi.call/err_bad_abi.c b/libffi/testsuite/libffi.call/err_bad_abi.c
index 03d7e96a452..4f121859dad 100644
--- a/libffi/testsuite/libffi.call/err_bad_abi.c
+++ b/libffi/testsuite/libffi.call/err_bad_abi.c
@@ -15,19 +15,11 @@ dummy_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args[1];
ffi_type* arg_types[1];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
arg_types[0] = NULL;
args[0] = NULL;
@@ -39,7 +31,7 @@ int main (void)
cif.abi= 255;
- CHECK(ffi_prep_closure(pcl, &cif, dummy_fn, NULL) == FFI_BAD_ABI);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, dummy_fn, NULL, code) == FFI_BAD_ABI);
exit(0);
}
diff --git a/libffi/testsuite/libffi.call/err_bad_typedef.c b/libffi/testsuite/libffi.call/err_bad_typedef.c
index 0f84fe557a4..7ec2728eb10 100644
--- a/libffi/testsuite/libffi.call/err_bad_typedef.c
+++ b/libffi/testsuite/libffi.call/err_bad_typedef.c
@@ -10,18 +10,8 @@
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
ffi_type* arg_types[1];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
arg_types[0] = NULL;
ffi_type badType = ffi_type_void;
diff --git a/libffi/testsuite/libffi.call/float2.c b/libffi/testsuite/libffi.call/float2.c
index fa9dd311d69..a0b296cf4b9 100644
--- a/libffi/testsuite/libffi.call/float2.c
+++ b/libffi/testsuite/libffi.call/float2.c
@@ -4,7 +4,8 @@
PR: none.
Originator: From the original ffitest.c */
-/* { dg-do run } */
+/* { dg-excess-errors "fails" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
#include "ffitest.h"
#include "float.h"
diff --git a/libffi/testsuite/libffi.call/nested_struct.c b/libffi/testsuite/libffi.call/nested_struct.c
index adce7ba434f..8aa527ede4e 100644
--- a/libffi/testsuite/libffi.call/nested_struct.c
+++ b/libffi/testsuite/libffi.call/nested_struct.c
@@ -68,10 +68,8 @@ cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[5];
ffi_type* cls_struct_fields1[5];
@@ -79,12 +77,6 @@ int main (void)
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -143,12 +135,12 @@ int main (void)
CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_combined_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);
res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1,
cls_struct_16byte2,
cls_struct_combined))
- (pcl))(e_dbl, f_dbl, g_dbl);
+ (code))(e_dbl, f_dbl, g_dbl);
/* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */
CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
diff --git a/libffi/testsuite/libffi.call/nested_struct1.c b/libffi/testsuite/libffi.call/nested_struct1.c
index f7fe72e5902..2a9f515cded 100644
--- a/libffi/testsuite/libffi.call/nested_struct1.c
+++ b/libffi/testsuite/libffi.call/nested_struct1.c
@@ -72,10 +72,8 @@ cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[5];
ffi_type* cls_struct_fields1[5];
@@ -83,12 +81,6 @@ int main (void)
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -150,13 +142,13 @@ int main (void)
CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_combined_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);
res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1,
cls_struct_16byte2,
cls_struct_combined,
cls_struct_16byte1))
- (pcl))(e_dbl, f_dbl, g_dbl, h_dbl);
+ (code))(e_dbl, f_dbl, g_dbl, h_dbl);
/* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8 3 2 4: 15 10 13 10 12 13" } */
CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
diff --git a/libffi/testsuite/libffi.call/nested_struct10.c b/libffi/testsuite/libffi.call/nested_struct10.c
index 8d9aba2acdc..d6a718bdd01 100644
--- a/libffi/testsuite/libffi.call/nested_struct10.c
+++ b/libffi/testsuite/libffi.call/nested_struct10.c
@@ -58,10 +58,8 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[4];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[4];
@@ -69,12 +67,6 @@ int main (void)
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
ffi_type* dbl_arg_types[4];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -129,9 +121,9 @@ int main (void)
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B, C))(pcl))(e_dbl, f_dbl, g_dbl);
+ res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
/* { dg-output "\n1 7 12 127 99 255 2 9: 270 242 143" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + f_dbl.z + g_dbl.d));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
diff --git a/libffi/testsuite/libffi.call/nested_struct2.c b/libffi/testsuite/libffi.call/nested_struct2.c
index 821fcc40f6b..de1584c18a1 100644
--- a/libffi/testsuite/libffi.call/nested_struct2.c
+++ b/libffi/testsuite/libffi.call/nested_struct2.c
@@ -49,22 +49,14 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3];
ffi_type cls_struct_type, cls_struct_type1;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -106,9 +98,9 @@ int main (void)
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B))(pcl))(e_dbl, f_dbl);
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
/* { dg-output "\n1 7 12 127 99: 13 233 134" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
diff --git a/libffi/testsuite/libffi.call/nested_struct3.c b/libffi/testsuite/libffi.call/nested_struct3.c
index f11aff49b94..58aa85362e8 100644
--- a/libffi/testsuite/libffi.call/nested_struct3.c
+++ b/libffi/testsuite/libffi.call/nested_struct3.c
@@ -50,22 +50,14 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3];
ffi_type cls_struct_type, cls_struct_type1;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -108,9 +100,9 @@ int main (void)
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B))(pcl))(e_dbl, f_dbl);
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
/* { dg-output "\n1 7 12 127 99: 13 233 134" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
diff --git a/libffi/testsuite/libffi.call/nested_struct4.c b/libffi/testsuite/libffi.call/nested_struct4.c
index 0553ce88166..98e491e65cf 100644
--- a/libffi/testsuite/libffi.call/nested_struct4.c
+++ b/libffi/testsuite/libffi.call/nested_struct4.c
@@ -50,22 +50,14 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3];
ffi_type cls_struct_type, cls_struct_type1;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -107,9 +99,9 @@ int main (void)
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B))(pcl))(e_dbl, f_dbl);
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
/* { dg-output "\n1 7 12 127 99: 13 233 134" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
diff --git a/libffi/testsuite/libffi.call/nested_struct5.c b/libffi/testsuite/libffi.call/nested_struct5.c
index a77931b59b8..d8e3537d5a0 100644
--- a/libffi/testsuite/libffi.call/nested_struct5.c
+++ b/libffi/testsuite/libffi.call/nested_struct5.c
@@ -50,22 +50,14 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3];
ffi_type cls_struct_type, cls_struct_type1;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -108,9 +100,9 @@ int main (void)
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B))(pcl))(e_dbl, f_dbl);
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
/* { dg-output "\n1 7 12 127 99: 13 233 134" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
diff --git a/libffi/testsuite/libffi.call/nested_struct6.c b/libffi/testsuite/libffi.call/nested_struct6.c
index af2821c769f..2f2b25a15db 100644
--- a/libffi/testsuite/libffi.call/nested_struct6.c
+++ b/libffi/testsuite/libffi.call/nested_struct6.c
@@ -57,10 +57,8 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[4];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3];
@@ -68,12 +66,6 @@ int main (void)
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
ffi_type* dbl_arg_types[4];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -127,9 +119,9 @@ int main (void)
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B, C))(pcl))(e_dbl, f_dbl, g_dbl);
+ res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
/* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
diff --git a/libffi/testsuite/libffi.call/nested_struct7.c b/libffi/testsuite/libffi.call/nested_struct7.c
index c7dd4f7347e..14c70239eb2 100644
--- a/libffi/testsuite/libffi.call/nested_struct7.c
+++ b/libffi/testsuite/libffi.call/nested_struct7.c
@@ -50,22 +50,14 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[3];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3];
ffi_type cls_struct_type, cls_struct_type1;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -107,9 +99,9 @@ int main (void)
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B))(pcl))(e_dbl, f_dbl);
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
/* { dg-output "\n1 7 12 127 99: 13 233 134" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
diff --git a/libffi/testsuite/libffi.call/nested_struct8.c b/libffi/testsuite/libffi.call/nested_struct8.c
index 775ff70fdaf..bb77ead8d32 100644
--- a/libffi/testsuite/libffi.call/nested_struct8.c
+++ b/libffi/testsuite/libffi.call/nested_struct8.c
@@ -57,10 +57,8 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[4];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3];
@@ -68,12 +66,6 @@ int main (void)
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
ffi_type* dbl_arg_types[4];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -127,9 +119,9 @@ int main (void)
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B, C))(pcl))(e_dbl, f_dbl, g_dbl);
+ res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
/* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
diff --git a/libffi/testsuite/libffi.call/nested_struct9.c b/libffi/testsuite/libffi.call/nested_struct9.c
index 70332de890b..e9f541c83a8 100644
--- a/libffi/testsuite/libffi.call/nested_struct9.c
+++ b/libffi/testsuite/libffi.call/nested_struct9.c
@@ -57,10 +57,8 @@ B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[4];
ffi_type* cls_struct_fields[3];
ffi_type* cls_struct_fields1[3];
@@ -68,12 +66,6 @@ int main (void)
ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
ffi_type* dbl_arg_types[4];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
cls_struct_type.size = 0;
cls_struct_type.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -127,9 +119,9 @@ int main (void)
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
- CHECK(ffi_prep_closure(pcl, &cif, B_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
- res_dbl = ((B(*)(A, B, C))(pcl))(e_dbl, f_dbl, g_dbl);
+ res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
/* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */
CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
diff --git a/libffi/testsuite/libffi.call/problem1.c b/libffi/testsuite/libffi.call/problem1.c
index ca70cc8d773..6a91555a1fa 100644
--- a/libffi/testsuite/libffi.call/problem1.c
+++ b/libffi/testsuite/libffi.call/problem1.c
@@ -45,19 +45,11 @@ int main(void)
ffi_type* my_ffi_struct_fields[4];
ffi_type my_ffi_struct_type;
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args[4];
ffi_type* arg_types[3];
-#ifdef USING_MMAP
- pcl = allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
-
struct my_ffi_struct g = { 1.0, 2.0, 3.0 };
struct my_ffi_struct f = { 1.0, 2.0, 3.0 };
struct my_ffi_struct res;
@@ -87,9 +79,9 @@ int main(void)
printf("res: %g %g %g\n", res.a, res.b, res.c);
/* { dg-output "\nres: 2 4 6" } */
- CHECK(ffi_prep_closure(pcl, &cif, stub, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, stub, NULL, code) == FFI_OK);
- res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(pcl))(g, f);
+ res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(code))(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" } */
diff --git a/libffi/testsuite/libffi.call/return_ldl.c b/libffi/testsuite/libffi.call/return_ldl.c
index 413bf94a67d..5c2fe65aece 100644
--- a/libffi/testsuite/libffi.call/return_ldl.c
+++ b/libffi/testsuite/libffi.call/return_ldl.c
@@ -4,7 +4,7 @@
PR: none.
Originator: <andreast@gcc.gnu.org> 20071113 */
-/* { dg-do run } */
+/* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
#include "ffitest.h"
static long double return_ldl(long double ldl)
diff --git a/libffi/testsuite/libffi.call/stret_large.c b/libffi/testsuite/libffi.call/stret_large.c
index 3327ac1b2ca..12819cf467d 100644
--- a/libffi/testsuite/libffi.call/stret_large.c
+++ b/libffi/testsuite/libffi.call/stret_large.c
@@ -75,21 +75,13 @@ cls_struct_108byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* us
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[15];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -139,10 +131,10 @@ int main (void)
res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n);
/* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_108byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_108byte_gn, NULL, code) == FFI_OK);
res_dbl = ((struct_108byte(*)(struct_108byte, struct_108byte,
- struct_108byte, struct_108byte))(pcl))(e_dbl, f_dbl, g_dbl, h_dbl);
+ struct_108byte, struct_108byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl);
/* { dg-output "\n22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */
printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b,
res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i,
diff --git a/libffi/testsuite/libffi.call/stret_large2.c b/libffi/testsuite/libffi.call/stret_large2.c
index 8550ab17cb0..e63bb67923a 100644
--- a/libffi/testsuite/libffi.call/stret_large2.c
+++ b/libffi/testsuite/libffi.call/stret_large2.c
@@ -77,21 +77,13 @@ cls_struct_116byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* us
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[16];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -142,10 +134,10 @@ int main (void)
res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n, res_dbl.o);
/* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_116byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_116byte_gn, NULL, code) == FFI_OK);
res_dbl = ((struct_116byte(*)(struct_116byte, struct_116byte,
- struct_116byte, struct_116byte))(pcl))(e_dbl, f_dbl, g_dbl, h_dbl);
+ struct_116byte, struct_116byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl);
/* { dg-output "\n22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */
printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b,
res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i,
diff --git a/libffi/testsuite/libffi.call/stret_medium.c b/libffi/testsuite/libffi.call/stret_medium.c
index 74863d8bc29..13c4464ffac 100644
--- a/libffi/testsuite/libffi.call/stret_medium.c
+++ b/libffi/testsuite/libffi.call/stret_medium.c
@@ -61,21 +61,13 @@ cls_struct_72byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* use
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[10];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -119,10 +111,10 @@ int main (void)
res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i);
/* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_72byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_72byte_gn, NULL, code) == FFI_OK);
res_dbl = ((struct_72byte(*)(struct_72byte, struct_72byte,
- struct_72byte, struct_72byte))(pcl))(e_dbl, f_dbl, g_dbl, h_dbl);
+ struct_72byte, struct_72byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl);
/* { dg-output "\n22 15 17 25 6 13 19 18 16" } */
printf("res: %g %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i);
diff --git a/libffi/testsuite/libffi.call/stret_medium2.c b/libffi/testsuite/libffi.call/stret_medium2.c
index 6319982c3c8..43703b21dd5 100644
--- a/libffi/testsuite/libffi.call/stret_medium2.c
+++ b/libffi/testsuite/libffi.call/stret_medium2.c
@@ -61,21 +61,13 @@ cls_struct_72byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* use
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
void* args_dbl[5];
ffi_type* cls_struct_fields[10];
ffi_type cls_struct_type;
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.alignment = 0;
cls_struct_type.type = FFI_TYPE_STRUCT;
@@ -119,10 +111,10 @@ int main (void)
res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i);
/* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */
- CHECK(ffi_prep_closure(pcl, &cif, cls_struct_72byte_gn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_72byte_gn, NULL, code) == FFI_OK);
res_dbl = ((struct_72byte(*)(struct_72byte, struct_72byte,
- struct_72byte, struct_72byte))(pcl))(e_dbl, f_dbl, g_dbl, h_dbl);
+ struct_72byte, struct_72byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl);
/* { dg-output "\n22 15 17 25 6 13 19 18 16" } */
printf("res: %g %g %g %g %g %g %g %g %lld\n", res_dbl.a, res_dbl.b, res_dbl.c,
res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i);
diff --git a/libffi/testsuite/libffi.special/unwindtest.cc b/libffi/testsuite/libffi.special/unwindtest.cc
index a3d803780ab..723871626d1 100644
--- a/libffi/testsuite/libffi.special/unwindtest.cc
+++ b/libffi/testsuite/libffi.special/unwindtest.cc
@@ -6,6 +6,7 @@
/* { dg-do run } */
#include "ffitestcxx.h"
+#include <stdint.h>
void
closure_test_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
@@ -27,7 +28,7 @@ void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp,
(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)(long)userdata;
+ (int)(*(int *)args[14]) + *(int *)args[15] + (int)(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]),
@@ -38,7 +39,7 @@ void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp,
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
(int)*(int *)args[12], (int)(*(int *)args[13]),
(int)(*(int *)args[14]), *(int *)args[15],
- (int)(long)userdata, (int)*(ffi_arg*)resp);
+ (int)(intptr_t)userdata, (int)*(ffi_arg*)resp);
throw (int)*(ffi_arg*)resp;
}
@@ -50,27 +51,20 @@ typedef int (*closure_test_type1)(float, float, float, float, signed short,
int main (void)
{
ffi_cif cif;
-#ifndef USING_MMAP
- static ffi_closure cl;
-#endif
- ffi_closure *pcl;
+ void *code;
+ ffi_closure *pcl = (ffi_closure *)ffi_closure_alloc(sizeof(ffi_closure), &code);
ffi_type * cl_arg_types[17];
-#ifdef USING_MMAP
- pcl = (ffi_closure *) allocate_mmap (sizeof(ffi_closure));
-#else
- pcl = &cl;
-#endif
{
cl_arg_types[1] = NULL;
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0,
&ffi_type_void, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn, NULL) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn, NULL, code) == FFI_OK);
try
{
- (*((closure_test_type)(pcl)))();
+ (*((closure_test_type)(code)))();
} catch (int exception_code)
{
CHECK(exception_code == 9);
@@ -104,11 +98,11 @@ int main (void)
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
&ffi_type_sint, cl_arg_types) == FFI_OK);
- CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn1,
- (void *) 3 /* userdata */) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1,
+ (void *) 3 /* userdata */, code) == FFI_OK);
try
{
- (*((closure_test_type1)pcl))
+ (*((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 "\n1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */