ffi 1.1.5 → 1.15.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +338 -0
- data/COPYING +49 -0
- data/Gemfile +14 -0
- data/LICENSE +21 -11
- data/LICENSE.SPECS +22 -0
- data/README.md +136 -0
- data/Rakefile +149 -154
- data/ext/ffi_c/AbstractMemory.c +133 -57
- data/ext/ffi_c/AbstractMemory.h +21 -12
- data/ext/ffi_c/ArrayType.c +27 -14
- data/ext/ffi_c/ArrayType.h +21 -12
- data/ext/ffi_c/Buffer.c +29 -25
- data/ext/ffi_c/Call.c +154 -125
- data/ext/ffi_c/Call.h +43 -20
- data/ext/ffi_c/ClosurePool.c +100 -42
- data/ext/ffi_c/ClosurePool.h +24 -13
- data/ext/ffi_c/DynamicLibrary.c +47 -28
- data/ext/ffi_c/DynamicLibrary.h +70 -12
- data/ext/ffi_c/Function.c +119 -167
- data/ext/ffi_c/Function.h +23 -19
- data/ext/ffi_c/FunctionInfo.c +55 -25
- data/ext/ffi_c/LastError.c +70 -21
- data/ext/ffi_c/LastError.h +21 -12
- data/ext/ffi_c/LongDouble.c +15 -9
- data/ext/ffi_c/LongDouble.h +21 -16
- data/ext/ffi_c/MappedType.c +22 -15
- data/ext/ffi_c/MappedType.h +21 -12
- data/ext/ffi_c/MemoryPointer.c +58 -33
- data/ext/ffi_c/MemoryPointer.h +22 -19
- data/ext/ffi_c/MethodHandle.c +49 -50
- data/ext/ffi_c/MethodHandle.h +24 -14
- data/ext/ffi_c/Platform.c +28 -62
- data/ext/ffi_c/Platform.h +21 -12
- data/ext/ffi_c/Pointer.c +63 -46
- data/ext/ffi_c/Pointer.h +22 -19
- data/ext/ffi_c/Struct.c +198 -80
- data/ext/ffi_c/Struct.h +33 -18
- data/ext/ffi_c/StructByValue.c +23 -20
- data/ext/ffi_c/StructByValue.h +21 -12
- data/ext/ffi_c/StructLayout.c +184 -39
- data/ext/ffi_c/Thread.c +73 -270
- data/ext/ffi_c/Thread.h +32 -35
- data/ext/ffi_c/Type.c +26 -32
- data/ext/ffi_c/Type.h +24 -10
- data/ext/ffi_c/Types.c +28 -20
- data/ext/ffi_c/Types.h +25 -16
- data/ext/ffi_c/Variadic.c +78 -39
- data/ext/ffi_c/compat.h +25 -17
- data/ext/ffi_c/extconf.rb +68 -31
- data/ext/ffi_c/ffi.c +27 -20
- data/ext/ffi_c/libffi/.appveyor.yml +66 -0
- data/ext/ffi_c/libffi/.gitattributes +4 -0
- data/ext/ffi_c/libffi/.github/issue_template.md +10 -0
- data/ext/ffi_c/libffi/.gitignore +38 -0
- data/ext/ffi_c/libffi/.travis/ar-lib +270 -0
- data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
- data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
- data/ext/ffi_c/libffi/.travis/build.sh +142 -0
- data/ext/ffi_c/libffi/.travis/compile +351 -0
- data/ext/ffi_c/libffi/.travis/install.sh +71 -0
- data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/moxie-sim.exp +60 -0
- data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/site.exp +27 -0
- data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
- data/ext/ffi_c/libffi/.travis.yml +83 -0
- data/ext/ffi_c/libffi/{ChangeLog → ChangeLog.old} +6366 -3559
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +353 -0
- data/ext/ffi_c/libffi/Makefile.am +123 -169
- data/ext/ffi_c/libffi/Makefile.in +1243 -1003
- data/ext/ffi_c/libffi/README.md +486 -0
- data/ext/ffi_c/libffi/acinclude.m4 +387 -0
- data/ext/ffi_c/libffi/autogen.sh +2 -0
- data/ext/ffi_c/libffi/config.guess +690 -504
- data/ext/ffi_c/libffi/config.sub +1353 -1207
- data/ext/ffi_c/libffi/configure +7308 -2449
- data/ext/ffi_c/libffi/configure.ac +178 -259
- data/ext/ffi_c/libffi/configure.host +311 -4
- data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
- data/ext/ffi_c/libffi/doc/Makefile.in +815 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +455 -58
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +37 -13
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +201 -0
- data/ext/ffi_c/libffi/include/Makefile.am +3 -3
- data/ext/ffi_c/libffi/include/Makefile.in +196 -75
- data/ext/ffi_c/libffi/include/ffi.h.in +163 -67
- data/ext/ffi_c/libffi/include/ffi_cfi.h +55 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +39 -12
- data/ext/ffi_c/libffi/install-sh +207 -209
- data/ext/ffi_c/libffi/libffi.map.in +76 -0
- data/ext/ffi_c/libffi/libffi.pc.in +3 -2
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +997 -0
- data/ext/ffi_c/libffi/libtool-ldflags +106 -0
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/ltmain.sh +3641 -2026
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +13 -0
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +50 -0
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +32 -14
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +33 -106
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +53 -0
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +38 -13
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +8 -29
- data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +11 -9
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +104 -52
- data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +18 -8
- data/ext/ffi_c/libffi/m4/ax_require_defined.m4 +37 -0
- data/ext/ffi_c/libffi/make_sunver.pl +333 -0
- data/ext/ffi_c/libffi/man/Makefile.am +2 -2
- data/ext/ffi_c/libffi/man/Makefile.in +151 -55
- data/ext/ffi_c/libffi/man/ffi.3 +10 -0
- data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +6 -4
- data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +73 -0
- data/ext/ffi_c/libffi/missing +153 -314
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
- data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
- data/ext/ffi_c/libffi/{include/ffi.h.vc64 → msvc_build/aarch64/aarch64_include/ffi.h} +151 -67
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
- data/ext/ffi_c/libffi/msvcc.sh +176 -20
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +1025 -0
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +97 -0
- data/ext/ffi_c/libffi/src/aarch64/internal.h +68 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +451 -0
- data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
- data/ext/ffi_c/libffi/src/alpha/ffi.c +335 -98
- data/ext/ffi_c/libffi/src/alpha/ffitarget.h +10 -1
- data/ext/ffi_c/libffi/src/alpha/internal.h +23 -0
- data/ext/ffi_c/libffi/src/alpha/osf.S +161 -266
- data/ext/ffi_c/libffi/src/arc/arcompact.S +135 -0
- data/ext/ffi_c/libffi/src/arc/ffi.c +266 -0
- data/ext/ffi_c/libffi/src/arc/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +663 -515
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +32 -8
- data/ext/ffi_c/libffi/src/arm/internal.h +7 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +305 -417
- data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/bfin/ffi.c +196 -0
- data/ext/ffi_c/libffi/src/bfin/ffitarget.h +43 -0
- data/ext/ffi_c/libffi/src/bfin/sysv.S +179 -0
- data/ext/ffi_c/libffi/src/closures.c +465 -59
- data/ext/ffi_c/libffi/src/cris/ffi.c +10 -7
- data/ext/ffi_c/libffi/src/cris/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
- data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
- data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
- data/ext/ffi_c/libffi/src/debug.c +6 -1
- data/ext/ffi_c/libffi/src/dlmalloc.c +17 -12
- data/ext/ffi_c/libffi/src/frv/ffi.c +2 -2
- data/ext/ffi_c/libffi/src/frv/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/ia64/ffi.c +35 -13
- data/ext/ffi_c/libffi/src/ia64/ffitarget.h +8 -2
- data/ext/ffi_c/libffi/src/ia64/unix.S +8 -1
- data/ext/ffi_c/libffi/src/java_raw_api.c +23 -5
- data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
- data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
- data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
- data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
- data/ext/ffi_c/libffi/src/m32r/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/m32r/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/m68k/ffi.c +87 -13
- data/ext/ffi_c/libffi/src/m68k/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/m68k/sysv.S +119 -32
- data/ext/ffi_c/libffi/src/m88k/ffi.c +400 -0
- data/ext/ffi_c/libffi/src/m88k/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/m88k/obsd.S +209 -0
- data/ext/ffi_c/libffi/src/metag/ffi.c +330 -0
- data/ext/ffi_c/libffi/{fficonfig.hw → src/metag/ffitarget.h} +22 -26
- data/ext/ffi_c/libffi/src/metag/sysv.S +311 -0
- data/ext/ffi_c/libffi/src/microblaze/ffi.c +321 -0
- data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/microblaze/sysv.S +302 -0
- data/ext/ffi_c/libffi/src/mips/ffi.c +135 -37
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +16 -14
- data/ext/ffi_c/libffi/src/mips/n32.S +128 -56
- data/ext/ffi_c/libffi/src/mips/o32.S +150 -27
- data/ext/ffi_c/libffi/src/moxie/eabi.S +55 -82
- data/ext/ffi_c/libffi/src/moxie/ffi.c +55 -46
- data/ext/ffi_c/libffi/src/moxie/ffitarget.h +52 -0
- data/ext/ffi_c/libffi/src/nios2/ffi.c +304 -0
- data/ext/ffi_c/libffi/src/nios2/ffitarget.h +52 -0
- data/ext/ffi_c/libffi/src/nios2/sysv.S +136 -0
- data/ext/ffi_c/libffi/src/or1k/ffi.c +328 -0
- data/ext/ffi_c/libffi/src/or1k/ffitarget.h +58 -0
- data/ext/ffi_c/libffi/src/or1k/sysv.S +107 -0
- data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +9 -7
- data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
- data/ext/ffi_c/libffi/src/powerpc/aix.S +245 -7
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +253 -4
- data/ext/ffi_c/libffi/src/powerpc/asm.h +2 -2
- data/ext/ffi_c/libffi/src/powerpc/darwin.S +2 -7
- data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +22 -26
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +105 -1378
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +123 -30
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1153 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +105 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +923 -0
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +110 -45
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +189 -85
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +436 -108
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +138 -68
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +73 -119
- data/ext/ffi_c/libffi/src/prep_cif.c +111 -25
- data/ext/ffi_c/libffi/src/raw_api.c +18 -5
- data/ext/ffi_c/libffi/src/riscv/ffi.c +481 -0
- data/ext/ffi_c/libffi/src/riscv/ffitarget.h +69 -0
- data/ext/ffi_c/libffi/src/riscv/sysv.S +293 -0
- data/ext/ffi_c/libffi/src/s390/ffi.c +294 -318
- data/ext/ffi_c/libffi/src/s390/ffitarget.h +9 -1
- data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
- data/ext/ffi_c/libffi/src/s390/sysv.S +257 -366
- data/ext/ffi_c/libffi/src/sh/ffi.c +4 -3
- data/ext/ffi_c/libffi/src/sh/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/sh64/ffi.c +3 -2
- data/ext/ffi_c/libffi/src/sh64/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/sparc/ffi.c +326 -527
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +608 -0
- data/ext/ffi_c/libffi/src/sparc/ffitarget.h +20 -7
- data/ext/ffi_c/libffi/src/sparc/internal.h +26 -0
- data/ext/ffi_c/libffi/src/sparc/v8.S +364 -234
- data/ext/ffi_c/libffi/src/sparc/v9.S +340 -207
- data/ext/ffi_c/libffi/src/tile/ffi.c +355 -0
- data/ext/ffi_c/libffi/src/tile/ffitarget.h +65 -0
- data/ext/ffi_c/libffi/src/tile/tile.S +360 -0
- data/ext/ffi_c/libffi/src/types.c +46 -15
- data/ext/ffi_c/libffi/src/vax/elfbsd.S +195 -0
- data/ext/ffi_c/libffi/src/vax/ffi.c +276 -0
- data/ext/ffi_c/libffi/src/vax/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/x86/asmnames.h +30 -0
- data/ext/ffi_c/libffi/src/x86/ffi.c +624 -498
- data/ext/ffi_c/libffi/src/x86/ffi64.c +379 -119
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +74 -35
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +318 -0
- data/ext/ffi_c/libffi/src/x86/internal.h +29 -0
- data/ext/ffi_c/libffi/src/x86/internal64.h +22 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +1070 -400
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +494 -299
- data/ext/ffi_c/libffi/src/x86/win64.S +231 -458
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +238 -0
- data/ext/ffi_c/libffi/src/xtensa/ffi.c +298 -0
- data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/xtensa/sysv.S +258 -0
- data/ext/ffi_c/libffi/stamp-h.in +1 -0
- data/ext/ffi_c/libffi/testsuite/Makefile.am +115 -73
- data/ext/ffi_c/libffi/testsuite/Makefile.in +262 -114
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +334 -24
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +21 -1
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/README +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h +50 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1745 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2885 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +743 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +28 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +25 -40
- data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +3 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +15 -12
- data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +4 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +107 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +6 -16
- data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +0 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +127 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +55 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +9 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +7 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +7 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +9 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +9 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +196 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +121 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +123 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +125 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call/closure_stdcall.c → libffi.closures/closure_simple.c} +7 -16
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +95 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +4 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +4 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +4 -4
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +10 -9
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +3 -3
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +10 -9
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_args.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c +55 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +1 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +11 -9
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +114 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +44 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +45 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +45 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +44 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +20 -19
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +6 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +8 -8
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +7 -6
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +121 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +6 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +6 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +6 -6
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +7 -7
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +7 -7
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +5 -5
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +2 -2
- data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest.cc +3 -10
- data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest_ffi_call.cc +3 -2
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc +71 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc +80 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c +16 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.special/special.exp → libffi.complex/complex.exp} +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +51 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +37 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +34 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +28 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +19 -0
- data/ext/ffi_c/libffi.bsd.mk +12 -6
- data/ext/ffi_c/libffi.darwin.mk +21 -9
- data/ext/ffi_c/libffi.gnu.mk +3 -2
- data/ext/ffi_c/libffi.mk +11 -6
- data/ext/ffi_c/libffi.vc.mk +1 -1
- data/ext/ffi_c/libffi.vc64.mk +1 -1
- data/ext/ffi_c/rbffi.h +22 -14
- data/ext/ffi_c/rbffi_endian.h +11 -2
- data/ffi.gemspec +42 -0
- data/lib/ffi/abstract_memory.rb +44 -0
- data/lib/ffi/autopointer.rb +70 -50
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/enum.rb +159 -24
- data/lib/ffi/errno.rb +21 -11
- data/lib/ffi/ffi.rb +25 -11
- data/lib/ffi/io.rb +24 -14
- data/lib/ffi/library.rb +174 -67
- data/lib/ffi/managedstruct.rb +63 -34
- data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
- data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/aarch64-freebsd12/types.conf +181 -0
- data/lib/ffi/platform/aarch64-linux/types.conf +104 -0
- data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
- data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/arm-linux/types.conf +110 -82
- data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- data/lib/ffi/platform/i386-darwin/types.conf +63 -63
- data/lib/ffi/platform/i386-freebsd/types.conf +89 -89
- data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/{i486-gnu → i386-gnu}/types.conf +84 -84
- data/lib/ffi/platform/i386-linux/types.conf +77 -77
- data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
- data/lib/ffi/platform/i386-openbsd/types.conf +89 -87
- data/lib/ffi/platform/i386-solaris/types.conf +96 -96
- data/lib/ffi/platform/i386-windows/types.conf +43 -96
- data/lib/ffi/platform/ia64-linux/types.conf +79 -79
- data/lib/ffi/platform/mips-linux/types.conf +79 -79
- data/lib/ffi/platform/mips64-linux/types.conf +104 -0
- data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
- data/lib/ffi/platform/mipsisa32r6-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +102 -0
- data/lib/ffi/platform/mipsisa64r6-linux/types.conf +104 -0
- data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +104 -0
- data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
- data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
- data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
- data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
- data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
- data/lib/ffi/platform/s390-linux/types.conf +79 -79
- data/lib/ffi/platform/s390x-linux/types.conf +79 -79
- data/lib/ffi/platform/sparc-linux/types.conf +79 -79
- data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
- data/lib/ffi/platform/sparc64-linux/types.conf +102 -0
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
- data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +93 -63
- data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -88
- data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
- data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
- data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -87
- data/lib/ffi/platform/x86_64-openbsd/types.conf +100 -92
- data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
- data/lib/ffi/platform/x86_64-windows/types.conf +52 -0
- data/lib/ffi/platform.rb +81 -26
- data/lib/ffi/pointer.rb +72 -27
- data/lib/ffi/struct.rb +99 -66
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/struct_layout_builder.rb +82 -17
- data/lib/ffi/tools/const_generator.rb +11 -8
- data/lib/ffi/tools/generator.rb +48 -1
- data/lib/ffi/tools/generator_task.rb +13 -16
- data/lib/ffi/tools/struct_generator.rb +6 -5
- data/lib/ffi/tools/types_generator.rb +14 -10
- data/lib/ffi/types.rb +31 -14
- data/lib/ffi/union.rb +23 -12
- data/lib/ffi/variadic.rb +25 -21
- data/lib/ffi/version.rb +3 -0
- data/lib/ffi.rb +20 -8
- data/rakelib/ffi_gem_helper.rb +65 -0
- data/samples/getlogin.rb +8 -0
- data/samples/getpid.rb +8 -0
- data/samples/gettimeofday.rb +18 -0
- data/samples/hello.rb +8 -0
- data/samples/inotify.rb +60 -0
- data/samples/pty.rb +75 -0
- data/samples/qsort.rb +20 -0
- metadata +413 -263
- data/History.txt +0 -1
- data/README.rdoc +0 -102
- data/ext/ffi_c/DataConverter.c +0 -91
- data/ext/ffi_c/Ffi_c.iml +0 -12
- data/ext/ffi_c/StructByReference.c +0 -158
- data/ext/ffi_c/StructByReference.h +0 -50
- data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
- data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
- data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
- data/ext/ffi_c/libffi/Makefile.vc +0 -141
- data/ext/ffi_c/libffi/Makefile.vc64 +0 -141
- data/ext/ffi_c/libffi/README +0 -342
- data/ext/ffi_c/libffi/aclocal.m4 +0 -1873
- data/ext/ffi_c/libffi/build-ios.sh +0 -67
- data/ext/ffi_c/libffi/compile +0 -143
- data/ext/ffi_c/libffi/depcomp +0 -630
- data/ext/ffi_c/libffi/doc/libffi.info +0 -593
- data/ext/ffi_c/libffi/doc/stamp-vti +0 -4
- data/ext/ffi_c/libffi/include/ffi.h.vc +0 -427
- data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +0 -76
- data/ext/ffi_c/libffi/m4/libtool.m4 +0 -7831
- data/ext/ffi_c/libffi/m4/ltoptions.m4 +0 -369
- data/ext/ffi_c/libffi/m4/ltsugar.m4 +0 -123
- data/ext/ffi_c/libffi/m4/ltversion.m4 +0 -23
- data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +0 -98
- data/ext/ffi_c/libffi/mdate-sh +0 -201
- data/ext/ffi_c/libffi/src/arm/gentramp.sh +0 -118
- data/ext/ffi_c/libffi/src/arm/trampoline.S +0 -4450
- data/ext/ffi_c/libffi/src/x86/darwin.S +0 -444
- data/ext/ffi_c/libffi/src/x86/darwin64.S +0 -416
- data/ext/ffi_c/libffi/src/x86/freebsd.S +0 -458
- data/ext/ffi_c/libffi/src/x86/win32.S +0 -1065
- data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +0 -300
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +0 -63
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +0 -96
- data/ext/ffi_c/libffi/texinfo.tex +0 -7210
- data/ext/ffi_c/win32/stdint.h +0 -199
- data/gen/Rakefile +0 -30
- data/gen/log +0 -1
- data/lib/Lib.iml +0 -13
- data/spec/ffi/Ffi.iml +0 -12
- data/spec/ffi/async_callback_spec.rb +0 -46
- data/spec/ffi/bool_spec.rb +0 -40
- data/spec/ffi/buffer_spec.rb +0 -215
- data/spec/ffi/callback_spec.rb +0 -668
- data/spec/ffi/custom_param_type.rb +0 -47
- data/spec/ffi/custom_type_spec.rb +0 -85
- data/spec/ffi/dup_spec.rb +0 -65
- data/spec/ffi/enum_spec.rb +0 -227
- data/spec/ffi/errno_spec.rb +0 -29
- data/spec/ffi/ffi_spec.rb +0 -40
- data/spec/ffi/function_spec.rb +0 -87
- data/spec/ffi/library_spec.rb +0 -208
- data/spec/ffi/long_double.rb +0 -41
- data/spec/ffi/managed_struct_spec.rb +0 -72
- data/spec/ffi/number_spec.rb +0 -247
- data/spec/ffi/pointer_spec.rb +0 -214
- data/spec/ffi/rbx/attach_function_spec.rb +0 -28
- data/spec/ffi/rbx/memory_pointer_spec.rb +0 -115
- data/spec/ffi/rbx/spec_helper.rb +0 -1
- data/spec/ffi/rbx/struct_spec.rb +0 -13
- data/spec/ffi/spec_helper.rb +0 -35
- data/spec/ffi/string_spec.rb +0 -119
- data/spec/ffi/strptr_spec.rb +0 -61
- data/spec/ffi/struct_callback_spec.rb +0 -80
- data/spec/ffi/struct_initialize_spec.rb +0 -46
- data/spec/ffi/struct_packed_spec.rb +0 -62
- data/spec/ffi/struct_spec.rb +0 -719
- data/spec/ffi/typedef_spec.rb +0 -89
- data/spec/ffi/union_spec.rb +0 -76
- data/spec/ffi/variadic_spec.rb +0 -103
- data/spec/spec.opts +0 -4
- data/tasks/ann.rake +0 -80
- data/tasks/extension.rake +0 -32
- data/tasks/gem.rake +0 -199
- data/tasks/git.rake +0 -41
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -50
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -301
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/yard.rake +0 -11
@@ -1,7 +1,8 @@
|
|
1
1
|
\input texinfo @c -*-texinfo-*-
|
2
2
|
@c %**start of header
|
3
3
|
@setfilename libffi.info
|
4
|
-
@
|
4
|
+
@include version.texi
|
5
|
+
@settitle libffi: the portable foreign function interface library
|
5
6
|
@setchapternewpage off
|
6
7
|
@c %**end of header
|
7
8
|
|
@@ -12,32 +13,43 @@
|
|
12
13
|
@syncodeindex pg cp
|
13
14
|
@syncodeindex tp cp
|
14
15
|
|
15
|
-
@include version.texi
|
16
|
-
|
17
16
|
@copying
|
18
17
|
|
19
|
-
This manual is for
|
18
|
+
This manual is for libffi, a portable foreign function interface
|
20
19
|
library.
|
21
20
|
|
22
|
-
Copyright @copyright{} 2008
|
21
|
+
Copyright @copyright{} 2008--2019 Anthony Green and Red Hat, Inc.
|
22
|
+
|
23
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
24
|
+
a copy of this software and associated documentation files (the
|
25
|
+
``Software''), to deal in the Software without restriction, including
|
26
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
27
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
28
|
+
permit persons to whom the Software is furnished to do so, subject to
|
29
|
+
the following conditions:
|
23
30
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
The above copyright notice and this permission notice shall be
|
32
|
+
included in all copies or substantial portions of the Software.
|
33
|
+
|
34
|
+
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
35
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
36
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
37
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
38
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
39
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
40
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
30
41
|
|
31
|
-
@end quotation
|
32
42
|
@end copying
|
33
43
|
|
34
44
|
@dircategory Development
|
35
45
|
@direntry
|
36
|
-
* libffi: (libffi). Portable foreign
|
46
|
+
* libffi: (libffi). Portable foreign function interface library.
|
37
47
|
@end direntry
|
38
48
|
|
39
49
|
@titlepage
|
40
|
-
@title
|
50
|
+
@title libffi: a foreign function interface library
|
51
|
+
@subtitle For Version @value{VERSION} of libffi
|
52
|
+
@author Anthony Green
|
41
53
|
@page
|
42
54
|
@vskip 0pt plus 1filll
|
43
55
|
@insertcopying
|
@@ -107,6 +119,7 @@ values passed between the two languages.
|
|
107
119
|
* Multiple ABIs:: Different passing styles on one platform.
|
108
120
|
* The Closure API:: Writing a generic function.
|
109
121
|
* Closure Example:: A closure example.
|
122
|
+
* Thread Safety:: Thread safety.
|
110
123
|
@end menu
|
111
124
|
|
112
125
|
|
@@ -133,8 +146,6 @@ This initializes @var{cif} according to the given parameters.
|
|
133
146
|
you want. @ref{Multiple ABIs} for more information.
|
134
147
|
|
135
148
|
@var{nargs} is the number of arguments that this function accepts.
|
136
|
-
@samp{libffi} does not yet handle varargs functions; see @ref{Missing
|
137
|
-
Features} for more information.
|
138
149
|
|
139
150
|
@var{rtype} is a pointer to an @code{ffi_type} structure that
|
140
151
|
describes the return type of the function. @xref{Types}.
|
@@ -150,6 +161,34 @@ objects is incorrect; or @code{FFI_BAD_ABI} if the @var{abi} parameter
|
|
150
161
|
is invalid.
|
151
162
|
@end defun
|
152
163
|
|
164
|
+
If the function being called is variadic (varargs) then
|
165
|
+
@code{ffi_prep_cif_var} must be used instead of @code{ffi_prep_cif}.
|
166
|
+
|
167
|
+
@findex ffi_prep_cif_var
|
168
|
+
@defun ffi_status ffi_prep_cif_var (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nfixedargs}, unsigned int @var{ntotalargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes})
|
169
|
+
This initializes @var{cif} according to the given parameters for
|
170
|
+
a call to a variadic function. In general its operation is the
|
171
|
+
same as for @code{ffi_prep_cif} except that:
|
172
|
+
|
173
|
+
@var{nfixedargs} is the number of fixed arguments, prior to any
|
174
|
+
variadic arguments. It must be greater than zero.
|
175
|
+
|
176
|
+
@var{ntotalargs} the total number of arguments, including variadic
|
177
|
+
and fixed arguments. @var{argtypes} must have this many elements.
|
178
|
+
|
179
|
+
Note that, different cif's must be prepped for calls to the same
|
180
|
+
function when different numbers of arguments are passed.
|
181
|
+
|
182
|
+
Also note that a call to @code{ffi_prep_cif_var} with
|
183
|
+
@var{nfixedargs}=@var{nototalargs} is NOT equivalent to a call to
|
184
|
+
@code{ffi_prep_cif}.
|
185
|
+
|
186
|
+
@end defun
|
187
|
+
|
188
|
+
Note that the resulting @code{ffi_cif} holds pointers to all the
|
189
|
+
@code{ffi_type} objects that were used during initialization. You
|
190
|
+
must ensure that these type objects have a lifetime at least as long
|
191
|
+
as that of the @code{ffi_cif}.
|
153
192
|
|
154
193
|
To call a function using an initialized @code{ffi_cif}, use the
|
155
194
|
@code{ffi_call} function:
|
@@ -162,11 +201,21 @@ This calls the function @var{fn} according to the description given in
|
|
162
201
|
|
163
202
|
@var{rvalue} is a pointer to a chunk of memory that will hold the
|
164
203
|
result of the function call. This must be large enough to hold the
|
165
|
-
result
|
204
|
+
result, no smaller than the system register size (generally 32 or 64
|
205
|
+
bits), and must be suitably aligned; it is the caller's responsibility
|
166
206
|
to ensure this. If @var{cif} declares that the function returns
|
167
207
|
@code{void} (using @code{ffi_type_void}), then @var{rvalue} is
|
168
|
-
ignored.
|
169
|
-
|
208
|
+
ignored.
|
209
|
+
|
210
|
+
In most situations, @samp{libffi} will handle promotion according to
|
211
|
+
the ABI. However, for historical reasons, there is a special case
|
212
|
+
with return values that must be handled by your code. In particular,
|
213
|
+
for integral (not @code{struct}) types that are narrower than the
|
214
|
+
system register size, the return value will be widened by
|
215
|
+
@samp{libffi}. @samp{libffi} provides a type, @code{ffi_arg}, that
|
216
|
+
can be used as the return type. For example, if the CIF was defined
|
217
|
+
with a return type of @code{char}, @samp{libffi} will try to store a
|
218
|
+
full @code{ffi_arg} into the return value.
|
170
219
|
|
171
220
|
@var{avalues} is a vector of @code{void *} pointers that point to the
|
172
221
|
memory locations holding the argument values for a call. If @var{cif}
|
@@ -174,6 +223,13 @@ declares that the function has no arguments (i.e., @var{nargs} was 0),
|
|
174
223
|
then @var{avalues} is ignored. Note that argument values may be
|
175
224
|
modified by the callee (for instance, structs passed by value); the
|
176
225
|
burden of copying pass-by-value arguments is placed on the caller.
|
226
|
+
|
227
|
+
Note that while the return value must be register-sized, arguments
|
228
|
+
should exactly match their declared type. For example, if an argument
|
229
|
+
is a @code{short}, then the entry in @var{avalues} should point to an
|
230
|
+
object declared as @code{short}; but if the return type is
|
231
|
+
@code{short}, then @var{rvalue} should point to an object declared as
|
232
|
+
a larger type -- usually @code{ffi_arg}.
|
177
233
|
@end defun
|
178
234
|
|
179
235
|
|
@@ -192,7 +248,7 @@ int main()
|
|
192
248
|
ffi_type *args[1];
|
193
249
|
void *values[1];
|
194
250
|
char *s;
|
195
|
-
|
251
|
+
ffi_arg rc;
|
196
252
|
|
197
253
|
/* Initialize the argument info vectors */
|
198
254
|
args[0] = &ffi_type_pointer;
|
@@ -200,7 +256,7 @@ int main()
|
|
200
256
|
|
201
257
|
/* Initialize the cif */
|
202
258
|
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
203
|
-
&
|
259
|
+
&ffi_type_sint, args) == FFI_OK)
|
204
260
|
@{
|
205
261
|
s = "Hello World!";
|
206
262
|
ffi_call(&cif, puts, &rc, values);
|
@@ -224,7 +280,11 @@ int main()
|
|
224
280
|
@menu
|
225
281
|
* Primitive Types:: Built-in types.
|
226
282
|
* Structures:: Structure types.
|
283
|
+
* Size and Alignment:: Size and alignment of types.
|
284
|
+
* Arrays Unions Enums:: Arrays, unions, and enumerations.
|
227
285
|
* Type Example:: Structure type example.
|
286
|
+
* Complex:: Complex types.
|
287
|
+
* Complex Type Example:: Complex type example.
|
228
288
|
@end menu
|
229
289
|
|
230
290
|
@node Primitive Types
|
@@ -323,6 +383,20 @@ On other platforms, it is not.
|
|
323
383
|
@tindex ffi_type_pointer
|
324
384
|
A generic @code{void *} pointer. You should use this for all
|
325
385
|
pointers, regardless of their real type.
|
386
|
+
|
387
|
+
@item ffi_type_complex_float
|
388
|
+
@tindex ffi_type_complex_float
|
389
|
+
The C @code{_Complex float} type.
|
390
|
+
|
391
|
+
@item ffi_type_complex_double
|
392
|
+
@tindex ffi_type_complex_double
|
393
|
+
The C @code{_Complex double} type.
|
394
|
+
|
395
|
+
@item ffi_type_complex_longdouble
|
396
|
+
@tindex ffi_type_complex_longdouble
|
397
|
+
The C @code{_Complex long double} type.
|
398
|
+
On platforms that have a C @code{long double} type, this is defined.
|
399
|
+
On other platforms, it is not.
|
326
400
|
@end table
|
327
401
|
|
328
402
|
Each of these is of type @code{ffi_type}, so you must take the address
|
@@ -332,13 +406,12 @@ when passing to @code{ffi_prep_cif}.
|
|
332
406
|
@node Structures
|
333
407
|
@subsection Structures
|
334
408
|
|
335
|
-
|
336
|
-
bit-fields, it is perfectly happy passing structures back and forth.
|
409
|
+
@samp{libffi} is perfectly happy passing structures back and forth.
|
337
410
|
You must first describe the structure to @samp{libffi} by creating a
|
338
411
|
new @code{ffi_type} object for it.
|
339
412
|
|
340
413
|
@tindex ffi_type
|
341
|
-
@deftp ffi_type
|
414
|
+
@deftp {Data type} ffi_type
|
342
415
|
The @code{ffi_type} has the following members:
|
343
416
|
@table @code
|
344
417
|
@item size_t size
|
@@ -353,9 +426,166 @@ For a structure, this should be set to @code{FFI_TYPE_STRUCT}.
|
|
353
426
|
@item ffi_type **elements
|
354
427
|
This is a @samp{NULL}-terminated array of pointers to @code{ffi_type}
|
355
428
|
objects. There is one element per field of the struct.
|
429
|
+
|
430
|
+
Note that @samp{libffi} has no special support for bit-fields. You
|
431
|
+
must manage these manually.
|
356
432
|
@end table
|
357
433
|
@end deftp
|
358
434
|
|
435
|
+
The @code{size} and @code{alignment} fields will be filled in by
|
436
|
+
@code{ffi_prep_cif} or @code{ffi_prep_cif_var}, as needed.
|
437
|
+
|
438
|
+
@node Size and Alignment
|
439
|
+
@subsection Size and Alignment
|
440
|
+
|
441
|
+
@code{libffi} will set the @code{size} and @code{alignment} fields of
|
442
|
+
an @code{ffi_type} object for you. It does so using its knowledge of
|
443
|
+
the ABI.
|
444
|
+
|
445
|
+
You might expect that you can simply read these fields for a type that
|
446
|
+
has been laid out by @code{libffi}. However, there are some caveats.
|
447
|
+
|
448
|
+
@itemize @bullet
|
449
|
+
@item
|
450
|
+
The size or alignment of some of the built-in types may vary depending
|
451
|
+
on the chosen ABI.
|
452
|
+
|
453
|
+
@item
|
454
|
+
The size and alignment of a new structure type will not be set by
|
455
|
+
@code{libffi} until it has been passed to @code{ffi_prep_cif} or
|
456
|
+
@code{ffi_get_struct_offsets}.
|
457
|
+
|
458
|
+
@item
|
459
|
+
A structure type cannot be shared across ABIs. Instead each ABI needs
|
460
|
+
its own copy of the structure type.
|
461
|
+
@end itemize
|
462
|
+
|
463
|
+
So, before examining these fields, it is safest to pass the
|
464
|
+
@code{ffi_type} object to @code{ffi_prep_cif} or
|
465
|
+
@code{ffi_get_struct_offsets} first. This function will do all the
|
466
|
+
needed setup.
|
467
|
+
|
468
|
+
@example
|
469
|
+
ffi_type *desired_type;
|
470
|
+
ffi_abi desired_abi;
|
471
|
+
@dots{}
|
472
|
+
ffi_cif cif;
|
473
|
+
if (ffi_prep_cif (&cif, desired_abi, 0, desired_type, NULL) == FFI_OK)
|
474
|
+
@{
|
475
|
+
size_t size = desired_type->size;
|
476
|
+
unsigned short alignment = desired_type->alignment;
|
477
|
+
@}
|
478
|
+
@end example
|
479
|
+
|
480
|
+
@code{libffi} also provides a way to get the offsets of the members of
|
481
|
+
a structure.
|
482
|
+
|
483
|
+
@findex ffi_get_struct_offsets
|
484
|
+
@defun ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, size_t *offsets)
|
485
|
+
Compute the offset of each element of the given structure type.
|
486
|
+
@var{abi} is the ABI to use; this is needed because in some cases the
|
487
|
+
layout depends on the ABI.
|
488
|
+
|
489
|
+
@var{offsets} is an out parameter. The caller is responsible for
|
490
|
+
providing enough space for all the results to be written -- one
|
491
|
+
element per element type in @var{struct_type}. If @var{offsets} is
|
492
|
+
@code{NULL}, then the type will be laid out but not otherwise
|
493
|
+
modified. This can be useful for accessing the type's size or layout,
|
494
|
+
as mentioned above.
|
495
|
+
|
496
|
+
This function returns @code{FFI_OK} on success; @code{FFI_BAD_ABI} if
|
497
|
+
@var{abi} is invalid; or @code{FFI_BAD_TYPEDEF} if @var{struct_type}
|
498
|
+
is invalid in some way. Note that only @code{FFI_STRUCT} types are
|
499
|
+
valid here.
|
500
|
+
@end defun
|
501
|
+
|
502
|
+
@node Arrays Unions Enums
|
503
|
+
@subsection Arrays, Unions, and Enumerations
|
504
|
+
|
505
|
+
@subsubsection Arrays
|
506
|
+
|
507
|
+
@samp{libffi} does not have direct support for arrays or unions.
|
508
|
+
However, they can be emulated using structures.
|
509
|
+
|
510
|
+
To emulate an array, simply create an @code{ffi_type} using
|
511
|
+
@code{FFI_TYPE_STRUCT} with as many members as there are elements in
|
512
|
+
the array.
|
513
|
+
|
514
|
+
@example
|
515
|
+
ffi_type array_type;
|
516
|
+
ffi_type **elements
|
517
|
+
int i;
|
518
|
+
|
519
|
+
elements = malloc ((n + 1) * sizeof (ffi_type *));
|
520
|
+
for (i = 0; i < n; ++i)
|
521
|
+
elements[i] = array_element_type;
|
522
|
+
elements[n] = NULL;
|
523
|
+
|
524
|
+
array_type.size = array_type.alignment = 0;
|
525
|
+
array_type.type = FFI_TYPE_STRUCT;
|
526
|
+
array_type.elements = elements;
|
527
|
+
@end example
|
528
|
+
|
529
|
+
Note that arrays cannot be passed or returned by value in C --
|
530
|
+
structure types created like this should only be used to refer to
|
531
|
+
members of real @code{FFI_TYPE_STRUCT} objects.
|
532
|
+
|
533
|
+
However, a phony array type like this will not cause any errors from
|
534
|
+
@samp{libffi} if you use it as an argument or return type. This may
|
535
|
+
be confusing.
|
536
|
+
|
537
|
+
@subsubsection Unions
|
538
|
+
|
539
|
+
A union can also be emulated using @code{FFI_TYPE_STRUCT}. In this
|
540
|
+
case, however, you must make sure that the size and alignment match
|
541
|
+
the real requirements of the union.
|
542
|
+
|
543
|
+
One simple way to do this is to ensue that each element type is laid
|
544
|
+
out. Then, give the new structure type a single element; the size of
|
545
|
+
the largest element; and the largest alignment seen as well.
|
546
|
+
|
547
|
+
This example uses the @code{ffi_prep_cif} trick to ensure that each
|
548
|
+
element type is laid out.
|
549
|
+
|
550
|
+
@example
|
551
|
+
ffi_abi desired_abi;
|
552
|
+
ffi_type union_type;
|
553
|
+
ffi_type **union_elements;
|
554
|
+
|
555
|
+
int i;
|
556
|
+
ffi_type element_types[2];
|
557
|
+
|
558
|
+
element_types[1] = NULL;
|
559
|
+
|
560
|
+
union_type.size = union_type.alignment = 0;
|
561
|
+
union_type.type = FFI_TYPE_STRUCT;
|
562
|
+
union_type.elements = element_types;
|
563
|
+
|
564
|
+
for (i = 0; union_elements[i]; ++i)
|
565
|
+
@{
|
566
|
+
ffi_cif cif;
|
567
|
+
if (ffi_prep_cif (&cif, desired_abi, 0, union_elements[i], NULL) == FFI_OK)
|
568
|
+
@{
|
569
|
+
if (union_elements[i]->size > union_type.size)
|
570
|
+
@{
|
571
|
+
union_type.size = union_elements[i];
|
572
|
+
size = union_elements[i]->size;
|
573
|
+
@}
|
574
|
+
if (union_elements[i]->alignment > union_type.alignment)
|
575
|
+
union_type.alignment = union_elements[i]->alignment;
|
576
|
+
@}
|
577
|
+
@}
|
578
|
+
@end example
|
579
|
+
|
580
|
+
@subsubsection Enumerations
|
581
|
+
|
582
|
+
@code{libffi} does not have any special support for C @code{enum}s.
|
583
|
+
Although any given @code{enum} is implemented using a specific
|
584
|
+
underlying integral type, exactly which type will be used cannot be
|
585
|
+
determined by @code{libffi} -- it may depend on the values in the
|
586
|
+
enumeration or on compiler flags such as @option{-fshort-enums}.
|
587
|
+
@xref{Structures unions enumerations and bit-fields implementation, , , gcc},
|
588
|
+
for more information about how GCC handles enumerations.
|
359
589
|
|
360
590
|
@node Type Example
|
361
591
|
@subsection Type Example
|
@@ -392,6 +622,7 @@ Here is the corresponding code to describe this struct to
|
|
392
622
|
int i;
|
393
623
|
|
394
624
|
tm_type.size = tm_type.alignment = 0;
|
625
|
+
tm_type.type = FFI_TYPE_STRUCT;
|
395
626
|
tm_type.elements = &tm_type_elements;
|
396
627
|
|
397
628
|
for (i = 0; i < 9; i++)
|
@@ -406,6 +637,135 @@ Here is the corresponding code to describe this struct to
|
|
406
637
|
@}
|
407
638
|
@end example
|
408
639
|
|
640
|
+
@node Complex
|
641
|
+
@subsection Complex Types
|
642
|
+
|
643
|
+
@samp{libffi} supports the complex types defined by the C99
|
644
|
+
standard (@code{_Complex float}, @code{_Complex double} and
|
645
|
+
@code{_Complex long double} with the built-in type descriptors
|
646
|
+
@code{ffi_type_complex_float}, @code{ffi_type_complex_double} and
|
647
|
+
@code{ffi_type_complex_longdouble}.
|
648
|
+
|
649
|
+
Custom complex types like @code{_Complex int} can also be used.
|
650
|
+
An @code{ffi_type} object has to be defined to describe the
|
651
|
+
complex type to @samp{libffi}.
|
652
|
+
|
653
|
+
@tindex ffi_type
|
654
|
+
@deftp {Data type} ffi_type
|
655
|
+
@table @code
|
656
|
+
@item size_t size
|
657
|
+
This must be manually set to the size of the complex type.
|
658
|
+
|
659
|
+
@item unsigned short alignment
|
660
|
+
This must be manually set to the alignment of the complex type.
|
661
|
+
|
662
|
+
@item unsigned short type
|
663
|
+
For a complex type, this must be set to @code{FFI_TYPE_COMPLEX}.
|
664
|
+
|
665
|
+
@item ffi_type **elements
|
666
|
+
|
667
|
+
This is a @samp{NULL}-terminated array of pointers to
|
668
|
+
@code{ffi_type} objects. The first element is set to the
|
669
|
+
@code{ffi_type} of the complex's base type. The second element
|
670
|
+
must be set to @code{NULL}.
|
671
|
+
@end table
|
672
|
+
@end deftp
|
673
|
+
|
674
|
+
The section @ref{Complex Type Example} shows a way to determine
|
675
|
+
the @code{size} and @code{alignment} members in a platform
|
676
|
+
independent way.
|
677
|
+
|
678
|
+
For platforms that have no complex support in @code{libffi} yet,
|
679
|
+
the functions @code{ffi_prep_cif} and @code{ffi_prep_args} abort
|
680
|
+
the program if they encounter a complex type.
|
681
|
+
|
682
|
+
@node Complex Type Example
|
683
|
+
@subsection Complex Type Example
|
684
|
+
|
685
|
+
This example demonstrates how to use complex types:
|
686
|
+
|
687
|
+
@example
|
688
|
+
#include <stdio.h>
|
689
|
+
#include <ffi.h>
|
690
|
+
#include <complex.h>
|
691
|
+
|
692
|
+
void complex_fn(_Complex float cf,
|
693
|
+
_Complex double cd,
|
694
|
+
_Complex long double cld)
|
695
|
+
@{
|
696
|
+
printf("cf=%f+%fi\ncd=%f+%fi\ncld=%f+%fi\n",
|
697
|
+
(float)creal (cf), (float)cimag (cf),
|
698
|
+
(float)creal (cd), (float)cimag (cd),
|
699
|
+
(float)creal (cld), (float)cimag (cld));
|
700
|
+
@}
|
701
|
+
|
702
|
+
int main()
|
703
|
+
@{
|
704
|
+
ffi_cif cif;
|
705
|
+
ffi_type *args[3];
|
706
|
+
void *values[3];
|
707
|
+
_Complex float cf;
|
708
|
+
_Complex double cd;
|
709
|
+
_Complex long double cld;
|
710
|
+
|
711
|
+
/* Initialize the argument info vectors */
|
712
|
+
args[0] = &ffi_type_complex_float;
|
713
|
+
args[1] = &ffi_type_complex_double;
|
714
|
+
args[2] = &ffi_type_complex_longdouble;
|
715
|
+
values[0] = &cf;
|
716
|
+
values[1] = &cd;
|
717
|
+
values[2] = &cld;
|
718
|
+
|
719
|
+
/* Initialize the cif */
|
720
|
+
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
|
721
|
+
&ffi_type_void, args) == FFI_OK)
|
722
|
+
@{
|
723
|
+
cf = 1.0 + 20.0 * I;
|
724
|
+
cd = 300.0 + 4000.0 * I;
|
725
|
+
cld = 50000.0 + 600000.0 * I;
|
726
|
+
/* Call the function */
|
727
|
+
ffi_call(&cif, (void (*)(void))complex_fn, 0, values);
|
728
|
+
@}
|
729
|
+
|
730
|
+
return 0;
|
731
|
+
@}
|
732
|
+
@end example
|
733
|
+
|
734
|
+
This is an example for defining a custom complex type descriptor
|
735
|
+
for compilers that support them:
|
736
|
+
|
737
|
+
@example
|
738
|
+
/*
|
739
|
+
* This macro can be used to define new complex type descriptors
|
740
|
+
* in a platform independent way.
|
741
|
+
*
|
742
|
+
* name: Name of the new descriptor is ffi_type_complex_<name>.
|
743
|
+
* type: The C base type of the complex type.
|
744
|
+
*/
|
745
|
+
#define FFI_COMPLEX_TYPEDEF(name, type, ffitype) \
|
746
|
+
static ffi_type *ffi_elements_complex_##name [2] = @{ \
|
747
|
+
(ffi_type *)(&ffitype), NULL \
|
748
|
+
@}; \
|
749
|
+
struct struct_align_complex_##name @{ \
|
750
|
+
char c; \
|
751
|
+
_Complex type x; \
|
752
|
+
@}; \
|
753
|
+
ffi_type ffi_type_complex_##name = @{ \
|
754
|
+
sizeof(_Complex type), \
|
755
|
+
offsetof(struct struct_align_complex_##name, x), \
|
756
|
+
FFI_TYPE_COMPLEX, \
|
757
|
+
(ffi_type **)ffi_elements_complex_##name \
|
758
|
+
@}
|
759
|
+
|
760
|
+
/* Define new complex type descriptors using the macro: */
|
761
|
+
/* ffi_type_complex_sint */
|
762
|
+
FFI_COMPLEX_TYPEDEF(sint, int, ffi_type_sint);
|
763
|
+
/* ffi_type_complex_uchar */
|
764
|
+
FFI_COMPLEX_TYPEDEF(uchar, unsigned char, ffi_type_uint8);
|
765
|
+
@end example
|
766
|
+
|
767
|
+
The new type descriptors can then be used like one of the built-in
|
768
|
+
type descriptors in the previous example.
|
409
769
|
|
410
770
|
@node Multiple ABIs
|
411
771
|
@section Multiple ABIs
|
@@ -462,30 +822,47 @@ the closure function:
|
|
462
822
|
|
463
823
|
@findex ffi_prep_closure_loc
|
464
824
|
@defun ffi_status ffi_prep_closure_loc (ffi_closure *@var{closure}, ffi_cif *@var{cif}, void (*@var{fun}) (ffi_cif *@var{cif}, void *@var{ret}, void **@var{args}, void *@var{user_data}), void *@var{user_data}, void *@var{codeloc})
|
465
|
-
Prepare a closure function.
|
825
|
+
Prepare a closure function. The arguments to
|
826
|
+
@code{ffi_prep_closure_loc} are:
|
466
827
|
|
467
|
-
@
|
468
|
-
|
828
|
+
@table @var
|
829
|
+
@item closure
|
830
|
+
The address of a @code{ffi_closure} object; this is the writable
|
831
|
+
address returned by @code{ffi_closure_alloc}.
|
469
832
|
|
470
|
-
@
|
833
|
+
@item cif
|
834
|
+
The @code{ffi_cif} describing the function parameters. Note that this
|
835
|
+
object, and the types to which it refers, must be kept alive until the
|
836
|
+
closure itself is freed.
|
837
|
+
|
838
|
+
@item user_data
|
839
|
+
An arbitrary datum that is passed, uninterpreted, to your closure
|
840
|
+
function.
|
471
841
|
|
472
|
-
@
|
473
|
-
|
842
|
+
@item codeloc
|
843
|
+
The executable address returned by @code{ffi_closure_alloc}.
|
474
844
|
|
475
|
-
@
|
476
|
-
|
845
|
+
@item fun
|
846
|
+
The function which will be called when the closure is invoked. It is
|
847
|
+
called with the arguments:
|
477
848
|
|
478
|
-
@var{fun} is the function which will be called when the closure is
|
479
|
-
invoked. It is called with the arguments:
|
480
849
|
@table @var
|
481
850
|
@item cif
|
482
851
|
The @code{ffi_cif} passed to @code{ffi_prep_closure_loc}.
|
483
852
|
|
484
853
|
@item ret
|
485
854
|
A pointer to the memory used for the function's return value.
|
486
|
-
|
487
|
-
@code{void}
|
488
|
-
|
855
|
+
|
856
|
+
If the function is declared as returning @code{void}, then this value
|
857
|
+
is garbage and should not be used.
|
858
|
+
|
859
|
+
Otherwise, @var{fun} must fill the object to which this points,
|
860
|
+
following the same special promotion behavior as @code{ffi_call}.
|
861
|
+
That is, in most cases, @var{ret} points to an object of exactly the
|
862
|
+
size of the type specified when @var{cif} was constructed. However,
|
863
|
+
integral types narrower than the system register size are widened. In
|
864
|
+
these cases your program may assume that @var{ret} points to an
|
865
|
+
@code{ffi_arg} object.
|
489
866
|
|
490
867
|
@item args
|
491
868
|
A vector of pointers to memory holding the arguments to the function.
|
@@ -494,10 +871,10 @@ A vector of pointers to memory holding the arguments to the function.
|
|
494
871
|
The same @var{user_data} that was passed to
|
495
872
|
@code{ffi_prep_closure_loc}.
|
496
873
|
@end table
|
874
|
+
@end table
|
497
875
|
|
498
876
|
@code{ffi_prep_closure_loc} will return @code{FFI_OK} if everything
|
499
|
-
went ok, and
|
500
|
-
@c FIXME: what?
|
877
|
+
went ok, and one of the other @code{ffi_status} values on error.
|
501
878
|
|
502
879
|
After calling @code{ffi_prep_closure_loc}, you can cast @var{codeloc}
|
503
880
|
to the appropriate pointer-to-function type.
|
@@ -511,28 +888,30 @@ writable and executable addresses.
|
|
511
888
|
@section Closure Example
|
512
889
|
|
513
890
|
A trivial example that creates a new @code{puts} by binding
|
514
|
-
@code{fputs} with @code{
|
891
|
+
@code{fputs} with @code{stdout}.
|
515
892
|
|
516
893
|
@example
|
517
894
|
#include <stdio.h>
|
518
895
|
#include <ffi.h>
|
519
896
|
|
520
897
|
/* Acts like puts with the file given at time of enclosure. */
|
521
|
-
void puts_binding(ffi_cif *cif,
|
522
|
-
|
898
|
+
void puts_binding(ffi_cif *cif, void *ret, void* args[],
|
899
|
+
void *stream)
|
523
900
|
@{
|
524
|
-
*ret = fputs(*(char **)args[0], stream);
|
901
|
+
*(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
|
525
902
|
@}
|
526
903
|
|
904
|
+
typedef int (*puts_t)(char *);
|
905
|
+
|
527
906
|
int main()
|
528
907
|
@{
|
529
908
|
ffi_cif cif;
|
530
909
|
ffi_type *args[1];
|
531
910
|
ffi_closure *closure;
|
532
911
|
|
533
|
-
|
912
|
+
void *bound_puts;
|
534
913
|
int rc;
|
535
|
-
|
914
|
+
|
536
915
|
/* Allocate closure and bound_puts */
|
537
916
|
closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
|
538
917
|
|
@@ -543,13 +922,13 @@ int main()
|
|
543
922
|
|
544
923
|
/* Initialize the cif */
|
545
924
|
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
|
546
|
-
&
|
925
|
+
&ffi_type_sint, args) == FFI_OK)
|
547
926
|
@{
|
548
927
|
/* Initialize the closure, setting stream to stdout */
|
549
|
-
if (ffi_prep_closure_loc(closure, &cif, puts_binding,
|
928
|
+
if (ffi_prep_closure_loc(closure, &cif, puts_binding,
|
550
929
|
stdout, bound_puts) == FFI_OK)
|
551
930
|
@{
|
552
|
-
rc = bound_puts("Hello World!");
|
931
|
+
rc = ((puts_t)bound_puts)("Hello World!");
|
553
932
|
/* rc now holds the result of the call to fputs */
|
554
933
|
@}
|
555
934
|
@}
|
@@ -563,6 +942,28 @@ int main()
|
|
563
942
|
|
564
943
|
@end example
|
565
944
|
|
945
|
+
@node Thread Safety
|
946
|
+
@section Thread Safety
|
947
|
+
|
948
|
+
@code{libffi} is not completely thread-safe. However, many parts are,
|
949
|
+
and if you follow some simple rules, you can use it safely in a
|
950
|
+
multi-threaded program.
|
951
|
+
|
952
|
+
@itemize @bullet
|
953
|
+
@item
|
954
|
+
@code{ffi_prep_cif} may modify the @code{ffi_type} objects passed to
|
955
|
+
it. It is best to ensure that only a single thread prepares a given
|
956
|
+
@code{ffi_cif} at a time.
|
957
|
+
|
958
|
+
@item
|
959
|
+
On some platforms, @code{ffi_prep_cif} may modify the size and
|
960
|
+
alignment of some types, depending on the chosen ABI. On these
|
961
|
+
platforms, if you switch between ABIs, you must ensure that there is
|
962
|
+
only one call to @code{ffi_prep_cif} at a time.
|
963
|
+
|
964
|
+
Currently the only affected platform is PowerPC and the only affected
|
965
|
+
type is @code{long double}.
|
966
|
+
@end itemize
|
566
967
|
|
567
968
|
@node Missing Features
|
568
969
|
@chapter Missing Features
|
@@ -572,25 +973,21 @@ support for these.
|
|
572
973
|
|
573
974
|
@itemize @bullet
|
574
975
|
@item
|
575
|
-
|
576
|
-
some platforms, depending on how the ABI is defined, but it is not
|
577
|
-
reliable.
|
976
|
+
Variadic closures.
|
578
977
|
|
579
978
|
@item
|
580
979
|
There is no support for bit fields in structures.
|
581
980
|
|
582
|
-
@item
|
583
|
-
The closure API is
|
584
|
-
|
585
|
-
@c FIXME: ...
|
586
|
-
|
587
981
|
@item
|
588
982
|
The ``raw'' API is undocumented.
|
589
|
-
@c argument promotion?
|
590
|
-
@c unions?
|
591
983
|
@c anything else?
|
984
|
+
|
985
|
+
@item
|
986
|
+
The Go API is undocumented.
|
592
987
|
@end itemize
|
593
988
|
|
989
|
+
Note that variadic support is very new and tested on a relatively
|
990
|
+
small number of platforms.
|
594
991
|
|
595
992
|
@node Index
|
596
993
|
@unnumbered Index
|