ffi 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.gitmodules +4 -0
- data/.travis.yml +42 -0
- data/.yardopts +5 -0
- data/CHANGELOG.md +131 -0
- data/COPYING +49 -0
- data/Gemfile +15 -0
- data/LICENSE +24 -0
- data/LICENSE.SPECS +22 -0
- data/README.md +115 -0
- data/Rakefile +195 -0
- data/appveyor.yml +27 -0
- data/ext/ffi_c/AbstractMemory.c +1109 -0
- data/ext/ffi_c/AbstractMemory.h +175 -0
- data/ext/ffi_c/ArrayType.c +162 -0
- data/ext/ffi_c/ArrayType.h +59 -0
- data/ext/ffi_c/Buffer.c +365 -0
- data/ext/ffi_c/Call.c +503 -0
- data/ext/ffi_c/Call.h +107 -0
- data/ext/ffi_c/ClosurePool.c +283 -0
- data/ext/ffi_c/ClosurePool.h +57 -0
- data/ext/ffi_c/DynamicLibrary.c +339 -0
- data/ext/ffi_c/DynamicLibrary.h +98 -0
- data/ext/ffi_c/Function.c +917 -0
- data/ext/ffi_c/Function.h +87 -0
- data/ext/ffi_c/FunctionInfo.c +271 -0
- data/ext/ffi_c/LastError.c +229 -0
- data/ext/ffi_c/LastError.h +47 -0
- data/ext/ffi_c/LongDouble.c +63 -0
- data/ext/ffi_c/LongDouble.h +51 -0
- data/ext/ffi_c/MappedType.c +168 -0
- data/ext/ffi_c/MappedType.h +59 -0
- data/ext/ffi_c/MemoryPointer.c +197 -0
- data/ext/ffi_c/MemoryPointer.h +53 -0
- data/ext/ffi_c/MethodHandle.c +358 -0
- data/ext/ffi_c/MethodHandle.h +55 -0
- data/ext/ffi_c/Platform.c +82 -0
- data/ext/ffi_c/Platform.h +45 -0
- data/ext/ffi_c/Pointer.c +508 -0
- data/ext/ffi_c/Pointer.h +63 -0
- data/ext/ffi_c/Struct.c +829 -0
- data/ext/ffi_c/Struct.h +106 -0
- data/ext/ffi_c/StructByValue.c +150 -0
- data/ext/ffi_c/StructByValue.h +55 -0
- data/ext/ffi_c/StructLayout.c +698 -0
- data/ext/ffi_c/Thread.c +137 -0
- data/ext/ffi_c/Thread.h +84 -0
- data/ext/ffi_c/Type.c +379 -0
- data/ext/ffi_c/Type.h +61 -0
- data/ext/ffi_c/Types.c +139 -0
- data/ext/ffi_c/Types.h +89 -0
- data/ext/ffi_c/Variadic.c +298 -0
- data/ext/ffi_c/compat.h +78 -0
- data/ext/ffi_c/extconf.rb +86 -0
- data/ext/ffi_c/ffi.c +93 -0
- data/ext/ffi_c/libffi.bsd.mk +40 -0
- data/ext/ffi_c/libffi.darwin.mk +105 -0
- data/ext/ffi_c/libffi.gnu.mk +32 -0
- data/ext/ffi_c/libffi.mk +18 -0
- data/ext/ffi_c/libffi.vc.mk +26 -0
- data/ext/ffi_c/libffi.vc64.mk +26 -0
- data/ext/ffi_c/libffi/.appveyor.yml +50 -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.yml +34 -0
- data/ext/ffi_c/libffi/.travis/ar-lib +270 -0
- data/ext/ffi_c/libffi/.travis/build.sh +34 -0
- data/ext/ffi_c/libffi/.travis/compile +351 -0
- data/ext/ffi_c/libffi/.travis/install.sh +22 -0
- data/ext/ffi_c/libffi/.travis/moxie-sim.exp +60 -0
- data/ext/ffi_c/libffi/.travis/site.exp +18 -0
- data/ext/ffi_c/libffi/ChangeLog.libffi +584 -0
- data/ext/ffi_c/libffi/ChangeLog.libffi-3.1 +6000 -0
- data/ext/ffi_c/libffi/ChangeLog.libgcj +40 -0
- data/ext/ffi_c/libffi/ChangeLog.v1 +764 -0
- data/ext/ffi_c/libffi/LICENSE +21 -0
- data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +352 -0
- data/ext/ffi_c/libffi/Makefile.am +166 -0
- data/ext/ffi_c/libffi/README.md +461 -0
- data/ext/ffi_c/libffi/acinclude.m4 +479 -0
- data/ext/ffi_c/libffi/autogen.sh +2 -0
- data/ext/ffi_c/libffi/config.guess +1466 -0
- data/ext/ffi_c/libffi/config.sub +1836 -0
- data/ext/ffi_c/libffi/configure.ac +394 -0
- data/ext/ffi_c/libffi/configure.host +289 -0
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +203 -0
- data/ext/ffi_c/libffi/include/Makefile.am +9 -0
- data/ext/ffi_c/libffi/include/ffi.h.in +511 -0
- data/ext/ffi_c/libffi/include/ffi_cfi.h +55 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +149 -0
- data/ext/ffi_c/libffi/libffi.map.in +80 -0
- data/ext/ffi_c/libffi/libffi.pc.in +11 -0
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +1043 -0
- data/ext/ffi_c/libffi/libtool-version +29 -0
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +13 -0
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +71 -0
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +194 -0
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +122 -0
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +74 -0
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +87 -0
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +70 -0
- data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +302 -0
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +263 -0
- data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +89 -0
- data/ext/ffi_c/libffi/m4/ax_require_defined.m4 +37 -0
- data/ext/ffi_c/libffi/man/Makefile.am +8 -0
- data/ext/ffi_c/libffi/man/ffi.3 +41 -0
- data/ext/ffi_c/libffi/man/ffi_call.3 +103 -0
- data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +68 -0
- data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +73 -0
- data/ext/ffi_c/libffi/msvcc.sh +328 -0
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +941 -0
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +81 -0
- data/ext/ffi_c/libffi/src/aarch64/internal.h +67 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +438 -0
- data/ext/ffi_c/libffi/src/alpha/ffi.c +521 -0
- data/ext/ffi_c/libffi/src/alpha/ffitarget.h +57 -0
- data/ext/ffi_c/libffi/src/alpha/internal.h +23 -0
- data/ext/ffi_c/libffi/src/alpha/osf.S +282 -0
- 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 +819 -0
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +82 -0
- data/ext/ffi_c/libffi/src/arm/internal.h +7 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +383 -0
- data/ext/ffi_c/libffi/src/avr32/ffi.c +423 -0
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +55 -0
- data/ext/ffi_c/libffi/src/avr32/sysv.S +208 -0
- 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 +966 -0
- data/ext/ffi_c/libffi/src/cris/ffi.c +386 -0
- data/ext/ffi_c/libffi/src/cris/ffitarget.h +56 -0
- data/ext/ffi_c/libffi/src/cris/sysv.S +215 -0
- data/ext/ffi_c/libffi/src/debug.c +64 -0
- data/ext/ffi_c/libffi/src/dlmalloc.c +5166 -0
- data/ext/ffi_c/libffi/src/frv/eabi.S +128 -0
- data/ext/ffi_c/libffi/src/frv/ffi.c +292 -0
- data/ext/ffi_c/libffi/src/frv/ffitarget.h +62 -0
- data/ext/ffi_c/libffi/src/ia64/ffi.c +604 -0
- data/ext/ffi_c/libffi/src/ia64/ffitarget.h +56 -0
- data/ext/ffi_c/libffi/src/ia64/ia64_flags.h +40 -0
- data/ext/ffi_c/libffi/src/ia64/unix.S +567 -0
- data/ext/ffi_c/libffi/src/java_raw_api.c +374 -0
- data/ext/ffi_c/libffi/src/m32r/ffi.c +232 -0
- data/ext/ffi_c/libffi/src/m32r/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/m32r/sysv.S +121 -0
- data/ext/ffi_c/libffi/src/m68k/ffi.c +362 -0
- data/ext/ffi_c/libffi/src/m68k/ffitarget.h +54 -0
- data/ext/ffi_c/libffi/src/m68k/sysv.S +357 -0
- 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/src/metag/ffitarget.h +53 -0
- 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 +1130 -0
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +244 -0
- data/ext/ffi_c/libffi/src/mips/n32.S +663 -0
- data/ext/ffi_c/libffi/src/mips/o32.S +502 -0
- data/ext/ffi_c/libffi/src/moxie/eabi.S +101 -0
- data/ext/ffi_c/libffi/src/moxie/ffi.c +285 -0
- 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 +719 -0
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +85 -0
- data/ext/ffi_c/libffi/src/pa/hpux32.S +368 -0
- data/ext/ffi_c/libffi/src/pa/linux.S +357 -0
- data/ext/ffi_c/libffi/src/powerpc/aix.S +566 -0
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +694 -0
- data/ext/ffi_c/libffi/src/powerpc/asm.h +125 -0
- data/ext/ffi_c/libffi/src/powerpc/darwin.S +378 -0
- data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +571 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +173 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +1440 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +974 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +94 -0
- data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +923 -0
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +198 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +228 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +488 -0
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +397 -0
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +175 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +261 -0
- data/ext/ffi_c/libffi/src/raw_api.c +267 -0
- 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 +756 -0
- data/ext/ffi_c/libffi/src/s390/ffitarget.h +70 -0
- data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
- data/ext/ffi_c/libffi/src/s390/sysv.S +325 -0
- data/ext/ffi_c/libffi/src/sh/ffi.c +717 -0
- data/ext/ffi_c/libffi/src/sh/ffitarget.h +54 -0
- data/ext/ffi_c/libffi/src/sh/sysv.S +850 -0
- data/ext/ffi_c/libffi/src/sh64/ffi.c +469 -0
- data/ext/ffi_c/libffi/src/sh64/ffitarget.h +58 -0
- data/ext/ffi_c/libffi/src/sh64/sysv.S +539 -0
- data/ext/ffi_c/libffi/src/sparc/ffi.c +468 -0
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +608 -0
- data/ext/ffi_c/libffi/src/sparc/ffitarget.h +81 -0
- data/ext/ffi_c/libffi/src/sparc/internal.h +26 -0
- data/ext/ffi_c/libffi/src/sparc/v8.S +443 -0
- data/ext/ffi_c/libffi/src/sparc/v9.S +440 -0
- 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 +108 -0
- 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 +754 -0
- data/ext/ffi_c/libffi/src/x86/ffi64.c +884 -0
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +147 -0
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +308 -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 +1129 -0
- data/ext/ffi_c/libffi/src/x86/unix64.S +566 -0
- data/ext/ffi_c/libffi/src/x86/win64.S +232 -0
- data/ext/ffi_c/libffi/src/x86/win64_intel.S +237 -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 +117 -0
- data/ext/ffi_c/libffi/testsuite/config/default.exp +1 -0
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +636 -0
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +283 -0
- data/ext/ffi_c/libffi/testsuite/lib/wrapper.exp +45 -0
- 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 +58 -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 +43 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +89 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +81 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +81 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +82 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +89 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +92 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c +95 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/closure_simple.c +55 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +94 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +95 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +96 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +102 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +89 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +93 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +113 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +95 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3float.c +95 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +109 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +98 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +124 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +113 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +117 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +97 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +88 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +93 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +92 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +132 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +115 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +95 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +92 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +93 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +66 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +43 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +105 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_many_mixed_args.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c +55 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +91 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +142 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_struct_va1.c +114 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar_va.c +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +43 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint_va.c +45 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulong_va.c +45 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +47 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +43 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort_va.c +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +26 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +138 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float.c +59 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +60 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +60 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float4.c +62 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +107 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +341 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +59 -0
- 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 +52 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +152 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +161 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +134 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct11.c +121 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +110 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +111 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +111 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +112 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +131 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +111 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +131 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +131 -0
- 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/problem1.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/promotion.c +59 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/pyobjc-tc.c +114 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl1.c +43 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl2.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl.c +35 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl1.c +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl2.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl3.c +42 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +34 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll.c +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +43 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +38 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +38 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +38 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +145 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +148 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +124 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +125 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +44 -0
- 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 +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +60 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +64 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +66 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +64 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +74 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +81 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +68 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/unwindtest.cc +117 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc +54 -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.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.complex/complex.exp +36 -0
- 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/rbffi.h +55 -0
- data/ext/ffi_c/rbffi_endian.h +59 -0
- data/ext/ffi_c/win32/stdbool.h +8 -0
- data/ext/ffi_c/win32/stdint.h +201 -0
- data/ffi.gemspec +43 -0
- data/lib/ffi.rb +20 -0
- data/lib/ffi/autopointer.rb +203 -0
- data/lib/ffi/buffer.rb +4 -0
- data/lib/ffi/callback.rb +4 -0
- data/lib/ffi/data_converter.rb +67 -0
- data/lib/ffi/enum.rb +296 -0
- data/lib/ffi/errno.rb +43 -0
- data/lib/ffi/ffi.rb +45 -0
- data/lib/ffi/io.rb +62 -0
- data/lib/ffi/library.rb +588 -0
- data/lib/ffi/managedstruct.rb +84 -0
- data/lib/ffi/memorypointer.rb +1 -0
- data/lib/ffi/platform.rb +172 -0
- data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/aarch64-freebsd12/types.conf +128 -0
- data/lib/ffi/platform/aarch64-linux/types.conf +104 -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 +104 -0
- data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
- data/lib/ffi/platform/i386-darwin/types.conf +100 -0
- data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
- data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
- data/lib/ffi/platform/i386-gnu/types.conf +107 -0
- data/lib/ffi/platform/i386-linux/types.conf +103 -0
- data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
- data/lib/ffi/platform/i386-openbsd/types.conf +128 -0
- data/lib/ffi/platform/i386-solaris/types.conf +122 -0
- data/lib/ffi/platform/i386-windows/types.conf +105 -0
- data/lib/ffi/platform/ia64-linux/types.conf +104 -0
- data/lib/ffi/platform/mips-linux/types.conf +102 -0
- 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 +102 -0
- 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 +180 -0
- data/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
- data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
- data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
- data/lib/ffi/platform/s390-linux/types.conf +102 -0
- data/lib/ffi/platform/s390x-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-linux/types.conf +102 -0
- data/lib/ffi/platform/sparc-solaris/types.conf +128 -0
- data/lib/ffi/platform/sparc64-linux/types.conf +102 -0
- data/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
- data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +126 -0
- data/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
- data/lib/ffi/platform/x86_64-freebsd12/types.conf +128 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +102 -0
- data/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
- data/lib/ffi/platform/x86_64-openbsd/types.conf +134 -0
- data/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +120 -0
- data/lib/ffi/pointer.rb +160 -0
- data/lib/ffi/struct.rb +311 -0
- data/lib/ffi/struct_by_reference.rb +72 -0
- data/lib/ffi/struct_layout.rb +96 -0
- data/lib/ffi/struct_layout_builder.rb +227 -0
- data/lib/ffi/tools/const_generator.rb +230 -0
- data/lib/ffi/tools/generator.rb +105 -0
- data/lib/ffi/tools/generator_task.rb +32 -0
- data/lib/ffi/tools/struct_generator.rb +194 -0
- data/lib/ffi/tools/types_generator.rb +134 -0
- data/lib/ffi/types.rb +194 -0
- data/lib/ffi/union.rb +43 -0
- data/lib/ffi/variadic.rb +78 -0
- data/lib/ffi/version.rb +3 -0
- data/samples/getlogin.rb +8 -0
- data/samples/getpid.rb +8 -0
- data/samples/gettimeofday.rb +18 -0
- data/samples/hello.rb +7 -0
- data/samples/inotify.rb +60 -0
- data/samples/pty.rb +76 -0
- data/samples/qsort.rb +21 -0
- data/samples/sample_helper.rb +6 -0
- metadata +663 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
* a copy of this software and associated documentation files (the
|
6
|
+
* ``Software''), to deal in the Software without restriction, including
|
7
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
* the following conditions:
|
11
|
+
*
|
12
|
+
* The above copyright notice and this permission notice shall be included
|
13
|
+
* in all copies or substantial portions of the Software.
|
14
|
+
*
|
15
|
+
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
|
24
|
+
/*
|
25
|
+
* vax Foreign Function Interface
|
26
|
+
*/
|
27
|
+
|
28
|
+
#ifndef LIBFFI_TARGET_H
|
29
|
+
#define LIBFFI_TARGET_H
|
30
|
+
|
31
|
+
#ifndef LIBFFI_ASM
|
32
|
+
typedef unsigned long ffi_arg;
|
33
|
+
typedef signed long ffi_sarg;
|
34
|
+
|
35
|
+
typedef enum ffi_abi {
|
36
|
+
FFI_FIRST_ABI = 0,
|
37
|
+
FFI_ELFBSD,
|
38
|
+
FFI_DEFAULT_ABI = FFI_ELFBSD,
|
39
|
+
FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
|
40
|
+
} ffi_abi;
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/* ---- Definitions for closures ----------------------------------------- */
|
44
|
+
|
45
|
+
#define FFI_CLOSURES 1
|
46
|
+
#define FFI_TRAMPOLINE_SIZE 15
|
47
|
+
#define FFI_NATIVE_RAW_API 0
|
48
|
+
|
49
|
+
#endif
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#ifndef ASMNAMES_H
|
2
|
+
#define ASMNAMES_H
|
3
|
+
|
4
|
+
#define C2(X, Y) X ## Y
|
5
|
+
#define C1(X, Y) C2(X, Y)
|
6
|
+
#ifdef __USER_LABEL_PREFIX__
|
7
|
+
# define C(X) C1(__USER_LABEL_PREFIX__, X)
|
8
|
+
#else
|
9
|
+
# define C(X) X
|
10
|
+
#endif
|
11
|
+
|
12
|
+
#ifdef __APPLE__
|
13
|
+
# define L(X) C1(L, X)
|
14
|
+
#else
|
15
|
+
# define L(X) C1(.L, X)
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#if defined(__ELF__) && defined(__PIC__)
|
19
|
+
# define PLT(X) X@PLT
|
20
|
+
#else
|
21
|
+
# define PLT(X) X
|
22
|
+
#endif
|
23
|
+
|
24
|
+
#ifdef __ELF__
|
25
|
+
# define ENDF(X) .type X,@function; .size X, . - X
|
26
|
+
#else
|
27
|
+
# define ENDF(X)
|
28
|
+
#endif
|
29
|
+
|
30
|
+
#endif /* ASMNAMES_H */
|
@@ -0,0 +1,754 @@
|
|
1
|
+
/* -----------------------------------------------------------------------
|
2
|
+
ffi.c - Copyright (c) 2017 Anthony Green
|
3
|
+
Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc.
|
4
|
+
Copyright (c) 2002 Ranjit Mathew
|
5
|
+
Copyright (c) 2002 Bo Thorsen
|
6
|
+
Copyright (c) 2002 Roger Sayle
|
7
|
+
Copyright (C) 2008, 2010 Free Software Foundation, Inc.
|
8
|
+
|
9
|
+
x86 Foreign Function Interface
|
10
|
+
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
12
|
+
a copy of this software and associated documentation files (the
|
13
|
+
``Software''), to deal in the Software without restriction, including
|
14
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
15
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
16
|
+
permit persons to whom the Software is furnished to do so, subject to
|
17
|
+
the following conditions:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be included
|
20
|
+
in all copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
23
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
24
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
25
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
26
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
27
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
29
|
+
DEALINGS IN THE SOFTWARE.
|
30
|
+
----------------------------------------------------------------------- */
|
31
|
+
|
32
|
+
#ifndef __x86_64__
|
33
|
+
#include <ffi.h>
|
34
|
+
#include <ffi_common.h>
|
35
|
+
#include <stdint.h>
|
36
|
+
#include <stdlib.h>
|
37
|
+
#include "internal.h"
|
38
|
+
|
39
|
+
/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
|
40
|
+
all further uses in this file will refer to the 80-bit type. */
|
41
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
42
|
+
# if FFI_TYPE_LONGDOUBLE != 4
|
43
|
+
# error FFI_TYPE_LONGDOUBLE out of date
|
44
|
+
# endif
|
45
|
+
#else
|
46
|
+
# undef FFI_TYPE_LONGDOUBLE
|
47
|
+
# define FFI_TYPE_LONGDOUBLE 4
|
48
|
+
#endif
|
49
|
+
|
50
|
+
#if defined(__GNUC__) && !defined(__declspec)
|
51
|
+
# define __declspec(x) __attribute__((x))
|
52
|
+
#endif
|
53
|
+
|
54
|
+
/* Perform machine dependent cif processing. */
|
55
|
+
ffi_status FFI_HIDDEN
|
56
|
+
ffi_prep_cif_machdep(ffi_cif *cif)
|
57
|
+
{
|
58
|
+
size_t bytes = 0;
|
59
|
+
int i, n, flags, cabi = cif->abi;
|
60
|
+
|
61
|
+
switch (cabi)
|
62
|
+
{
|
63
|
+
case FFI_SYSV:
|
64
|
+
case FFI_STDCALL:
|
65
|
+
case FFI_THISCALL:
|
66
|
+
case FFI_FASTCALL:
|
67
|
+
case FFI_MS_CDECL:
|
68
|
+
case FFI_PASCAL:
|
69
|
+
case FFI_REGISTER:
|
70
|
+
break;
|
71
|
+
default:
|
72
|
+
return FFI_BAD_ABI;
|
73
|
+
}
|
74
|
+
|
75
|
+
switch (cif->rtype->type)
|
76
|
+
{
|
77
|
+
case FFI_TYPE_VOID:
|
78
|
+
flags = X86_RET_VOID;
|
79
|
+
break;
|
80
|
+
case FFI_TYPE_FLOAT:
|
81
|
+
flags = X86_RET_FLOAT;
|
82
|
+
break;
|
83
|
+
case FFI_TYPE_DOUBLE:
|
84
|
+
flags = X86_RET_DOUBLE;
|
85
|
+
break;
|
86
|
+
case FFI_TYPE_LONGDOUBLE:
|
87
|
+
flags = X86_RET_LDOUBLE;
|
88
|
+
break;
|
89
|
+
case FFI_TYPE_UINT8:
|
90
|
+
flags = X86_RET_UINT8;
|
91
|
+
break;
|
92
|
+
case FFI_TYPE_UINT16:
|
93
|
+
flags = X86_RET_UINT16;
|
94
|
+
break;
|
95
|
+
case FFI_TYPE_SINT8:
|
96
|
+
flags = X86_RET_SINT8;
|
97
|
+
break;
|
98
|
+
case FFI_TYPE_SINT16:
|
99
|
+
flags = X86_RET_SINT16;
|
100
|
+
break;
|
101
|
+
case FFI_TYPE_INT:
|
102
|
+
case FFI_TYPE_SINT32:
|
103
|
+
case FFI_TYPE_UINT32:
|
104
|
+
case FFI_TYPE_POINTER:
|
105
|
+
flags = X86_RET_INT32;
|
106
|
+
break;
|
107
|
+
case FFI_TYPE_SINT64:
|
108
|
+
case FFI_TYPE_UINT64:
|
109
|
+
flags = X86_RET_INT64;
|
110
|
+
break;
|
111
|
+
case FFI_TYPE_STRUCT:
|
112
|
+
#ifndef X86
|
113
|
+
/* ??? This should be a different ABI rather than an ifdef. */
|
114
|
+
if (cif->rtype->size == 1)
|
115
|
+
flags = X86_RET_STRUCT_1B;
|
116
|
+
else if (cif->rtype->size == 2)
|
117
|
+
flags = X86_RET_STRUCT_2B;
|
118
|
+
else if (cif->rtype->size == 4)
|
119
|
+
flags = X86_RET_INT32;
|
120
|
+
else if (cif->rtype->size == 8)
|
121
|
+
flags = X86_RET_INT64;
|
122
|
+
else
|
123
|
+
#endif
|
124
|
+
{
|
125
|
+
do_struct:
|
126
|
+
switch (cabi)
|
127
|
+
{
|
128
|
+
case FFI_THISCALL:
|
129
|
+
case FFI_FASTCALL:
|
130
|
+
case FFI_STDCALL:
|
131
|
+
case FFI_MS_CDECL:
|
132
|
+
flags = X86_RET_STRUCTARG;
|
133
|
+
break;
|
134
|
+
default:
|
135
|
+
flags = X86_RET_STRUCTPOP;
|
136
|
+
break;
|
137
|
+
}
|
138
|
+
/* Allocate space for return value pointer. */
|
139
|
+
bytes += FFI_ALIGN (sizeof(void*), FFI_SIZEOF_ARG);
|
140
|
+
}
|
141
|
+
break;
|
142
|
+
case FFI_TYPE_COMPLEX:
|
143
|
+
switch (cif->rtype->elements[0]->type)
|
144
|
+
{
|
145
|
+
case FFI_TYPE_DOUBLE:
|
146
|
+
case FFI_TYPE_LONGDOUBLE:
|
147
|
+
case FFI_TYPE_SINT64:
|
148
|
+
case FFI_TYPE_UINT64:
|
149
|
+
goto do_struct;
|
150
|
+
case FFI_TYPE_FLOAT:
|
151
|
+
case FFI_TYPE_INT:
|
152
|
+
case FFI_TYPE_SINT32:
|
153
|
+
case FFI_TYPE_UINT32:
|
154
|
+
flags = X86_RET_INT64;
|
155
|
+
break;
|
156
|
+
case FFI_TYPE_SINT16:
|
157
|
+
case FFI_TYPE_UINT16:
|
158
|
+
flags = X86_RET_INT32;
|
159
|
+
break;
|
160
|
+
case FFI_TYPE_SINT8:
|
161
|
+
case FFI_TYPE_UINT8:
|
162
|
+
flags = X86_RET_STRUCT_2B;
|
163
|
+
break;
|
164
|
+
default:
|
165
|
+
return FFI_BAD_TYPEDEF;
|
166
|
+
}
|
167
|
+
break;
|
168
|
+
default:
|
169
|
+
return FFI_BAD_TYPEDEF;
|
170
|
+
}
|
171
|
+
cif->flags = flags;
|
172
|
+
|
173
|
+
for (i = 0, n = cif->nargs; i < n; i++)
|
174
|
+
{
|
175
|
+
ffi_type *t = cif->arg_types[i];
|
176
|
+
|
177
|
+
bytes = FFI_ALIGN (bytes, t->alignment);
|
178
|
+
bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG);
|
179
|
+
}
|
180
|
+
cif->bytes = FFI_ALIGN (bytes, FFI_SIZEOF_ARG);
|
181
|
+
|
182
|
+
return FFI_OK;
|
183
|
+
}
|
184
|
+
|
185
|
+
static ffi_arg
|
186
|
+
extend_basic_type(void *arg, int type)
|
187
|
+
{
|
188
|
+
switch (type)
|
189
|
+
{
|
190
|
+
case FFI_TYPE_SINT8:
|
191
|
+
return *(SINT8 *)arg;
|
192
|
+
case FFI_TYPE_UINT8:
|
193
|
+
return *(UINT8 *)arg;
|
194
|
+
case FFI_TYPE_SINT16:
|
195
|
+
return *(SINT16 *)arg;
|
196
|
+
case FFI_TYPE_UINT16:
|
197
|
+
return *(UINT16 *)arg;
|
198
|
+
|
199
|
+
case FFI_TYPE_SINT32:
|
200
|
+
case FFI_TYPE_UINT32:
|
201
|
+
case FFI_TYPE_POINTER:
|
202
|
+
case FFI_TYPE_FLOAT:
|
203
|
+
return *(UINT32 *)arg;
|
204
|
+
|
205
|
+
default:
|
206
|
+
abort();
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
struct call_frame
|
211
|
+
{
|
212
|
+
void *ebp; /* 0 */
|
213
|
+
void *retaddr; /* 4 */
|
214
|
+
void (*fn)(void); /* 8 */
|
215
|
+
int flags; /* 12 */
|
216
|
+
void *rvalue; /* 16 */
|
217
|
+
unsigned regs[3]; /* 20-28 */
|
218
|
+
};
|
219
|
+
|
220
|
+
struct abi_params
|
221
|
+
{
|
222
|
+
int dir; /* parameter growth direction */
|
223
|
+
int static_chain; /* the static chain register used by gcc */
|
224
|
+
int nregs; /* number of register parameters */
|
225
|
+
int regs[3];
|
226
|
+
};
|
227
|
+
|
228
|
+
static const struct abi_params abi_params[FFI_LAST_ABI] = {
|
229
|
+
[FFI_SYSV] = { 1, R_ECX, 0 },
|
230
|
+
[FFI_THISCALL] = { 1, R_EAX, 1, { R_ECX } },
|
231
|
+
[FFI_FASTCALL] = { 1, R_EAX, 2, { R_ECX, R_EDX } },
|
232
|
+
[FFI_STDCALL] = { 1, R_ECX, 0 },
|
233
|
+
[FFI_PASCAL] = { -1, R_ECX, 0 },
|
234
|
+
/* ??? No defined static chain; gcc does not support REGISTER. */
|
235
|
+
[FFI_REGISTER] = { -1, R_ECX, 3, { R_EAX, R_EDX, R_ECX } },
|
236
|
+
[FFI_MS_CDECL] = { 1, R_ECX, 0 }
|
237
|
+
};
|
238
|
+
|
239
|
+
#ifdef HAVE_FASTCALL
|
240
|
+
#ifdef _MSC_VER
|
241
|
+
#define FFI_DECLARE_FASTCALL __fastcall
|
242
|
+
#else
|
243
|
+
#define FFI_DECLARE_FASTCALL __declspec(fastcall)
|
244
|
+
#endif
|
245
|
+
#else
|
246
|
+
#define FFI_DECLARE_FASTCALL
|
247
|
+
#endif
|
248
|
+
|
249
|
+
extern void FFI_DECLARE_FASTCALL ffi_call_i386(struct call_frame *, char *) FFI_HIDDEN;
|
250
|
+
|
251
|
+
static void
|
252
|
+
ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
253
|
+
void **avalue, void *closure)
|
254
|
+
{
|
255
|
+
size_t rsize, bytes;
|
256
|
+
struct call_frame *frame;
|
257
|
+
char *stack, *argp;
|
258
|
+
ffi_type **arg_types;
|
259
|
+
int flags, cabi, i, n, dir, narg_reg;
|
260
|
+
const struct abi_params *pabi;
|
261
|
+
|
262
|
+
flags = cif->flags;
|
263
|
+
cabi = cif->abi;
|
264
|
+
pabi = &abi_params[cabi];
|
265
|
+
dir = pabi->dir;
|
266
|
+
|
267
|
+
rsize = 0;
|
268
|
+
if (rvalue == NULL)
|
269
|
+
{
|
270
|
+
switch (flags)
|
271
|
+
{
|
272
|
+
case X86_RET_FLOAT:
|
273
|
+
case X86_RET_DOUBLE:
|
274
|
+
case X86_RET_LDOUBLE:
|
275
|
+
case X86_RET_STRUCTPOP:
|
276
|
+
case X86_RET_STRUCTARG:
|
277
|
+
/* The float cases need to pop the 387 stack.
|
278
|
+
The struct cases need to pass a valid pointer to the callee. */
|
279
|
+
rsize = cif->rtype->size;
|
280
|
+
break;
|
281
|
+
default:
|
282
|
+
/* We can pretend that the callee returns nothing. */
|
283
|
+
flags = X86_RET_VOID;
|
284
|
+
break;
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
288
|
+
bytes = cif->bytes;
|
289
|
+
stack = alloca(bytes + sizeof(*frame) + rsize);
|
290
|
+
argp = (dir < 0 ? stack + bytes : stack);
|
291
|
+
frame = (struct call_frame *)(stack + bytes);
|
292
|
+
if (rsize)
|
293
|
+
rvalue = frame + 1;
|
294
|
+
|
295
|
+
frame->fn = fn;
|
296
|
+
frame->flags = flags;
|
297
|
+
frame->rvalue = rvalue;
|
298
|
+
frame->regs[pabi->static_chain] = (unsigned)closure;
|
299
|
+
|
300
|
+
narg_reg = 0;
|
301
|
+
switch (flags)
|
302
|
+
{
|
303
|
+
case X86_RET_STRUCTARG:
|
304
|
+
/* The pointer is passed as the first argument. */
|
305
|
+
if (pabi->nregs > 0)
|
306
|
+
{
|
307
|
+
frame->regs[pabi->regs[0]] = (unsigned)rvalue;
|
308
|
+
narg_reg = 1;
|
309
|
+
break;
|
310
|
+
}
|
311
|
+
/* fallthru */
|
312
|
+
case X86_RET_STRUCTPOP:
|
313
|
+
*(void **)argp = rvalue;
|
314
|
+
argp += sizeof(void *);
|
315
|
+
break;
|
316
|
+
}
|
317
|
+
|
318
|
+
arg_types = cif->arg_types;
|
319
|
+
for (i = 0, n = cif->nargs; i < n; i++)
|
320
|
+
{
|
321
|
+
ffi_type *ty = arg_types[i];
|
322
|
+
void *valp = avalue[i];
|
323
|
+
size_t z = ty->size;
|
324
|
+
int t = ty->type;
|
325
|
+
|
326
|
+
if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT)
|
327
|
+
{
|
328
|
+
ffi_arg val = extend_basic_type (valp, t);
|
329
|
+
|
330
|
+
if (t != FFI_TYPE_FLOAT && narg_reg < pabi->nregs)
|
331
|
+
frame->regs[pabi->regs[narg_reg++]] = val;
|
332
|
+
else if (dir < 0)
|
333
|
+
{
|
334
|
+
argp -= 4;
|
335
|
+
*(ffi_arg *)argp = val;
|
336
|
+
}
|
337
|
+
else
|
338
|
+
{
|
339
|
+
*(ffi_arg *)argp = val;
|
340
|
+
argp += 4;
|
341
|
+
}
|
342
|
+
}
|
343
|
+
else
|
344
|
+
{
|
345
|
+
size_t za = FFI_ALIGN (z, FFI_SIZEOF_ARG);
|
346
|
+
size_t align = FFI_SIZEOF_ARG;
|
347
|
+
|
348
|
+
/* Issue 434: For thiscall and fastcall, if the paramter passed
|
349
|
+
as 64-bit integer or struct, all following integer paramters
|
350
|
+
will be passed on stack. */
|
351
|
+
if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
|
352
|
+
&& (t == FFI_TYPE_SINT64
|
353
|
+
|| t == FFI_TYPE_UINT64
|
354
|
+
|| t == FFI_TYPE_STRUCT))
|
355
|
+
narg_reg = 2;
|
356
|
+
|
357
|
+
/* Alignment rules for arguments are quite complex. Vectors and
|
358
|
+
structures with 16 byte alignment get it. Note that long double
|
359
|
+
on Darwin does have 16 byte alignment, and does not get this
|
360
|
+
alignment if passed directly; a structure with a long double
|
361
|
+
inside, however, would get 16 byte alignment. Since libffi does
|
362
|
+
not support vectors, we need non concern ourselves with other
|
363
|
+
cases. */
|
364
|
+
if (t == FFI_TYPE_STRUCT && ty->alignment >= 16)
|
365
|
+
align = 16;
|
366
|
+
|
367
|
+
if (dir < 0)
|
368
|
+
{
|
369
|
+
/* ??? These reverse argument ABIs are probably too old
|
370
|
+
to have cared about alignment. Someone should check. */
|
371
|
+
argp -= za;
|
372
|
+
memcpy (argp, valp, z);
|
373
|
+
}
|
374
|
+
else
|
375
|
+
{
|
376
|
+
argp = (char *)FFI_ALIGN (argp, align);
|
377
|
+
memcpy (argp, valp, z);
|
378
|
+
argp += za;
|
379
|
+
}
|
380
|
+
}
|
381
|
+
}
|
382
|
+
FFI_ASSERT (dir > 0 || argp == stack);
|
383
|
+
|
384
|
+
ffi_call_i386 (frame, stack);
|
385
|
+
}
|
386
|
+
|
387
|
+
void
|
388
|
+
ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
389
|
+
{
|
390
|
+
ffi_call_int (cif, fn, rvalue, avalue, NULL);
|
391
|
+
}
|
392
|
+
|
393
|
+
void
|
394
|
+
ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
395
|
+
void **avalue, void *closure)
|
396
|
+
{
|
397
|
+
ffi_call_int (cif, fn, rvalue, avalue, closure);
|
398
|
+
}
|
399
|
+
|
400
|
+
/** private members **/
|
401
|
+
|
402
|
+
void FFI_HIDDEN ffi_closure_i386(void);
|
403
|
+
void FFI_HIDDEN ffi_closure_STDCALL(void);
|
404
|
+
void FFI_HIDDEN ffi_closure_REGISTER(void);
|
405
|
+
|
406
|
+
struct closure_frame
|
407
|
+
{
|
408
|
+
unsigned rettemp[4]; /* 0 */
|
409
|
+
unsigned regs[3]; /* 16-24 */
|
410
|
+
ffi_cif *cif; /* 28 */
|
411
|
+
void (*fun)(ffi_cif*,void*,void**,void*); /* 32 */
|
412
|
+
void *user_data; /* 36 */
|
413
|
+
};
|
414
|
+
|
415
|
+
int FFI_HIDDEN FFI_DECLARE_FASTCALL
|
416
|
+
ffi_closure_inner (struct closure_frame *frame, char *stack)
|
417
|
+
{
|
418
|
+
ffi_cif *cif = frame->cif;
|
419
|
+
int cabi, i, n, flags, dir, narg_reg;
|
420
|
+
const struct abi_params *pabi;
|
421
|
+
ffi_type **arg_types;
|
422
|
+
char *argp;
|
423
|
+
void *rvalue;
|
424
|
+
void **avalue;
|
425
|
+
|
426
|
+
cabi = cif->abi;
|
427
|
+
flags = cif->flags;
|
428
|
+
narg_reg = 0;
|
429
|
+
rvalue = frame->rettemp;
|
430
|
+
pabi = &abi_params[cabi];
|
431
|
+
dir = pabi->dir;
|
432
|
+
argp = (dir < 0 ? stack + cif->bytes : stack);
|
433
|
+
|
434
|
+
switch (flags)
|
435
|
+
{
|
436
|
+
case X86_RET_STRUCTARG:
|
437
|
+
if (pabi->nregs > 0)
|
438
|
+
{
|
439
|
+
rvalue = (void *)frame->regs[pabi->regs[0]];
|
440
|
+
narg_reg = 1;
|
441
|
+
frame->rettemp[0] = (unsigned)rvalue;
|
442
|
+
break;
|
443
|
+
}
|
444
|
+
/* fallthru */
|
445
|
+
case X86_RET_STRUCTPOP:
|
446
|
+
rvalue = *(void **)argp;
|
447
|
+
argp += sizeof(void *);
|
448
|
+
frame->rettemp[0] = (unsigned)rvalue;
|
449
|
+
break;
|
450
|
+
}
|
451
|
+
|
452
|
+
n = cif->nargs;
|
453
|
+
avalue = alloca(sizeof(void *) * n);
|
454
|
+
|
455
|
+
arg_types = cif->arg_types;
|
456
|
+
for (i = 0; i < n; ++i)
|
457
|
+
{
|
458
|
+
ffi_type *ty = arg_types[i];
|
459
|
+
size_t z = ty->size;
|
460
|
+
int t = ty->type;
|
461
|
+
void *valp;
|
462
|
+
|
463
|
+
if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT)
|
464
|
+
{
|
465
|
+
if (t != FFI_TYPE_FLOAT && narg_reg < pabi->nregs)
|
466
|
+
valp = &frame->regs[pabi->regs[narg_reg++]];
|
467
|
+
else if (dir < 0)
|
468
|
+
{
|
469
|
+
argp -= 4;
|
470
|
+
valp = argp;
|
471
|
+
}
|
472
|
+
else
|
473
|
+
{
|
474
|
+
valp = argp;
|
475
|
+
argp += 4;
|
476
|
+
}
|
477
|
+
}
|
478
|
+
else
|
479
|
+
{
|
480
|
+
size_t za = FFI_ALIGN (z, FFI_SIZEOF_ARG);
|
481
|
+
size_t align = FFI_SIZEOF_ARG;
|
482
|
+
|
483
|
+
/* See the comment in ffi_call_int. */
|
484
|
+
if (t == FFI_TYPE_STRUCT && ty->alignment >= 16)
|
485
|
+
align = 16;
|
486
|
+
|
487
|
+
/* Issue 434: For thiscall and fastcall, if the paramter passed
|
488
|
+
as 64-bit integer or struct, all following integer paramters
|
489
|
+
will be passed on stack. */
|
490
|
+
if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
|
491
|
+
&& (t == FFI_TYPE_SINT64
|
492
|
+
|| t == FFI_TYPE_UINT64
|
493
|
+
|| t == FFI_TYPE_STRUCT))
|
494
|
+
narg_reg = 2;
|
495
|
+
|
496
|
+
if (dir < 0)
|
497
|
+
{
|
498
|
+
/* ??? These reverse argument ABIs are probably too old
|
499
|
+
to have cared about alignment. Someone should check. */
|
500
|
+
argp -= za;
|
501
|
+
valp = argp;
|
502
|
+
}
|
503
|
+
else
|
504
|
+
{
|
505
|
+
argp = (char *)FFI_ALIGN (argp, align);
|
506
|
+
valp = argp;
|
507
|
+
argp += za;
|
508
|
+
}
|
509
|
+
}
|
510
|
+
|
511
|
+
avalue[i] = valp;
|
512
|
+
}
|
513
|
+
|
514
|
+
frame->fun (cif, rvalue, avalue, frame->user_data);
|
515
|
+
|
516
|
+
if (cabi == FFI_STDCALL)
|
517
|
+
return flags + (cif->bytes << X86_RET_POP_SHIFT);
|
518
|
+
else
|
519
|
+
return flags;
|
520
|
+
}
|
521
|
+
|
522
|
+
ffi_status
|
523
|
+
ffi_prep_closure_loc (ffi_closure* closure,
|
524
|
+
ffi_cif* cif,
|
525
|
+
void (*fun)(ffi_cif*,void*,void**,void*),
|
526
|
+
void *user_data,
|
527
|
+
void *codeloc)
|
528
|
+
{
|
529
|
+
char *tramp = closure->tramp;
|
530
|
+
void (*dest)(void);
|
531
|
+
int op = 0xb8; /* movl imm, %eax */
|
532
|
+
|
533
|
+
switch (cif->abi)
|
534
|
+
{
|
535
|
+
case FFI_SYSV:
|
536
|
+
case FFI_THISCALL:
|
537
|
+
case FFI_FASTCALL:
|
538
|
+
case FFI_MS_CDECL:
|
539
|
+
dest = ffi_closure_i386;
|
540
|
+
break;
|
541
|
+
case FFI_STDCALL:
|
542
|
+
case FFI_PASCAL:
|
543
|
+
dest = ffi_closure_STDCALL;
|
544
|
+
break;
|
545
|
+
case FFI_REGISTER:
|
546
|
+
dest = ffi_closure_REGISTER;
|
547
|
+
op = 0x68; /* pushl imm */
|
548
|
+
break;
|
549
|
+
default:
|
550
|
+
return FFI_BAD_ABI;
|
551
|
+
}
|
552
|
+
|
553
|
+
/* movl or pushl immediate. */
|
554
|
+
tramp[0] = op;
|
555
|
+
*(void **)(tramp + 1) = codeloc;
|
556
|
+
|
557
|
+
/* jmp dest */
|
558
|
+
tramp[5] = 0xe9;
|
559
|
+
*(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10);
|
560
|
+
|
561
|
+
closure->cif = cif;
|
562
|
+
closure->fun = fun;
|
563
|
+
closure->user_data = user_data;
|
564
|
+
|
565
|
+
return FFI_OK;
|
566
|
+
}
|
567
|
+
|
568
|
+
void FFI_HIDDEN ffi_go_closure_EAX(void);
|
569
|
+
void FFI_HIDDEN ffi_go_closure_ECX(void);
|
570
|
+
void FFI_HIDDEN ffi_go_closure_STDCALL(void);
|
571
|
+
|
572
|
+
ffi_status
|
573
|
+
ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
|
574
|
+
void (*fun)(ffi_cif*,void*,void**,void*))
|
575
|
+
{
|
576
|
+
void (*dest)(void);
|
577
|
+
|
578
|
+
switch (cif->abi)
|
579
|
+
{
|
580
|
+
case FFI_SYSV:
|
581
|
+
case FFI_MS_CDECL:
|
582
|
+
dest = ffi_go_closure_ECX;
|
583
|
+
break;
|
584
|
+
case FFI_THISCALL:
|
585
|
+
case FFI_FASTCALL:
|
586
|
+
dest = ffi_go_closure_EAX;
|
587
|
+
break;
|
588
|
+
case FFI_STDCALL:
|
589
|
+
case FFI_PASCAL:
|
590
|
+
dest = ffi_go_closure_STDCALL;
|
591
|
+
break;
|
592
|
+
case FFI_REGISTER:
|
593
|
+
default:
|
594
|
+
return FFI_BAD_ABI;
|
595
|
+
}
|
596
|
+
|
597
|
+
closure->tramp = dest;
|
598
|
+
closure->cif = cif;
|
599
|
+
closure->fun = fun;
|
600
|
+
|
601
|
+
return FFI_OK;
|
602
|
+
}
|
603
|
+
|
604
|
+
/* ------- Native raw API support -------------------------------- */
|
605
|
+
|
606
|
+
#if !FFI_NO_RAW_API
|
607
|
+
|
608
|
+
void FFI_HIDDEN ffi_closure_raw_SYSV(void);
|
609
|
+
void FFI_HIDDEN ffi_closure_raw_THISCALL(void);
|
610
|
+
|
611
|
+
ffi_status
|
612
|
+
ffi_prep_raw_closure_loc (ffi_raw_closure *closure,
|
613
|
+
ffi_cif *cif,
|
614
|
+
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
|
615
|
+
void *user_data,
|
616
|
+
void *codeloc)
|
617
|
+
{
|
618
|
+
char *tramp = closure->tramp;
|
619
|
+
void (*dest)(void);
|
620
|
+
int i;
|
621
|
+
|
622
|
+
/* We currently don't support certain kinds of arguments for raw
|
623
|
+
closures. This should be implemented by a separate assembly
|
624
|
+
language routine, since it would require argument processing,
|
625
|
+
something we don't do now for performance. */
|
626
|
+
for (i = cif->nargs-1; i >= 0; i--)
|
627
|
+
switch (cif->arg_types[i]->type)
|
628
|
+
{
|
629
|
+
case FFI_TYPE_STRUCT:
|
630
|
+
case FFI_TYPE_LONGDOUBLE:
|
631
|
+
return FFI_BAD_TYPEDEF;
|
632
|
+
}
|
633
|
+
|
634
|
+
switch (cif->abi)
|
635
|
+
{
|
636
|
+
case FFI_THISCALL:
|
637
|
+
dest = ffi_closure_raw_THISCALL;
|
638
|
+
break;
|
639
|
+
case FFI_SYSV:
|
640
|
+
dest = ffi_closure_raw_SYSV;
|
641
|
+
break;
|
642
|
+
default:
|
643
|
+
return FFI_BAD_ABI;
|
644
|
+
}
|
645
|
+
|
646
|
+
/* movl imm, %eax. */
|
647
|
+
tramp[0] = 0xb8;
|
648
|
+
*(void **)(tramp + 1) = codeloc;
|
649
|
+
|
650
|
+
/* jmp dest */
|
651
|
+
tramp[5] = 0xe9;
|
652
|
+
*(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10);
|
653
|
+
|
654
|
+
closure->cif = cif;
|
655
|
+
closure->fun = fun;
|
656
|
+
closure->user_data = user_data;
|
657
|
+
|
658
|
+
return FFI_OK;
|
659
|
+
}
|
660
|
+
|
661
|
+
void
|
662
|
+
ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
|
663
|
+
{
|
664
|
+
size_t rsize, bytes;
|
665
|
+
struct call_frame *frame;
|
666
|
+
char *stack, *argp;
|
667
|
+
ffi_type **arg_types;
|
668
|
+
int flags, cabi, i, n, narg_reg;
|
669
|
+
const struct abi_params *pabi;
|
670
|
+
|
671
|
+
flags = cif->flags;
|
672
|
+
cabi = cif->abi;
|
673
|
+
pabi = &abi_params[cabi];
|
674
|
+
|
675
|
+
rsize = 0;
|
676
|
+
if (rvalue == NULL)
|
677
|
+
{
|
678
|
+
switch (flags)
|
679
|
+
{
|
680
|
+
case X86_RET_FLOAT:
|
681
|
+
case X86_RET_DOUBLE:
|
682
|
+
case X86_RET_LDOUBLE:
|
683
|
+
case X86_RET_STRUCTPOP:
|
684
|
+
case X86_RET_STRUCTARG:
|
685
|
+
/* The float cases need to pop the 387 stack.
|
686
|
+
The struct cases need to pass a valid pointer to the callee. */
|
687
|
+
rsize = cif->rtype->size;
|
688
|
+
break;
|
689
|
+
default:
|
690
|
+
/* We can pretend that the callee returns nothing. */
|
691
|
+
flags = X86_RET_VOID;
|
692
|
+
break;
|
693
|
+
}
|
694
|
+
}
|
695
|
+
|
696
|
+
bytes = cif->bytes;
|
697
|
+
argp = stack =
|
698
|
+
(void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16);
|
699
|
+
frame = (struct call_frame *)(stack + bytes);
|
700
|
+
if (rsize)
|
701
|
+
rvalue = frame + 1;
|
702
|
+
|
703
|
+
frame->fn = fn;
|
704
|
+
frame->flags = flags;
|
705
|
+
frame->rvalue = rvalue;
|
706
|
+
|
707
|
+
narg_reg = 0;
|
708
|
+
switch (flags)
|
709
|
+
{
|
710
|
+
case X86_RET_STRUCTARG:
|
711
|
+
/* The pointer is passed as the first argument. */
|
712
|
+
if (pabi->nregs > 0)
|
713
|
+
{
|
714
|
+
frame->regs[pabi->regs[0]] = (unsigned)rvalue;
|
715
|
+
narg_reg = 1;
|
716
|
+
break;
|
717
|
+
}
|
718
|
+
/* fallthru */
|
719
|
+
case X86_RET_STRUCTPOP:
|
720
|
+
*(void **)argp = rvalue;
|
721
|
+
argp += sizeof(void *);
|
722
|
+
bytes -= sizeof(void *);
|
723
|
+
break;
|
724
|
+
}
|
725
|
+
|
726
|
+
arg_types = cif->arg_types;
|
727
|
+
for (i = 0, n = cif->nargs; narg_reg < pabi->nregs && i < n; i++)
|
728
|
+
{
|
729
|
+
ffi_type *ty = arg_types[i];
|
730
|
+
size_t z = ty->size;
|
731
|
+
int t = ty->type;
|
732
|
+
|
733
|
+
if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT && t != FFI_TYPE_FLOAT)
|
734
|
+
{
|
735
|
+
ffi_arg val = extend_basic_type (avalue, t);
|
736
|
+
frame->regs[pabi->regs[narg_reg++]] = val;
|
737
|
+
z = FFI_SIZEOF_ARG;
|
738
|
+
}
|
739
|
+
else
|
740
|
+
{
|
741
|
+
memcpy (argp, avalue, z);
|
742
|
+
z = FFI_ALIGN (z, FFI_SIZEOF_ARG);
|
743
|
+
argp += z;
|
744
|
+
}
|
745
|
+
avalue += z;
|
746
|
+
bytes -= z;
|
747
|
+
}
|
748
|
+
if (i < n)
|
749
|
+
memcpy (argp, avalue, bytes);
|
750
|
+
|
751
|
+
ffi_call_i386 (frame, stack);
|
752
|
+
}
|
753
|
+
#endif /* !FFI_NO_RAW_API */
|
754
|
+
#endif /* !__x86_64__ */
|