ffi 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- data/LICENSE +51 -0
- data/README +0 -0
- data/Rakefile +90 -0
- data/ext/AbstractMemory.c +254 -0
- data/ext/AbstractMemory.h +36 -0
- data/ext/Buffer.c +94 -0
- data/ext/Callback.c +240 -0
- data/ext/Callback.h +47 -0
- data/ext/Invoker.c +269 -0
- data/ext/MemoryPointer.c +164 -0
- data/ext/MemoryPointer.h +25 -0
- data/ext/Platform.c +41 -0
- data/ext/Platform.h +23 -0
- data/ext/Types.c +65 -0
- data/ext/Types.h +51 -0
- data/ext/extconf.rb +13 -0
- data/ext/ffi.c +54 -0
- data/ext/ffi.mk +24 -0
- data/ext/libffi.darwin.mk +44 -0
- data/ext/libffi.mk +10 -0
- data/ext/libffi/ChangeLog +3243 -0
- data/ext/libffi/ChangeLog.libffi +347 -0
- data/ext/libffi/ChangeLog.libgcj +40 -0
- data/ext/libffi/ChangeLog.v1 +764 -0
- data/ext/libffi/LICENSE +21 -0
- data/ext/libffi/Makefile.am +177 -0
- data/ext/libffi/Makefile.in +1640 -0
- data/ext/libffi/README +328 -0
- data/ext/libffi/TODO +1 -0
- data/ext/libffi/acinclude.m4 +92 -0
- data/ext/libffi/aclocal.m4 +7516 -0
- data/ext/libffi/compile +142 -0
- data/ext/libffi/config.guess +1516 -0
- data/ext/libffi/config.sub +1626 -0
- data/ext/libffi/configure +24414 -0
- data/ext/libffi/configure.ac +365 -0
- data/ext/libffi/configure.host +11 -0
- data/ext/libffi/depcomp +584 -0
- data/ext/libffi/doc/libffi.info +533 -0
- data/ext/libffi/doc/libffi.texi +541 -0
- data/ext/libffi/doc/stamp-vti +4 -0
- data/ext/libffi/doc/version.texi +4 -0
- data/ext/libffi/fficonfig.h.in +160 -0
- data/ext/libffi/include/Makefile.am +9 -0
- data/ext/libffi/include/Makefile.in +422 -0
- data/ext/libffi/include/ffi.h.in +393 -0
- data/ext/libffi/include/ffi_common.h +98 -0
- data/ext/libffi/install-sh +323 -0
- data/ext/libffi/libffi.pc.in +10 -0
- data/ext/libffi/libtool-version +29 -0
- data/ext/libffi/ltcf-c.sh +861 -0
- data/ext/libffi/ltcf-cxx.sh +1069 -0
- data/ext/libffi/ltcf-gcj.sh +700 -0
- data/ext/libffi/ltconfig +2862 -0
- data/ext/libffi/ltmain.sh +6930 -0
- data/ext/libffi/man/Makefile.am +8 -0
- data/ext/libffi/man/Makefile.in +395 -0
- data/ext/libffi/man/ffi.3 +31 -0
- data/ext/libffi/man/ffi_call.3 +103 -0
- data/ext/libffi/man/ffi_prep_cif.3 +66 -0
- data/ext/libffi/mdate-sh +201 -0
- data/ext/libffi/missing +353 -0
- data/ext/libffi/mkinstalldirs +158 -0
- data/ext/libffi/src/alpha/ffi.c +284 -0
- data/ext/libffi/src/alpha/ffitarget.h +48 -0
- data/ext/libffi/src/alpha/osf.S +366 -0
- data/ext/libffi/src/arm/ffi.c +309 -0
- data/ext/libffi/src/arm/ffitarget.h +49 -0
- data/ext/libffi/src/arm/sysv.S +299 -0
- data/ext/libffi/src/closures.c +596 -0
- data/ext/libffi/src/cris/ffi.c +383 -0
- data/ext/libffi/src/cris/ffitarget.h +51 -0
- data/ext/libffi/src/cris/sysv.S +215 -0
- data/ext/libffi/src/debug.c +59 -0
- data/ext/libffi/src/dlmalloc.c +5099 -0
- data/ext/libffi/src/frv/eabi.S +128 -0
- data/ext/libffi/src/frv/ffi.c +292 -0
- data/ext/libffi/src/frv/ffitarget.h +61 -0
- data/ext/libffi/src/ia64/ffi.c +580 -0
- data/ext/libffi/src/ia64/ffitarget.h +50 -0
- data/ext/libffi/src/ia64/ia64_flags.h +40 -0
- data/ext/libffi/src/ia64/unix.S +560 -0
- data/ext/libffi/src/java_raw_api.c +359 -0
- data/ext/libffi/src/m32r/ffi.c +232 -0
- data/ext/libffi/src/m32r/ffitarget.h +48 -0
- data/ext/libffi/src/m32r/sysv.S +121 -0
- data/ext/libffi/src/m68k/ffi.c +278 -0
- data/ext/libffi/src/m68k/ffitarget.h +49 -0
- data/ext/libffi/src/m68k/sysv.S +234 -0
- data/ext/libffi/src/mips/ffi.c +926 -0
- data/ext/libffi/src/mips/ffitarget.h +202 -0
- data/ext/libffi/src/mips/n32.S +534 -0
- data/ext/libffi/src/mips/o32.S +381 -0
- data/ext/libffi/src/pa/ffi.c +709 -0
- data/ext/libffi/src/pa/ffitarget.h +77 -0
- data/ext/libffi/src/pa/hpux32.S +368 -0
- data/ext/libffi/src/pa/linux.S +357 -0
- data/ext/libffi/src/powerpc/aix.S +225 -0
- data/ext/libffi/src/powerpc/aix_closure.S +247 -0
- data/ext/libffi/src/powerpc/asm.h +125 -0
- data/ext/libffi/src/powerpc/darwin.S +245 -0
- data/ext/libffi/src/powerpc/darwin_closure.S +317 -0
- data/ext/libffi/src/powerpc/ffi.c +1429 -0
- data/ext/libffi/src/powerpc/ffi_darwin.c +800 -0
- data/ext/libffi/src/powerpc/ffitarget.h +118 -0
- data/ext/libffi/src/powerpc/linux64.S +187 -0
- data/ext/libffi/src/powerpc/linux64_closure.S +236 -0
- data/ext/libffi/src/powerpc/ppc_closure.S +327 -0
- data/ext/libffi/src/powerpc/sysv.S +230 -0
- data/ext/libffi/src/prep_cif.c +174 -0
- data/ext/libffi/src/raw_api.c +254 -0
- data/ext/libffi/src/s390/ffi.c +780 -0
- data/ext/libffi/src/s390/ffitarget.h +60 -0
- data/ext/libffi/src/s390/sysv.S +434 -0
- data/ext/libffi/src/sh/ffi.c +716 -0
- data/ext/libffi/src/sh/ffitarget.h +49 -0
- data/ext/libffi/src/sh/sysv.S +850 -0
- data/ext/libffi/src/sh64/ffi.c +453 -0
- data/ext/libffi/src/sh64/ffitarget.h +53 -0
- data/ext/libffi/src/sh64/sysv.S +530 -0
- data/ext/libffi/src/sparc/ffi.c +610 -0
- data/ext/libffi/src/sparc/ffitarget.h +66 -0
- data/ext/libffi/src/sparc/v8.S +272 -0
- data/ext/libffi/src/sparc/v9.S +307 -0
- data/ext/libffi/src/types.c +77 -0
- data/ext/libffi/src/x86/darwin.S +443 -0
- data/ext/libffi/src/x86/darwin64.S +416 -0
- data/ext/libffi/src/x86/ffi.c +475 -0
- data/ext/libffi/src/x86/ffi64.c +572 -0
- data/ext/libffi/src/x86/ffitarget.h +90 -0
- data/ext/libffi/src/x86/freebsd.S +458 -0
- data/ext/libffi/src/x86/sysv.S +437 -0
- data/ext/libffi/src/x86/unix64.S +418 -0
- data/ext/libffi/src/x86/win32.S +391 -0
- data/ext/libffi/testsuite/Makefile.am +71 -0
- data/ext/libffi/testsuite/Makefile.in +447 -0
- data/ext/libffi/testsuite/config/default.exp +1 -0
- data/ext/libffi/testsuite/lib/libffi-dg.exp +289 -0
- data/ext/libffi/testsuite/lib/target-libpath.exp +263 -0
- data/ext/libffi/testsuite/lib/wrapper.exp +45 -0
- data/ext/libffi/testsuite/libffi.call/call.exp +36 -0
- data/ext/libffi/testsuite/libffi.call/closure_fn0.c +97 -0
- data/ext/libffi/testsuite/libffi.call/closure_fn1.c +89 -0
- data/ext/libffi/testsuite/libffi.call/closure_fn2.c +89 -0
- data/ext/libffi/testsuite/libffi.call/closure_fn3.c +90 -0
- data/ext/libffi/testsuite/libffi.call/closure_fn4.c +97 -0
- data/ext/libffi/testsuite/libffi.call/closure_fn5.c +99 -0
- data/ext/libffi/testsuite/libffi.call/closure_fn6.c +98 -0
- data/ext/libffi/testsuite/libffi.call/closure_stdcall.c +72 -0
- data/ext/libffi/testsuite/libffi.call/cls_12byte.c +102 -0
- data/ext/libffi/testsuite/libffi.call/cls_16byte.c +103 -0
- data/ext/libffi/testsuite/libffi.call/cls_18byte.c +104 -0
- data/ext/libffi/testsuite/libffi.call/cls_19byte.c +110 -0
- data/ext/libffi/testsuite/libffi.call/cls_1_1byte.c +97 -0
- data/ext/libffi/testsuite/libffi.call/cls_20byte.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_20byte1.c +101 -0
- data/ext/libffi/testsuite/libffi.call/cls_24byte.c +121 -0
- data/ext/libffi/testsuite/libffi.call/cls_2byte.c +98 -0
- data/ext/libffi/testsuite/libffi.call/cls_3_1byte.c +103 -0
- data/ext/libffi/testsuite/libffi.call/cls_3byte1.c +98 -0
- data/ext/libffi/testsuite/libffi.call/cls_3byte2.c +98 -0
- data/ext/libffi/testsuite/libffi.call/cls_4_1byte.c +106 -0
- data/ext/libffi/testsuite/libffi.call/cls_4byte.c +98 -0
- data/ext/libffi/testsuite/libffi.call/cls_5_1_byte.c +117 -0
- data/ext/libffi/testsuite/libffi.call/cls_5byte.c +106 -0
- data/ext/libffi/testsuite/libffi.call/cls_64byte.c +132 -0
- data/ext/libffi/testsuite/libffi.call/cls_6_1_byte.c +121 -0
- data/ext/libffi/testsuite/libffi.call/cls_6byte.c +107 -0
- data/ext/libffi/testsuite/libffi.call/cls_7_1_byte.c +125 -0
- data/ext/libffi/testsuite/libffi.call/cls_7byte.c +105 -0
- data/ext/libffi/testsuite/libffi.call/cls_8byte.c +96 -0
- data/ext/libffi/testsuite/libffi.call/cls_9byte1.c +98 -0
- data/ext/libffi/testsuite/libffi.call/cls_9byte2.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_double.c +101 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_float.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_longdouble.c +100 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_pointer.c +101 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_sint16.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_sint32.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_sint64.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_uint16.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_uint32.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_align_uint64.c +100 -0
- data/ext/libffi/testsuite/libffi.call/cls_double.c +51 -0
- data/ext/libffi/testsuite/libffi.call/cls_float.c +51 -0
- data/ext/libffi/testsuite/libffi.call/cls_multi_schar.c +82 -0
- data/ext/libffi/testsuite/libffi.call/cls_multi_sshort.c +82 -0
- data/ext/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +94 -0
- data/ext/libffi/testsuite/libffi.call/cls_multi_uchar.c +99 -0
- data/ext/libffi/testsuite/libffi.call/cls_multi_ushort.c +82 -0
- data/ext/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +94 -0
- data/ext/libffi/testsuite/libffi.call/cls_schar.c +52 -0
- data/ext/libffi/testsuite/libffi.call/cls_sint.c +50 -0
- data/ext/libffi/testsuite/libffi.call/cls_sshort.c +50 -0
- data/ext/libffi/testsuite/libffi.call/cls_uchar.c +50 -0
- data/ext/libffi/testsuite/libffi.call/cls_uint.c +51 -0
- data/ext/libffi/testsuite/libffi.call/cls_ulonglong.c +54 -0
- data/ext/libffi/testsuite/libffi.call/cls_ushort.c +51 -0
- data/ext/libffi/testsuite/libffi.call/ffitest.h +86 -0
- data/ext/libffi/testsuite/libffi.call/float.c +59 -0
- data/ext/libffi/testsuite/libffi.call/float1.c +58 -0
- data/ext/libffi/testsuite/libffi.call/float2.c +57 -0
- data/ext/libffi/testsuite/libffi.call/float3.c +72 -0
- data/ext/libffi/testsuite/libffi.call/float4.c +62 -0
- data/ext/libffi/testsuite/libffi.call/many.c +69 -0
- data/ext/libffi/testsuite/libffi.call/many_win32.c +63 -0
- data/ext/libffi/testsuite/libffi.call/negint.c +53 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct.c +160 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct1.c +169 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct10.c +141 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct2.c +118 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct3.c +119 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct4.c +119 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct5.c +120 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct6.c +139 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct7.c +119 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct8.c +139 -0
- data/ext/libffi/testsuite/libffi.call/nested_struct9.c +139 -0
- data/ext/libffi/testsuite/libffi.call/problem1.c +98 -0
- data/ext/libffi/testsuite/libffi.call/promotion.c +59 -0
- data/ext/libffi/testsuite/libffi.call/pyobjc-tc.c +114 -0
- data/ext/libffi/testsuite/libffi.call/return_dbl.c +35 -0
- data/ext/libffi/testsuite/libffi.call/return_dbl1.c +43 -0
- data/ext/libffi/testsuite/libffi.call/return_dbl2.c +42 -0
- data/ext/libffi/testsuite/libffi.call/return_fl.c +35 -0
- data/ext/libffi/testsuite/libffi.call/return_fl1.c +36 -0
- data/ext/libffi/testsuite/libffi.call/return_fl2.c +49 -0
- data/ext/libffi/testsuite/libffi.call/return_fl3.c +42 -0
- data/ext/libffi/testsuite/libffi.call/return_ldl.c +34 -0
- data/ext/libffi/testsuite/libffi.call/return_ll.c +41 -0
- data/ext/libffi/testsuite/libffi.call/return_ll1.c +42 -0
- data/ext/libffi/testsuite/libffi.call/return_sc.c +36 -0
- data/ext/libffi/testsuite/libffi.call/return_sl.c +38 -0
- data/ext/libffi/testsuite/libffi.call/return_uc.c +38 -0
- data/ext/libffi/testsuite/libffi.call/return_ul.c +38 -0
- data/ext/libffi/testsuite/libffi.call/strlen.c +44 -0
- data/ext/libffi/testsuite/libffi.call/strlen_win32.c +44 -0
- data/ext/libffi/testsuite/libffi.call/struct1.c +65 -0
- data/ext/libffi/testsuite/libffi.call/struct2.c +67 -0
- data/ext/libffi/testsuite/libffi.call/struct3.c +59 -0
- data/ext/libffi/testsuite/libffi.call/struct4.c +63 -0
- data/ext/libffi/testsuite/libffi.call/struct5.c +65 -0
- data/ext/libffi/testsuite/libffi.call/struct6.c +64 -0
- data/ext/libffi/testsuite/libffi.call/struct7.c +74 -0
- data/ext/libffi/testsuite/libffi.call/struct8.c +80 -0
- data/ext/libffi/testsuite/libffi.call/struct9.c +67 -0
- data/ext/libffi/testsuite/libffi.special/ffitestcxx.h +86 -0
- data/ext/libffi/testsuite/libffi.special/special.exp +38 -0
- data/ext/libffi/testsuite/libffi.special/unwindtest.cc +123 -0
- data/ext/libffi/testsuite/libffi.special/unwindtest_ffi_call.cc +53 -0
- data/ext/libffi/texinfo.tex +7482 -0
- data/ext/rbffi.h +32 -0
- data/lib/ffi.rb +2 -0
- data/lib/ffi/buffer.rb +25 -0
- data/lib/ffi/callback.rb +10 -0
- data/lib/ffi/ffi.rb +259 -0
- data/lib/ffi/memorypointer.rb +169 -0
- data/lib/ffi/platform.rb +75 -0
- data/lib/ffi/struct.rb +263 -0
- data/nbproject/Makefile-Default.mk +54 -0
- data/nbproject/Makefile-impl.mk +123 -0
- data/nbproject/configurations.xml +169 -0
- data/nbproject/private/configurations.xml +22 -0
- data/nbproject/private/private.xml +7 -0
- data/nbproject/project.properties +0 -0
- data/nbproject/project.xml +11 -0
- data/samples/getlogin.rb +7 -0
- data/samples/getpid.rb +7 -0
- data/samples/gettimeofday.rb +13 -0
- data/samples/hello.rb +7 -0
- data/samples/qsort.rb +20 -0
- data/specs/buffer_spec.rb +141 -0
- data/specs/callback_spec.rb +31 -0
- data/specs/rbx/attach_function_spec.rb +26 -0
- data/specs/rbx/memory_pointer_spec.rb +108 -0
- data/specs/rbx/spec_helper.rb +1 -0
- data/specs/rbx/struct_spec.rb +13 -0
- data/specs/spec_helper.rb +2 -0
- metadata +359 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
/* Area: closure_call
|
2
|
+
Purpose: Check multiple values passing from different type.
|
3
|
+
Also, exceed the limit of gpr and fpr registers on PowerPC
|
4
|
+
Darwin.
|
5
|
+
Limitations: none.
|
6
|
+
PR: none.
|
7
|
+
Originator: <andreast@gcc.gnu.org> 20030828 */
|
8
|
+
|
9
|
+
/* { dg-do run } */
|
10
|
+
#include "ffitest.h"
|
11
|
+
|
12
|
+
static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args,
|
13
|
+
void* userdata)
|
14
|
+
{
|
15
|
+
*(ffi_arg*)resp =
|
16
|
+
(int)*(double *)args[0] +(int)(*(double *)args[1]) +
|
17
|
+
(int)(*(double *)args[2]) + (int)*(double *)args[3] +
|
18
|
+
(int)(*(signed short *)args[4]) + (int)(*(double *)args[5]) +
|
19
|
+
(int)*(double *)args[6] + (int)(*(int *)args[7]) +
|
20
|
+
(int)(*(double *)args[8]) + (int)*(int *)args[9] +
|
21
|
+
(int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
|
22
|
+
(int)*(int *)args[12] + (int)(*(float *)args[13]) +
|
23
|
+
(int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata;
|
24
|
+
|
25
|
+
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
|
26
|
+
(int)*(double *)args[0], (int)(*(double *)args[1]),
|
27
|
+
(int)(*(double *)args[2]), (int)*(double *)args[3],
|
28
|
+
(int)(*(signed short *)args[4]), (int)(*(double *)args[5]),
|
29
|
+
(int)*(double *)args[6], (int)(*(int *)args[7]),
|
30
|
+
(int)(*(double*)args[8]), (int)*(int *)args[9],
|
31
|
+
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
|
32
|
+
(int)*(int *)args[12], (int)(*(float *)args[13]),
|
33
|
+
(int)(*(int *)args[14]), *(int *)args[15], (int)(long)userdata,
|
34
|
+
(int)*(ffi_arg *)resp);
|
35
|
+
}
|
36
|
+
|
37
|
+
typedef int (*closure_test_type2)(double, double, double, double, signed short,
|
38
|
+
double, double, int, double, int, int, float,
|
39
|
+
int, float, int, int);
|
40
|
+
|
41
|
+
int main (void)
|
42
|
+
{
|
43
|
+
ffi_cif cif;
|
44
|
+
#ifndef USING_MMAP
|
45
|
+
static ffi_closure cl;
|
46
|
+
#endif
|
47
|
+
ffi_closure *pcl;
|
48
|
+
ffi_type * cl_arg_types[17];
|
49
|
+
int res;
|
50
|
+
|
51
|
+
#ifdef USING_MMAP
|
52
|
+
pcl = allocate_mmap (sizeof(ffi_closure));
|
53
|
+
#else
|
54
|
+
pcl = &cl;
|
55
|
+
#endif
|
56
|
+
|
57
|
+
cl_arg_types[0] = &ffi_type_double;
|
58
|
+
cl_arg_types[1] = &ffi_type_double;
|
59
|
+
cl_arg_types[2] = &ffi_type_double;
|
60
|
+
cl_arg_types[3] = &ffi_type_double;
|
61
|
+
cl_arg_types[4] = &ffi_type_sshort;
|
62
|
+
cl_arg_types[5] = &ffi_type_double;
|
63
|
+
cl_arg_types[6] = &ffi_type_double;
|
64
|
+
cl_arg_types[7] = &ffi_type_sint;
|
65
|
+
cl_arg_types[8] = &ffi_type_double;
|
66
|
+
cl_arg_types[9] = &ffi_type_sint;
|
67
|
+
cl_arg_types[10] = &ffi_type_sint;
|
68
|
+
cl_arg_types[11] = &ffi_type_float;
|
69
|
+
cl_arg_types[12] = &ffi_type_sint;
|
70
|
+
cl_arg_types[13] = &ffi_type_float;
|
71
|
+
cl_arg_types[14] = &ffi_type_sint;
|
72
|
+
cl_arg_types[15] = &ffi_type_sint;
|
73
|
+
cl_arg_types[16] = NULL;
|
74
|
+
|
75
|
+
/* Initialize the cif */
|
76
|
+
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
|
77
|
+
&ffi_type_sint, cl_arg_types) == FFI_OK);
|
78
|
+
|
79
|
+
CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn2,
|
80
|
+
(void *) 3 /* userdata */) == FFI_OK);
|
81
|
+
|
82
|
+
res = (*((closure_test_type2)pcl))
|
83
|
+
(1, 2, 3, 4, 127, 5, 6, 8, 9, 10, 11, 12.0, 13,
|
84
|
+
19.0, 21, 1);
|
85
|
+
/* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
|
86
|
+
printf("res: %d\n",res);
|
87
|
+
/* { dg-output "\nres: 255" } */
|
88
|
+
exit(0);
|
89
|
+
}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
/* Area: closure_call
|
2
|
+
Purpose: Check multiple values passing from different type.
|
3
|
+
Also, exceed the limit of gpr and fpr registers on PowerPC
|
4
|
+
Darwin.
|
5
|
+
Limitations: none.
|
6
|
+
PR: none.
|
7
|
+
Originator: <andreast@gcc.gnu.org> 20030828 */
|
8
|
+
|
9
|
+
/* { dg-do run } */
|
10
|
+
#include "ffitest.h"
|
11
|
+
|
12
|
+
static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args,
|
13
|
+
void* userdata)
|
14
|
+
{
|
15
|
+
*(ffi_arg*)resp =
|
16
|
+
(int)*(float *)args[0] +(int)(*(float *)args[1]) +
|
17
|
+
(int)(*(float *)args[2]) + (int)*(float *)args[3] +
|
18
|
+
(int)(*(float *)args[4]) + (int)(*(float *)args[5]) +
|
19
|
+
(int)*(float *)args[6] + (int)(*(float *)args[7]) +
|
20
|
+
(int)(*(double *)args[8]) + (int)*(int *)args[9] +
|
21
|
+
(int)(*(float *)args[10]) + (int)(*(float *)args[11]) +
|
22
|
+
(int)*(int *)args[12] + (int)(*(float *)args[13]) +
|
23
|
+
(int)(*(float *)args[14]) + *(int *)args[15] + (int)(long)userdata;
|
24
|
+
|
25
|
+
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
|
26
|
+
(int)*(float *)args[0], (int)(*(float *)args[1]),
|
27
|
+
(int)(*(float *)args[2]), (int)*(float *)args[3],
|
28
|
+
(int)(*(float *)args[4]), (int)(*(float *)args[5]),
|
29
|
+
(int)*(float *)args[6], (int)(*(float *)args[7]),
|
30
|
+
(int)(*(double *)args[8]), (int)*(int *)args[9],
|
31
|
+
(int)(*(float *)args[10]), (int)(*(float *)args[11]),
|
32
|
+
(int)*(int *)args[12], (int)(*(float *)args[13]),
|
33
|
+
(int)(*(float *)args[14]), *(int *)args[15], (int)(long)userdata,
|
34
|
+
(int)*(ffi_arg *)resp);
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
typedef int (*closure_test_type3)(float, float, float, float, float, float,
|
39
|
+
float, float, double, int, float, float, int,
|
40
|
+
float, float, int);
|
41
|
+
|
42
|
+
int main (void)
|
43
|
+
{
|
44
|
+
ffi_cif cif;
|
45
|
+
#ifndef USING_MMAP
|
46
|
+
static ffi_closure cl;
|
47
|
+
#endif
|
48
|
+
ffi_closure *pcl;
|
49
|
+
ffi_type * cl_arg_types[17];
|
50
|
+
int res;
|
51
|
+
|
52
|
+
#ifdef USING_MMAP
|
53
|
+
pcl = allocate_mmap (sizeof(ffi_closure));
|
54
|
+
#else
|
55
|
+
pcl = &cl;
|
56
|
+
#endif
|
57
|
+
|
58
|
+
cl_arg_types[0] = &ffi_type_float;
|
59
|
+
cl_arg_types[1] = &ffi_type_float;
|
60
|
+
cl_arg_types[2] = &ffi_type_float;
|
61
|
+
cl_arg_types[3] = &ffi_type_float;
|
62
|
+
cl_arg_types[4] = &ffi_type_float;
|
63
|
+
cl_arg_types[5] = &ffi_type_float;
|
64
|
+
cl_arg_types[6] = &ffi_type_float;
|
65
|
+
cl_arg_types[7] = &ffi_type_float;
|
66
|
+
cl_arg_types[8] = &ffi_type_double;
|
67
|
+
cl_arg_types[9] = &ffi_type_sint;
|
68
|
+
cl_arg_types[10] = &ffi_type_float;
|
69
|
+
cl_arg_types[11] = &ffi_type_float;
|
70
|
+
cl_arg_types[12] = &ffi_type_sint;
|
71
|
+
cl_arg_types[13] = &ffi_type_float;
|
72
|
+
cl_arg_types[14] = &ffi_type_float;
|
73
|
+
cl_arg_types[15] = &ffi_type_sint;
|
74
|
+
cl_arg_types[16] = NULL;
|
75
|
+
|
76
|
+
/* Initialize the cif */
|
77
|
+
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
|
78
|
+
&ffi_type_sint, cl_arg_types) == FFI_OK);
|
79
|
+
|
80
|
+
CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn3,
|
81
|
+
(void *) 3 /* userdata */) == FFI_OK);
|
82
|
+
|
83
|
+
res = (*((closure_test_type3)pcl))
|
84
|
+
(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9, 10, 11.11, 12.0, 13,
|
85
|
+
19.19, 21.21, 1);
|
86
|
+
/* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 19 21 1 3: 135" } */
|
87
|
+
printf("res: %d\n",res);
|
88
|
+
/* { dg-output "\nres: 135" } */
|
89
|
+
exit(0);
|
90
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
/* Area: closure_call
|
2
|
+
Purpose: Check multiple long long values passing.
|
3
|
+
Also, exceed the limit of gpr and fpr registers on PowerPC
|
4
|
+
Darwin.
|
5
|
+
Limitations: none.
|
6
|
+
PR: none.
|
7
|
+
Originator: <andreast@gcc.gnu.org> 20031026 */
|
8
|
+
|
9
|
+
/* { dg-do run } */
|
10
|
+
|
11
|
+
#include "ffitest.h"
|
12
|
+
|
13
|
+
static void
|
14
|
+
closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
|
15
|
+
void* userdata)
|
16
|
+
{
|
17
|
+
*(ffi_arg*)resp =
|
18
|
+
(int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] +
|
19
|
+
(int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] +
|
20
|
+
(int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] +
|
21
|
+
(int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] +
|
22
|
+
(int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] +
|
23
|
+
(int)*(unsigned long long *)args[10] +
|
24
|
+
(int)*(unsigned long long *)args[11] +
|
25
|
+
(int)*(unsigned long long *)args[12] +
|
26
|
+
(int)*(unsigned long long *)args[13] +
|
27
|
+
(int)*(unsigned long long *)args[14] +
|
28
|
+
*(int *)args[15] + (int)(long)userdata;
|
29
|
+
|
30
|
+
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
|
31
|
+
(int)*(unsigned long long *)args[0],
|
32
|
+
(int)*(unsigned long long *)args[1],
|
33
|
+
(int)*(unsigned long long *)args[2],
|
34
|
+
(int)*(unsigned long long *)args[3],
|
35
|
+
(int)*(unsigned long long *)args[4],
|
36
|
+
(int)*(unsigned long long *)args[5],
|
37
|
+
(int)*(unsigned long long *)args[6],
|
38
|
+
(int)*(unsigned long long *)args[7],
|
39
|
+
(int)*(unsigned long long *)args[8],
|
40
|
+
(int)*(unsigned long long *)args[9],
|
41
|
+
(int)*(unsigned long long *)args[10],
|
42
|
+
(int)*(unsigned long long *)args[11],
|
43
|
+
(int)*(unsigned long long *)args[12],
|
44
|
+
(int)*(unsigned long long *)args[13],
|
45
|
+
(int)*(unsigned long long *)args[14],
|
46
|
+
*(int *)args[15],
|
47
|
+
(int)(long)userdata, (int)*(ffi_arg *)resp);
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
|
52
|
+
unsigned long long, unsigned long long,
|
53
|
+
unsigned long long, unsigned long long,
|
54
|
+
unsigned long long, unsigned long long,
|
55
|
+
unsigned long long, unsigned long long,
|
56
|
+
unsigned long long, unsigned long long,
|
57
|
+
unsigned long long, unsigned long long,
|
58
|
+
unsigned long long, int);
|
59
|
+
|
60
|
+
int main (void)
|
61
|
+
{
|
62
|
+
ffi_cif cif;
|
63
|
+
#ifndef USING_MMAP
|
64
|
+
static ffi_closure cl;
|
65
|
+
#endif
|
66
|
+
ffi_closure *pcl;
|
67
|
+
ffi_type * cl_arg_types[17];
|
68
|
+
int i, res;
|
69
|
+
|
70
|
+
#ifdef USING_MMAP
|
71
|
+
pcl = allocate_mmap (sizeof(ffi_closure));
|
72
|
+
#else
|
73
|
+
pcl = &cl;
|
74
|
+
#endif
|
75
|
+
|
76
|
+
for (i = 0; i < 15; i++) {
|
77
|
+
cl_arg_types[i] = &ffi_type_uint64;
|
78
|
+
}
|
79
|
+
cl_arg_types[15] = &ffi_type_sint;
|
80
|
+
cl_arg_types[16] = NULL;
|
81
|
+
|
82
|
+
/* Initialize the cif */
|
83
|
+
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
|
84
|
+
&ffi_type_sint, cl_arg_types) == FFI_OK);
|
85
|
+
|
86
|
+
CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn0,
|
87
|
+
(void *) 3 /* userdata */) == FFI_OK);
|
88
|
+
|
89
|
+
res = (*((closure_test_type0)pcl))
|
90
|
+
(1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11LL, 12LL,
|
91
|
+
13LL, 19LL, 21LL, 1);
|
92
|
+
/* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
|
93
|
+
printf("res: %d\n",res);
|
94
|
+
/* { dg-output "\nres: 680" } */
|
95
|
+
|
96
|
+
exit(0);
|
97
|
+
}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
/* Area: closure_call
|
2
|
+
Purpose: Check multiple long long values passing.
|
3
|
+
Exceed the limit of gpr registers on PowerPC
|
4
|
+
Darwin.
|
5
|
+
Limitations: none.
|
6
|
+
PR: none.
|
7
|
+
Originator: <andreast@gcc.gnu.org> 20031026 */
|
8
|
+
|
9
|
+
/* { dg-do run } */
|
10
|
+
#include "ffitest.h"
|
11
|
+
|
12
|
+
static void
|
13
|
+
closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args,
|
14
|
+
void* userdata)
|
15
|
+
{
|
16
|
+
*(ffi_arg*)resp =
|
17
|
+
(int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] +
|
18
|
+
(int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] +
|
19
|
+
(int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] +
|
20
|
+
(int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] +
|
21
|
+
(int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] +
|
22
|
+
(int)*(int *)args[10] +
|
23
|
+
(int)*(unsigned long long *)args[11] +
|
24
|
+
(int)*(unsigned long long *)args[12] +
|
25
|
+
(int)*(unsigned long long *)args[13] +
|
26
|
+
(int)*(unsigned long long *)args[14] +
|
27
|
+
*(int *)args[15] + (int)(long)userdata;
|
28
|
+
|
29
|
+
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
|
30
|
+
(int)*(unsigned long long *)args[0],
|
31
|
+
(int)*(unsigned long long *)args[1],
|
32
|
+
(int)*(unsigned long long *)args[2],
|
33
|
+
(int)*(unsigned long long *)args[3],
|
34
|
+
(int)*(unsigned long long *)args[4],
|
35
|
+
(int)*(unsigned long long *)args[5],
|
36
|
+
(int)*(unsigned long long *)args[6],
|
37
|
+
(int)*(unsigned long long *)args[7],
|
38
|
+
(int)*(unsigned long long *)args[8],
|
39
|
+
(int)*(unsigned long long *)args[9],
|
40
|
+
(int)*(int *)args[10],
|
41
|
+
(int)*(unsigned long long *)args[11],
|
42
|
+
(int)*(unsigned long long *)args[12],
|
43
|
+
(int)*(unsigned long long *)args[13],
|
44
|
+
(int)*(unsigned long long *)args[14],
|
45
|
+
*(int *)args[15],
|
46
|
+
(int)(long)userdata, (int)*(ffi_arg *)resp);
|
47
|
+
|
48
|
+
}
|
49
|
+
|
50
|
+
typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
|
51
|
+
unsigned long long, unsigned long long,
|
52
|
+
unsigned long long, unsigned long long,
|
53
|
+
unsigned long long, unsigned long long,
|
54
|
+
unsigned long long, unsigned long long,
|
55
|
+
int, unsigned long long,
|
56
|
+
unsigned long long, unsigned long long,
|
57
|
+
unsigned long long, int);
|
58
|
+
|
59
|
+
int main (void)
|
60
|
+
{
|
61
|
+
ffi_cif cif;
|
62
|
+
#ifndef USING_MMAP
|
63
|
+
static ffi_closure cl;
|
64
|
+
#endif
|
65
|
+
ffi_closure *pcl;
|
66
|
+
ffi_type * cl_arg_types[17];
|
67
|
+
int i, res;
|
68
|
+
#ifdef USING_MMAP
|
69
|
+
pcl = allocate_mmap (sizeof(ffi_closure));
|
70
|
+
#else
|
71
|
+
pcl = &cl;
|
72
|
+
#endif
|
73
|
+
|
74
|
+
for (i = 0; i < 10; i++) {
|
75
|
+
cl_arg_types[i] = &ffi_type_uint64;
|
76
|
+
}
|
77
|
+
cl_arg_types[10] = &ffi_type_sint;
|
78
|
+
for (i = 11; i < 15; i++) {
|
79
|
+
cl_arg_types[i] = &ffi_type_uint64;
|
80
|
+
}
|
81
|
+
cl_arg_types[15] = &ffi_type_sint;
|
82
|
+
cl_arg_types[16] = NULL;
|
83
|
+
|
84
|
+
/* Initialize the cif */
|
85
|
+
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
|
86
|
+
&ffi_type_sint, cl_arg_types) == FFI_OK);
|
87
|
+
|
88
|
+
CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn5,
|
89
|
+
(void *) 3 /* userdata */) == FFI_OK);
|
90
|
+
|
91
|
+
res = (*((closure_test_type0)pcl))
|
92
|
+
(1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11, 12LL,
|
93
|
+
13LL, 19LL, 21LL, 1);
|
94
|
+
/* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
|
95
|
+
printf("res: %d\n",res);
|
96
|
+
/* { dg-output "\nres: 680" } */
|
97
|
+
|
98
|
+
exit(0);
|
99
|
+
}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
/* Area: closure_call
|
2
|
+
Purpose: Check multiple values passing from different type.
|
3
|
+
Also, exceed the limit of gpr and fpr registers on PowerPC.
|
4
|
+
Limitations: none.
|
5
|
+
PR: PR23404
|
6
|
+
Originator: <andreast@gcc.gnu.org> 20050830 */
|
7
|
+
|
8
|
+
/* { dg-do run } */
|
9
|
+
#include "ffitest.h"
|
10
|
+
|
11
|
+
static void
|
12
|
+
closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
|
13
|
+
void* userdata)
|
14
|
+
{
|
15
|
+
*(ffi_arg*)resp =
|
16
|
+
(int)*(unsigned long long *)args[0] +
|
17
|
+
(int)(*(unsigned long long *)args[1]) +
|
18
|
+
(int)(*(unsigned long long *)args[2]) +
|
19
|
+
(int)*(unsigned long long *)args[3] +
|
20
|
+
(int)(*(int *)args[4]) + (int)(*(double *)args[5]) +
|
21
|
+
(int)*(double *)args[6] + (int)(*(float *)args[7]) +
|
22
|
+
(int)(*(double *)args[8]) + (int)*(double *)args[9] +
|
23
|
+
(int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
|
24
|
+
(int)*(int *)args[12] + (int)(*(int *)args[13]) +
|
25
|
+
(int)(*(double *)args[14]) + (int)*(double *)args[15] +
|
26
|
+
(int)(long)userdata;
|
27
|
+
|
28
|
+
printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
|
29
|
+
(int)*(unsigned long long *)args[0],
|
30
|
+
(int)(*(unsigned long long *)args[1]),
|
31
|
+
(int)(*(unsigned long long *)args[2]),
|
32
|
+
(int)*(unsigned long long *)args[3],
|
33
|
+
(int)(*(int *)args[4]), (int)(*(double *)args[5]),
|
34
|
+
(int)*(double *)args[6], (int)(*(float *)args[7]),
|
35
|
+
(int)(*(double *)args[8]), (int)*(double *)args[9],
|
36
|
+
(int)(*(int *)args[10]), (int)(*(float *)args[11]),
|
37
|
+
(int)*(int *)args[12], (int)(*(int *)args[13]),
|
38
|
+
(int)(*(double *)args[14]), (int)(*(double *)args[15]),
|
39
|
+
(int)(long)userdata, (int)*(ffi_arg *)resp);
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
typedef int (*closure_test_type0)(unsigned long long,
|
44
|
+
unsigned long long,
|
45
|
+
unsigned long long,
|
46
|
+
unsigned long long,
|
47
|
+
int, double, double, float, double, double,
|
48
|
+
int, float, int, int, double, double);
|
49
|
+
|
50
|
+
int main (void)
|
51
|
+
{
|
52
|
+
ffi_cif cif;
|
53
|
+
#ifndef USING_MMAP
|
54
|
+
static ffi_closure cl;
|
55
|
+
#endif
|
56
|
+
ffi_closure *pcl;
|
57
|
+
ffi_type * cl_arg_types[17];
|
58
|
+
int res;
|
59
|
+
|
60
|
+
#ifdef USING_MMAP
|
61
|
+
pcl = allocate_mmap (sizeof(ffi_closure));
|
62
|
+
#else
|
63
|
+
pcl = &cl;
|
64
|
+
#endif
|
65
|
+
|
66
|
+
cl_arg_types[0] = &ffi_type_uint64;
|
67
|
+
cl_arg_types[1] = &ffi_type_uint64;
|
68
|
+
cl_arg_types[2] = &ffi_type_uint64;
|
69
|
+
cl_arg_types[3] = &ffi_type_uint64;
|
70
|
+
cl_arg_types[4] = &ffi_type_sint;
|
71
|
+
cl_arg_types[5] = &ffi_type_double;
|
72
|
+
cl_arg_types[6] = &ffi_type_double;
|
73
|
+
cl_arg_types[7] = &ffi_type_float;
|
74
|
+
cl_arg_types[8] = &ffi_type_double;
|
75
|
+
cl_arg_types[9] = &ffi_type_double;
|
76
|
+
cl_arg_types[10] = &ffi_type_sint;
|
77
|
+
cl_arg_types[11] = &ffi_type_float;
|
78
|
+
cl_arg_types[12] = &ffi_type_sint;
|
79
|
+
cl_arg_types[13] = &ffi_type_sint;
|
80
|
+
cl_arg_types[14] = &ffi_type_double;
|
81
|
+
cl_arg_types[15] = &ffi_type_double;
|
82
|
+
cl_arg_types[16] = NULL;
|
83
|
+
|
84
|
+
/* Initialize the cif */
|
85
|
+
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
|
86
|
+
&ffi_type_sint, cl_arg_types) == FFI_OK);
|
87
|
+
|
88
|
+
CHECK(ffi_prep_closure(pcl, &cif, closure_test_fn0,
|
89
|
+
(void *) 3 /* userdata */) == FFI_OK);
|
90
|
+
|
91
|
+
res = (*((closure_test_type0)pcl))
|
92
|
+
(1, 2, 3, 4, 127, 429., 7., 8., 9.5, 10., 11, 12., 13,
|
93
|
+
19, 21., 1.);
|
94
|
+
/* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
|
95
|
+
printf("res: %d\n",res);
|
96
|
+
/* { dg-output "\nres: 680" } */
|
97
|
+
exit(0);
|
98
|
+
}
|