ffi 1.15.5 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +118 -0
- data/Gemfile +10 -3
- data/README.md +4 -3
- data/Rakefile +25 -10
- data/ext/ffi_c/AbstractMemory.c +99 -74
- data/ext/ffi_c/AbstractMemory.h +3 -2
- data/ext/ffi_c/ArrayType.c +51 -15
- data/ext/ffi_c/ArrayType.h +1 -0
- data/ext/ffi_c/Buffer.c +90 -33
- data/ext/ffi_c/Call.c +29 -12
- data/ext/ffi_c/Call.h +3 -2
- data/ext/ffi_c/DynamicLibrary.c +90 -27
- data/ext/ffi_c/Function.c +244 -98
- data/ext/ffi_c/Function.h +1 -0
- data/ext/ffi_c/FunctionInfo.c +81 -25
- data/ext/ffi_c/LastError.c +29 -11
- data/ext/ffi_c/MappedType.c +66 -23
- data/ext/ffi_c/MappedType.h +0 -2
- data/ext/ffi_c/MemoryPointer.c +36 -9
- data/ext/ffi_c/MethodHandle.c +3 -1
- data/ext/ffi_c/Pointer.c +82 -40
- data/ext/ffi_c/Pointer.h +1 -0
- data/ext/ffi_c/Struct.c +166 -84
- data/ext/ffi_c/Struct.h +7 -4
- data/ext/ffi_c/StructByValue.c +48 -16
- data/ext/ffi_c/StructLayout.c +130 -61
- data/ext/ffi_c/Type.c +120 -51
- data/ext/ffi_c/Type.h +3 -1
- data/ext/ffi_c/Types.c +8 -2
- data/ext/ffi_c/Types.h +0 -1
- data/ext/ffi_c/Variadic.c +71 -26
- data/ext/ffi_c/compat.h +22 -22
- data/ext/ffi_c/extconf.rb +19 -2
- data/ext/ffi_c/ffi.c +4 -0
- data/ext/ffi_c/libffi/.allow-ai-service +0 -0
- data/ext/ffi_c/libffi/.appveyor/site.exp +16 -0
- data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +7 -0
- data/ext/ffi_c/libffi/.appveyor.yml +27 -9
- data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/build-in-container.sh +4 -6
- data/ext/ffi_c/libffi/.ci/build.sh +124 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/install.sh +14 -7
- data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
- data/ext/ffi_c/libffi/{.travis → .ci}/site.exp +5 -3
- data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
- data/ext/ffi_c/libffi/.github/workflows/build.yml +479 -0
- data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +172 -0
- data/ext/ffi_c/libffi/.gitignore +10 -2
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +12 -5
- data/ext/ffi_c/libffi/Makefile.in +118 -51
- data/ext/ffi_c/libffi/README.md +150 -105
- data/ext/ffi_c/libffi/acinclude.m4 +10 -112
- data/ext/ffi_c/libffi/compile +348 -0
- data/ext/ffi_c/libffi/config.guess +623 -556
- data/ext/ffi_c/libffi/config.sub +75 -34
- data/ext/ffi_c/libffi/configure +4571 -3830
- data/ext/ffi_c/libffi/configure.ac +64 -28
- data/ext/ffi_c/libffi/configure.host +26 -7
- data/ext/ffi_c/libffi/doc/Makefile.in +9 -6
- data/ext/ffi_c/libffi/doc/libffi.texi +82 -33
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +12 -47
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +163 -52
- data/ext/ffi_c/libffi/include/Makefile.am +1 -1
- data/ext/ffi_c/libffi/include/Makefile.in +10 -9
- data/ext/ffi_c/libffi/include/ffi.h.in +55 -60
- data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +33 -2
- data/ext/ffi_c/libffi/include/tramp.h +45 -0
- data/ext/ffi_c/libffi/install-sh +92 -69
- data/ext/ffi_c/libffi/libffi.map.in +5 -0
- data/ext/ffi_c/libffi/libtool-version +2 -2
- data/ext/ffi_c/libffi/ltmain.sh +518 -333
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +18 -14
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -45
- data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
- data/ext/ffi_c/libffi/man/Makefile.in +9 -6
- data/ext/ffi_c/libffi/missing +1 -1
- data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +2 -2
- data/ext/ffi_c/libffi/msvcc.sh +1 -1
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +172 -55
- data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +331 -87
- data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
- data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
- data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +62 -17
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +3 -3
- data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +113 -42
- data/ext/ffi_c/libffi/src/closures.c +136 -50
- data/ext/ffi_c/libffi/src/debug.c +2 -2
- data/ext/ffi_c/libffi/src/dlmalloc.c +6 -1
- data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
- data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
- data/ext/ffi_c/libffi/src/loongarch64/ffi.c +624 -0
- data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
- data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
- data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
- data/ext/ffi_c/libffi/src/mips/ffi.c +250 -67
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
- data/ext/ffi_c/libffi/src/mips/n32.S +193 -33
- data/ext/ffi_c/libffi/src/mips/o32.S +61 -4
- data/ext/ffi_c/libffi/src/moxie/ffi.c +47 -22
- data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
- data/ext/ffi_c/libffi/src/pa/ffi.c +32 -33
- data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +22 -8
- data/ext/ffi_c/libffi/src/pa/hpux32.S +83 -36
- data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
- data/ext/ffi_c/libffi/src/pa/linux.S +82 -35
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +36 -24
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1 -1
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +2 -0
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +2 -0
- data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
- data/ext/ffi_c/libffi/src/prep_cif.c +22 -2
- data/ext/ffi_c/libffi/src/riscv/ffi.c +37 -4
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +23 -1
- data/ext/ffi_c/libffi/src/tramp.c +716 -0
- data/ext/ffi_c/libffi/src/types.c +4 -6
- data/ext/ffi_c/libffi/src/wasm32/ffi.c +947 -0
- data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
- data/ext/ffi_c/libffi/src/x86/ffi.c +99 -37
- data/ext/ffi_c/libffi/src/x86/ffi64.c +67 -12
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +9 -5
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +44 -1
- data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
- data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
- data/ext/ffi_c/libffi/src/x86/sysv.S +172 -38
- data/ext/ffi_c/libffi/src/x86/sysv_intel.S +91 -88
- data/ext/ffi_c/libffi/src/x86/unix64.S +96 -6
- data/ext/ffi_c/libffi/src/x86/win64.S +20 -7
- data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
- data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
- data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
- data/ext/ffi_c/libffi/testsuite/Makefile.am +79 -114
- data/ext/ffi_c/libffi/testsuite/Makefile.in +89 -121
- data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +86 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
- data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +43 -21
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +99 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +108 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +114 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +119 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn0.c +3 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +21 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +7 -6
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +6 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +18 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +22 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +24 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +29 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +21 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +35 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +19 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +18 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +22 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +13 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +29 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +24 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +28 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +24 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +39 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +25 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +14 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +14 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +14 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +20 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +40 -25
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +40 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +18 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +18 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +19 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +3 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +11 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +22 -3
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +5 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +6 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +6 -2
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +9 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +5 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +4 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +2 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +3 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -138
- data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +21 -21
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +32 -9
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +12 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +21 -5
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct2.c +10 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +10 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +9 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct9.c +11 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +6 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +1 -0
- data/ext/ffi_c/libffi.bsd.mk +2 -2
- data/ext/ffi_c/libffi.darwin.mk +2 -2
- data/ext/ffi_c/libffi.gnu.mk +2 -2
- data/ext/ffi_c/rbffi.h +1 -1
- data/ffi.gemspec +3 -3
- data/lib/ffi/autopointer.rb +8 -31
- data/lib/ffi/compat.rb +43 -0
- data/lib/ffi/data_converter.rb +2 -2
- data/lib/ffi/dynamic_library.rb +118 -0
- data/lib/ffi/enum.rb +18 -12
- data/lib/ffi/ffi.rb +3 -0
- data/lib/ffi/function.rb +71 -0
- data/lib/ffi/io.rb +2 -2
- data/lib/ffi/library.rb +72 -88
- data/lib/ffi/library_path.rb +109 -0
- data/lib/ffi/managedstruct.rb +1 -1
- data/lib/ffi/platform/aarch64-linux/types.conf +74 -3
- data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
- data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
- data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
- data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
- data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
- data/lib/ffi/platform.rb +15 -13
- data/lib/ffi/pointer.rb +6 -6
- data/lib/ffi/struct.rb +6 -5
- data/lib/ffi/struct_layout.rb +3 -3
- data/lib/ffi/struct_layout_builder.rb +9 -9
- data/lib/ffi/types.rb +65 -37
- data/lib/ffi/variadic.rb +19 -8
- data/lib/ffi/version.rb +1 -1
- data/samples/hello_ractor.rb +11 -0
- data/samples/qsort_ractor.rb +28 -0
- data/sig/ffi/abstract_memory.rbs +165 -0
- data/sig/ffi/auto_pointer.rbs +27 -0
- data/sig/ffi/buffer.rbs +18 -0
- data/sig/ffi/data_converter.rbs +10 -0
- data/sig/ffi/dynamic_library.rbs +9 -0
- data/sig/ffi/enum.rbs +38 -0
- data/sig/ffi/function.rbs +39 -0
- data/sig/ffi/library.rbs +42 -0
- data/sig/ffi/native_type.rbs +86 -0
- data/sig/ffi/pointer.rbs +42 -0
- data/sig/ffi/struct.rbs +76 -0
- data/sig/ffi/struct_by_reference.rbs +11 -0
- data/sig/ffi/struct_by_value.rbs +7 -0
- data/sig/ffi/struct_layout.rbs +9 -0
- data/sig/ffi/struct_layout_builder.rbs +5 -0
- data/sig/ffi/type.rbs +39 -0
- data/sig/ffi.rbs +26 -0
- data.tar.gz.sig +0 -0
- metadata +122 -28
- metadata.gz.sig +1 -0
- data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
- data/ext/ffi_c/libffi/.travis/build.sh +0 -142
- data/ext/ffi_c/libffi/.travis.yml +0 -83
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
- /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
- /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
- /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
- /data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +0 -0
@@ -1,9 +1,9 @@
|
|
1
1
|
/* -----------------------------------------------------------------------
|
2
|
-
sysv.S - Copyright (c) 2017 Anthony Green
|
2
|
+
sysv.S - Copyright (c) 2017, 2022 Anthony Green
|
3
3
|
- Copyright (c) 2013 The Written Word, Inc.
|
4
4
|
- Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc.
|
5
|
-
|
6
|
-
X86 Foreign Function Interface
|
5
|
+
|
6
|
+
X86 Foreign Function Interface
|
7
7
|
|
8
8
|
Permission is hereby granted, free of charge, to any person obtaining
|
9
9
|
a copy of this software and associated documentation files (the
|
@@ -29,11 +29,11 @@
|
|
29
29
|
#ifndef __x86_64__
|
30
30
|
#ifdef _MSC_VER
|
31
31
|
|
32
|
-
#define LIBFFI_ASM
|
32
|
+
#define LIBFFI_ASM
|
33
33
|
#include <fficonfig.h>
|
34
34
|
#include <ffi.h>
|
35
35
|
#include <ffi_cfi.h>
|
36
|
-
#include "internal.h"
|
36
|
+
#include "internal.h"
|
37
37
|
|
38
38
|
#define C2(X, Y) X ## Y
|
39
39
|
#define C1(X, Y) C2(X, Y)
|
@@ -89,8 +89,8 @@ L(UW0):
|
|
89
89
|
perspective of the unwind info, it hasn't moved. */
|
90
90
|
mov ebp, ecx
|
91
91
|
L(UW1):
|
92
|
-
|
93
|
-
|
92
|
+
/* cfi_def_cfa(%ebp, 8) */
|
93
|
+
/* cfi_rel_offset(%ebp, 0) */
|
94
94
|
|
95
95
|
mov esp, edx /* set outgoing argument stack */
|
96
96
|
mov eax, [20+R_EAX*4+ebp] /* set register arguments */
|
@@ -102,7 +102,7 @@ L(UW1):
|
|
102
102
|
mov ecx, [12+ebp] /* load return type code */
|
103
103
|
mov [ebp+8], ebx /* preserve %ebx */
|
104
104
|
L(UW2):
|
105
|
-
|
105
|
+
/* cfi_rel_offset(%ebx, 8) */
|
106
106
|
|
107
107
|
and ecx, X86_RET_TYPE_MASK
|
108
108
|
lea ebx, [L(store_table) + ecx * 8]
|
@@ -148,13 +148,13 @@ L(e1):
|
|
148
148
|
mov esp, ebp
|
149
149
|
pop ebp
|
150
150
|
L(UW3):
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
151
|
+
/* cfi_remember_state */
|
152
|
+
/* cfi_def_cfa(%esp, 4) */
|
153
|
+
/* cfi_restore(%ebx) */
|
154
|
+
/* cfi_restore(%ebp) */
|
155
155
|
ret
|
156
156
|
L(UW4):
|
157
|
-
|
157
|
+
/* cfi_restore_state */
|
158
158
|
|
159
159
|
E(L(store_table), X86_RET_STRUCTPOP)
|
160
160
|
jmp L(e1)
|
@@ -174,7 +174,7 @@ E(L(store_table), X86_RET_UNUSED15)
|
|
174
174
|
int 3
|
175
175
|
|
176
176
|
L(UW5):
|
177
|
-
|
177
|
+
/* cfi_endproc */
|
178
178
|
ENDF(@ffi_call_i386@8)
|
179
179
|
|
180
180
|
/* The inner helper is declared as
|
@@ -242,10 +242,10 @@ ALIGN 16
|
|
242
242
|
PUBLIC ffi_go_closure_EAX
|
243
243
|
ffi_go_closure_EAX PROC C
|
244
244
|
L(UW6):
|
245
|
-
|
245
|
+
/* cfi_startproc */
|
246
246
|
sub esp, closure_FS
|
247
247
|
L(UW7):
|
248
|
-
|
248
|
+
/* cfi_def_cfa_offset(closure_FS + 4) */
|
249
249
|
FFI_CLOSURE_SAVE_REGS
|
250
250
|
mov edx, [eax+4] /* copy cif */
|
251
251
|
mov ecx, [eax +8] /* copy fun */
|
@@ -254,17 +254,17 @@ L(UW7):
|
|
254
254
|
mov [esp+closure_CF+36], eax /* closure is user_data */
|
255
255
|
jmp L(do_closure_i386)
|
256
256
|
L(UW8):
|
257
|
-
|
257
|
+
/* cfi_endproc */
|
258
258
|
ENDF(ffi_go_closure_EAX)
|
259
259
|
|
260
260
|
ALIGN 16
|
261
261
|
PUBLIC ffi_go_closure_ECX
|
262
262
|
ffi_go_closure_ECX PROC C
|
263
263
|
L(UW9):
|
264
|
-
|
264
|
+
/* cfi_startproc */
|
265
265
|
sub esp, closure_FS
|
266
266
|
L(UW10):
|
267
|
-
|
267
|
+
/* cfi_def_cfa_offset(closure_FS + 4) */
|
268
268
|
FFI_CLOSURE_SAVE_REGS
|
269
269
|
mov edx, [ecx+4] /* copy cif */
|
270
270
|
mov eax, [ecx+8] /* copy fun */
|
@@ -273,7 +273,7 @@ L(UW10):
|
|
273
273
|
mov [esp+closure_CF+36], ecx /* closure is user_data */
|
274
274
|
jmp L(do_closure_i386)
|
275
275
|
L(UW11):
|
276
|
-
|
276
|
+
/* cfi_endproc */
|
277
277
|
ENDF(ffi_go_closure_ECX)
|
278
278
|
|
279
279
|
/* The closure entry points are reached from the ffi_closure trampoline.
|
@@ -283,10 +283,10 @@ ALIGN 16
|
|
283
283
|
PUBLIC ffi_closure_i386
|
284
284
|
ffi_closure_i386 PROC C
|
285
285
|
L(UW12):
|
286
|
-
|
286
|
+
/* cfi_startproc */
|
287
287
|
sub esp, closure_FS
|
288
288
|
L(UW13):
|
289
|
-
|
289
|
+
/* cfi_def_cfa_offset(closure_FS + 4) */
|
290
290
|
|
291
291
|
FFI_CLOSURE_SAVE_REGS
|
292
292
|
FFI_CLOSURE_COPY_TRAMP_DATA
|
@@ -331,17 +331,17 @@ E(L(load_table2), X86_RET_VOID)
|
|
331
331
|
L(e2):
|
332
332
|
add esp, closure_FS
|
333
333
|
L(UW16):
|
334
|
-
|
334
|
+
/* cfi_adjust_cfa_offset(-closure_FS) */
|
335
335
|
ret
|
336
336
|
L(UW17):
|
337
|
-
|
337
|
+
/* cfi_adjust_cfa_offset(closure_FS) */
|
338
338
|
E(L(load_table2), X86_RET_STRUCTPOP)
|
339
339
|
add esp, closure_FS
|
340
340
|
L(UW18):
|
341
|
-
|
341
|
+
/* cfi_adjust_cfa_offset(-closure_FS) */
|
342
342
|
ret 4
|
343
343
|
L(UW19):
|
344
|
-
|
344
|
+
/* cfi_adjust_cfa_offset(closure_FS) */
|
345
345
|
E(L(load_table2), X86_RET_STRUCTARG)
|
346
346
|
jmp L(e2)
|
347
347
|
E(L(load_table2), X86_RET_STRUCT_1B)
|
@@ -358,17 +358,17 @@ E(L(load_table2), X86_RET_UNUSED15)
|
|
358
358
|
int 3
|
359
359
|
|
360
360
|
L(UW20):
|
361
|
-
|
361
|
+
/* cfi_endproc */
|
362
362
|
ENDF(ffi_closure_i386)
|
363
363
|
|
364
364
|
ALIGN 16
|
365
365
|
PUBLIC ffi_go_closure_STDCALL
|
366
366
|
ffi_go_closure_STDCALL PROC C
|
367
367
|
L(UW21):
|
368
|
-
|
368
|
+
/* cfi_startproc */
|
369
369
|
sub esp, closure_FS
|
370
370
|
L(UW22):
|
371
|
-
|
371
|
+
/* cfi_def_cfa_offset(closure_FS + 4) */
|
372
372
|
FFI_CLOSURE_SAVE_REGS
|
373
373
|
mov edx, [ecx+4] /* copy cif */
|
374
374
|
mov eax, [ecx+8] /* copy fun */
|
@@ -377,7 +377,7 @@ L(UW22):
|
|
377
377
|
mov [esp+closure_CF+36], ecx /* closure is user_data */
|
378
378
|
jmp L(do_closure_STDCALL)
|
379
379
|
L(UW23):
|
380
|
-
|
380
|
+
/* cfi_endproc */
|
381
381
|
ENDF(ffi_go_closure_STDCALL)
|
382
382
|
|
383
383
|
/* For REGISTER, we have no available parameter registers, and so we
|
@@ -387,19 +387,19 @@ ALIGN 16
|
|
387
387
|
PUBLIC ffi_closure_REGISTER
|
388
388
|
ffi_closure_REGISTER PROC C
|
389
389
|
L(UW24):
|
390
|
-
|
391
|
-
|
392
|
-
|
390
|
+
/* cfi_startproc */
|
391
|
+
/* cfi_def_cfa(%esp, 8) */
|
392
|
+
/* cfi_offset(%eip, -8) */
|
393
393
|
sub esp, closure_FS-4
|
394
394
|
L(UW25):
|
395
|
-
|
395
|
+
/* cfi_def_cfa_offset(closure_FS + 4) */
|
396
396
|
FFI_CLOSURE_SAVE_REGS
|
397
397
|
mov ecx, [esp+closure_FS-4] /* load retaddr */
|
398
398
|
mov eax, [esp+closure_FS] /* load closure */
|
399
399
|
mov [esp+closure_FS], ecx /* move retaddr */
|
400
400
|
jmp L(do_closure_REGISTER)
|
401
401
|
L(UW26):
|
402
|
-
|
402
|
+
/* cfi_endproc */
|
403
403
|
ENDF(ffi_closure_REGISTER)
|
404
404
|
|
405
405
|
/* For STDCALL (and others), we need to pop N bytes of arguments off
|
@@ -410,10 +410,10 @@ ALIGN 16
|
|
410
410
|
PUBLIC ffi_closure_STDCALL
|
411
411
|
ffi_closure_STDCALL PROC C
|
412
412
|
L(UW27):
|
413
|
-
|
413
|
+
/* cfi_startproc */
|
414
414
|
sub esp, closure_FS
|
415
415
|
L(UW28):
|
416
|
-
|
416
|
+
/* cfi_def_cfa_offset(closure_FS + 4) */
|
417
417
|
|
418
418
|
FFI_CLOSURE_SAVE_REGS
|
419
419
|
|
@@ -504,7 +504,7 @@ E(L(load_table3), X86_RET_UNUSED15)
|
|
504
504
|
int 3
|
505
505
|
|
506
506
|
L(UW31):
|
507
|
-
|
507
|
+
/* cfi_endproc */
|
508
508
|
ENDF(ffi_closure_STDCALL)
|
509
509
|
|
510
510
|
#if !FFI_NO_RAW_API
|
@@ -515,13 +515,13 @@ ALIGN 16
|
|
515
515
|
PUBLIC ffi_closure_raw_SYSV
|
516
516
|
ffi_closure_raw_SYSV PROC C
|
517
517
|
L(UW32):
|
518
|
-
|
518
|
+
/* cfi_startproc */
|
519
519
|
sub esp, raw_closure_S_FS
|
520
520
|
L(UW33):
|
521
|
-
|
521
|
+
/* cfi_def_cfa_offset(raw_closure_S_FS + 4) */
|
522
522
|
mov [esp+raw_closure_S_FS-4], ebx
|
523
523
|
L(UW34):
|
524
|
-
|
524
|
+
/* cfi_rel_offset(%ebx, raw_closure_S_FS-4) */
|
525
525
|
|
526
526
|
mov edx, [eax+FFI_TRAMPOLINE_SIZE+8] /* load cl->user_data */
|
527
527
|
mov [esp+12], edx
|
@@ -535,16 +535,16 @@ L(UW34):
|
|
535
535
|
|
536
536
|
mov eax, [ebx+20] /* load cif->flags */
|
537
537
|
and eax, X86_RET_TYPE_MASK
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
538
|
+
/* #ifdef __PIC__ */
|
539
|
+
/* call __x86.get_pc_thunk.bx */
|
540
|
+
/* L(pc4): */
|
541
|
+
/* lea ecx, L(load_table4)-L(pc4)(%ebx, %eax, 8), %ecx */
|
542
|
+
/* #else */
|
543
543
|
lea ecx, [L(load_table4)+eax+8]
|
544
|
-
|
544
|
+
/* #endif */
|
545
545
|
mov ebx, [esp+raw_closure_S_FS-4]
|
546
546
|
L(UW35):
|
547
|
-
|
547
|
+
/* cfi_restore(%ebx) */
|
548
548
|
mov eax, [esp+16] /* Optimistic load */
|
549
549
|
jmp dword ptr [ecx]
|
550
550
|
|
@@ -581,17 +581,17 @@ E(L(load_table4), X86_RET_VOID)
|
|
581
581
|
L(e4):
|
582
582
|
add esp, raw_closure_S_FS
|
583
583
|
L(UW36):
|
584
|
-
|
584
|
+
/* cfi_adjust_cfa_offset(-raw_closure_S_FS) */
|
585
585
|
ret
|
586
586
|
L(UW37):
|
587
|
-
|
587
|
+
/* cfi_adjust_cfa_offset(raw_closure_S_FS) */
|
588
588
|
E(L(load_table4), X86_RET_STRUCTPOP)
|
589
589
|
add esp, raw_closure_S_FS
|
590
590
|
L(UW38):
|
591
|
-
|
591
|
+
/* cfi_adjust_cfa_offset(-raw_closure_S_FS) */
|
592
592
|
ret 4
|
593
593
|
L(UW39):
|
594
|
-
|
594
|
+
/* cfi_adjust_cfa_offset(raw_closure_S_FS) */
|
595
595
|
E(L(load_table4), X86_RET_STRUCTARG)
|
596
596
|
jmp L(e4)
|
597
597
|
E(L(load_table4), X86_RET_STRUCT_1B)
|
@@ -608,7 +608,7 @@ E(L(load_table4), X86_RET_UNUSED15)
|
|
608
608
|
int 3
|
609
609
|
|
610
610
|
L(UW40):
|
611
|
-
|
611
|
+
/* cfi_endproc */
|
612
612
|
ENDF(ffi_closure_raw_SYSV)
|
613
613
|
|
614
614
|
#define raw_closure_T_FS (16+16+8)
|
@@ -617,26 +617,26 @@ ALIGN 16
|
|
617
617
|
PUBLIC ffi_closure_raw_THISCALL
|
618
618
|
ffi_closure_raw_THISCALL PROC C
|
619
619
|
L(UW41):
|
620
|
-
|
620
|
+
/* cfi_startproc */
|
621
621
|
/* Rearrange the stack such that %ecx is the first argument.
|
622
622
|
This means moving the return address. */
|
623
623
|
pop edx
|
624
624
|
L(UW42):
|
625
|
-
|
626
|
-
|
625
|
+
/* cfi_def_cfa_offset(0) */
|
626
|
+
/* cfi_register(%eip, %edx) */
|
627
627
|
push ecx
|
628
628
|
L(UW43):
|
629
|
-
|
629
|
+
/* cfi_adjust_cfa_offset(4) */
|
630
630
|
push edx
|
631
631
|
L(UW44):
|
632
|
-
|
633
|
-
|
632
|
+
/* cfi_adjust_cfa_offset(4) */
|
633
|
+
/* cfi_rel_offset(%eip, 0) */
|
634
634
|
sub esp, raw_closure_T_FS
|
635
635
|
L(UW45):
|
636
|
-
|
636
|
+
/* cfi_adjust_cfa_offset(raw_closure_T_FS) */
|
637
637
|
mov [esp+raw_closure_T_FS-4], ebx
|
638
638
|
L(UW46):
|
639
|
-
|
639
|
+
/* cfi_rel_offset(%ebx, raw_closure_T_FS-4) */
|
640
640
|
|
641
641
|
mov edx, [eax+FFI_TRAMPOLINE_SIZE+8] /* load cl->user_data */
|
642
642
|
mov [esp+12], edx
|
@@ -650,16 +650,16 @@ L(UW46):
|
|
650
650
|
|
651
651
|
mov eax, [ebx+20] /* load cif->flags */
|
652
652
|
and eax, X86_RET_TYPE_MASK
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
653
|
+
/* #ifdef __PIC__ */
|
654
|
+
/* call __x86.get_pc_thunk.bx */
|
655
|
+
/* L(pc5): */
|
656
|
+
/* leal L(load_table5)-L(pc5)(%ebx, %eax, 8), %ecx */
|
657
|
+
/* #else */
|
658
658
|
lea ecx, [L(load_table5)+eax*8]
|
659
|
-
|
659
|
+
/*#endif */
|
660
660
|
mov ebx, [esp+raw_closure_T_FS-4]
|
661
661
|
L(UW47):
|
662
|
-
|
662
|
+
/* cfi_restore(%ebx) */
|
663
663
|
mov eax, [esp+16] /* Optimistic load */
|
664
664
|
jmp DWORD PTR [ecx]
|
665
665
|
|
@@ -696,18 +696,18 @@ E(L(load_table5), X86_RET_VOID)
|
|
696
696
|
L(e5):
|
697
697
|
add esp, raw_closure_T_FS
|
698
698
|
L(UW48):
|
699
|
-
|
699
|
+
/* cfi_adjust_cfa_offset(-raw_closure_T_FS) */
|
700
700
|
/* Remove the extra %ecx argument we pushed. */
|
701
701
|
ret 4
|
702
702
|
L(UW49):
|
703
|
-
|
703
|
+
/* cfi_adjust_cfa_offset(raw_closure_T_FS) */
|
704
704
|
E(L(load_table5), X86_RET_STRUCTPOP)
|
705
705
|
add esp, raw_closure_T_FS
|
706
706
|
L(UW50):
|
707
|
-
|
707
|
+
/* cfi_adjust_cfa_offset(-raw_closure_T_FS) */
|
708
708
|
ret 8
|
709
709
|
L(UW51):
|
710
|
-
|
710
|
+
/* cfi_adjust_cfa_offset(raw_closure_T_FS) */
|
711
711
|
E(L(load_table5), X86_RET_STRUCTARG)
|
712
712
|
jmp L(e5)
|
713
713
|
E(L(load_table5), X86_RET_STRUCT_1B)
|
@@ -724,7 +724,7 @@ E(L(load_table5), X86_RET_UNUSED15)
|
|
724
724
|
int 3
|
725
725
|
|
726
726
|
L(UW52):
|
727
|
-
|
727
|
+
/* cfi_endproc */
|
728
728
|
ENDF(ffi_closure_raw_THISCALL)
|
729
729
|
|
730
730
|
#endif /* !FFI_NO_RAW_API */
|
@@ -743,20 +743,23 @@ ENDF(ffi_closure_raw_THISCALL)
|
|
743
743
|
# define COMDAT(X)
|
744
744
|
#endif
|
745
745
|
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
746
|
+
#if 0
|
747
|
+
#if defined(__PIC__)
|
748
|
+
COMDAT(C(__x86.get_pc_thunk.bx))
|
749
|
+
C(__x86.get_pc_thunk.bx):
|
750
|
+
movl (%esp), %ebx
|
751
|
+
ret
|
752
|
+
ENDF(C(__x86.get_pc_thunk.bx))
|
753
|
+
# if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
|
754
|
+
COMDAT(C(__x86.get_pc_thunk.dx))
|
755
|
+
C(__x86.get_pc_thunk.dx):
|
756
|
+
movl (%esp), %edx
|
757
|
+
ret
|
758
|
+
ENDF(C(__x86.get_pc_thunk.dx))
|
759
|
+
#endif /* DARWIN || HIDDEN */
|
760
|
+
#endif /* __PIC__ */
|
761
|
+
#endif
|
762
|
+
|
760
763
|
|
761
764
|
#if 0
|
762
765
|
/* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */
|
@@ -992,4 +995,4 @@ L(EFDE9):
|
|
992
995
|
#endif
|
993
996
|
#endif
|
994
997
|
|
995
|
-
END
|
998
|
+
END
|
@@ -39,14 +39,13 @@
|
|
39
39
|
actual table. The entry points into the table are all 8 bytes.
|
40
40
|
The use of ORG asserts that we're at the correct location. */
|
41
41
|
/* ??? The clang assembler doesn't handle .org with symbolic expressions. */
|
42
|
-
#
|
42
|
+
#ifdef __CET__
|
43
|
+
/* Double slot size to 16 byte to add 4 bytes of ENDBR64. */
|
44
|
+
# define E(BASE, X) .balign 8; .org BASE + X * 16
|
45
|
+
#elif defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
|
43
46
|
# define E(BASE, X) .balign 8
|
44
47
|
#else
|
45
|
-
#
|
46
|
-
# define E(BASE, X) .balign 8; .org BASE + X * 16
|
47
|
-
# else
|
48
|
-
# define E(BASE, X) .balign 8; .org BASE + X * 8
|
49
|
-
# endif
|
48
|
+
# define E(BASE, X) .balign 8; .org BASE + X * 8
|
50
49
|
#endif
|
51
50
|
|
52
51
|
/* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
|
@@ -456,6 +455,97 @@ L(sse_entry2):
|
|
456
455
|
L(UW17):
|
457
456
|
ENDF(C(ffi_go_closure_unix64))
|
458
457
|
|
458
|
+
#if defined(FFI_EXEC_STATIC_TRAMP)
|
459
|
+
.balign 8
|
460
|
+
.globl C(ffi_closure_unix64_sse_alt)
|
461
|
+
FFI_HIDDEN(C(ffi_closure_unix64_sse_alt))
|
462
|
+
|
463
|
+
C(ffi_closure_unix64_sse_alt):
|
464
|
+
/* See the comments above trampoline_code_table. */
|
465
|
+
_CET_ENDBR
|
466
|
+
movq 8(%rsp), %r10 /* Load closure in r10 */
|
467
|
+
addq $16, %rsp /* Restore the stack */
|
468
|
+
jmp C(ffi_closure_unix64_sse)
|
469
|
+
ENDF(C(ffi_closure_unix64_sse_alt))
|
470
|
+
|
471
|
+
.balign 8
|
472
|
+
.globl C(ffi_closure_unix64_alt)
|
473
|
+
FFI_HIDDEN(C(ffi_closure_unix64_alt))
|
474
|
+
|
475
|
+
C(ffi_closure_unix64_alt):
|
476
|
+
/* See the comments above trampoline_code_table. */
|
477
|
+
_CET_ENDBR
|
478
|
+
movq 8(%rsp), %r10 /* Load closure in r10 */
|
479
|
+
addq $16, %rsp /* Restore the stack */
|
480
|
+
jmp C(ffi_closure_unix64)
|
481
|
+
ENDF(C(ffi_closure_unix64_alt))
|
482
|
+
|
483
|
+
/*
|
484
|
+
* Below is the definition of the trampoline code table. Each element in
|
485
|
+
* the code table is a trampoline.
|
486
|
+
*
|
487
|
+
* Because we jump to the trampoline, we place a _CET_ENDBR at the
|
488
|
+
* beginning of the trampoline to mark it as a valid branch target. This is
|
489
|
+
* part of the the Intel CET (Control Flow Enforcement Technology).
|
490
|
+
*/
|
491
|
+
/*
|
492
|
+
* The trampoline uses register r10. It saves the original value of r10 on
|
493
|
+
* the stack.
|
494
|
+
*
|
495
|
+
* The trampoline has two parameters - target code to jump to and data for
|
496
|
+
* the target code. The trampoline extracts the parameters from its parameter
|
497
|
+
* block (see tramp_table_map()). The trampoline saves the data address on
|
498
|
+
* the stack. Finally, it jumps to the target code.
|
499
|
+
*
|
500
|
+
* The target code can choose to:
|
501
|
+
*
|
502
|
+
* - restore the value of r10
|
503
|
+
* - load the data address in a register
|
504
|
+
* - restore the stack pointer to what it was when the trampoline was invoked.
|
505
|
+
*/
|
506
|
+
#ifdef ENDBR_PRESENT
|
507
|
+
# define X86_DATA_OFFSET 4077
|
508
|
+
# ifdef __ILP32__
|
509
|
+
# define X86_CODE_OFFSET 4069
|
510
|
+
# else
|
511
|
+
# define X86_CODE_OFFSET 4073
|
512
|
+
# endif
|
513
|
+
#else
|
514
|
+
# define X86_DATA_OFFSET 4081
|
515
|
+
# ifdef __ILP32__
|
516
|
+
# define X86_CODE_OFFSET 4073
|
517
|
+
# else
|
518
|
+
# define X86_CODE_OFFSET 4077
|
519
|
+
# endif
|
520
|
+
#endif
|
521
|
+
|
522
|
+
.align UNIX64_TRAMP_MAP_SIZE
|
523
|
+
.globl trampoline_code_table
|
524
|
+
FFI_HIDDEN(C(trampoline_code_table))
|
525
|
+
|
526
|
+
C(trampoline_code_table):
|
527
|
+
.rept UNIX64_TRAMP_MAP_SIZE / UNIX64_TRAMP_SIZE
|
528
|
+
_CET_ENDBR
|
529
|
+
subq $16, %rsp /* Make space on the stack */
|
530
|
+
movq %r10, (%rsp) /* Save %r10 on stack */
|
531
|
+
#ifdef __ILP32__
|
532
|
+
movl X86_DATA_OFFSET(%rip), %r10d /* Copy data into %r10 */
|
533
|
+
#else
|
534
|
+
movq X86_DATA_OFFSET(%rip), %r10 /* Copy data into %r10 */
|
535
|
+
#endif
|
536
|
+
movq %r10, 8(%rsp) /* Save data on stack */
|
537
|
+
#ifdef __ILP32__
|
538
|
+
movl X86_CODE_OFFSET(%rip), %r10d /* Copy code into %r10 */
|
539
|
+
#else
|
540
|
+
movq X86_CODE_OFFSET(%rip), %r10 /* Copy code into %r10 */
|
541
|
+
#endif
|
542
|
+
jmp *%r10 /* Jump to code */
|
543
|
+
.align 8
|
544
|
+
.endr
|
545
|
+
ENDF(C(trampoline_code_table))
|
546
|
+
.align UNIX64_TRAMP_MAP_SIZE
|
547
|
+
#endif /* FFI_EXEC_STATIC_TRAMP */
|
548
|
+
|
459
549
|
/* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */
|
460
550
|
|
461
551
|
#ifdef __APPLE__
|
@@ -85,14 +85,13 @@ C(ffi_call_win64):
|
|
85
85
|
|
86
86
|
/* Below, we're space constrained most of the time. Thus we eschew the
|
87
87
|
modern "mov, pop, ret" sequence (5 bytes) for "leave, ret" (2 bytes). */
|
88
|
-
|
89
|
-
leaveq
|
90
|
-
cfi_remember_state
|
91
|
-
cfi_def_cfa(%rsp, 8)
|
92
|
-
cfi_restore(%rbp)
|
93
|
-
ret
|
88
|
+
#define epilogue \
|
89
|
+
leaveq; \
|
90
|
+
cfi_remember_state; \
|
91
|
+
cfi_def_cfa(%rsp, 8); \
|
92
|
+
cfi_restore(%rbp); \
|
93
|
+
ret; \
|
94
94
|
cfi_restore_state
|
95
|
-
.endm
|
96
95
|
|
97
96
|
.align 8
|
98
97
|
0:
|
@@ -234,6 +233,20 @@ C(ffi_closure_win64):
|
|
234
233
|
|
235
234
|
cfi_endproc
|
236
235
|
SEH(.seh_endproc)
|
236
|
+
|
237
|
+
#if defined(FFI_EXEC_STATIC_TRAMP)
|
238
|
+
.align 8
|
239
|
+
.globl C(ffi_closure_win64_alt)
|
240
|
+
FFI_HIDDEN(C(ffi_closure_win64_alt))
|
241
|
+
|
242
|
+
SEH(.seh_proc ffi_closure_win64_alt)
|
243
|
+
C(ffi_closure_win64_alt):
|
244
|
+
_CET_ENDBR
|
245
|
+
movq 8(%rsp), %r10
|
246
|
+
addq $16, %rsp
|
247
|
+
jmp C(ffi_closure_win64)
|
248
|
+
SEH(.seh_endproc)
|
249
|
+
#endif
|
237
250
|
#endif /* __x86_64__ */
|
238
251
|
|
239
252
|
#if defined __ELF__ && defined __linux__
|
@@ -86,11 +86,16 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
|
|
86
86
|
break;
|
87
87
|
}
|
88
88
|
|
89
|
-
/* Round
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
/* Round up stack size needed for arguments.
|
90
|
+
Allocate FFI_REGISTER_ARGS_SPACE bytes when there are only arguments
|
91
|
+
passed in registers, round space reserved for arguments passed on stack
|
92
|
+
up to ABI-specified alignment. */
|
93
|
+
if (cif->bytes < FFI_REGISTER_NARGS * 4)
|
94
|
+
cif->bytes = FFI_REGISTER_ARGS_SPACE;
|
95
|
+
else
|
96
|
+
cif->bytes = FFI_REGISTER_ARGS_SPACE +
|
97
|
+
FFI_ALIGN(cif->bytes - FFI_REGISTER_NARGS * 4,
|
98
|
+
XTENSA_STACK_ALIGNMENT);
|
94
99
|
return FFI_OK;
|
95
100
|
}
|
96
101
|
|
@@ -232,6 +237,9 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
232
237
|
void *user_data,
|
233
238
|
void *codeloc)
|
234
239
|
{
|
240
|
+
if (cif->abi != FFI_SYSV)
|
241
|
+
return FFI_BAD_ABI;
|
242
|
+
|
235
243
|
/* copye trampoline to stack and patch 'ffi_closure_SYSV' pointer */
|
236
244
|
memcpy(closure->tramp, ffi_trampoline, FFI_TRAMPOLINE_SIZE);
|
237
245
|
*(unsigned int*)(&closure->tramp[8]) = (unsigned int)ffi_closure_SYSV;
|
@@ -277,15 +285,15 @@ ffi_closure_SYSV_inner(ffi_closure *closure, void **values, void *rvalue)
|
|
277
285
|
if (arg_types[i]->alignment == 8 && (areg & 1) != 0)
|
278
286
|
areg++;
|
279
287
|
|
280
|
-
// skip the entry
|
288
|
+
// skip the entry a1, * framework, see ffi_trampoline
|
281
289
|
if (areg == FFI_REGISTER_NARGS)
|
282
|
-
areg
|
290
|
+
areg = (FFI_REGISTER_ARGS_SPACE + 32) / 4;
|
283
291
|
|
284
292
|
if (arg_types[i]->type == FFI_TYPE_STRUCT)
|
285
293
|
{
|
286
294
|
int numregs = ((arg_types[i]->size + 3) & ~3) / 4;
|
287
295
|
if (areg < FFI_REGISTER_NARGS && areg + numregs > FFI_REGISTER_NARGS)
|
288
|
-
areg =
|
296
|
+
areg = (FFI_REGISTER_ARGS_SPACE + 32) / 4;
|
289
297
|
}
|
290
298
|
|
291
299
|
avalue[i] = &values[areg];
|
@@ -43,6 +43,10 @@ typedef enum ffi_abi {
|
|
43
43
|
#endif
|
44
44
|
|
45
45
|
#define FFI_REGISTER_NARGS 6
|
46
|
+
#define XTENSA_STACK_ALIGNMENT 16
|
47
|
+
#define FFI_REGISTER_ARGS_SPACE ((FFI_REGISTER_NARGS * 4 + \
|
48
|
+
XTENSA_STACK_ALIGNMENT - 1) & \
|
49
|
+
-XTENSA_STACK_ALIGNMENT)
|
46
50
|
|
47
51
|
/* ---- Definitions for closures ----------------------------------------- */
|
48
52
|
|