diff options
Diffstat (limited to 'libffi/testsuite/libffi.call')
42 files changed, 488 insertions, 92 deletions
diff --git a/libffi/testsuite/libffi.call/closure_fn0.c b/libffi/testsuite/libffi.call/closure_fn0.c index f418f01b38c..6d9b2cb50ed 100644 --- a/libffi/testsuite/libffi.call/closure_fn0.c +++ b/libffi/testsuite/libffi.call/closure_fn0.c @@ -45,11 +45,19 @@ 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; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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_uint; cl_arg_types[2] = &ffi_type_uint64; diff --git a/libffi/testsuite/libffi.call/closure_fn1.c b/libffi/testsuite/libffi.call/closure_fn1.c index f98a01796cd..41818ad9584 100644 --- a/libffi/testsuite/libffi.call/closure_fn1.c +++ b/libffi/testsuite/libffi.call/closure_fn1.c @@ -9,6 +9,7 @@ /* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */ #include "ffitest.h" + static void closure_test_fn1(ffi_cif* cif,void* resp,void** args, void* userdata) { @@ -40,11 +41,19 @@ typedef int (*closure_test_type1)(float, float, float, float, signed short, int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/closure_fn2.c b/libffi/testsuite/libffi.call/closure_fn2.c index 5b06ec8406d..2a98f962110 100644 --- a/libffi/testsuite/libffi.call/closure_fn2.c +++ b/libffi/testsuite/libffi.call/closure_fn2.c @@ -41,11 +41,19 @@ typedef int (*closure_test_type2)(double, double, double, double, signed short, int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/closure_fn3.c b/libffi/testsuite/libffi.call/closure_fn3.c index 6af54c76ac0..4f744c8109e 100644 --- a/libffi/testsuite/libffi.call/closure_fn3.c +++ b/libffi/testsuite/libffi.call/closure_fn3.c @@ -42,11 +42,18 @@ typedef int (*closure_test_type3)(float, float, float, float, float, float, int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/closure_fn4.c b/libffi/testsuite/libffi.call/closure_fn4.c index 87ca0db9185..cbaaf303cb4 100644 --- a/libffi/testsuite/libffi.call/closure_fn4.c +++ b/libffi/testsuite/libffi.call/closure_fn4.c @@ -59,11 +59,19 @@ typedef int (*closure_test_type0)(unsigned long long, unsigned long long, int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; } diff --git a/libffi/testsuite/libffi.call/closure_fn5.c b/libffi/testsuite/libffi.call/closure_fn5.c index f7918c16868..6a4fc67a6de 100644 --- a/libffi/testsuite/libffi.call/closure_fn5.c +++ b/libffi/testsuite/libffi.call/closure_fn5.c @@ -59,10 +59,17 @@ typedef int (*closure_test_type0)(unsigned long long, unsigned long long, int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_12byte.c b/libffi/testsuite/libffi.call/cls_12byte.c index a917a709d61..f8a87ec8797 100644 --- a/libffi/testsuite/libffi.call/cls_12byte.c +++ b/libffi/testsuite/libffi.call/cls_12byte.c @@ -41,13 +41,21 @@ static void cls_struct_12byte_gn(ffi_cif* cif, void* resp, void** args, void* us int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_16byte.c b/libffi/testsuite/libffi.call/cls_16byte.c index ae0e7c754ee..f8a3b5786a8 100644 --- a/libffi/testsuite/libffi.call/cls_16byte.c +++ b/libffi/testsuite/libffi.call/cls_16byte.c @@ -42,13 +42,21 @@ static void cls_struct_16byte_gn(ffi_cif* cif, void* resp, void** args, void* us int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_18byte.c b/libffi/testsuite/libffi.call/cls_18byte.c index 0b1d07f25db..50ce9ffdae5 100644 --- a/libffi/testsuite/libffi.call/cls_18byte.c +++ b/libffi/testsuite/libffi.call/cls_18byte.c @@ -46,13 +46,21 @@ cls_struct_18byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_19byte.c b/libffi/testsuite/libffi.call/cls_19byte.c index 2bb0b6780ee..3bef9387967 100644 --- a/libffi/testsuite/libffi.call/cls_19byte.c +++ b/libffi/testsuite/libffi.call/cls_19byte.c @@ -49,13 +49,21 @@ cls_struct_19byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; @@ -85,7 +93,7 @@ int main (void) ffi_call(&cif, FFI_FN(cls_struct_19byte_fn), &res_dbl, args_dbl); /* { dg-output "1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */ - printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, + printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d, res_dbl.e); /* { dg-output "\nres: 5 252 250 8 239" } */ diff --git a/libffi/testsuite/libffi.call/cls_1_1byte.c b/libffi/testsuite/libffi.call/cls_1_1byte.c index f7682fef550..cdf49631275 100644 --- a/libffi/testsuite/libffi.call/cls_1_1byte.c +++ b/libffi/testsuite/libffi.call/cls_1_1byte.c @@ -40,13 +40,21 @@ cls_struct_1_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_20byte.c b/libffi/testsuite/libffi.call/cls_20byte.c index f3cc0ebbd13..b02b84dc61f 100644 --- a/libffi/testsuite/libffi.call/cls_20byte.c +++ b/libffi/testsuite/libffi.call/cls_20byte.c @@ -42,13 +42,21 @@ cls_struct_20byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_20byte1.c b/libffi/testsuite/libffi.call/cls_20byte1.c index 089f02e327e..41866fe6b99 100644 --- a/libffi/testsuite/libffi.call/cls_20byte1.c +++ b/libffi/testsuite/libffi.call/cls_20byte1.c @@ -42,13 +42,21 @@ cls_struct_20byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_24byte.c b/libffi/testsuite/libffi.call/cls_24byte.c index f3adb9da352..ff0f841b5c5 100644 --- a/libffi/testsuite/libffi.call/cls_24byte.c +++ b/libffi/testsuite/libffi.call/cls_24byte.c @@ -53,13 +53,21 @@ cls_struct_24byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_2byte.c b/libffi/testsuite/libffi.call/cls_2byte.c index 672437d05c9..2e381771ec8 100644 --- a/libffi/testsuite/libffi.call/cls_2byte.c +++ b/libffi/testsuite/libffi.call/cls_2byte.c @@ -42,13 +42,21 @@ cls_struct_2byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_3_1byte.c b/libffi/testsuite/libffi.call/cls_3_1byte.c index 26f6501d365..8e3044f7655 100644 --- a/libffi/testsuite/libffi.call/cls_3_1byte.c +++ b/libffi/testsuite/libffi.call/cls_3_1byte.c @@ -46,13 +46,21 @@ cls_struct_3_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_3byte1.c b/libffi/testsuite/libffi.call/cls_3byte1.c index 9f51f55f6fc..294067faf5e 100644 --- a/libffi/testsuite/libffi.call/cls_3byte1.c +++ b/libffi/testsuite/libffi.call/cls_3byte1.c @@ -42,13 +42,21 @@ cls_struct_3byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_3byte2.c b/libffi/testsuite/libffi.call/cls_3byte2.c index 815debf5917..c429958f35e 100644 --- a/libffi/testsuite/libffi.call/cls_3byte2.c +++ b/libffi/testsuite/libffi.call/cls_3byte2.c @@ -42,13 +42,21 @@ cls_struct_3byte_gn1(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_4_1byte.c b/libffi/testsuite/libffi.call/cls_4_1byte.c index 000506eabed..008e24a7120 100644 --- a/libffi/testsuite/libffi.call/cls_4_1byte.c +++ b/libffi/testsuite/libffi.call/cls_4_1byte.c @@ -48,13 +48,21 @@ cls_struct_4_1byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_4byte.c b/libffi/testsuite/libffi.call/cls_4byte.c index fdf9b9bf600..ecb2ce9dae8 100644 --- a/libffi/testsuite/libffi.call/cls_4byte.c +++ b/libffi/testsuite/libffi.call/cls_4byte.c @@ -42,13 +42,21 @@ cls_struct_4byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_5byte.c b/libffi/testsuite/libffi.call/cls_5byte.c index 877ea4cbff2..6274a197cad 100644 --- a/libffi/testsuite/libffi.call/cls_5byte.c +++ b/libffi/testsuite/libffi.call/cls_5byte.c @@ -45,13 +45,21 @@ cls_struct_5byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_64byte.c b/libffi/testsuite/libffi.call/cls_64byte.c index 28d5590735f..cc1b7714b54 100644 --- a/libffi/testsuite/libffi.call/cls_64byte.c +++ b/libffi/testsuite/libffi.call/cls_64byte.c @@ -58,13 +58,21 @@ cls_struct_64byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_6byte.c b/libffi/testsuite/libffi.call/cls_6byte.c index 5eb17d2430f..0c1ab28f0c2 100644 --- a/libffi/testsuite/libffi.call/cls_6byte.c +++ b/libffi/testsuite/libffi.call/cls_6byte.c @@ -47,13 +47,21 @@ cls_struct_6byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_7byte.c b/libffi/testsuite/libffi.call/cls_7byte.c index 9c1765af835..a7998ddabb7 100644 --- a/libffi/testsuite/libffi.call/cls_7byte.c +++ b/libffi/testsuite/libffi.call/cls_7byte.c @@ -47,13 +47,21 @@ cls_struct_7byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_8byte.c b/libffi/testsuite/libffi.call/cls_8byte.c index d9050d494c8..efa1afc1677 100644 --- a/libffi/testsuite/libffi.call/cls_8byte.c +++ b/libffi/testsuite/libffi.call/cls_8byte.c @@ -41,13 +41,21 @@ cls_struct_8byte_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_9byte1.c b/libffi/testsuite/libffi.call/cls_9byte1.c index 06acca48b71..69945709f90 100644 --- a/libffi/testsuite/libffi.call/cls_9byte1.c +++ b/libffi/testsuite/libffi.call/cls_9byte1.c @@ -43,13 +43,21 @@ static void cls_struct_9byte_gn(ffi_cif* cif, void* resp, void** args, int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_9byte2.c b/libffi/testsuite/libffi.call/cls_9byte2.c index 21d7b49ab5c..976ed59a0f8 100644 --- a/libffi/testsuite/libffi.call/cls_9byte2.c +++ b/libffi/testsuite/libffi.call/cls_9byte2.c @@ -43,13 +43,21 @@ static void cls_struct_9byte_gn(ffi_cif* cif, void* resp, void** args, int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_double.c b/libffi/testsuite/libffi.call/cls_double.c index 51ec26a3a05..3df6cf3fcf7 100644 --- a/libffi/testsuite/libffi.call/cls_double.c +++ b/libffi/testsuite/libffi.call/cls_double.c @@ -20,11 +20,19 @@ typedef double (*cls_ret_double)(double); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_float.c b/libffi/testsuite/libffi.call/cls_float.c index bd1601ebc78..ac4ec482b0f 100644 --- a/libffi/testsuite/libffi.call/cls_float.c +++ b/libffi/testsuite/libffi.call/cls_float.c @@ -21,11 +21,19 @@ typedef float (*cls_ret_float)(float); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_schar.c b/libffi/testsuite/libffi.call/cls_schar.c index ecdbfb69575..1e607ab2848 100644 --- a/libffi/testsuite/libffi.call/cls_schar.c +++ b/libffi/testsuite/libffi.call/cls_schar.c @@ -19,11 +19,19 @@ typedef signed char (*cls_ret_schar)(signed char); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_sint.c b/libffi/testsuite/libffi.call/cls_sint.c index caae0d45691..c85067bf126 100644 --- a/libffi/testsuite/libffi.call/cls_sint.c +++ b/libffi/testsuite/libffi.call/cls_sint.c @@ -19,11 +19,19 @@ typedef signed int (*cls_ret_sint)(signed int); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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_sint32; cl_arg_types[1] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_sshort.c b/libffi/testsuite/libffi.call/cls_sshort.c index 3b1e4c60d48..65e687227d8 100644 --- a/libffi/testsuite/libffi.call/cls_sshort.c +++ b/libffi/testsuite/libffi.call/cls_sshort.c @@ -19,11 +19,19 @@ typedef signed short (*cls_ret_sshort)(signed short); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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_sint16; cl_arg_types[1] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_uchar.c b/libffi/testsuite/libffi.call/cls_uchar.c index e5027b2e45c..6a1e63709da 100644 --- a/libffi/testsuite/libffi.call/cls_uchar.c +++ b/libffi/testsuite/libffi.call/cls_uchar.c @@ -19,11 +19,19 @@ typedef unsigned char (*cls_ret_uchar)(unsigned char); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_uint.c b/libffi/testsuite/libffi.call/cls_uint.c index 08f29122bd4..501e179fd7f 100644 --- a/libffi/testsuite/libffi.call/cls_uint.c +++ b/libffi/testsuite/libffi.call/cls_uint.c @@ -20,11 +20,19 @@ typedef unsigned int (*cls_ret_uint)(unsigned int); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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_uint32; cl_arg_types[1] = NULL; diff --git a/libffi/testsuite/libffi.call/cls_ulonglong.c b/libffi/testsuite/libffi.call/cls_ulonglong.c index 80dc2db7aaa..072da8c1e50 100644 --- a/libffi/testsuite/libffi.call/cls_ulonglong.c +++ b/libffi/testsuite/libffi.call/cls_ulonglong.c @@ -20,11 +20,19 @@ typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/cls_ushort.c b/libffi/testsuite/libffi.call/cls_ushort.c index 3599f6776a5..f6626b9c30c 100644 --- a/libffi/testsuite/libffi.call/cls_ushort.c +++ b/libffi/testsuite/libffi.call/cls_ushort.c @@ -20,11 +20,19 @@ typedef unsigned short (*cls_ret_ushort)(unsigned short); int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/ffitest.h b/libffi/testsuite/libffi.call/ffitest.h index 7856405d2f5..2d0df0e7734 100644 --- a/libffi/testsuite/libffi.call/ffitest.h +++ b/libffi/testsuite/libffi.call/ffitest.h @@ -2,8 +2,77 @@ #include <stdio.h> #include <string.h> #include <ffi.h> +#include "fficonfig.h" #define MAX_ARGS 256 -#define CHECK(x) !(x) ? abort() : 0 +#define CHECK(x) !(x) ? abort() : 0 + +/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a + file open. */ +#ifdef HAVE_MMAP_ANON +# undef HAVE_MMAP_DEV_ZERO + +# include <sys/mman.h> +# ifndef MAP_FAILED +# define MAP_FAILED -1 +# endif +# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON) +# define MAP_ANONYMOUS MAP_ANON +# endif +# define USING_MMAP + +#endif + +#ifdef HAVE_MMAP_DEV_ZERO + +# include <sys/mman.h> +# ifndef MAP_FAILED +# define MAP_FAILED -1 +# endif +# define USING_MMAP + +#endif + +#ifdef USING_MMAP +static inline void * +allocate_mmap (size_t size) +{ + void *page; +#if defined (HAVE_MMAP_DEV_ZERO) + static int dev_zero_fd = -1; +#endif + +#ifdef HAVE_MMAP_DEV_ZERO + if (dev_zero_fd == -1) + { + dev_zero_fd = open ("/dev/zero", O_RDONLY); + if (dev_zero_fd == -1) + { + perror ("open /dev/zero: %m"); + exit (1); + } + } +#endif + + +#ifdef HAVE_MMAP_ANON + page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +#endif +#ifdef HAVE_MMAP_DEV_ZERO + page = mmap (NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE, dev_zero_fd, 0); +#endif + + if (page == MAP_FAILED) + { + perror ("virtual memory exhausted"); + exit (1); + } + + return page; +} + +#endif diff --git a/libffi/testsuite/libffi.call/nested_struct.c b/libffi/testsuite/libffi.call/nested_struct.c index e9fb4f9dfa4..86d685a68a7 100644 --- a/libffi/testsuite/libffi.call/nested_struct.c +++ b/libffi/testsuite/libffi.call/nested_struct.c @@ -67,8 +67,10 @@ cls_struct_combined_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; void* args_dbl[5]; ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields1[5]; @@ -76,6 +78,12 @@ 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; diff --git a/libffi/testsuite/libffi.call/nested_struct1.c b/libffi/testsuite/libffi.call/nested_struct1.c index 57373fb7b74..1d87945defc 100644 --- a/libffi/testsuite/libffi.call/nested_struct1.c +++ b/libffi/testsuite/libffi.call/nested_struct1.c @@ -71,8 +71,10 @@ cls_struct_combined_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; void* args_dbl[5]; ffi_type* cls_struct_fields[5]; ffi_type* cls_struct_fields1[5]; @@ -80,6 +82,12 @@ 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; diff --git a/libffi/testsuite/libffi.call/nested_struct2.c b/libffi/testsuite/libffi.call/nested_struct2.c index 7c06685b11f..3572a4c49cc 100644 --- a/libffi/testsuite/libffi.call/nested_struct2.c +++ b/libffi/testsuite/libffi.call/nested_struct2.c @@ -58,14 +58,22 @@ B_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/nested_struct3.c b/libffi/testsuite/libffi.call/nested_struct3.c index 0f578b222bc..95cf2f3b44f 100644 --- a/libffi/testsuite/libffi.call/nested_struct3.c +++ b/libffi/testsuite/libffi.call/nested_struct3.c @@ -49,14 +49,22 @@ B_gn(ffi_cif* cif, void* resp, void** args, void* userdata) int main (void) { ffi_cif cif; +#ifndef USING_MMAP static ffi_closure cl; - ffi_closure *pcl = &cl; +#endif + ffi_closure *pcl; 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; diff --git a/libffi/testsuite/libffi.call/problem1.c b/libffi/testsuite/libffi.call/problem1.c index f3bd3b57739..5b6397f4efa 100644 --- a/libffi/testsuite/libffi.call/problem1.c +++ b/libffi/testsuite/libffi.call/problem1.c @@ -29,61 +29,69 @@ my_ffi_struct callee(struct my_ffi_struct a1, struct my_ffi_struct a2) void stub(ffi_cif* cif, void* resp, void** args, void* userdata) { - struct my_ffi_struct a1; - struct my_ffi_struct a2; + struct my_ffi_struct a1; + struct my_ffi_struct a2; - a1 = *(struct my_ffi_struct*)(args[0]); - a2 = *(struct my_ffi_struct*)(args[1]); + a1 = *(struct my_ffi_struct*)(args[0]); + a2 = *(struct my_ffi_struct*)(args[1]); - *(my_ffi_struct *)resp = callee(a1, a2); + *(my_ffi_struct *)resp = callee(a1, a2); } int main(void) { - ffi_type* my_ffi_struct_fields[4]; - ffi_type my_ffi_struct_type; - ffi_cif cif; - static ffi_closure cl; - ffi_closure *pcl = &cl; - void* args[4]; - ffi_type* arg_types[3]; - - 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; - - my_ffi_struct_type.size = 0; - my_ffi_struct_type.alignment = 0; - my_ffi_struct_type.type = FFI_TYPE_STRUCT; - my_ffi_struct_type.elements = my_ffi_struct_fields; - - my_ffi_struct_fields[0] = &ffi_type_double; - my_ffi_struct_fields[1] = &ffi_type_double; - my_ffi_struct_fields[2] = &ffi_type_double; - my_ffi_struct_fields[3] = NULL; - - arg_types[0] = &my_ffi_struct_type; - arg_types[1] = &my_ffi_struct_type; - arg_types[2] = NULL; - - CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &my_ffi_struct_type, - arg_types) == FFI_OK); - - args[0] = &g; - args[1] = &f; - args[2] = NULL; - ffi_call(&cif, FFI_FN(callee), &res, args); - /* { dg-output "1 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" } */ - - CHECK(ffi_prep_closure(pcl, &cif, stub, NULL) == FFI_OK); - - res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(pcl))(g, f); - /* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */ - printf("res: %g %g %g\n", res.a, res.b, res.c); - /* { dg-output "\nres: 2 4 6" } */ - - exit(0);; + 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* 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; + + my_ffi_struct_type.size = 0; + my_ffi_struct_type.alignment = 0; + my_ffi_struct_type.type = FFI_TYPE_STRUCT; + my_ffi_struct_type.elements = my_ffi_struct_fields; + + my_ffi_struct_fields[0] = &ffi_type_double; + my_ffi_struct_fields[1] = &ffi_type_double; + my_ffi_struct_fields[2] = &ffi_type_double; + my_ffi_struct_fields[3] = NULL; + + arg_types[0] = &my_ffi_struct_type; + arg_types[1] = &my_ffi_struct_type; + arg_types[2] = NULL; + + CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &my_ffi_struct_type, + arg_types) == FFI_OK); + + args[0] = &g; + args[1] = &f; + args[2] = NULL; + ffi_call(&cif, FFI_FN(callee), &res, args); + /* { dg-output "1 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" } */ + + CHECK(ffi_prep_closure(pcl, &cif, stub, NULL) == FFI_OK); + + res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(pcl))(g, f); + /* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */ + printf("res: %g %g %g\n", res.a, res.b, res.c); + /* { dg-output "\nres: 2 4 6" } */ + + exit(0);; } |