ffi 1.9.18 → 1.9.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +22 -0
- data/.gitmodules +3 -0
- data/.travis.yml +52 -0
- data/.yardopts +5 -0
- data/Gemfile +15 -0
- data/{spec/ffi/LICENSE.SPECS → LICENSE.SPECS} +1 -1
- data/README.md +3 -4
- data/Rakefile +41 -5
- data/appveyor.yml +22 -0
- data/ext/ffi_c/AbstractMemory.c +6 -1
- data/ext/ffi_c/Call.c +1 -22
- data/ext/ffi_c/Call.h +0 -9
- data/ext/ffi_c/Closure.c +54 -0
- data/ext/ffi_c/{ClosurePool.h → Closure.h} +13 -23
- data/ext/ffi_c/Function.c +16 -25
- data/ext/ffi_c/Function.h +1 -2
- data/ext/ffi_c/FunctionInfo.c +0 -4
- data/ext/ffi_c/MethodHandle.c +33 -268
- data/ext/ffi_c/Platform.c +10 -2
- data/ext/ffi_c/extconf.rb +10 -5
- data/ext/ffi_c/ffi.c +2 -2
- data/ext/ffi_c/libffi/.appveyor.yml +48 -0
- data/ext/ffi_c/libffi/.gitignore +36 -0
- data/ext/ffi_c/libffi/.travis/install.sh +14 -0
- data/ext/ffi_c/libffi/.travis.yml +30 -0
- data/ext/ffi_c/libffi/ChangeLog.libffi +2 -2
- data/ext/ffi_c/libffi/{ChangeLog → ChangeLog.libffi-3.1} +1402 -2
- data/ext/ffi_c/libffi/ChangeLog.v1 +1 -1
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +169 -158
- data/ext/ffi_c/libffi/Makefile.in +927 -938
- data/ext/ffi_c/libffi/README +164 -52
- data/ext/ffi_c/libffi/acinclude.m4 +387 -0
- data/ext/ffi_c/libffi/autogen.sh +2 -0
- data/ext/ffi_c/libffi/config.guess +336 -371
- data/ext/ffi_c/libffi/config.sub +246 -115
- data/ext/ffi_c/libffi/configure +6976 -2189
- data/ext/ffi_c/libffi/configure.ac +148 -256
- data/ext/ffi_c/libffi/configure.host +277 -4
- data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
- data/ext/ffi_c/libffi/doc/Makefile.in +811 -0
- data/ext/ffi_c/libffi/doc/libffi.texi +430 -45
- data/ext/ffi_c/libffi/doc/version.texi +4 -4
- data/ext/ffi_c/libffi/fficonfig.h.in +24 -13
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +203 -0
- data/ext/ffi_c/libffi/include/Makefile.am +3 -3
- data/ext/ffi_c/libffi/include/Makefile.in +188 -71
- data/ext/ffi_c/libffi/include/ffi.h.in +112 -50
- data/ext/ffi_c/libffi/include/ffi_cfi.h +55 -0
- data/ext/ffi_c/libffi/include/ffi_common.h +32 -11
- data/ext/ffi_c/libffi/install-sh +190 -202
- data/ext/ffi_c/libffi/libffi.map.in +80 -0
- data/ext/ffi_c/libffi/libffi.pc.in +3 -2
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +1043 -0
- data/ext/ffi_c/libffi/libtool-ldflags +106 -0
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/ltmain.sh +3553 -2033
- data/ext/ffi_c/libffi/m4/asmcfi.m4 +13 -0
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +69 -0
- data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +13 -8
- data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +31 -104
- data/ext/ffi_c/libffi/m4/{ax_check_compiler_flags.m4 → ax_check_compile_flag.m4} +30 -34
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +32 -11
- data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +6 -5
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +31 -21
- data/ext/ffi_c/libffi/man/Makefile.am +2 -2
- data/ext/ffi_c/libffi/man/Makefile.in +141 -49
- data/ext/ffi_c/libffi/man/ffi.3 +10 -0
- data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +6 -4
- data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +73 -0
- data/ext/ffi_c/libffi/missing +150 -311
- data/ext/ffi_c/libffi/msvcc.sh +72 -9
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +964 -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 +335 -98
- data/ext/ffi_c/libffi/src/alpha/ffitarget.h +10 -1
- data/ext/ffi_c/libffi/src/alpha/internal.h +23 -0
- data/ext/ffi_c/libffi/src/alpha/osf.S +161 -266
- data/ext/ffi_c/libffi/src/arc/arcompact.S +135 -0
- data/ext/ffi_c/libffi/src/arc/ffi.c +266 -0
- data/ext/ffi_c/libffi/src/arc/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/arm/ffi.c +608 -517
- data/ext/ffi_c/libffi/src/arm/ffitarget.h +24 -7
- data/ext/ffi_c/libffi/src/arm/internal.h +7 -0
- data/ext/ffi_c/libffi/src/arm/sysv.S +303 -417
- data/ext/ffi_c/libffi/src/avr32/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/bfin/ffi.c +196 -0
- data/ext/ffi_c/libffi/src/bfin/ffitarget.h +43 -0
- data/ext/ffi_c/libffi/src/bfin/sysv.S +179 -0
- data/ext/ffi_c/libffi/src/closures.c +366 -45
- data/ext/ffi_c/libffi/src/cris/ffi.c +10 -7
- data/ext/ffi_c/libffi/src/cris/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/debug.c +6 -1
- data/ext/ffi_c/libffi/src/dlmalloc.c +16 -11
- data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/frv/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/ia64/ffi.c +11 -7
- data/ext/ffi_c/libffi/src/ia64/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/ia64/unix.S +2 -0
- data/ext/ffi_c/libffi/src/java_raw_api.c +23 -5
- data/ext/ffi_c/libffi/src/m32r/ffi.c +1 -1
- data/ext/ffi_c/libffi/src/m32r/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/m68k/ffi.c +87 -13
- data/ext/ffi_c/libffi/src/m68k/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/m68k/sysv.S +119 -32
- data/ext/ffi_c/libffi/src/m88k/ffi.c +400 -0
- data/ext/ffi_c/libffi/src/m88k/ffitarget.h +49 -0
- data/ext/ffi_c/libffi/src/m88k/obsd.S +209 -0
- data/ext/ffi_c/libffi/src/metag/ffi.c +330 -0
- data/ext/ffi_c/libffi/{fficonfig.hw → src/metag/ffitarget.h} +22 -26
- data/ext/ffi_c/libffi/src/metag/sysv.S +311 -0
- data/ext/ffi_c/libffi/src/microblaze/ffi.c +321 -0
- data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +53 -0
- data/ext/ffi_c/libffi/src/microblaze/sysv.S +302 -0
- data/ext/ffi_c/libffi/src/mips/ffi.c +103 -28
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +10 -3
- data/ext/ffi_c/libffi/src/mips/n32.S +128 -56
- data/ext/ffi_c/libffi/src/mips/o32.S +148 -27
- data/ext/ffi_c/libffi/src/moxie/eabi.S +55 -82
- data/ext/ffi_c/libffi/src/moxie/ffi.c +40 -44
- 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/ffitarget.h +8 -1
- data/ext/ffi_c/libffi/src/powerpc/aix.S +245 -7
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +253 -4
- data/ext/ffi_c/libffi/src/powerpc/asm.h +2 -2
- data/ext/ffi_c/libffi/src/powerpc/darwin.S +2 -7
- data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +22 -26
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +103 -1378
- data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +111 -30
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +945 -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 +103 -44
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +100 -59
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +360 -108
- data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +138 -68
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +68 -112
- data/ext/ffi_c/libffi/src/prep_cif.c +108 -24
- data/ext/ffi_c/libffi/src/raw_api.c +18 -5
- data/ext/ffi_c/libffi/src/s390/ffi.c +294 -318
- data/ext/ffi_c/libffi/src/s390/ffitarget.h +9 -1
- data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
- data/ext/ffi_c/libffi/src/s390/sysv.S +257 -366
- data/ext/ffi_c/libffi/src/sh/ffi.c +4 -3
- data/ext/ffi_c/libffi/src/sh/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/sh64/ffi.c +3 -2
- data/ext/ffi_c/libffi/src/sh64/ffitarget.h +6 -1
- data/ext/ffi_c/libffi/src/sparc/ffi.c +326 -527
- data/ext/ffi_c/libffi/src/sparc/ffi64.c +608 -0
- data/ext/ffi_c/libffi/src/sparc/ffitarget.h +20 -7
- data/ext/ffi_c/libffi/src/sparc/internal.h +26 -0
- data/ext/ffi_c/libffi/src/sparc/v8.S +364 -234
- data/ext/ffi_c/libffi/src/sparc/v9.S +340 -207
- data/ext/ffi_c/libffi/src/tile/ffi.c +355 -0
- data/ext/ffi_c/libffi/src/tile/ffitarget.h +65 -0
- data/ext/ffi_c/libffi/src/tile/tile.S +360 -0
- data/ext/ffi_c/libffi/src/types.c +43 -14
- 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 +591 -500
- data/ext/ffi_c/libffi/src/x86/ffi64.c +359 -116
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +55 -35
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +287 -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 +975 -400
- data/ext/ffi_c/libffi/src/x86/unix64.S +398 -299
- data/ext/ffi_c/libffi/src/x86/win64.S +222 -458
- 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 +253 -0
- data/ext/ffi_c/libffi/stamp-h.in +1 -0
- data/ext/ffi_c/libffi/testsuite/Makefile.am +79 -73
- data/ext/ffi_c/libffi/testsuite/Makefile.in +219 -111
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +121 -25
- data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +21 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +4 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/{closure_stdcall.c → closure_simple.c} +7 -16
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +4 -4
- 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 +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +4 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +4 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +4 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +10 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +3 -3
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +10 -9
- 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_pointer.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +11 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_struct_va1.c +114 -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_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 +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort_va.c +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +23 -40
- data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +3 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +6 -4
- data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +4 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +107 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +18 -19
- data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +6 -16
- data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +57 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +70 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +0 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +6 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +8 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +6 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct11.c +121 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +6 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +6 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +6 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +46 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +127 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +7 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +7 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +5 -5
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +49 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +55 -0
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +9 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +7 -7
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +7 -6
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +9 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +9 -9
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +2 -2
- data/ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c +61 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.call}/unwindtest.cc +3 -10
- data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.call}/unwindtest_ffi_call.cc +2 -1
- 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.special/special.exp → libffi.complex/complex.exp} +9 -8
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +51 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +7 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +86 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +78 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +37 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +41 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +44 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +10 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +34 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +28 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +1 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +36 -0
- data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +19 -0
- data/ext/ffi_c/libffi.bsd.mk +11 -5
- data/ext/ffi_c/libffi.darwin.mk +14 -4
- data/ext/ffi_c/libffi.gnu.mk +3 -2
- data/ext/ffi_c/libffi.mk +10 -5
- data/ext/ffi_c/libffi.vc.mk +1 -1
- data/ext/ffi_c/libffi.vc64.mk +1 -1
- data/ffi.gemspec +16 -3
- data/lib/ffi/enum.rb +124 -0
- data/lib/ffi/library.rb +66 -14
- data/lib/ffi/platform/sparc64-linux/types.conf +102 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +113 -20
- data/lib/ffi/platform.rb +7 -2
- data/lib/ffi/pointer.rb +1 -0
- data/lib/ffi/struct.rb +0 -2
- data/lib/ffi/version.rb +1 -2
- 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 +164 -115
- data/ext/ffi_c/ClosurePool.c +0 -283
- data/ext/ffi_c/libffi/Makefile.vc +0 -141
- data/ext/ffi_c/libffi/Makefile.vc64 +0 -141
- data/ext/ffi_c/libffi/aclocal.m4 +0 -1873
- data/ext/ffi_c/libffi/build-ios.sh +0 -67
- data/ext/ffi_c/libffi/compile +0 -143
- data/ext/ffi_c/libffi/depcomp +0 -630
- data/ext/ffi_c/libffi/doc/libffi.info +0 -593
- data/ext/ffi_c/libffi/doc/stamp-vti +0 -4
- data/ext/ffi_c/libffi/include/ffi.h.vc +0 -427
- data/ext/ffi_c/libffi/include/ffi.h.vc64 +0 -427
- data/ext/ffi_c/libffi/m4/libtool.m4 +0 -7831
- data/ext/ffi_c/libffi/m4/ltoptions.m4 +0 -369
- data/ext/ffi_c/libffi/m4/ltsugar.m4 +0 -123
- data/ext/ffi_c/libffi/m4/ltversion.m4 +0 -23
- data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +0 -98
- data/ext/ffi_c/libffi/mdate-sh +0 -201
- data/ext/ffi_c/libffi/src/arm/gentramp.sh +0 -118
- data/ext/ffi_c/libffi/src/arm/trampoline.S +0 -4450
- data/ext/ffi_c/libffi/src/x86/darwin.S +0 -444
- data/ext/ffi_c/libffi/src/x86/darwin64.S +0 -416
- data/ext/ffi_c/libffi/src/x86/freebsd.S +0 -458
- data/ext/ffi_c/libffi/src/x86/win32.S +0 -1065
- data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +0 -300
- data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +0 -63
- data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +0 -44
- data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +0 -96
- data/ext/ffi_c/libffi/texinfo.tex +0 -7210
- data/gen/Rakefile +0 -30
- data/libtest/Benchmark.c +0 -52
- data/libtest/BoolTest.c +0 -34
- data/libtest/BufferTest.c +0 -31
- data/libtest/ClosureTest.c +0 -205
- data/libtest/EnumTest.c +0 -51
- data/libtest/FunctionTest.c +0 -70
- data/libtest/GNUmakefile +0 -149
- data/libtest/GlobalVariable.c +0 -62
- data/libtest/LastErrorTest.c +0 -21
- data/libtest/NumberTest.c +0 -132
- data/libtest/PointerTest.c +0 -63
- data/libtest/ReferenceTest.c +0 -23
- data/libtest/StringTest.c +0 -34
- data/libtest/StructTest.c +0 -243
- data/libtest/UnionTest.c +0 -43
- data/libtest/VariadicTest.c +0 -99
- data/spec/ffi/async_callback_spec.rb +0 -35
- data/spec/ffi/bool_spec.rb +0 -32
- data/spec/ffi/buffer_spec.rb +0 -279
- data/spec/ffi/callback_spec.rb +0 -773
- data/spec/ffi/custom_param_type.rb +0 -37
- data/spec/ffi/custom_type_spec.rb +0 -74
- data/spec/ffi/dup_spec.rb +0 -52
- data/spec/ffi/enum_spec.rb +0 -423
- data/spec/ffi/errno_spec.rb +0 -20
- data/spec/ffi/ffi_spec.rb +0 -28
- data/spec/ffi/fixtures/Benchmark.c +0 -52
- data/spec/ffi/fixtures/BoolTest.c +0 -34
- data/spec/ffi/fixtures/BufferTest.c +0 -31
- data/spec/ffi/fixtures/ClosureTest.c +0 -205
- data/spec/ffi/fixtures/EnumTest.c +0 -51
- data/spec/ffi/fixtures/FunctionTest.c +0 -142
- data/spec/ffi/fixtures/GNUmakefile +0 -149
- data/spec/ffi/fixtures/GlobalVariable.c +0 -62
- data/spec/ffi/fixtures/LastErrorTest.c +0 -21
- data/spec/ffi/fixtures/NumberTest.c +0 -132
- data/spec/ffi/fixtures/PipeHelper.h +0 -21
- data/spec/ffi/fixtures/PipeHelperPosix.c +0 -41
- data/spec/ffi/fixtures/PipeHelperWindows.c +0 -72
- data/spec/ffi/fixtures/PointerTest.c +0 -63
- data/spec/ffi/fixtures/ReferenceTest.c +0 -23
- data/spec/ffi/fixtures/StringTest.c +0 -34
- data/spec/ffi/fixtures/StructTest.c +0 -243
- data/spec/ffi/fixtures/UnionTest.c +0 -43
- data/spec/ffi/fixtures/VariadicTest.c +0 -99
- data/spec/ffi/fixtures/classes.rb +0 -438
- data/spec/ffi/function_spec.rb +0 -97
- data/spec/ffi/io_spec.rb +0 -16
- data/spec/ffi/library_spec.rb +0 -286
- data/spec/ffi/long_double.rb +0 -30
- data/spec/ffi/managed_struct_spec.rb +0 -68
- data/spec/ffi/memorypointer_spec.rb +0 -78
- data/spec/ffi/number_spec.rb +0 -247
- data/spec/ffi/platform_spec.rb +0 -114
- data/spec/ffi/pointer_spec.rb +0 -285
- data/spec/ffi/rbx/attach_function_spec.rb +0 -34
- data/spec/ffi/rbx/memory_pointer_spec.rb +0 -194
- data/spec/ffi/rbx/spec_helper.rb +0 -6
- data/spec/ffi/rbx/struct_spec.rb +0 -18
- data/spec/ffi/spec_helper.rb +0 -93
- data/spec/ffi/string_spec.rb +0 -118
- data/spec/ffi/strptr_spec.rb +0 -50
- data/spec/ffi/struct_by_ref_spec.rb +0 -43
- data/spec/ffi/struct_callback_spec.rb +0 -69
- data/spec/ffi/struct_initialize_spec.rb +0 -35
- data/spec/ffi/struct_packed_spec.rb +0 -50
- data/spec/ffi/struct_spec.rb +0 -886
- data/spec/ffi/typedef_spec.rb +0 -91
- data/spec/ffi/union_spec.rb +0 -67
- data/spec/ffi/variadic_spec.rb +0 -132
- data/spec/spec.opts +0 -4
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* -----------------------------------------------------------------------
|
|
2
|
-
ffi64.c - Copyright (c)
|
|
2
|
+
ffi64.c - Copyright (c) 2013 The Written Word, Inc.
|
|
3
|
+
Copyright (c) 2011 Anthony Green
|
|
3
4
|
Copyright (c) 2008, 2010 Red Hat, Inc.
|
|
4
5
|
Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
|
|
5
|
-
|
|
6
|
-
x86-64 Foreign Function Interface
|
|
6
|
+
|
|
7
|
+
x86-64 Foreign Function Interface
|
|
7
8
|
|
|
8
9
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
9
10
|
a copy of this software and associated documentation files (the
|
|
@@ -31,21 +32,44 @@
|
|
|
31
32
|
|
|
32
33
|
#include <stdlib.h>
|
|
33
34
|
#include <stdarg.h>
|
|
35
|
+
#include <stdint.h>
|
|
36
|
+
#include "internal64.h"
|
|
34
37
|
|
|
35
38
|
#ifdef __x86_64__
|
|
36
39
|
|
|
37
40
|
#define MAX_GPR_REGS 6
|
|
38
41
|
#define MAX_SSE_REGS 8
|
|
39
42
|
|
|
43
|
+
#if defined(__INTEL_COMPILER)
|
|
44
|
+
#include "xmmintrin.h"
|
|
45
|
+
#define UINT128 __m128
|
|
46
|
+
#else
|
|
47
|
+
#if defined(__SUNPRO_C)
|
|
48
|
+
#include <sunmedia_types.h>
|
|
49
|
+
#define UINT128 __m128i
|
|
50
|
+
#else
|
|
51
|
+
#define UINT128 __int128_t
|
|
52
|
+
#endif
|
|
53
|
+
#endif
|
|
54
|
+
|
|
55
|
+
union big_int_union
|
|
56
|
+
{
|
|
57
|
+
UINT32 i32;
|
|
58
|
+
UINT64 i64;
|
|
59
|
+
UINT128 i128;
|
|
60
|
+
};
|
|
61
|
+
|
|
40
62
|
struct register_args
|
|
41
63
|
{
|
|
42
64
|
/* Registers for argument passing. */
|
|
43
65
|
UINT64 gpr[MAX_GPR_REGS];
|
|
44
|
-
|
|
66
|
+
union big_int_union sse[MAX_SSE_REGS];
|
|
67
|
+
UINT64 rax; /* ssecount */
|
|
68
|
+
UINT64 r10; /* static chain */
|
|
45
69
|
};
|
|
46
70
|
|
|
47
71
|
extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
|
|
48
|
-
void *raddr, void (*fnaddr)(void)
|
|
72
|
+
void *raddr, void (*fnaddr)(void)) FFI_HIDDEN;
|
|
49
73
|
|
|
50
74
|
/* All reference to register classes here is identical to the code in
|
|
51
75
|
gcc/config/i386/i386.c. Do *not* change one without the other. */
|
|
@@ -132,7 +156,7 @@ merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
|
|
|
132
156
|
|
|
133
157
|
See the x86-64 PS ABI for details.
|
|
134
158
|
*/
|
|
135
|
-
static
|
|
159
|
+
static size_t
|
|
136
160
|
classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
137
161
|
size_t byte_offset)
|
|
138
162
|
{
|
|
@@ -147,8 +171,9 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
|
147
171
|
case FFI_TYPE_UINT64:
|
|
148
172
|
case FFI_TYPE_SINT64:
|
|
149
173
|
case FFI_TYPE_POINTER:
|
|
174
|
+
do_integer:
|
|
150
175
|
{
|
|
151
|
-
|
|
176
|
+
size_t size = byte_offset + type->size;
|
|
152
177
|
|
|
153
178
|
if (size <= 4)
|
|
154
179
|
{
|
|
@@ -168,7 +193,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
|
168
193
|
}
|
|
169
194
|
else if (size <= 16)
|
|
170
195
|
{
|
|
171
|
-
classes[0] = classes[1] =
|
|
196
|
+
classes[0] = classes[1] = X86_64_INTEGER_CLASS;
|
|
172
197
|
return 2;
|
|
173
198
|
}
|
|
174
199
|
else
|
|
@@ -183,16 +208,18 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
|
183
208
|
case FFI_TYPE_DOUBLE:
|
|
184
209
|
classes[0] = X86_64_SSEDF_CLASS;
|
|
185
210
|
return 1;
|
|
211
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
|
186
212
|
case FFI_TYPE_LONGDOUBLE:
|
|
187
213
|
classes[0] = X86_64_X87_CLASS;
|
|
188
214
|
classes[1] = X86_64_X87UP_CLASS;
|
|
189
215
|
return 2;
|
|
216
|
+
#endif
|
|
190
217
|
case FFI_TYPE_STRUCT:
|
|
191
218
|
{
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
ffi_type **ptr;
|
|
195
|
-
int i;
|
|
219
|
+
const size_t UNITS_PER_WORD = 8;
|
|
220
|
+
size_t words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
|
|
221
|
+
ffi_type **ptr;
|
|
222
|
+
unsigned int i;
|
|
196
223
|
enum x86_64_reg_class subclasses[MAX_CLASSES];
|
|
197
224
|
|
|
198
225
|
/* If the struct is larger than 32 bytes, pass it on the stack. */
|
|
@@ -206,6 +233,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
|
206
233
|
signalize memory class, so handle it as special case. */
|
|
207
234
|
if (!words)
|
|
208
235
|
{
|
|
236
|
+
case FFI_TYPE_VOID:
|
|
209
237
|
classes[0] = X86_64_NO_CLASS;
|
|
210
238
|
return 1;
|
|
211
239
|
}
|
|
@@ -213,16 +241,16 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
|
213
241
|
/* Merge the fields of structure. */
|
|
214
242
|
for (ptr = type->elements; *ptr != NULL; ptr++)
|
|
215
243
|
{
|
|
216
|
-
|
|
244
|
+
size_t num;
|
|
217
245
|
|
|
218
|
-
byte_offset =
|
|
246
|
+
byte_offset = FFI_ALIGN (byte_offset, (*ptr)->alignment);
|
|
219
247
|
|
|
220
248
|
num = classify_argument (*ptr, subclasses, byte_offset % 8);
|
|
221
249
|
if (num == 0)
|
|
222
250
|
return 0;
|
|
223
251
|
for (i = 0; i < num; i++)
|
|
224
252
|
{
|
|
225
|
-
|
|
253
|
+
size_t pos = byte_offset / 8;
|
|
226
254
|
classes[i + pos] =
|
|
227
255
|
merge_classes (subclasses[i], classes[i + pos]);
|
|
228
256
|
}
|
|
@@ -275,22 +303,55 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
|
|
|
275
303
|
}
|
|
276
304
|
return words;
|
|
277
305
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
306
|
+
case FFI_TYPE_COMPLEX:
|
|
307
|
+
{
|
|
308
|
+
ffi_type *inner = type->elements[0];
|
|
309
|
+
switch (inner->type)
|
|
310
|
+
{
|
|
311
|
+
case FFI_TYPE_INT:
|
|
312
|
+
case FFI_TYPE_UINT8:
|
|
313
|
+
case FFI_TYPE_SINT8:
|
|
314
|
+
case FFI_TYPE_UINT16:
|
|
315
|
+
case FFI_TYPE_SINT16:
|
|
316
|
+
case FFI_TYPE_UINT32:
|
|
317
|
+
case FFI_TYPE_SINT32:
|
|
318
|
+
case FFI_TYPE_UINT64:
|
|
319
|
+
case FFI_TYPE_SINT64:
|
|
320
|
+
goto do_integer;
|
|
321
|
+
|
|
322
|
+
case FFI_TYPE_FLOAT:
|
|
323
|
+
classes[0] = X86_64_SSE_CLASS;
|
|
324
|
+
if (byte_offset % 8)
|
|
325
|
+
{
|
|
326
|
+
classes[1] = X86_64_SSESF_CLASS;
|
|
327
|
+
return 2;
|
|
328
|
+
}
|
|
329
|
+
return 1;
|
|
330
|
+
case FFI_TYPE_DOUBLE:
|
|
331
|
+
classes[0] = classes[1] = X86_64_SSEDF_CLASS;
|
|
332
|
+
return 2;
|
|
333
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
|
334
|
+
case FFI_TYPE_LONGDOUBLE:
|
|
335
|
+
classes[0] = X86_64_COMPLEX_X87_CLASS;
|
|
336
|
+
return 1;
|
|
337
|
+
#endif
|
|
338
|
+
}
|
|
339
|
+
}
|
|
281
340
|
}
|
|
282
|
-
|
|
341
|
+
abort();
|
|
283
342
|
}
|
|
284
343
|
|
|
285
344
|
/* Examine the argument and return set number of register required in each
|
|
286
345
|
class. Return zero iff parameter should be passed in memory, otherwise
|
|
287
346
|
the number of registers. */
|
|
288
347
|
|
|
289
|
-
static
|
|
348
|
+
static size_t
|
|
290
349
|
examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES],
|
|
291
350
|
_Bool in_return, int *pngpr, int *pnsse)
|
|
292
351
|
{
|
|
293
|
-
|
|
352
|
+
size_t n;
|
|
353
|
+
unsigned int i;
|
|
354
|
+
int ngpr, nsse;
|
|
294
355
|
|
|
295
356
|
n = classify_argument (type, classes, 0);
|
|
296
357
|
if (n == 0)
|
|
@@ -328,18 +389,72 @@ examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES],
|
|
|
328
389
|
|
|
329
390
|
/* Perform machine dependent cif processing. */
|
|
330
391
|
|
|
392
|
+
#ifndef __ILP32__
|
|
393
|
+
extern ffi_status
|
|
394
|
+
ffi_prep_cif_machdep_efi64(ffi_cif *cif);
|
|
395
|
+
#endif
|
|
396
|
+
|
|
331
397
|
ffi_status
|
|
332
398
|
ffi_prep_cif_machdep (ffi_cif *cif)
|
|
333
399
|
{
|
|
334
|
-
int gprcount, ssecount, i, avn,
|
|
400
|
+
int gprcount, ssecount, i, avn, ngpr, nsse;
|
|
401
|
+
unsigned flags;
|
|
335
402
|
enum x86_64_reg_class classes[MAX_CLASSES];
|
|
336
|
-
size_t bytes;
|
|
403
|
+
size_t bytes, n, rtype_size;
|
|
404
|
+
ffi_type *rtype;
|
|
405
|
+
|
|
406
|
+
#ifndef __ILP32__
|
|
407
|
+
if (cif->abi == FFI_EFI64)
|
|
408
|
+
return ffi_prep_cif_machdep_efi64(cif);
|
|
409
|
+
#endif
|
|
410
|
+
if (cif->abi != FFI_UNIX64)
|
|
411
|
+
return FFI_BAD_ABI;
|
|
337
412
|
|
|
338
413
|
gprcount = ssecount = 0;
|
|
339
414
|
|
|
340
|
-
|
|
341
|
-
|
|
415
|
+
rtype = cif->rtype;
|
|
416
|
+
rtype_size = rtype->size;
|
|
417
|
+
switch (rtype->type)
|
|
342
418
|
{
|
|
419
|
+
case FFI_TYPE_VOID:
|
|
420
|
+
flags = UNIX64_RET_VOID;
|
|
421
|
+
break;
|
|
422
|
+
case FFI_TYPE_UINT8:
|
|
423
|
+
flags = UNIX64_RET_UINT8;
|
|
424
|
+
break;
|
|
425
|
+
case FFI_TYPE_SINT8:
|
|
426
|
+
flags = UNIX64_RET_SINT8;
|
|
427
|
+
break;
|
|
428
|
+
case FFI_TYPE_UINT16:
|
|
429
|
+
flags = UNIX64_RET_UINT16;
|
|
430
|
+
break;
|
|
431
|
+
case FFI_TYPE_SINT16:
|
|
432
|
+
flags = UNIX64_RET_SINT16;
|
|
433
|
+
break;
|
|
434
|
+
case FFI_TYPE_UINT32:
|
|
435
|
+
flags = UNIX64_RET_UINT32;
|
|
436
|
+
break;
|
|
437
|
+
case FFI_TYPE_INT:
|
|
438
|
+
case FFI_TYPE_SINT32:
|
|
439
|
+
flags = UNIX64_RET_SINT32;
|
|
440
|
+
break;
|
|
441
|
+
case FFI_TYPE_UINT64:
|
|
442
|
+
case FFI_TYPE_SINT64:
|
|
443
|
+
flags = UNIX64_RET_INT64;
|
|
444
|
+
break;
|
|
445
|
+
case FFI_TYPE_POINTER:
|
|
446
|
+
flags = (sizeof(void *) == 4 ? UNIX64_RET_UINT32 : UNIX64_RET_INT64);
|
|
447
|
+
break;
|
|
448
|
+
case FFI_TYPE_FLOAT:
|
|
449
|
+
flags = UNIX64_RET_XMM32;
|
|
450
|
+
break;
|
|
451
|
+
case FFI_TYPE_DOUBLE:
|
|
452
|
+
flags = UNIX64_RET_XMM64;
|
|
453
|
+
break;
|
|
454
|
+
case FFI_TYPE_LONGDOUBLE:
|
|
455
|
+
flags = UNIX64_RET_X87;
|
|
456
|
+
break;
|
|
457
|
+
case FFI_TYPE_STRUCT:
|
|
343
458
|
n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
|
|
344
459
|
if (n == 0)
|
|
345
460
|
{
|
|
@@ -347,22 +462,62 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
|
|
347
462
|
memory is the first argument. Allocate a register for it. */
|
|
348
463
|
gprcount++;
|
|
349
464
|
/* We don't have to do anything in asm for the return. */
|
|
350
|
-
flags =
|
|
465
|
+
flags = UNIX64_RET_VOID | UNIX64_FLAG_RET_IN_MEM;
|
|
351
466
|
}
|
|
352
|
-
else
|
|
467
|
+
else
|
|
353
468
|
{
|
|
354
|
-
/* Mark which registers the result appears in. */
|
|
355
469
|
_Bool sse0 = SSE_CLASS_P (classes[0]);
|
|
356
|
-
|
|
357
|
-
if (
|
|
358
|
-
flags
|
|
359
|
-
else if (
|
|
360
|
-
flags
|
|
361
|
-
else
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
470
|
+
|
|
471
|
+
if (rtype_size == 4 && sse0)
|
|
472
|
+
flags = UNIX64_RET_XMM32;
|
|
473
|
+
else if (rtype_size == 8)
|
|
474
|
+
flags = sse0 ? UNIX64_RET_XMM64 : UNIX64_RET_INT64;
|
|
475
|
+
else
|
|
476
|
+
{
|
|
477
|
+
_Bool sse1 = n == 2 && SSE_CLASS_P (classes[1]);
|
|
478
|
+
if (sse0 && sse1)
|
|
479
|
+
flags = UNIX64_RET_ST_XMM0_XMM1;
|
|
480
|
+
else if (sse0)
|
|
481
|
+
flags = UNIX64_RET_ST_XMM0_RAX;
|
|
482
|
+
else if (sse1)
|
|
483
|
+
flags = UNIX64_RET_ST_RAX_XMM0;
|
|
484
|
+
else
|
|
485
|
+
flags = UNIX64_RET_ST_RAX_RDX;
|
|
486
|
+
flags |= rtype_size << UNIX64_SIZE_SHIFT;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
break;
|
|
490
|
+
case FFI_TYPE_COMPLEX:
|
|
491
|
+
switch (rtype->elements[0]->type)
|
|
492
|
+
{
|
|
493
|
+
case FFI_TYPE_UINT8:
|
|
494
|
+
case FFI_TYPE_SINT8:
|
|
495
|
+
case FFI_TYPE_UINT16:
|
|
496
|
+
case FFI_TYPE_SINT16:
|
|
497
|
+
case FFI_TYPE_INT:
|
|
498
|
+
case FFI_TYPE_UINT32:
|
|
499
|
+
case FFI_TYPE_SINT32:
|
|
500
|
+
case FFI_TYPE_UINT64:
|
|
501
|
+
case FFI_TYPE_SINT64:
|
|
502
|
+
flags = UNIX64_RET_ST_RAX_RDX | ((unsigned) rtype_size << UNIX64_SIZE_SHIFT);
|
|
503
|
+
break;
|
|
504
|
+
case FFI_TYPE_FLOAT:
|
|
505
|
+
flags = UNIX64_RET_XMM64;
|
|
506
|
+
break;
|
|
507
|
+
case FFI_TYPE_DOUBLE:
|
|
508
|
+
flags = UNIX64_RET_ST_XMM0_XMM1 | (16 << UNIX64_SIZE_SHIFT);
|
|
509
|
+
break;
|
|
510
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
|
511
|
+
case FFI_TYPE_LONGDOUBLE:
|
|
512
|
+
flags = UNIX64_RET_X87_2;
|
|
513
|
+
break;
|
|
514
|
+
#endif
|
|
515
|
+
default:
|
|
516
|
+
return FFI_BAD_TYPEDEF;
|
|
365
517
|
}
|
|
518
|
+
break;
|
|
519
|
+
default:
|
|
520
|
+
return FFI_BAD_TYPEDEF;
|
|
366
521
|
}
|
|
367
522
|
|
|
368
523
|
/* Go over all arguments and determine the way they should be passed.
|
|
@@ -379,7 +534,7 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
|
|
379
534
|
if (align < 8)
|
|
380
535
|
align = 8;
|
|
381
536
|
|
|
382
|
-
bytes =
|
|
537
|
+
bytes = FFI_ALIGN (bytes, align);
|
|
383
538
|
bytes += cif->arg_types[i]->size;
|
|
384
539
|
}
|
|
385
540
|
else
|
|
@@ -389,53 +544,58 @@ ffi_prep_cif_machdep (ffi_cif *cif)
|
|
|
389
544
|
}
|
|
390
545
|
}
|
|
391
546
|
if (ssecount)
|
|
392
|
-
flags |=
|
|
547
|
+
flags |= UNIX64_FLAG_XMM_ARGS;
|
|
548
|
+
|
|
393
549
|
cif->flags = flags;
|
|
394
|
-
cif->bytes =
|
|
550
|
+
cif->bytes = (unsigned) FFI_ALIGN (bytes, 8);
|
|
395
551
|
|
|
396
552
|
return FFI_OK;
|
|
397
553
|
}
|
|
398
554
|
|
|
399
|
-
void
|
|
400
|
-
|
|
555
|
+
static void
|
|
556
|
+
ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
|
557
|
+
void **avalue, void *closure)
|
|
401
558
|
{
|
|
402
559
|
enum x86_64_reg_class classes[MAX_CLASSES];
|
|
403
560
|
char *stack, *argp;
|
|
404
561
|
ffi_type **arg_types;
|
|
405
|
-
int gprcount, ssecount, ngpr, nsse, i, avn;
|
|
406
|
-
_Bool ret_in_memory;
|
|
562
|
+
int gprcount, ssecount, ngpr, nsse, i, avn, flags;
|
|
407
563
|
struct register_args *reg_args;
|
|
408
564
|
|
|
409
565
|
/* Can't call 32-bit mode from 64-bit mode. */
|
|
410
566
|
FFI_ASSERT (cif->abi == FFI_UNIX64);
|
|
411
567
|
|
|
412
568
|
/* If the return value is a struct and we don't have a return value
|
|
413
|
-
address then we need to make one.
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
569
|
+
address then we need to make one. Otherwise we can ignore it. */
|
|
570
|
+
flags = cif->flags;
|
|
571
|
+
if (rvalue == NULL)
|
|
572
|
+
{
|
|
573
|
+
if (flags & UNIX64_FLAG_RET_IN_MEM)
|
|
574
|
+
rvalue = alloca (cif->rtype->size);
|
|
575
|
+
else
|
|
576
|
+
flags = UNIX64_RET_VOID;
|
|
577
|
+
}
|
|
419
578
|
|
|
420
579
|
/* Allocate the space for the arguments, plus 4 words of temp space. */
|
|
421
580
|
stack = alloca (sizeof (struct register_args) + cif->bytes + 4*8);
|
|
422
581
|
reg_args = (struct register_args *) stack;
|
|
423
582
|
argp = stack + sizeof (struct register_args);
|
|
424
583
|
|
|
584
|
+
reg_args->r10 = (uintptr_t) closure;
|
|
585
|
+
|
|
425
586
|
gprcount = ssecount = 0;
|
|
426
587
|
|
|
427
588
|
/* If the return value is passed in memory, add the pointer as the
|
|
428
589
|
first integer argument. */
|
|
429
|
-
if (
|
|
430
|
-
reg_args->gpr[gprcount++] = (long) rvalue;
|
|
590
|
+
if (flags & UNIX64_FLAG_RET_IN_MEM)
|
|
591
|
+
reg_args->gpr[gprcount++] = (unsigned long) rvalue;
|
|
431
592
|
|
|
432
593
|
avn = cif->nargs;
|
|
433
594
|
arg_types = cif->arg_types;
|
|
434
595
|
|
|
435
596
|
for (i = 0; i < avn; ++i)
|
|
436
597
|
{
|
|
437
|
-
size_t size = arg_types[i]->size;
|
|
438
|
-
int n;
|
|
598
|
+
size_t n, size = arg_types[i]->size;
|
|
439
599
|
|
|
440
600
|
n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
|
|
441
601
|
if (n == 0
|
|
@@ -449,7 +609,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
|
|
449
609
|
align = 8;
|
|
450
610
|
|
|
451
611
|
/* Pass this argument in memory. */
|
|
452
|
-
argp = (void *)
|
|
612
|
+
argp = (void *) FFI_ALIGN (argp, align);
|
|
453
613
|
memcpy (argp, avalue[i], size);
|
|
454
614
|
argp += size;
|
|
455
615
|
}
|
|
@@ -457,24 +617,44 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
|
|
457
617
|
{
|
|
458
618
|
/* The argument is passed entirely in registers. */
|
|
459
619
|
char *a = (char *) avalue[i];
|
|
460
|
-
int j;
|
|
620
|
+
unsigned int j;
|
|
461
621
|
|
|
462
622
|
for (j = 0; j < n; j++, a += 8, size -= 8)
|
|
463
623
|
{
|
|
464
624
|
switch (classes[j])
|
|
465
625
|
{
|
|
626
|
+
case X86_64_NO_CLASS:
|
|
627
|
+
case X86_64_SSEUP_CLASS:
|
|
628
|
+
break;
|
|
466
629
|
case X86_64_INTEGER_CLASS:
|
|
467
630
|
case X86_64_INTEGERSI_CLASS:
|
|
468
|
-
|
|
469
|
-
|
|
631
|
+
/* Sign-extend integer arguments passed in general
|
|
632
|
+
purpose registers, to cope with the fact that
|
|
633
|
+
LLVM incorrectly assumes that this will be done
|
|
634
|
+
(the x86-64 PS ABI does not specify this). */
|
|
635
|
+
switch (arg_types[i]->type)
|
|
636
|
+
{
|
|
637
|
+
case FFI_TYPE_SINT8:
|
|
638
|
+
reg_args->gpr[gprcount] = (SINT64) *((SINT8 *) a);
|
|
639
|
+
break;
|
|
640
|
+
case FFI_TYPE_SINT16:
|
|
641
|
+
reg_args->gpr[gprcount] = (SINT64) *((SINT16 *) a);
|
|
642
|
+
break;
|
|
643
|
+
case FFI_TYPE_SINT32:
|
|
644
|
+
reg_args->gpr[gprcount] = (SINT64) *((SINT32 *) a);
|
|
645
|
+
break;
|
|
646
|
+
default:
|
|
647
|
+
reg_args->gpr[gprcount] = 0;
|
|
648
|
+
memcpy (®_args->gpr[gprcount], a, size);
|
|
649
|
+
}
|
|
470
650
|
gprcount++;
|
|
471
651
|
break;
|
|
472
652
|
case X86_64_SSE_CLASS:
|
|
473
653
|
case X86_64_SSEDF_CLASS:
|
|
474
|
-
reg_args->sse[ssecount++]
|
|
654
|
+
memcpy (®_args->sse[ssecount++].i64, a, sizeof(UINT64));
|
|
475
655
|
break;
|
|
476
656
|
case X86_64_SSESF_CLASS:
|
|
477
|
-
reg_args->sse[ssecount++]
|
|
657
|
+
memcpy (®_args->sse[ssecount++].i32, a, sizeof(UINT32));
|
|
478
658
|
break;
|
|
479
659
|
default:
|
|
480
660
|
abort();
|
|
@@ -482,13 +662,56 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
|
|
482
662
|
}
|
|
483
663
|
}
|
|
484
664
|
}
|
|
665
|
+
reg_args->rax = ssecount;
|
|
485
666
|
|
|
486
667
|
ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args),
|
|
487
|
-
|
|
668
|
+
flags, rvalue, fn);
|
|
488
669
|
}
|
|
489
670
|
|
|
671
|
+
#ifndef __ILP32__
|
|
672
|
+
extern void
|
|
673
|
+
ffi_call_efi64(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue);
|
|
674
|
+
#endif
|
|
490
675
|
|
|
491
|
-
|
|
676
|
+
void
|
|
677
|
+
ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
|
678
|
+
{
|
|
679
|
+
#ifndef __ILP32__
|
|
680
|
+
if (cif->abi == FFI_EFI64)
|
|
681
|
+
return ffi_call_efi64(cif, fn, rvalue, avalue);
|
|
682
|
+
#endif
|
|
683
|
+
ffi_call_int (cif, fn, rvalue, avalue, NULL);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
#ifndef __ILP32__
|
|
687
|
+
extern void
|
|
688
|
+
ffi_call_go_efi64(ffi_cif *cif, void (*fn)(void), void *rvalue,
|
|
689
|
+
void **avalue, void *closure);
|
|
690
|
+
#endif
|
|
691
|
+
|
|
692
|
+
void
|
|
693
|
+
ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
|
|
694
|
+
void **avalue, void *closure)
|
|
695
|
+
{
|
|
696
|
+
#ifndef __ILP32__
|
|
697
|
+
if (cif->abi == FFI_EFI64)
|
|
698
|
+
ffi_call_go_efi64(cif, fn, rvalue, avalue, closure);
|
|
699
|
+
#endif
|
|
700
|
+
ffi_call_int (cif, fn, rvalue, avalue, closure);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
extern void ffi_closure_unix64(void) FFI_HIDDEN;
|
|
705
|
+
extern void ffi_closure_unix64_sse(void) FFI_HIDDEN;
|
|
706
|
+
|
|
707
|
+
#ifndef __ILP32__
|
|
708
|
+
extern ffi_status
|
|
709
|
+
ffi_prep_closure_loc_efi64(ffi_closure* closure,
|
|
710
|
+
ffi_cif* cif,
|
|
711
|
+
void (*fun)(ffi_cif*, void*, void**, void*),
|
|
712
|
+
void *user_data,
|
|
713
|
+
void *codeloc);
|
|
714
|
+
#endif
|
|
492
715
|
|
|
493
716
|
ffi_status
|
|
494
717
|
ffi_prep_closure_loc (ffi_closure* closure,
|
|
@@ -497,27 +720,31 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
|
497
720
|
void *user_data,
|
|
498
721
|
void *codeloc)
|
|
499
722
|
{
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
tramp =
|
|
723
|
+
static const unsigned char trampoline[16] = {
|
|
724
|
+
/* leaq -0x7(%rip),%r10 # 0x0 */
|
|
725
|
+
0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff,
|
|
726
|
+
/* jmpq *0x3(%rip) # 0x10 */
|
|
727
|
+
0xff, 0x25, 0x03, 0x00, 0x00, 0x00,
|
|
728
|
+
/* nopl (%rax) */
|
|
729
|
+
0x0f, 0x1f, 0x00
|
|
730
|
+
};
|
|
731
|
+
void (*dest)(void);
|
|
732
|
+
char *tramp = closure->tramp;
|
|
510
733
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
734
|
+
#ifndef __ILP32__
|
|
735
|
+
if (cif->abi == FFI_EFI64)
|
|
736
|
+
return ffi_prep_closure_loc_efi64(closure, cif, fun, user_data, codeloc);
|
|
737
|
+
#endif
|
|
738
|
+
if (cif->abi != FFI_UNIX64)
|
|
739
|
+
return FFI_BAD_ABI;
|
|
515
740
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
741
|
+
if (cif->flags & UNIX64_FLAG_XMM_ARGS)
|
|
742
|
+
dest = ffi_closure_unix64_sse;
|
|
743
|
+
else
|
|
744
|
+
dest = ffi_closure_unix64;
|
|
519
745
|
|
|
520
|
-
tramp
|
|
746
|
+
memcpy (tramp, trampoline, sizeof(trampoline));
|
|
747
|
+
*(UINT64 *)(tramp + 16) = (uintptr_t)dest;
|
|
521
748
|
|
|
522
749
|
closure->cif = cif;
|
|
523
750
|
closure->fun = fun;
|
|
@@ -526,53 +753,40 @@ ffi_prep_closure_loc (ffi_closure* closure,
|
|
|
526
753
|
return FFI_OK;
|
|
527
754
|
}
|
|
528
755
|
|
|
529
|
-
int
|
|
530
|
-
ffi_closure_unix64_inner(
|
|
531
|
-
|
|
756
|
+
int FFI_HIDDEN
|
|
757
|
+
ffi_closure_unix64_inner(ffi_cif *cif,
|
|
758
|
+
void (*fun)(ffi_cif*, void*, void**, void*),
|
|
759
|
+
void *user_data,
|
|
760
|
+
void *rvalue,
|
|
761
|
+
struct register_args *reg_args,
|
|
762
|
+
char *argp)
|
|
532
763
|
{
|
|
533
|
-
ffi_cif *cif;
|
|
534
764
|
void **avalue;
|
|
535
765
|
ffi_type **arg_types;
|
|
536
766
|
long i, avn;
|
|
537
767
|
int gprcount, ssecount, ngpr, nsse;
|
|
538
|
-
int
|
|
768
|
+
int flags;
|
|
539
769
|
|
|
540
|
-
|
|
541
|
-
|
|
770
|
+
avn = cif->nargs;
|
|
771
|
+
flags = cif->flags;
|
|
772
|
+
avalue = alloca(avn * sizeof(void *));
|
|
542
773
|
gprcount = ssecount = 0;
|
|
543
774
|
|
|
544
|
-
|
|
545
|
-
if (ret != FFI_TYPE_VOID)
|
|
775
|
+
if (flags & UNIX64_FLAG_RET_IN_MEM)
|
|
546
776
|
{
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
rvalue = (void *) reg_args->gpr[gprcount++];
|
|
554
|
-
/* We don't have to do anything in asm for the return. */
|
|
555
|
-
ret = FFI_TYPE_VOID;
|
|
556
|
-
}
|
|
557
|
-
else if (ret == FFI_TYPE_STRUCT && n == 2)
|
|
558
|
-
{
|
|
559
|
-
/* Mark which register the second word of the structure goes in. */
|
|
560
|
-
_Bool sse0 = SSE_CLASS_P (classes[0]);
|
|
561
|
-
_Bool sse1 = SSE_CLASS_P (classes[1]);
|
|
562
|
-
if (!sse0 && sse1)
|
|
563
|
-
ret |= 1 << 8;
|
|
564
|
-
else if (sse0 && !sse1)
|
|
565
|
-
ret |= 1 << 9;
|
|
566
|
-
}
|
|
777
|
+
/* On return, %rax will contain the address that was passed
|
|
778
|
+
by the caller in %rdi. */
|
|
779
|
+
void *r = (void *)(uintptr_t)reg_args->gpr[gprcount++];
|
|
780
|
+
*(void **)rvalue = r;
|
|
781
|
+
rvalue = r;
|
|
782
|
+
flags = (sizeof(void *) == 4 ? UNIX64_RET_UINT32 : UNIX64_RET_INT64);
|
|
567
783
|
}
|
|
568
784
|
|
|
569
|
-
avn = cif->nargs;
|
|
570
785
|
arg_types = cif->arg_types;
|
|
571
|
-
|
|
572
786
|
for (i = 0; i < avn; ++i)
|
|
573
787
|
{
|
|
574
788
|
enum x86_64_reg_class classes[MAX_CLASSES];
|
|
575
|
-
|
|
789
|
+
size_t n;
|
|
576
790
|
|
|
577
791
|
n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
|
|
578
792
|
if (n == 0
|
|
@@ -586,7 +800,7 @@ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
|
|
|
586
800
|
align = 8;
|
|
587
801
|
|
|
588
802
|
/* Pass this argument in memory. */
|
|
589
|
-
argp = (void *)
|
|
803
|
+
argp = (void *) FFI_ALIGN (argp, align);
|
|
590
804
|
avalue[i] = argp;
|
|
591
805
|
argp += arg_types[i]->size;
|
|
592
806
|
}
|
|
@@ -612,7 +826,7 @@ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
|
|
|
612
826
|
else
|
|
613
827
|
{
|
|
614
828
|
char *a = alloca (16);
|
|
615
|
-
int j;
|
|
829
|
+
unsigned int j;
|
|
616
830
|
|
|
617
831
|
avalue[i] = a;
|
|
618
832
|
for (j = 0; j < n; j++, a += 8)
|
|
@@ -626,10 +840,39 @@ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
|
|
|
626
840
|
}
|
|
627
841
|
|
|
628
842
|
/* Invoke the closure. */
|
|
629
|
-
|
|
843
|
+
fun (cif, rvalue, avalue, user_data);
|
|
630
844
|
|
|
631
845
|
/* Tell assembly how to perform return type promotions. */
|
|
632
|
-
return
|
|
846
|
+
return flags;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
extern void ffi_go_closure_unix64(void) FFI_HIDDEN;
|
|
850
|
+
extern void ffi_go_closure_unix64_sse(void) FFI_HIDDEN;
|
|
851
|
+
|
|
852
|
+
#ifndef __ILP32__
|
|
853
|
+
extern ffi_status
|
|
854
|
+
ffi_prep_go_closure_efi64(ffi_go_closure* closure, ffi_cif* cif,
|
|
855
|
+
void (*fun)(ffi_cif*, void*, void**, void*));
|
|
856
|
+
#endif
|
|
857
|
+
|
|
858
|
+
ffi_status
|
|
859
|
+
ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
|
|
860
|
+
void (*fun)(ffi_cif*, void*, void**, void*))
|
|
861
|
+
{
|
|
862
|
+
#ifndef __ILP32__
|
|
863
|
+
if (cif->abi == FFI_EFI64)
|
|
864
|
+
return ffi_prep_go_closure_efi64(closure, cif, fun);
|
|
865
|
+
#endif
|
|
866
|
+
if (cif->abi != FFI_UNIX64)
|
|
867
|
+
return FFI_BAD_ABI;
|
|
868
|
+
|
|
869
|
+
closure->tramp = (cif->flags & UNIX64_FLAG_XMM_ARGS
|
|
870
|
+
? ffi_go_closure_unix64_sse
|
|
871
|
+
: ffi_go_closure_unix64);
|
|
872
|
+
closure->cif = cif;
|
|
873
|
+
closure->fun = fun;
|
|
874
|
+
|
|
875
|
+
return FFI_OK;
|
|
633
876
|
}
|
|
634
877
|
|
|
635
878
|
#endif /* __x86_64__ */
|