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
@@ -31,6 +31,7 @@
|
|
31
31
|
|
32
32
|
#include <stdint.h>
|
33
33
|
#include <stdlib.h>
|
34
|
+
#include <stdio.h>
|
34
35
|
|
35
36
|
#ifdef __GNUC__
|
36
37
|
# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
|
@@ -77,22 +78,39 @@ static void ffi_prep_args(char *stack,
|
|
77
78
|
{
|
78
79
|
int i;
|
79
80
|
void **p_argv;
|
80
|
-
char *argp;
|
81
|
+
char *argp, *argp_f;
|
81
82
|
ffi_type **p_arg;
|
82
83
|
|
84
|
+
memset(stack, 0, bytes);
|
85
|
+
|
83
86
|
#ifdef FFI_MIPS_N32
|
87
|
+
int soft_float = (ecif->cif->abi == FFI_N32_SOFT_FLOAT
|
88
|
+
|| ecif->cif->abi == FFI_N64_SOFT_FLOAT);
|
84
89
|
/* If more than 8 double words are used, the remainder go
|
85
90
|
on the stack. We reorder stuff on the stack here to
|
86
91
|
support this easily. */
|
87
|
-
if
|
88
|
-
|
92
|
+
/* if ret is _Complex long double, args reg shift2, and a0 should holds pointer to rvalue */
|
93
|
+
if (ecif->cif->rtype->type == FFI_TYPE_COMPLEX && ecif->cif->rtype->elements[0]->type == FFI_TYPE_LONGDOUBLE)
|
94
|
+
{
|
95
|
+
if (bytes + 16 > 8 * sizeof(ffi_arg))
|
96
|
+
argp = &stack[bytes - (8 * sizeof(ffi_arg))];
|
97
|
+
else
|
98
|
+
argp = stack;
|
99
|
+
* (unsigned long *) argp = (unsigned long) ecif->rvalue;
|
100
|
+
argp += 16;
|
101
|
+
}
|
89
102
|
else
|
90
|
-
|
103
|
+
{
|
104
|
+
if (bytes > 8 * sizeof(ffi_arg))
|
105
|
+
argp = &stack[bytes - (8 * sizeof(ffi_arg))];
|
106
|
+
else
|
107
|
+
argp = stack;
|
108
|
+
}
|
91
109
|
#else
|
92
110
|
argp = stack;
|
93
111
|
#endif
|
94
112
|
|
95
|
-
|
113
|
+
argp_f = argp;
|
96
114
|
|
97
115
|
#ifdef FFI_MIPS_N32
|
98
116
|
if ( ecif->cif->rstruct_flag != 0 )
|
@@ -133,7 +151,7 @@ static void ffi_prep_args(char *stack,
|
|
133
151
|
if (type == FFI_TYPE_POINTER)
|
134
152
|
type = (ecif->cif->abi == FFI_N64
|
135
153
|
|| ecif->cif->abi == FFI_N64_SOFT_FLOAT)
|
136
|
-
? FFI_TYPE_SINT64 :
|
154
|
+
? FFI_TYPE_SINT64 : FFI_TYPE_UINT32;
|
137
155
|
|
138
156
|
if (i < 8 && (ecif->cif->abi == FFI_N32_SOFT_FLOAT
|
139
157
|
|| ecif->cif->abi == FFI_N64_SOFT_FLOAT))
|
@@ -183,6 +201,25 @@ static void ffi_prep_args(char *stack,
|
|
183
201
|
#endif
|
184
202
|
break;
|
185
203
|
|
204
|
+
#ifdef FFI_MIPS_N32
|
205
|
+
case FFI_TYPE_COMPLEX:
|
206
|
+
/* expand from 4+4 to 8+8 if pass with fpr reg */
|
207
|
+
/* argp will wind back to stack when we process all of reg args */
|
208
|
+
/* all var_args passed with gpr, should be expand */
|
209
|
+
if(!soft_float
|
210
|
+
&& (*p_arg)->elements[0]->type == FFI_TYPE_FLOAT
|
211
|
+
&& argp>=argp_f
|
212
|
+
&& i < ecif->cif->mips_nfixedargs)
|
213
|
+
{
|
214
|
+
*(float *) argp = *(float *)(* p_argv);
|
215
|
+
argp += z;
|
216
|
+
char *tmp = (void *) (*p_argv);
|
217
|
+
*(float *) argp = *(float *)(tmp+4);
|
218
|
+
}
|
219
|
+
else
|
220
|
+
memcpy(argp, *p_argv, (*p_arg)->size);
|
221
|
+
break;
|
222
|
+
#endif
|
186
223
|
/* This can only happen with 64bit slots. */
|
187
224
|
case FFI_TYPE_FLOAT:
|
188
225
|
*(float *) argp = *(float *)(* p_argv);
|
@@ -235,6 +272,24 @@ static void ffi_prep_args(char *stack,
|
|
235
272
|
passed in an integer register". This code traverses structure
|
236
273
|
definitions and generates the appropriate flags. */
|
237
274
|
|
275
|
+
static int
|
276
|
+
calc_n32_struct_flags_element(unsigned *flags, ffi_type *e,
|
277
|
+
unsigned *loc, unsigned *arg_reg)
|
278
|
+
{
|
279
|
+
/* Align this object. */
|
280
|
+
*loc = FFI_ALIGN(*loc, e->alignment);
|
281
|
+
if (e->type == FFI_TYPE_DOUBLE)
|
282
|
+
{
|
283
|
+
/* Already aligned to FFI_SIZEOF_ARG. */
|
284
|
+
*arg_reg = *loc / FFI_SIZEOF_ARG;
|
285
|
+
if (*arg_reg > 7)
|
286
|
+
return 1;
|
287
|
+
*flags += (FFI_TYPE_DOUBLE << (*arg_reg * FFI_FLAG_BITS));
|
288
|
+
}
|
289
|
+
*loc += e->size;
|
290
|
+
return 0;
|
291
|
+
}
|
292
|
+
|
238
293
|
static unsigned
|
239
294
|
calc_n32_struct_flags(int soft_float, ffi_type *arg,
|
240
295
|
unsigned *loc, unsigned *arg_reg)
|
@@ -249,19 +304,16 @@ calc_n32_struct_flags(int soft_float, ffi_type *arg,
|
|
249
304
|
|
250
305
|
while ((e = arg->elements[index]))
|
251
306
|
{
|
252
|
-
|
253
|
-
*loc = FFI_ALIGN(*loc, e->alignment);
|
254
|
-
if (e->type == FFI_TYPE_DOUBLE)
|
307
|
+
if (e->type == FFI_TYPE_COMPLEX)
|
255
308
|
{
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
flags += (FFI_TYPE_DOUBLE << (*arg_reg * FFI_FLAG_BITS));
|
261
|
-
*loc += e->size;
|
309
|
+
if (calc_n32_struct_flags_element(&flags, e->elements[0], loc, arg_reg))
|
310
|
+
break;
|
311
|
+
if (calc_n32_struct_flags_element(&flags, e->elements[0], loc, arg_reg))
|
312
|
+
break;
|
262
313
|
}
|
263
314
|
else
|
264
|
-
|
315
|
+
if (calc_n32_struct_flags_element(&flags, e, loc, arg_reg))
|
316
|
+
break;
|
265
317
|
index++;
|
266
318
|
}
|
267
319
|
/* Next Argument register at alignment of FFI_SIZEOF_ARG. */
|
@@ -273,7 +325,7 @@ calc_n32_struct_flags(int soft_float, ffi_type *arg,
|
|
273
325
|
static unsigned
|
274
326
|
calc_n32_return_struct_flags(int soft_float, ffi_type *arg)
|
275
327
|
{
|
276
|
-
unsigned flags
|
328
|
+
unsigned flags;
|
277
329
|
unsigned small = FFI_TYPE_SMALLSTRUCT;
|
278
330
|
ffi_type *e;
|
279
331
|
|
@@ -292,33 +344,48 @@ calc_n32_return_struct_flags(int soft_float, ffi_type *arg)
|
|
292
344
|
|
293
345
|
e = arg->elements[0];
|
294
346
|
|
295
|
-
if (e->type ==
|
296
|
-
flags = FFI_TYPE_DOUBLE;
|
297
|
-
else if (e->type == FFI_TYPE_FLOAT)
|
298
|
-
flags = FFI_TYPE_FLOAT;
|
299
|
-
|
300
|
-
if (flags && (e = arg->elements[1]))
|
347
|
+
if (e->type == FFI_TYPE_COMPLEX)
|
301
348
|
{
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
flags += FFI_TYPE_FLOAT << FFI_FLAG_BITS;
|
306
|
-
else
|
349
|
+
int type = e->elements[0]->type;
|
350
|
+
|
351
|
+
if (type != FFI_TYPE_DOUBLE && type != FFI_TYPE_FLOAT)
|
307
352
|
return small;
|
308
353
|
|
309
|
-
if (
|
354
|
+
if (arg->elements[1])
|
310
355
|
{
|
311
|
-
/*
|
312
|
-
|
356
|
+
/* Two floating point fields with more fields!
|
357
|
+
This must be passed the old way. */
|
313
358
|
return small;
|
314
359
|
}
|
315
|
-
|
316
|
-
|
360
|
+
|
361
|
+
flags = (type << FFI_FLAG_BITS) + type;
|
317
362
|
}
|
318
363
|
else
|
319
|
-
|
320
|
-
|
364
|
+
{
|
365
|
+
if (e->type != FFI_TYPE_DOUBLE && e->type != FFI_TYPE_FLOAT)
|
366
|
+
return small;
|
367
|
+
|
368
|
+
flags = e->type;
|
321
369
|
|
370
|
+
if (arg->elements[1])
|
371
|
+
{
|
372
|
+
e = arg->elements[1];
|
373
|
+
if (e->type != FFI_TYPE_DOUBLE && e->type != FFI_TYPE_FLOAT)
|
374
|
+
return small;
|
375
|
+
|
376
|
+
if (arg->elements[2])
|
377
|
+
{
|
378
|
+
/* There are three arguments and the first two are
|
379
|
+
floats! This must be passed the old way. */
|
380
|
+
return small;
|
381
|
+
}
|
382
|
+
|
383
|
+
flags += e->type << FFI_FLAG_BITS;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
if (soft_float)
|
388
|
+
flags += FFI_TYPE_STRUCT_SOFT;
|
322
389
|
return flags;
|
323
390
|
}
|
324
391
|
|
@@ -335,7 +402,7 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
335
402
|
* does not have special handling for floating point args.
|
336
403
|
*/
|
337
404
|
|
338
|
-
if (cif->rtype->type != FFI_TYPE_STRUCT && cif->abi == FFI_O32)
|
405
|
+
if (cif->rtype->type != FFI_TYPE_STRUCT && cif->rtype->type != FFI_TYPE_COMPLEX && cif->abi == FFI_O32)
|
339
406
|
{
|
340
407
|
if (cif->nargs > 0 && cif->nargs == nfixedargs)
|
341
408
|
{
|
@@ -403,7 +470,10 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
403
470
|
case FFI_TYPE_STRUCT:
|
404
471
|
case FFI_TYPE_FLOAT:
|
405
472
|
case FFI_TYPE_DOUBLE:
|
473
|
+
case FFI_TYPE_COMPLEX:
|
406
474
|
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2);
|
475
|
+
if (cif->rtype->type == FFI_TYPE_COMPLEX)
|
476
|
+
cif->flags += ((*cif->rtype->elements[0]).type) << (FFI_FLAG_BITS * 4);
|
407
477
|
break;
|
408
478
|
|
409
479
|
case FFI_TYPE_SINT64:
|
@@ -421,7 +491,6 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
421
491
|
#ifdef FFI_MIPS_N32
|
422
492
|
/* Set the flags necessary for N32 processing */
|
423
493
|
{
|
424
|
-
int type;
|
425
494
|
unsigned arg_reg = 0;
|
426
495
|
unsigned loc = 0;
|
427
496
|
unsigned count = (cif->nargs < 8) ? cif->nargs : 8;
|
@@ -453,29 +522,14 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
453
522
|
|
454
523
|
while (count-- > 0 && arg_reg < 8)
|
455
524
|
{
|
456
|
-
|
525
|
+
ffi_type *t = cif->arg_types[index];
|
457
526
|
|
458
|
-
|
459
|
-
if (soft_float || index >= nfixedargs)
|
460
|
-
{
|
461
|
-
switch (type)
|
462
|
-
{
|
463
|
-
case FFI_TYPE_FLOAT:
|
464
|
-
type = FFI_TYPE_UINT32;
|
465
|
-
break;
|
466
|
-
case FFI_TYPE_DOUBLE:
|
467
|
-
type = FFI_TYPE_UINT64;
|
468
|
-
break;
|
469
|
-
default:
|
470
|
-
break;
|
471
|
-
}
|
472
|
-
}
|
473
|
-
switch (type)
|
527
|
+
switch (t->type)
|
474
528
|
{
|
475
529
|
case FFI_TYPE_FLOAT:
|
476
530
|
case FFI_TYPE_DOUBLE:
|
477
|
-
|
478
|
-
|
531
|
+
if (!soft_float && index < nfixedargs)
|
532
|
+
cif->flags += t->type << (arg_reg * FFI_FLAG_BITS);
|
479
533
|
arg_reg++;
|
480
534
|
break;
|
481
535
|
case FFI_TYPE_LONGDOUBLE:
|
@@ -491,17 +545,71 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
491
545
|
cif->flags +=
|
492
546
|
(FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
|
493
547
|
arg_reg++;
|
548
|
+
if (arg_reg >= 8)
|
549
|
+
continue;
|
494
550
|
cif->flags +=
|
495
551
|
(FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
|
496
552
|
arg_reg++;
|
497
553
|
}
|
498
554
|
break;
|
499
555
|
|
556
|
+
case FFI_TYPE_COMPLEX:
|
557
|
+
switch (t->elements[0]->type)
|
558
|
+
{
|
559
|
+
case FFI_TYPE_LONGDOUBLE:
|
560
|
+
arg_reg = FFI_ALIGN(arg_reg, 2);
|
561
|
+
if (soft_float || index >= nfixedargs)
|
562
|
+
{
|
563
|
+
arg_reg += 2;
|
564
|
+
}
|
565
|
+
else
|
566
|
+
{
|
567
|
+
cif->flags +=
|
568
|
+
(FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
|
569
|
+
arg_reg++;
|
570
|
+
if (arg_reg >= 8)
|
571
|
+
continue;
|
572
|
+
cif->flags +=
|
573
|
+
(FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
|
574
|
+
arg_reg++;
|
575
|
+
if (arg_reg >= 8)
|
576
|
+
continue;
|
577
|
+
}
|
578
|
+
/* passthrough */
|
579
|
+
case FFI_TYPE_FLOAT:
|
580
|
+
// one fpr can only holds one arg even it is single
|
581
|
+
cif->bytes += 16;
|
582
|
+
/* passthrough */
|
583
|
+
case FFI_TYPE_SINT32:
|
584
|
+
case FFI_TYPE_UINT32:
|
585
|
+
case FFI_TYPE_DOUBLE:
|
586
|
+
if (soft_float || index >= nfixedargs)
|
587
|
+
{
|
588
|
+
arg_reg += 2;
|
589
|
+
}
|
590
|
+
else
|
591
|
+
{
|
592
|
+
uint32_t type = t->elements[0]->type != FFI_TYPE_LONGDOUBLE? t->elements[0]->type: FFI_TYPE_DOUBLE;
|
593
|
+
cif->flags +=
|
594
|
+
(type << (arg_reg * FFI_FLAG_BITS));
|
595
|
+
arg_reg++;
|
596
|
+
if (arg_reg >= 8)
|
597
|
+
continue;
|
598
|
+
cif->flags +=
|
599
|
+
(type << (arg_reg * FFI_FLAG_BITS));
|
600
|
+
arg_reg++;
|
601
|
+
}
|
602
|
+
break;
|
603
|
+
default:
|
604
|
+
arg_reg += 2;
|
605
|
+
break;
|
606
|
+
}
|
607
|
+
break;
|
608
|
+
|
500
609
|
case FFI_TYPE_STRUCT:
|
501
610
|
loc = arg_reg * FFI_SIZEOF_ARG;
|
502
611
|
cif->flags += calc_n32_struct_flags(soft_float || index >= nfixedargs,
|
503
|
-
|
504
|
-
&loc, &arg_reg);
|
612
|
+
t, &loc, &arg_reg);
|
505
613
|
break;
|
506
614
|
|
507
615
|
default:
|
@@ -541,7 +649,7 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
541
649
|
if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32)
|
542
650
|
cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
|
543
651
|
else
|
544
|
-
cif->flags +=
|
652
|
+
cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
|
545
653
|
break;
|
546
654
|
|
547
655
|
case FFI_TYPE_FLOAT:
|
@@ -553,7 +661,7 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
553
661
|
/* else fall through */
|
554
662
|
case FFI_TYPE_DOUBLE:
|
555
663
|
if (soft_float)
|
556
|
-
cif->flags +=
|
664
|
+
cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
|
557
665
|
else
|
558
666
|
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
|
559
667
|
break;
|
@@ -563,8 +671,9 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
563
671
|
two doubles. */
|
564
672
|
if (soft_float)
|
565
673
|
{
|
566
|
-
|
567
|
-
|
674
|
+
/* if ret is long double, the ret is given by v0 and a0, no idea why
|
675
|
+
* Let's us VOID | VOID | LONGDOUBLE for it*/
|
676
|
+
cif->flags += FFI_TYPE_LONGDOUBLE << (FFI_FLAG_BITS * 8);
|
568
677
|
}
|
569
678
|
else
|
570
679
|
{
|
@@ -574,13 +683,52 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
|
|
574
683
|
<< (4 + (FFI_FLAG_BITS * 8));
|
575
684
|
}
|
576
685
|
break;
|
686
|
+
case FFI_TYPE_COMPLEX:
|
687
|
+
{
|
688
|
+
int type = cif->rtype->elements[0]->type;
|
689
|
+
|
690
|
+
cif->flags += (FFI_TYPE_COMPLEX << (FFI_FLAG_BITS * 8));
|
691
|
+
if (soft_float || (type != FFI_TYPE_FLOAT && type != FFI_TYPE_DOUBLE && type != FFI_TYPE_LONGDOUBLE))
|
692
|
+
{
|
693
|
+
switch (type)
|
694
|
+
{
|
695
|
+
case FFI_TYPE_DOUBLE:
|
696
|
+
case FFI_TYPE_SINT64:
|
697
|
+
case FFI_TYPE_UINT64:
|
698
|
+
case FFI_TYPE_INT:
|
699
|
+
type = FFI_TYPE_SMALLSTRUCT2;
|
700
|
+
break;
|
701
|
+
case FFI_TYPE_LONGDOUBLE:
|
702
|
+
type = FFI_TYPE_LONGDOUBLE;
|
703
|
+
break;
|
704
|
+
case FFI_TYPE_FLOAT:
|
705
|
+
default:
|
706
|
+
type = FFI_TYPE_SMALLSTRUCT;
|
707
|
+
}
|
708
|
+
cif->flags += type << (4 + (FFI_FLAG_BITS * 8));
|
709
|
+
}
|
710
|
+
else
|
711
|
+
{
|
712
|
+
//cif->flags += (type + (type << FFI_FLAG_BITS))
|
713
|
+
// << (4 + (FFI_FLAG_BITS * 8));
|
714
|
+
cif->flags += type << (4 + (FFI_FLAG_BITS * 8));
|
715
|
+
}
|
716
|
+
break;
|
717
|
+
}
|
718
|
+
case FFI_TYPE_UINT32:
|
719
|
+
/* In the N32 or N64 ABI unsigned 32-bit integer should be
|
720
|
+
*sign*-extended. */
|
721
|
+
cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
|
722
|
+
break;
|
723
|
+
case FFI_TYPE_SINT64:
|
724
|
+
cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
|
725
|
+
break;
|
577
726
|
default:
|
578
|
-
cif->flags +=
|
727
|
+
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
|
579
728
|
break;
|
580
729
|
}
|
581
730
|
}
|
582
731
|
#endif
|
583
|
-
|
584
732
|
return FFI_OK;
|
585
733
|
}
|
586
734
|
|
@@ -618,7 +766,7 @@ void ffi_call_int(ffi_cif *cif, void (*fn)(void), void *rvalue,
|
|
618
766
|
/* value address then we need to make one */
|
619
767
|
|
620
768
|
if ((rvalue == NULL) &&
|
621
|
-
(cif->rtype->type == FFI_TYPE_STRUCT))
|
769
|
+
(cif->rtype->type == FFI_TYPE_STRUCT || cif->rtype->type == FFI_TYPE_COMPLEX))
|
622
770
|
ecif.rvalue = alloca(cif->rtype->size);
|
623
771
|
else
|
624
772
|
ecif.rvalue = rvalue;
|
@@ -830,6 +978,11 @@ ffi_closure_mips_inner_O32 (ffi_cif *cif,
|
|
830
978
|
argn = 1;
|
831
979
|
seen_int = 1;
|
832
980
|
}
|
981
|
+
if ((cif->flags >> (FFI_FLAG_BITS * 2)) == FFI_TYPE_COMPLEX)
|
982
|
+
{
|
983
|
+
rvalue = fpr;
|
984
|
+
argn = 1;
|
985
|
+
}
|
833
986
|
|
834
987
|
i = 0;
|
835
988
|
avn = cif->nargs;
|
@@ -902,6 +1055,9 @@ ffi_closure_mips_inner_O32 (ffi_cif *cif,
|
|
902
1055
|
}
|
903
1056
|
else
|
904
1057
|
{
|
1058
|
+
if (cif->rtype->type == FFI_TYPE_COMPLEX) {
|
1059
|
+
__asm__ volatile ("move $v1, %0" : : "r"(cif->rtype->size));
|
1060
|
+
}
|
905
1061
|
return cif->rtype->type;
|
906
1062
|
}
|
907
1063
|
}
|
@@ -991,6 +1147,8 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
|
|
991
1147
|
#endif
|
992
1148
|
argn = 1;
|
993
1149
|
}
|
1150
|
+
if (cif->rtype->type == FFI_TYPE_COMPLEX && cif->rtype->elements[0]->type == FFI_TYPE_LONGDOUBLE)
|
1151
|
+
argn = 2;
|
994
1152
|
|
995
1153
|
i = 0;
|
996
1154
|
avn = cif->nargs;
|
@@ -1015,6 +1173,31 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
|
|
1015
1173
|
#endif
|
1016
1174
|
avaluep[i] = (char *) argp;
|
1017
1175
|
}
|
1176
|
+
else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
|
1177
|
+
{
|
1178
|
+
argp = (argn >= 8 || i >= cif->mips_nfixedargs || soft_float) ? ar + argn : fpr + argn;
|
1179
|
+
avaluep[i] = (char *) argp;
|
1180
|
+
}
|
1181
|
+
else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_LONGDOUBLE)
|
1182
|
+
{
|
1183
|
+
/* align long double */
|
1184
|
+
argn += ((argn & 0x1)? 1 : 0);
|
1185
|
+
argp = (argn >= 8 || i >= cif->mips_nfixedargs || soft_float) ? ar + argn : fpr + argn;
|
1186
|
+
avaluep[i] = (char *) argp;
|
1187
|
+
}
|
1188
|
+
else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_FLOAT)
|
1189
|
+
{
|
1190
|
+
if (argn >= 8 || i >= cif->mips_nfixedargs || soft_float)
|
1191
|
+
argp = ar + argn;
|
1192
|
+
else
|
1193
|
+
{
|
1194
|
+
argp = fpr + argn;
|
1195
|
+
/* the normal args for function holds 8bytes, while here we convert it to ptr */
|
1196
|
+
uint32_t *tmp = (uint32_t *)argp;
|
1197
|
+
tmp[1] = tmp[2];
|
1198
|
+
}
|
1199
|
+
avaluep[i] = (char *) argp;
|
1200
|
+
}
|
1018
1201
|
else
|
1019
1202
|
{
|
1020
1203
|
unsigned type = arg_types[i]->type;
|
@@ -1027,10 +1210,10 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
|
|
1027
1210
|
/* The size of a pointer depends on the ABI */
|
1028
1211
|
if (type == FFI_TYPE_POINTER)
|
1029
1212
|
type = (cif->abi == FFI_N64 || cif->abi == FFI_N64_SOFT_FLOAT)
|
1030
|
-
? FFI_TYPE_SINT64 :
|
1213
|
+
? FFI_TYPE_SINT64 : FFI_TYPE_UINT32;
|
1031
1214
|
|
1032
1215
|
if (soft_float && type == FFI_TYPE_FLOAT)
|
1033
|
-
type =
|
1216
|
+
type = FFI_TYPE_SINT32;
|
1034
1217
|
|
1035
1218
|
switch (type)
|
1036
1219
|
{
|
@@ -80,6 +80,7 @@
|
|
80
80
|
# endif
|
81
81
|
#endif
|
82
82
|
|
83
|
+
#define FFI_TARGET_HAS_COMPLEX_TYPE 1
|
83
84
|
#define FFI_FLAG_BITS 2
|
84
85
|
|
85
86
|
/* SGI's strange assembler requires that we multiply by 4 rather
|
@@ -111,6 +112,12 @@
|
|
111
112
|
#define FFI_TYPE_STRUCT_SMALL 93
|
112
113
|
#define FFI_TYPE_STRUCT_SMALL2 109
|
113
114
|
|
115
|
+
#define FFI_TYPE_COMPLEX_SMALL 95
|
116
|
+
#define FFI_TYPE_COMPLEX_SMALL2 111
|
117
|
+
#define FFI_TYPE_COMPLEX_FF 47
|
118
|
+
#define FFI_TYPE_COMPLEX_DD 63
|
119
|
+
#define FFI_TYPE_COMPLEX_LDLD 79
|
120
|
+
|
114
121
|
/* and for n32 soft float, add 16 * 2^4 */
|
115
122
|
#define FFI_TYPE_STRUCT_D_SOFT 317
|
116
123
|
#define FFI_TYPE_STRUCT_F_SOFT 301
|