ffi 1.9.18-x86-mingw32 → 1.9.21-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/README.md +3 -2
- data/Rakefile +14 -4
- data/ext/ffi_c/AbstractMemory.c +6 -1
- data/ext/ffi_c/Platform.c +10 -2
- data/ext/ffi_c/extconf.rb +7 -2
- data/ext/ffi_c/libffi.bsd.mk +9 -3
- data/ext/ffi_c/libffi.darwin.mk +14 -4
- data/ext/ffi_c/libffi.gnu.mk +2 -1
- data/ext/ffi_c/libffi.mk +9 -4
- 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 +166 -157
- data/ext/ffi_c/libffi/Makefile.in +923 -938
- data/ext/ffi_c/libffi/README +164 -52
- data/ext/ffi_c/libffi/acinclude.m4 +381 -0
- data/ext/ffi_c/libffi/aclocal.m4 +645 -384
- data/ext/ffi_c/libffi/autogen.sh +2 -0
- data/ext/ffi_c/libffi/autom4te.cache/output.0 +21972 -0
- data/ext/ffi_c/libffi/autom4te.cache/output.1 +21972 -0
- data/ext/ffi_c/libffi/autom4te.cache/output.2 +21972 -0
- data/ext/ffi_c/libffi/autom4te.cache/output.3 +21972 -0
- data/ext/ffi_c/libffi/autom4te.cache/requests +331 -0
- data/ext/ffi_c/libffi/autom4te.cache/traces.0 +4010 -0
- data/ext/ffi_c/libffi/autom4te.cache/traces.1 +1005 -0
- data/ext/ffi_c/libffi/autom4te.cache/traces.2 +4010 -0
- data/ext/ffi_c/libffi/autom4te.cache/traces.3 +4010 -0
- data/ext/ffi_c/libffi/compile +218 -14
- data/ext/ffi_c/libffi/config.guess +329 -368
- data/ext/ffi_c/libffi/config.sub +232 -112
- data/ext/ffi_c/libffi/configure +6970 -2189
- data/ext/ffi_c/libffi/configure.ac +148 -256
- data/ext/ffi_c/libffi/configure.host +265 -4
- data/ext/ffi_c/libffi/depcomp +346 -185
- 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/{mdate-sh → doc/mdate-sh} +40 -13
- data/ext/ffi_c/libffi/{texinfo.tex → doc/texinfo.tex} +3990 -1121
- 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/fficonfig.h.in~ +210 -0
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +207 -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 +107 -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 +637 -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/m4/libtool.m4 +1691 -1135
- data/ext/ffi_c/libffi/m4/ltoptions.m4 +104 -36
- data/ext/ffi_c/libffi/m4/ltsugar.m4 +4 -3
- data/ext/ffi_c/libffi/m4/ltversion.m4 +6 -6
- data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +4 -3
- 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 +941 -0
- data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +81 -0
- data/ext/ffi_c/libffi/src/aarch64/internal.h +67 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +438 -0
- data/ext/ffi_c/libffi/src/alpha/ffi.c +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 +597 -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 +319 -44
- 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/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 +95 -28
- data/ext/ffi_c/libffi/src/mips/ffitarget.h +9 -2
- data/ext/ffi_c/libffi/src/mips/n32.S +126 -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 +6 -6
- data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +3 -1
- 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 +25 -25
- 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 +100 -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 +589 -500
- data/ext/ffi_c/libffi/src/x86/ffi64.c +338 -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 +78 -73
- data/ext/ffi_c/libffi/testsuite/Makefile.in +218 -111
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +120 -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_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/ffi.gemspec +2 -2
- data/lib/2.0/ffi_c.so +0 -0
- data/lib/2.1/ffi_c.so +0 -0
- data/lib/2.2/ffi_c.so +0 -0
- data/lib/2.3/ffi_c.so +0 -0
- data/lib/2.4/ffi_c.so +0 -0
- data/lib/2.5/ffi_c.so +0 -0
- data/lib/ffi/enum.rb +124 -0
- data/lib/ffi/library.rb +65 -13
- data/lib/ffi/platform.rb +7 -2
- data/lib/ffi/platform/sparc64-linux/types.conf +102 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +113 -20
- data/lib/ffi/pointer.rb +1 -0
- data/lib/ffi/struct.rb +0 -2
- data/lib/ffi/version.rb +1 -1
- data/spec/ffi/bitmask_spec.rb +575 -0
- data/spec/ffi/embed-test/ext/Makefile +242 -0
- data/spec/ffi/fixtures/BitmaskTest.c +51 -0
- data/spec/ffi/rbx/memory_pointer_spec.rb +4 -0
- data/spec/ffi/struct_spec.rb +0 -4
- metadata +158 -32
- data/ext/ffi_c/libffi/Makefile.vc +0 -141
- data/ext/ffi_c/libffi/Makefile.vc64 +0 -141
- data/ext/ffi_c/libffi/build-ios.sh +0 -67
- 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/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
@@ -0,0 +1,58 @@
|
|
1
|
+
/* -----------------------------------------------------------------------
|
2
|
+
ffitarget.h - Copyright (c) 2014 Sebastian Macke <sebastian@macke.de>
|
3
|
+
|
4
|
+
OpenRISC Target configuration macros
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
``Software''), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included
|
15
|
+
in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
24
|
+
DEALINGS IN THE SOFTWARE.
|
25
|
+
----------------------------------------------------------------------- */
|
26
|
+
|
27
|
+
#ifndef LIBFFI_TARGET_H
|
28
|
+
#define LIBFFI_TARGET_H
|
29
|
+
|
30
|
+
#ifndef LIBFFI_H
|
31
|
+
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
|
32
|
+
#endif
|
33
|
+
|
34
|
+
/* ---- System specific configurations ----------------------------------- */
|
35
|
+
|
36
|
+
#ifndef LIBFFI_ASM
|
37
|
+
typedef unsigned long ffi_arg;
|
38
|
+
typedef signed long ffi_sarg;
|
39
|
+
|
40
|
+
typedef enum ffi_abi {
|
41
|
+
FFI_FIRST_ABI = 0,
|
42
|
+
FFI_SYSV,
|
43
|
+
FFI_LAST_ABI,
|
44
|
+
FFI_DEFAULT_ABI = FFI_SYSV
|
45
|
+
} ffi_abi;
|
46
|
+
#endif
|
47
|
+
|
48
|
+
/* ---- Definitions for closures ----------------------------------------- */
|
49
|
+
|
50
|
+
#define FFI_CLOSURES 1
|
51
|
+
#define FFI_NATIVE_RAW_API 0
|
52
|
+
#define FFI_TRAMPOLINE_SIZE (24)
|
53
|
+
|
54
|
+
#define FFI_TARGET_SPECIFIC_VARIADIC 1
|
55
|
+
#define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs;
|
56
|
+
|
57
|
+
#endif
|
58
|
+
|
@@ -0,0 +1,107 @@
|
|
1
|
+
/* -----------------------------------------------------------------------
|
2
|
+
sysv.S - Copyright (c) 2014 Sebastian Macke <sebastian@macke.de>
|
3
|
+
|
4
|
+
OpenRISC Foreign Function Interface
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
``Software''), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included
|
15
|
+
in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
24
|
+
DEALINGS IN THE SOFTWARE.
|
25
|
+
----------------------------------------------------------------------- */
|
26
|
+
|
27
|
+
#define LIBFFI_ASM
|
28
|
+
#include <fficonfig.h>
|
29
|
+
#include <ffi.h>
|
30
|
+
|
31
|
+
.text
|
32
|
+
.globl ffi_call_SYSV
|
33
|
+
.type ffi_call_SYSV, @function
|
34
|
+
/*
|
35
|
+
r3: size to allocate on stack
|
36
|
+
r4: extended cif structure
|
37
|
+
r5: function pointer ffi_prep_args
|
38
|
+
r6: ret address
|
39
|
+
r7: function to call
|
40
|
+
r8: flag for return type
|
41
|
+
*/
|
42
|
+
|
43
|
+
ffi_call_SYSV:
|
44
|
+
/* Store registers used on stack */
|
45
|
+
l.sw -4(r1), r9 /* return address */
|
46
|
+
l.sw -8(r1), r1 /* stack address */
|
47
|
+
l.sw -12(r1), r14 /* callee saved registers */
|
48
|
+
l.sw -16(r1), r16
|
49
|
+
l.sw -20(r1), r18
|
50
|
+
l.sw -24(r1), r20
|
51
|
+
|
52
|
+
l.ori r14, r1, 0x0 /* save stack pointer */
|
53
|
+
l.addi r1, r1, -24
|
54
|
+
|
55
|
+
l.ori r16, r7, 0x0 /* save function address */
|
56
|
+
l.ori r18, r6, 0x0 /* save ret address */
|
57
|
+
l.ori r20, r8, 0x0 /* save flag */
|
58
|
+
|
59
|
+
l.sub r1, r1, r3 /* reserve space on stack */
|
60
|
+
|
61
|
+
/* Call ffi_prep_args */
|
62
|
+
l.ori r3, r1, 0x0 /* first argument stack address, second already ecif */
|
63
|
+
l.jalr r5
|
64
|
+
l.nop
|
65
|
+
|
66
|
+
/* Load register arguments and call*/
|
67
|
+
|
68
|
+
l.lwz r3, 0(r1)
|
69
|
+
l.lwz r4, 4(r1)
|
70
|
+
l.lwz r5, 8(r1)
|
71
|
+
l.lwz r6, 12(r1)
|
72
|
+
l.lwz r7, 16(r1)
|
73
|
+
l.lwz r8, 20(r1)
|
74
|
+
l.ori r1, r11, 0x0 /* new stack pointer */
|
75
|
+
l.jalr r16
|
76
|
+
l.nop
|
77
|
+
|
78
|
+
/* handle return values */
|
79
|
+
|
80
|
+
l.sfeqi r20, FFI_TYPE_STRUCT
|
81
|
+
l.bf ret /* structs don't return an rvalue */
|
82
|
+
l.nop
|
83
|
+
|
84
|
+
/* copy ret address */
|
85
|
+
|
86
|
+
l.sfeqi r20, FFI_TYPE_UINT64
|
87
|
+
l.bnf four_byte_ret /* 8 byte value is returned */
|
88
|
+
l.nop
|
89
|
+
|
90
|
+
l.sw 4(r18), r12
|
91
|
+
|
92
|
+
four_byte_ret:
|
93
|
+
l.sw 0(r18), r11
|
94
|
+
|
95
|
+
ret:
|
96
|
+
/* return */
|
97
|
+
l.ori r1, r14, 0x0 /* reset stack pointer */
|
98
|
+
l.lwz r9, -4(r1)
|
99
|
+
l.lwz r1, -8(r1)
|
100
|
+
l.lwz r14, -12(r1)
|
101
|
+
l.lwz r16, -16(r1)
|
102
|
+
l.lwz r18, -20(r1)
|
103
|
+
l.lwz r20, -24(r1)
|
104
|
+
l.jr r9
|
105
|
+
l.nop
|
106
|
+
|
107
|
+
.size ffi_call_SYSV, .-ffi_call_SYSV
|
@@ -1,5 +1,6 @@
|
|
1
1
|
/* -----------------------------------------------------------------*-C-*-
|
2
|
-
ffitarget.h - Copyright (c)
|
2
|
+
ffitarget.h - Copyright (c) 2012 Anthony Green
|
3
|
+
Copyright (c) 1996-2003 Red Hat, Inc.
|
3
4
|
Target configuration macros for hppa.
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining
|
@@ -27,6 +28,10 @@
|
|
27
28
|
#ifndef LIBFFI_TARGET_H
|
28
29
|
#define LIBFFI_TARGET_H
|
29
30
|
|
31
|
+
#ifndef LIBFFI_H
|
32
|
+
#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
|
33
|
+
#endif
|
34
|
+
|
30
35
|
/* ---- System specific configurations ----------------------------------- */
|
31
36
|
|
32
37
|
#ifndef LIBFFI_ASM
|
@@ -57,6 +62,8 @@ typedef enum ffi_abi {
|
|
57
62
|
} ffi_abi;
|
58
63
|
#endif
|
59
64
|
|
65
|
+
#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
|
66
|
+
|
60
67
|
/* ---- Definitions for closures ----------------------------------------- */
|
61
68
|
|
62
69
|
#define FFI_CLOSURES 1
|
@@ -137,7 +137,7 @@ ffi_call_AIX:
|
|
137
137
|
mtcrf 0x40, r31
|
138
138
|
mtctr r0
|
139
139
|
/* Load all those argument registers. */
|
140
|
-
|
140
|
+
/* We have set up a nice stack frame, just load it into registers. */
|
141
141
|
ld r3, 40+(1*8)(r1)
|
142
142
|
ld r4, 40+(2*8)(r1)
|
143
143
|
ld r5, 40+(3*8)(r1)
|
@@ -150,7 +150,7 @@ ffi_call_AIX:
|
|
150
150
|
|
151
151
|
L1:
|
152
152
|
/* Load all the FP registers. */
|
153
|
-
bf 6,L2
|
153
|
+
bf 6,L2 /* 2f + 0x18 */
|
154
154
|
lfd f1,-32-(13*8)(r28)
|
155
155
|
lfd f2,-32-(12*8)(r28)
|
156
156
|
lfd f3,-32-(11*8)(r28)
|
@@ -239,7 +239,7 @@ L(float_return_value):
|
|
239
239
|
mtcrf 0x40, r31
|
240
240
|
mtctr r0
|
241
241
|
/* Load all those argument registers. */
|
242
|
-
|
242
|
+
/* We have set up a nice stack frame, just load it into registers. */
|
243
243
|
lwz r3, 20+(1*4)(r1)
|
244
244
|
lwz r4, 20+(2*4)(r1)
|
245
245
|
lwz r5, 20+(3*4)(r1)
|
@@ -252,7 +252,7 @@ L(float_return_value):
|
|
252
252
|
|
253
253
|
L1:
|
254
254
|
/* Load all the FP registers. */
|
255
|
-
bf 6,L2
|
255
|
+
bf 6,L2 /* 2f + 0x18 */
|
256
256
|
lfd f1,-16-(13*8)(r28)
|
257
257
|
lfd f2,-16-(12*8)(r28)
|
258
258
|
lfd f3,-16-(11*8)(r28)
|
@@ -307,7 +307,7 @@ L(float_return_value):
|
|
307
307
|
#endif
|
308
308
|
.long 0
|
309
309
|
.byte 0,0,0,1,128,4,0,0
|
310
|
-
|
310
|
+
/* END(ffi_call_AIX) */
|
311
311
|
|
312
312
|
.csect .text[PR]
|
313
313
|
.align 2
|
@@ -325,4 +325,4 @@ ffi_call_DARWIN:
|
|
325
325
|
blr
|
326
326
|
.long 0
|
327
327
|
.byte 0,0,0,0,0,0,0,0
|
328
|
-
|
328
|
+
/* END(ffi_call_DARWIN) */
|
@@ -167,6 +167,7 @@ ffi_closure_ASM:
|
|
167
167
|
|
168
168
|
/* look up the proper starting point in table */
|
169
169
|
/* by using return type as offset */
|
170
|
+
lhz r3, 10(r3) /* load type from return type */
|
170
171
|
ld r4, LC..60(2) /* get address of jump table */
|
171
172
|
sldi r3, r3, 4 /* now multiply return type by 16 */
|
172
173
|
ld r0, 240+16(r1) /* load return address */
|
@@ -339,8 +340,9 @@ L..finish:
|
|
339
340
|
|
340
341
|
/* look up the proper starting point in table */
|
341
342
|
/* by using return type as offset */
|
343
|
+
lhz r3, 6(r3) /* load type from return type */
|
342
344
|
lwz r4, LC..60(2) /* get address of jump table */
|
343
|
-
slwi r3, r3, 4 /* now multiply return type by
|
345
|
+
slwi r3, r3, 4 /* now multiply return type by 16 */
|
344
346
|
lwz r0, 176+8(r1) /* load return address */
|
345
347
|
add r3, r3, r4 /* add contents of table to table address */
|
346
348
|
mtctr r3
|
@@ -93,7 +93,7 @@
|
|
93
93
|
/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
|
94
94
|
past a 2^align boundary. */
|
95
95
|
#ifdef PROF
|
96
|
-
#define
|
96
|
+
#define EFFI_ALIGN(name, alignt, words) \
|
97
97
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
|
98
98
|
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
|
99
99
|
.align ALIGNARG(2); \
|
@@ -104,7 +104,7 @@
|
|
104
104
|
EALIGN_W_##words; \
|
105
105
|
0:
|
106
106
|
#else /* PROF */
|
107
|
-
#define
|
107
|
+
#define EFFI_ALIGN(name, alignt, words) \
|
108
108
|
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
|
109
109
|
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
|
110
110
|
.align ALIGNARG(alignt); \
|
@@ -318,11 +318,6 @@ _ffi_call_AIX:
|
|
318
318
|
|
319
319
|
#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78)
|
320
320
|
|
321
|
-
.static_data
|
322
|
-
.align LOG2_GPR_BYTES
|
323
|
-
LLFB0$non_lazy_ptr:
|
324
|
-
.g_long Lstartcode
|
325
|
-
|
326
321
|
.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
|
327
322
|
EH_frame1:
|
328
323
|
.set L$set$0,LECIE1-LSCIE1
|
@@ -335,7 +330,7 @@ LSCIE1:
|
|
335
330
|
.byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor
|
336
331
|
.byte 0x41 ; CIE RA Column
|
337
332
|
.byte 0x1 ; uleb128 0x1; Augmentation size
|
338
|
-
.byte 0x10 ; FDE Encoding (
|
333
|
+
.byte 0x10 ; FDE Encoding (pcrel)
|
339
334
|
.byte 0xc ; DW_CFA_def_cfa
|
340
335
|
.byte 0x1 ; uleb128 0x1
|
341
336
|
.byte 0x0 ; uleb128 0x0
|
@@ -349,7 +344,7 @@ LSFDE1:
|
|
349
344
|
.long L$set$1 ; FDE Length
|
350
345
|
LASFDE1:
|
351
346
|
.long LASFDE1-EH_frame1 ; FDE CIE offset
|
352
|
-
.g_long
|
347
|
+
.g_long Lstartcode-. ; FDE initial location
|
353
348
|
.set L$set$3,LFE1-Lstartcode
|
354
349
|
.g_long L$set$3 ; FDE address range
|
355
350
|
.byte 0x0 ; uleb128 0x0; Augmentation size
|
@@ -192,7 +192,7 @@ LCFI1:
|
|
192
192
|
lg r0,0(r3) ; size => r0
|
193
193
|
lhz r3,FFI_TYPE_TYPE(r3) ; type => r3
|
194
194
|
|
195
|
-
/* The helper will have intercepted
|
195
|
+
/* The helper will have intercepted structure returns and inserted
|
196
196
|
the caller`s destination address for structs returned by ref. */
|
197
197
|
|
198
198
|
/* r3 contains the return type so use it to look up in a table
|
@@ -353,7 +353,7 @@ Lret_type13:
|
|
353
353
|
bgt Lstructend ; not a special small case
|
354
354
|
b Lsmallstruct ; see if we need more.
|
355
355
|
#else
|
356
|
-
|
356
|
+
cmpwi 0,r0,4
|
357
357
|
bgt Lfinish ; not by value
|
358
358
|
lg r3,0(r5)
|
359
359
|
b Lfinish
|
@@ -467,11 +467,6 @@ Lendcode:
|
|
467
467
|
#define EH_FRAME_OFFSETA MODE_CHOICE(176,0x90)
|
468
468
|
#define EH_FRAME_OFFSETB MODE_CHOICE(1,3)
|
469
469
|
|
470
|
-
.static_data
|
471
|
-
.align LOG2_GPR_BYTES
|
472
|
-
LLFB1$non_lazy_ptr:
|
473
|
-
.g_long Lstartcode
|
474
|
-
|
475
470
|
.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
|
476
471
|
EH_frame1:
|
477
472
|
.set L$set$0,LECIE1-LSCIE1
|
@@ -484,7 +479,7 @@ LSCIE1:
|
|
484
479
|
.byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor
|
485
480
|
.byte 0x41 ; CIE RA Column
|
486
481
|
.byte 0x1 ; uleb128 0x1; Augmentation size
|
487
|
-
.byte 0x10 ; FDE Encoding (
|
482
|
+
.byte 0x10 ; FDE Encoding (pcrel)
|
488
483
|
.byte 0xc ; DW_CFA_def_cfa
|
489
484
|
.byte 0x1 ; uleb128 0x1
|
490
485
|
.byte 0x0 ; uleb128 0x0
|
@@ -498,9 +493,9 @@ LSFDE1:
|
|
498
493
|
|
499
494
|
LASFDE1:
|
500
495
|
.long LASFDE1-EH_frame1 ; FDE CIE offset
|
501
|
-
.g_long
|
502
|
-
.set L$set$
|
503
|
-
.g_long L$set$
|
496
|
+
.g_long Lstartcode-. ; FDE initial location
|
497
|
+
.set L$set$2,LFE1-Lstartcode
|
498
|
+
.g_long L$set$2 ; FDE address range
|
504
499
|
.byte 0x0 ; uleb128 0x0; Augmentation size
|
505
500
|
.byte 0x4 ; DW_CFA_advance_loc4
|
506
501
|
.set L$set$3,LCFI1-LCFI0
|
@@ -523,18 +518,18 @@ LEFDE1:
|
|
523
518
|
L_ffi_closure_helper_DARWIN$stub:
|
524
519
|
.indirect_symbol _ffi_closure_helper_DARWIN
|
525
520
|
mflr r0
|
526
|
-
bcl 20,31,"
|
527
|
-
"
|
521
|
+
bcl 20,31,"L1$spb"
|
522
|
+
"L1$spb":
|
528
523
|
mflr r11
|
529
|
-
addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr-"
|
524
|
+
addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L1$spb")
|
530
525
|
mtlr r0
|
531
|
-
lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr-"
|
526
|
+
lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L1$spb")(r11)
|
532
527
|
mtctr r12
|
533
528
|
bctr
|
534
529
|
.lazy_symbol_pointer
|
535
530
|
L_ffi_closure_helper_DARWIN$lazy_ptr:
|
536
531
|
.indirect_symbol _ffi_closure_helper_DARWIN
|
537
|
-
.
|
532
|
+
.g_long dyld_stub_binding_helper
|
538
533
|
|
539
534
|
#if defined(__ppc64__)
|
540
535
|
.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
|
@@ -542,34 +537,35 @@ L_ffi_closure_helper_DARWIN$lazy_ptr:
|
|
542
537
|
L_darwin64_struct_ret_by_value_p$stub:
|
543
538
|
.indirect_symbol _darwin64_struct_ret_by_value_p
|
544
539
|
mflr r0
|
545
|
-
bcl 20,31,"
|
546
|
-
"
|
540
|
+
bcl 20,31,"L2$spb"
|
541
|
+
"L2$spb":
|
547
542
|
mflr r11
|
548
|
-
addis r11,r11,ha16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"
|
543
|
+
addis r11,r11,ha16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L2$spb")
|
549
544
|
mtlr r0
|
550
|
-
lwzu r12,lo16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"
|
545
|
+
lwzu r12,lo16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L2$spb")(r11)
|
551
546
|
mtctr r12
|
552
547
|
bctr
|
553
548
|
.lazy_symbol_pointer
|
554
549
|
L_darwin64_struct_ret_by_value_p$lazy_ptr:
|
555
550
|
.indirect_symbol _darwin64_struct_ret_by_value_p
|
556
|
-
.
|
551
|
+
.g_long dyld_stub_binding_helper
|
552
|
+
|
557
553
|
.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
|
558
554
|
.align 5
|
559
555
|
L_darwin64_pass_struct_floats$stub:
|
560
556
|
.indirect_symbol _darwin64_pass_struct_floats
|
561
557
|
mflr r0
|
562
|
-
bcl 20,31,"
|
563
|
-
"
|
558
|
+
bcl 20,31,"L3$spb"
|
559
|
+
"L3$spb":
|
564
560
|
mflr r11
|
565
|
-
addis r11,r11,ha16(L_darwin64_pass_struct_floats$lazy_ptr-"
|
561
|
+
addis r11,r11,ha16(L_darwin64_pass_struct_floats$lazy_ptr-"L3$spb")
|
566
562
|
mtlr r0
|
567
|
-
lwzu r12,lo16(L_darwin64_pass_struct_floats$lazy_ptr-"
|
563
|
+
lwzu r12,lo16(L_darwin64_pass_struct_floats$lazy_ptr-"L3$spb")(r11)
|
568
564
|
mtctr r12
|
569
565
|
bctr
|
570
566
|
.lazy_symbol_pointer
|
571
567
|
L_darwin64_pass_struct_floats$lazy_ptr:
|
572
568
|
.indirect_symbol _darwin64_pass_struct_floats
|
573
|
-
.
|
569
|
+
.g_long dyld_stub_binding_helper
|
574
570
|
# endif
|
575
571
|
#endif
|
@@ -1,5 +1,7 @@
|
|
1
1
|
/* -----------------------------------------------------------------------
|
2
|
-
ffi.c - Copyright (C)
|
2
|
+
ffi.c - Copyright (C) 2013 IBM
|
3
|
+
Copyright (C) 2011 Anthony Green
|
4
|
+
Copyright (C) 2011 Kyle Moffett
|
3
5
|
Copyright (C) 2008 Red Hat, Inc
|
4
6
|
Copyright (C) 2007, 2008 Free Software Foundation, Inc
|
5
7
|
Copyright (c) 1998 Geoffrey Keating
|
@@ -26,919 +28,120 @@
|
|
26
28
|
OTHER DEALINGS IN THE SOFTWARE.
|
27
29
|
----------------------------------------------------------------------- */
|
28
30
|
|
29
|
-
#include
|
30
|
-
#include
|
31
|
-
|
32
|
-
#include <stdlib.h>
|
33
|
-
#include <stdio.h>
|
34
|
-
|
35
|
-
|
36
|
-
extern void ffi_closure_SYSV (void);
|
37
|
-
extern void FFI_HIDDEN ffi_closure_LINUX64 (void);
|
38
|
-
|
39
|
-
enum {
|
40
|
-
/* The assembly depends on these exact flags. */
|
41
|
-
FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */
|
42
|
-
FLAG_RETURNS_NOTHING = 1 << (31-30), /* These go in cr7 */
|
43
|
-
FLAG_RETURNS_FP = 1 << (31-29),
|
44
|
-
FLAG_RETURNS_64BITS = 1 << (31-28),
|
45
|
-
|
46
|
-
FLAG_RETURNS_128BITS = 1 << (31-27), /* cr6 */
|
47
|
-
FLAG_SYSV_SMST_R4 = 1 << (31-26), /* use r4 for FFI_SYSV 8 byte
|
48
|
-
structs. */
|
49
|
-
FLAG_SYSV_SMST_R3 = 1 << (31-25), /* use r3 for FFI_SYSV 4 byte
|
50
|
-
structs. */
|
51
|
-
/* Bits (31-24) through (31-19) store shift value for SMST */
|
52
|
-
|
53
|
-
FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
|
54
|
-
FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
|
55
|
-
FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
|
56
|
-
FLAG_RETVAL_REFERENCE = 1 << (31- 4)
|
57
|
-
};
|
58
|
-
|
59
|
-
/* About the SYSV ABI. */
|
60
|
-
unsigned int NUM_GPR_ARG_REGISTERS = 8;
|
61
|
-
#ifndef __NO_FPRS__
|
62
|
-
unsigned int NUM_FPR_ARG_REGISTERS = 8;
|
63
|
-
#else
|
64
|
-
unsigned int NUM_FPR_ARG_REGISTERS = 0;
|
65
|
-
#endif
|
66
|
-
|
67
|
-
enum { ASM_NEEDS_REGISTERS = 4 };
|
68
|
-
|
69
|
-
/* ffi_prep_args_SYSV is called by the assembly routine once stack space
|
70
|
-
has been allocated for the function's arguments.
|
71
|
-
|
72
|
-
The stack layout we want looks like this:
|
73
|
-
|
74
|
-
| Return address from ffi_call_SYSV 4bytes | higher addresses
|
75
|
-
|--------------------------------------------|
|
76
|
-
| Previous backchain pointer 4 | stack pointer here
|
77
|
-
|--------------------------------------------|<+ <<< on entry to
|
78
|
-
| Saved r28-r31 4*4 | | ffi_call_SYSV
|
79
|
-
|--------------------------------------------| |
|
80
|
-
| GPR registers r3-r10 8*4 | | ffi_call_SYSV
|
81
|
-
|--------------------------------------------| |
|
82
|
-
| FPR registers f1-f8 (optional) 8*8 | |
|
83
|
-
|--------------------------------------------| | stack |
|
84
|
-
| Space for copied structures | | grows |
|
85
|
-
|--------------------------------------------| | down V
|
86
|
-
| Parameters that didn't fit in registers | |
|
87
|
-
|--------------------------------------------| | lower addresses
|
88
|
-
| Space for callee's LR 4 | |
|
89
|
-
|--------------------------------------------| | stack pointer here
|
90
|
-
| Current backchain pointer 4 |-/ during
|
91
|
-
|--------------------------------------------| <<< ffi_call_SYSV
|
92
|
-
|
93
|
-
*/
|
94
|
-
|
95
|
-
void
|
96
|
-
ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
|
97
|
-
{
|
98
|
-
const unsigned bytes = ecif->cif->bytes;
|
99
|
-
const unsigned flags = ecif->cif->flags;
|
100
|
-
|
101
|
-
typedef union {
|
102
|
-
char *c;
|
103
|
-
unsigned *u;
|
104
|
-
long long *ll;
|
105
|
-
float *f;
|
106
|
-
double *d;
|
107
|
-
} valp;
|
108
|
-
|
109
|
-
/* 'stacktop' points at the previous backchain pointer. */
|
110
|
-
valp stacktop;
|
111
|
-
|
112
|
-
/* 'gpr_base' points at the space for gpr3, and grows upwards as
|
113
|
-
we use GPR registers. */
|
114
|
-
valp gpr_base;
|
115
|
-
int intarg_count;
|
116
|
-
|
117
|
-
/* 'fpr_base' points at the space for fpr1, and grows upwards as
|
118
|
-
we use FPR registers. */
|
119
|
-
valp fpr_base;
|
120
|
-
int fparg_count;
|
121
|
-
|
122
|
-
/* 'copy_space' grows down as we put structures in it. It should
|
123
|
-
stay 16-byte aligned. */
|
124
|
-
valp copy_space;
|
125
|
-
|
126
|
-
/* 'next_arg' grows up as we put parameters in it. */
|
127
|
-
valp next_arg;
|
128
|
-
|
129
|
-
int i, ii MAYBE_UNUSED;
|
130
|
-
ffi_type **ptr;
|
131
|
-
double double_tmp;
|
132
|
-
union {
|
133
|
-
void **v;
|
134
|
-
char **c;
|
135
|
-
signed char **sc;
|
136
|
-
unsigned char **uc;
|
137
|
-
signed short **ss;
|
138
|
-
unsigned short **us;
|
139
|
-
unsigned int **ui;
|
140
|
-
long long **ll;
|
141
|
-
float **f;
|
142
|
-
double **d;
|
143
|
-
} p_argv;
|
144
|
-
size_t struct_copy_size;
|
145
|
-
unsigned gprvalue;
|
146
|
-
|
147
|
-
if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
|
148
|
-
NUM_FPR_ARG_REGISTERS = 0;
|
149
|
-
|
150
|
-
stacktop.c = (char *) stack + bytes;
|
151
|
-
gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
|
152
|
-
intarg_count = 0;
|
153
|
-
fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS;
|
154
|
-
fparg_count = 0;
|
155
|
-
copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c);
|
156
|
-
next_arg.u = stack + 2;
|
157
|
-
|
158
|
-
/* Check that everything starts aligned properly. */
|
159
|
-
FFI_ASSERT (((unsigned) (char *) stack & 0xF) == 0);
|
160
|
-
FFI_ASSERT (((unsigned) copy_space.c & 0xF) == 0);
|
161
|
-
FFI_ASSERT (((unsigned) stacktop.c & 0xF) == 0);
|
162
|
-
FFI_ASSERT ((bytes & 0xF) == 0);
|
163
|
-
FFI_ASSERT (copy_space.c >= next_arg.c);
|
164
|
-
|
165
|
-
/* Deal with return values that are actually pass-by-reference. */
|
166
|
-
if (flags & FLAG_RETVAL_REFERENCE)
|
167
|
-
{
|
168
|
-
*gpr_base.u++ = (unsigned long) (char *) ecif->rvalue;
|
169
|
-
intarg_count++;
|
170
|
-
}
|
171
|
-
|
172
|
-
/* Now for the arguments. */
|
173
|
-
p_argv.v = ecif->avalue;
|
174
|
-
for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
|
175
|
-
i > 0;
|
176
|
-
i--, ptr++, p_argv.v++)
|
177
|
-
{
|
178
|
-
switch ((*ptr)->type)
|
179
|
-
{
|
180
|
-
case FFI_TYPE_FLOAT:
|
181
|
-
/* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */
|
182
|
-
if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
|
183
|
-
goto soft_float_prep;
|
184
|
-
double_tmp = **p_argv.f;
|
185
|
-
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
|
186
|
-
{
|
187
|
-
*next_arg.f = (float) double_tmp;
|
188
|
-
next_arg.u += 1;
|
189
|
-
intarg_count++;
|
190
|
-
}
|
191
|
-
else
|
192
|
-
*fpr_base.d++ = double_tmp;
|
193
|
-
fparg_count++;
|
194
|
-
FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
|
195
|
-
break;
|
196
|
-
|
197
|
-
case FFI_TYPE_DOUBLE:
|
198
|
-
/* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */
|
199
|
-
if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
|
200
|
-
goto soft_double_prep;
|
201
|
-
double_tmp = **p_argv.d;
|
202
|
-
|
203
|
-
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
|
204
|
-
{
|
205
|
-
if (intarg_count >= NUM_GPR_ARG_REGISTERS
|
206
|
-
&& intarg_count % 2 != 0)
|
207
|
-
{
|
208
|
-
intarg_count++;
|
209
|
-
next_arg.u++;
|
210
|
-
}
|
211
|
-
*next_arg.d = double_tmp;
|
212
|
-
next_arg.u += 2;
|
213
|
-
}
|
214
|
-
else
|
215
|
-
*fpr_base.d++ = double_tmp;
|
216
|
-
fparg_count++;
|
217
|
-
FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
|
218
|
-
break;
|
219
|
-
|
220
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
221
|
-
case FFI_TYPE_LONGDOUBLE:
|
222
|
-
if ((ecif->cif->abi != FFI_LINUX)
|
223
|
-
&& (ecif->cif->abi != FFI_LINUX_SOFT_FLOAT))
|
224
|
-
goto do_struct;
|
225
|
-
/* The soft float ABI for long doubles works like this,
|
226
|
-
a long double is passed in four consecutive gprs if available.
|
227
|
-
A maximum of 2 long doubles can be passed in gprs.
|
228
|
-
If we do not have 4 gprs left, the long double is passed on the
|
229
|
-
stack, 4-byte aligned. */
|
230
|
-
if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
|
231
|
-
{
|
232
|
-
unsigned int int_tmp = (*p_argv.ui)[0];
|
233
|
-
if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3)
|
234
|
-
{
|
235
|
-
if (intarg_count < NUM_GPR_ARG_REGISTERS)
|
236
|
-
intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
|
237
|
-
*next_arg.u = int_tmp;
|
238
|
-
next_arg.u++;
|
239
|
-
for (ii = 1; ii < 4; ii++)
|
240
|
-
{
|
241
|
-
int_tmp = (*p_argv.ui)[ii];
|
242
|
-
*next_arg.u = int_tmp;
|
243
|
-
next_arg.u++;
|
244
|
-
}
|
245
|
-
}
|
246
|
-
else
|
247
|
-
{
|
248
|
-
*gpr_base.u++ = int_tmp;
|
249
|
-
for (ii = 1; ii < 4; ii++)
|
250
|
-
{
|
251
|
-
int_tmp = (*p_argv.ui)[ii];
|
252
|
-
*gpr_base.u++ = int_tmp;
|
253
|
-
}
|
254
|
-
}
|
255
|
-
intarg_count +=4;
|
256
|
-
}
|
257
|
-
else
|
258
|
-
{
|
259
|
-
double_tmp = (*p_argv.d)[0];
|
260
|
-
|
261
|
-
if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1)
|
262
|
-
{
|
263
|
-
if (intarg_count >= NUM_GPR_ARG_REGISTERS
|
264
|
-
&& intarg_count % 2 != 0)
|
265
|
-
{
|
266
|
-
intarg_count++;
|
267
|
-
next_arg.u++;
|
268
|
-
}
|
269
|
-
*next_arg.d = double_tmp;
|
270
|
-
next_arg.u += 2;
|
271
|
-
double_tmp = (*p_argv.d)[1];
|
272
|
-
*next_arg.d = double_tmp;
|
273
|
-
next_arg.u += 2;
|
274
|
-
}
|
275
|
-
else
|
276
|
-
{
|
277
|
-
*fpr_base.d++ = double_tmp;
|
278
|
-
double_tmp = (*p_argv.d)[1];
|
279
|
-
*fpr_base.d++ = double_tmp;
|
280
|
-
}
|
281
|
-
|
282
|
-
fparg_count += 2;
|
283
|
-
FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
|
284
|
-
}
|
285
|
-
break;
|
286
|
-
#endif
|
287
|
-
|
288
|
-
case FFI_TYPE_UINT64:
|
289
|
-
case FFI_TYPE_SINT64:
|
290
|
-
soft_double_prep:
|
291
|
-
if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
|
292
|
-
intarg_count++;
|
293
|
-
if (intarg_count >= NUM_GPR_ARG_REGISTERS)
|
294
|
-
{
|
295
|
-
if (intarg_count % 2 != 0)
|
296
|
-
{
|
297
|
-
intarg_count++;
|
298
|
-
next_arg.u++;
|
299
|
-
}
|
300
|
-
*next_arg.ll = **p_argv.ll;
|
301
|
-
next_arg.u += 2;
|
302
|
-
}
|
303
|
-
else
|
304
|
-
{
|
305
|
-
/* whoops: abi states only certain register pairs
|
306
|
-
* can be used for passing long long int
|
307
|
-
* specifically (r3,r4), (r5,r6), (r7,r8),
|
308
|
-
* (r9,r10) and if next arg is long long but
|
309
|
-
* not correct starting register of pair then skip
|
310
|
-
* until the proper starting register
|
311
|
-
*/
|
312
|
-
if (intarg_count % 2 != 0)
|
313
|
-
{
|
314
|
-
intarg_count ++;
|
315
|
-
gpr_base.u++;
|
316
|
-
}
|
317
|
-
*gpr_base.ll++ = **p_argv.ll;
|
318
|
-
}
|
319
|
-
intarg_count += 2;
|
320
|
-
break;
|
321
|
-
|
322
|
-
case FFI_TYPE_STRUCT:
|
323
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
324
|
-
do_struct:
|
325
|
-
#endif
|
326
|
-
struct_copy_size = ((*ptr)->size + 15) & ~0xF;
|
327
|
-
copy_space.c -= struct_copy_size;
|
328
|
-
memcpy (copy_space.c, *p_argv.c, (*ptr)->size);
|
329
|
-
|
330
|
-
gprvalue = (unsigned long) copy_space.c;
|
331
|
-
|
332
|
-
FFI_ASSERT (copy_space.c > next_arg.c);
|
333
|
-
FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY);
|
334
|
-
goto putgpr;
|
335
|
-
|
336
|
-
case FFI_TYPE_UINT8:
|
337
|
-
gprvalue = **p_argv.uc;
|
338
|
-
goto putgpr;
|
339
|
-
case FFI_TYPE_SINT8:
|
340
|
-
gprvalue = **p_argv.sc;
|
341
|
-
goto putgpr;
|
342
|
-
case FFI_TYPE_UINT16:
|
343
|
-
gprvalue = **p_argv.us;
|
344
|
-
goto putgpr;
|
345
|
-
case FFI_TYPE_SINT16:
|
346
|
-
gprvalue = **p_argv.ss;
|
347
|
-
goto putgpr;
|
348
|
-
|
349
|
-
case FFI_TYPE_INT:
|
350
|
-
case FFI_TYPE_UINT32:
|
351
|
-
case FFI_TYPE_SINT32:
|
352
|
-
case FFI_TYPE_POINTER:
|
353
|
-
soft_float_prep:
|
354
|
-
|
355
|
-
gprvalue = **p_argv.ui;
|
356
|
-
|
357
|
-
putgpr:
|
358
|
-
if (intarg_count >= NUM_GPR_ARG_REGISTERS)
|
359
|
-
*next_arg.u++ = gprvalue;
|
360
|
-
else
|
361
|
-
*gpr_base.u++ = gprvalue;
|
362
|
-
intarg_count++;
|
363
|
-
break;
|
364
|
-
}
|
365
|
-
}
|
366
|
-
|
367
|
-
/* Check that we didn't overrun the stack... */
|
368
|
-
FFI_ASSERT (copy_space.c >= next_arg.c);
|
369
|
-
FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
|
370
|
-
FFI_ASSERT (fpr_base.u
|
371
|
-
<= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
|
372
|
-
FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
|
373
|
-
}
|
374
|
-
|
375
|
-
/* About the LINUX64 ABI. */
|
376
|
-
enum {
|
377
|
-
NUM_GPR_ARG_REGISTERS64 = 8,
|
378
|
-
NUM_FPR_ARG_REGISTERS64 = 13
|
379
|
-
};
|
380
|
-
enum { ASM_NEEDS_REGISTERS64 = 4 };
|
381
|
-
|
382
|
-
/* ffi_prep_args64 is called by the assembly routine once stack space
|
383
|
-
has been allocated for the function's arguments.
|
384
|
-
|
385
|
-
The stack layout we want looks like this:
|
386
|
-
|
387
|
-
| Ret addr from ffi_call_LINUX64 8bytes | higher addresses
|
388
|
-
|--------------------------------------------|
|
389
|
-
| CR save area 8bytes |
|
390
|
-
|--------------------------------------------|
|
391
|
-
| Previous backchain pointer 8 | stack pointer here
|
392
|
-
|--------------------------------------------|<+ <<< on entry to
|
393
|
-
| Saved r28-r31 4*8 | | ffi_call_LINUX64
|
394
|
-
|--------------------------------------------| |
|
395
|
-
| GPR registers r3-r10 8*8 | |
|
396
|
-
|--------------------------------------------| |
|
397
|
-
| FPR registers f1-f13 (optional) 13*8 | |
|
398
|
-
|--------------------------------------------| |
|
399
|
-
| Parameter save area | |
|
400
|
-
|--------------------------------------------| |
|
401
|
-
| TOC save area 8 | |
|
402
|
-
|--------------------------------------------| | stack |
|
403
|
-
| Linker doubleword 8 | | grows |
|
404
|
-
|--------------------------------------------| | down V
|
405
|
-
| Compiler doubleword 8 | |
|
406
|
-
|--------------------------------------------| | lower addresses
|
407
|
-
| Space for callee's LR 8 | |
|
408
|
-
|--------------------------------------------| |
|
409
|
-
| CR save area 8 | |
|
410
|
-
|--------------------------------------------| | stack pointer here
|
411
|
-
| Current backchain pointer 8 |-/ during
|
412
|
-
|--------------------------------------------| <<< ffi_call_LINUX64
|
413
|
-
|
414
|
-
*/
|
31
|
+
#include "ffi.h"
|
32
|
+
#include "ffi_common.h"
|
33
|
+
#include "ffi_powerpc.h"
|
415
34
|
|
35
|
+
#if HAVE_LONG_DOUBLE_VARIANT
|
36
|
+
/* Adjust ffi_type_longdouble. */
|
416
37
|
void FFI_HIDDEN
|
417
|
-
|
38
|
+
ffi_prep_types (ffi_abi abi)
|
418
39
|
{
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
double *d;
|
427
|
-
} valp;
|
428
|
-
|
429
|
-
/* 'stacktop' points at the previous backchain pointer. */
|
430
|
-
valp stacktop;
|
431
|
-
|
432
|
-
/* 'next_arg' points at the space for gpr3, and grows upwards as
|
433
|
-
we use GPR registers, then continues at rest. */
|
434
|
-
valp gpr_base;
|
435
|
-
valp gpr_end;
|
436
|
-
valp rest;
|
437
|
-
valp next_arg;
|
438
|
-
|
439
|
-
/* 'fpr_base' points at the space for fpr3, and grows upwards as
|
440
|
-
we use FPR registers. */
|
441
|
-
valp fpr_base;
|
442
|
-
int fparg_count;
|
443
|
-
|
444
|
-
int i, words;
|
445
|
-
ffi_type **ptr;
|
446
|
-
double double_tmp;
|
447
|
-
union {
|
448
|
-
void **v;
|
449
|
-
char **c;
|
450
|
-
signed char **sc;
|
451
|
-
unsigned char **uc;
|
452
|
-
signed short **ss;
|
453
|
-
unsigned short **us;
|
454
|
-
signed int **si;
|
455
|
-
unsigned int **ui;
|
456
|
-
unsigned long **ul;
|
457
|
-
float **f;
|
458
|
-
double **d;
|
459
|
-
} p_argv;
|
460
|
-
unsigned long gprvalue;
|
461
|
-
|
462
|
-
stacktop.c = (char *) stack + bytes;
|
463
|
-
gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64;
|
464
|
-
gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64;
|
465
|
-
rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64;
|
466
|
-
fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
|
467
|
-
fparg_count = 0;
|
468
|
-
next_arg.ul = gpr_base.ul;
|
469
|
-
|
470
|
-
/* Check that everything starts aligned properly. */
|
471
|
-
FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
|
472
|
-
FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
|
473
|
-
FFI_ASSERT ((bytes & 0xF) == 0);
|
474
|
-
|
475
|
-
/* Deal with return values that are actually pass-by-reference. */
|
476
|
-
if (flags & FLAG_RETVAL_REFERENCE)
|
477
|
-
*next_arg.ul++ = (unsigned long) (char *) ecif->rvalue;
|
478
|
-
|
479
|
-
/* Now for the arguments. */
|
480
|
-
p_argv.v = ecif->avalue;
|
481
|
-
for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
|
482
|
-
i > 0;
|
483
|
-
i--, ptr++, p_argv.v++)
|
484
|
-
{
|
485
|
-
switch ((*ptr)->type)
|
486
|
-
{
|
487
|
-
case FFI_TYPE_FLOAT:
|
488
|
-
double_tmp = **p_argv.f;
|
489
|
-
*next_arg.f = (float) double_tmp;
|
490
|
-
if (++next_arg.ul == gpr_end.ul)
|
491
|
-
next_arg.ul = rest.ul;
|
492
|
-
if (fparg_count < NUM_FPR_ARG_REGISTERS64)
|
493
|
-
*fpr_base.d++ = double_tmp;
|
494
|
-
fparg_count++;
|
495
|
-
FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
|
496
|
-
break;
|
497
|
-
|
498
|
-
case FFI_TYPE_DOUBLE:
|
499
|
-
double_tmp = **p_argv.d;
|
500
|
-
*next_arg.d = double_tmp;
|
501
|
-
if (++next_arg.ul == gpr_end.ul)
|
502
|
-
next_arg.ul = rest.ul;
|
503
|
-
if (fparg_count < NUM_FPR_ARG_REGISTERS64)
|
504
|
-
*fpr_base.d++ = double_tmp;
|
505
|
-
fparg_count++;
|
506
|
-
FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
|
507
|
-
break;
|
508
|
-
|
509
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
510
|
-
case FFI_TYPE_LONGDOUBLE:
|
511
|
-
double_tmp = (*p_argv.d)[0];
|
512
|
-
*next_arg.d = double_tmp;
|
513
|
-
if (++next_arg.ul == gpr_end.ul)
|
514
|
-
next_arg.ul = rest.ul;
|
515
|
-
if (fparg_count < NUM_FPR_ARG_REGISTERS64)
|
516
|
-
*fpr_base.d++ = double_tmp;
|
517
|
-
fparg_count++;
|
518
|
-
double_tmp = (*p_argv.d)[1];
|
519
|
-
*next_arg.d = double_tmp;
|
520
|
-
if (++next_arg.ul == gpr_end.ul)
|
521
|
-
next_arg.ul = rest.ul;
|
522
|
-
if (fparg_count < NUM_FPR_ARG_REGISTERS64)
|
523
|
-
*fpr_base.d++ = double_tmp;
|
524
|
-
fparg_count++;
|
525
|
-
FFI_ASSERT (__LDBL_MANT_DIG__ == 106);
|
526
|
-
FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
|
527
|
-
break;
|
528
|
-
#endif
|
529
|
-
|
530
|
-
case FFI_TYPE_STRUCT:
|
531
|
-
words = ((*ptr)->size + 7) / 8;
|
532
|
-
if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
|
533
|
-
{
|
534
|
-
size_t first = gpr_end.c - next_arg.c;
|
535
|
-
memcpy (next_arg.c, *p_argv.c, first);
|
536
|
-
memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
|
537
|
-
next_arg.c = rest.c + words * 8 - first;
|
538
|
-
}
|
539
|
-
else
|
540
|
-
{
|
541
|
-
char *where = next_arg.c;
|
542
|
-
|
543
|
-
/* Structures with size less than eight bytes are passed
|
544
|
-
left-padded. */
|
545
|
-
if ((*ptr)->size < 8)
|
546
|
-
where += 8 - (*ptr)->size;
|
547
|
-
|
548
|
-
memcpy (where, *p_argv.c, (*ptr)->size);
|
549
|
-
next_arg.ul += words;
|
550
|
-
if (next_arg.ul == gpr_end.ul)
|
551
|
-
next_arg.ul = rest.ul;
|
552
|
-
}
|
553
|
-
break;
|
554
|
-
|
555
|
-
case FFI_TYPE_UINT8:
|
556
|
-
gprvalue = **p_argv.uc;
|
557
|
-
goto putgpr;
|
558
|
-
case FFI_TYPE_SINT8:
|
559
|
-
gprvalue = **p_argv.sc;
|
560
|
-
goto putgpr;
|
561
|
-
case FFI_TYPE_UINT16:
|
562
|
-
gprvalue = **p_argv.us;
|
563
|
-
goto putgpr;
|
564
|
-
case FFI_TYPE_SINT16:
|
565
|
-
gprvalue = **p_argv.ss;
|
566
|
-
goto putgpr;
|
567
|
-
case FFI_TYPE_UINT32:
|
568
|
-
gprvalue = **p_argv.ui;
|
569
|
-
goto putgpr;
|
570
|
-
case FFI_TYPE_INT:
|
571
|
-
case FFI_TYPE_SINT32:
|
572
|
-
gprvalue = **p_argv.si;
|
573
|
-
goto putgpr;
|
574
|
-
|
575
|
-
case FFI_TYPE_UINT64:
|
576
|
-
case FFI_TYPE_SINT64:
|
577
|
-
case FFI_TYPE_POINTER:
|
578
|
-
gprvalue = **p_argv.ul;
|
579
|
-
putgpr:
|
580
|
-
*next_arg.ul++ = gprvalue;
|
581
|
-
if (next_arg.ul == gpr_end.ul)
|
582
|
-
next_arg.ul = rest.ul;
|
583
|
-
break;
|
584
|
-
}
|
585
|
-
}
|
586
|
-
|
587
|
-
FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS
|
588
|
-
|| (next_arg.ul >= gpr_base.ul
|
589
|
-
&& next_arg.ul <= gpr_base.ul + 4));
|
40
|
+
# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
41
|
+
# ifdef POWERPC64
|
42
|
+
ffi_prep_types_linux64 (abi);
|
43
|
+
# else
|
44
|
+
ffi_prep_types_sysv (abi);
|
45
|
+
# endif
|
46
|
+
# endif
|
590
47
|
}
|
591
|
-
|
592
|
-
|
48
|
+
#endif
|
593
49
|
|
594
50
|
/* Perform machine dependent cif processing */
|
595
|
-
ffi_status
|
51
|
+
ffi_status FFI_HIDDEN
|
596
52
|
ffi_prep_cif_machdep (ffi_cif *cif)
|
597
53
|
{
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
int fparg_count = 0, intarg_count = 0;
|
603
|
-
unsigned flags = 0;
|
604
|
-
unsigned struct_copy_size = 0;
|
605
|
-
unsigned type = cif->rtype->type;
|
606
|
-
unsigned size = cif->rtype->size;
|
607
|
-
|
608
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
609
|
-
NUM_FPR_ARG_REGISTERS = 0;
|
610
|
-
|
611
|
-
if (cif->abi != FFI_LINUX64)
|
612
|
-
{
|
613
|
-
/* All the machine-independent calculation of cif->bytes will be wrong.
|
614
|
-
Redo the calculation for SYSV. */
|
615
|
-
|
616
|
-
/* Space for the frame pointer, callee's LR, and the asm's temp regs. */
|
617
|
-
bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int);
|
618
|
-
|
619
|
-
/* Space for the GPR registers. */
|
620
|
-
bytes += NUM_GPR_ARG_REGISTERS * sizeof (int);
|
621
|
-
}
|
622
|
-
else
|
623
|
-
{
|
624
|
-
/* 64-bit ABI. */
|
625
|
-
|
626
|
-
/* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp
|
627
|
-
regs. */
|
628
|
-
bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long);
|
629
|
-
|
630
|
-
/* Space for the mandatory parm save area and general registers. */
|
631
|
-
bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long);
|
632
|
-
}
|
633
|
-
|
634
|
-
/* Return value handling. The rules for SYSV are as follows:
|
635
|
-
- 32-bit (or less) integer values are returned in gpr3;
|
636
|
-
- Structures of size <= 4 bytes also returned in gpr3;
|
637
|
-
- 64-bit integer values and structures between 5 and 8 bytes are returned
|
638
|
-
in gpr3 and gpr4;
|
639
|
-
- Single/double FP values are returned in fpr1;
|
640
|
-
- Larger structures are allocated space and a pointer is passed as
|
641
|
-
the first argument.
|
642
|
-
- long doubles (if not equivalent to double) are returned in
|
643
|
-
fpr1,fpr2 for Linux and as for large structs for SysV.
|
644
|
-
For LINUX64:
|
645
|
-
- integer values in gpr3;
|
646
|
-
- Structures/Unions by reference;
|
647
|
-
- Single/double FP values in fpr1, long double in fpr1,fpr2.
|
648
|
-
- soft-float float/doubles are treated as UINT32/UINT64 respectivley.
|
649
|
-
- soft-float long doubles are returned in gpr3-gpr6. */
|
650
|
-
switch (type)
|
651
|
-
{
|
652
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
653
|
-
case FFI_TYPE_LONGDOUBLE:
|
654
|
-
if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64
|
655
|
-
&& cif->abi != FFI_LINUX_SOFT_FLOAT)
|
656
|
-
goto byref;
|
657
|
-
flags |= FLAG_RETURNS_128BITS;
|
658
|
-
/* Fall through. */
|
659
|
-
#endif
|
660
|
-
case FFI_TYPE_DOUBLE:
|
661
|
-
flags |= FLAG_RETURNS_64BITS;
|
662
|
-
/* Fall through. */
|
663
|
-
case FFI_TYPE_FLOAT:
|
664
|
-
/* With FFI_LINUX_SOFT_FLOAT no fp registers are used. */
|
665
|
-
if (cif->abi != FFI_LINUX_SOFT_FLOAT)
|
666
|
-
flags |= FLAG_RETURNS_FP;
|
667
|
-
break;
|
668
|
-
|
669
|
-
case FFI_TYPE_UINT64:
|
670
|
-
case FFI_TYPE_SINT64:
|
671
|
-
flags |= FLAG_RETURNS_64BITS;
|
672
|
-
break;
|
673
|
-
|
674
|
-
case FFI_TYPE_STRUCT:
|
675
|
-
if (cif->abi == FFI_SYSV)
|
676
|
-
{
|
677
|
-
/* The final SYSV ABI says that structures smaller or equal 8 bytes
|
678
|
-
are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
|
679
|
-
in memory. */
|
680
|
-
|
681
|
-
/* Treat structs with size <= 8 bytes. */
|
682
|
-
if (size <= 8)
|
683
|
-
{
|
684
|
-
flags |= FLAG_RETURNS_SMST;
|
685
|
-
/* These structs are returned in r3. We pack the type and the
|
686
|
-
precalculated shift value (needed in the sysv.S) into flags.
|
687
|
-
The same applies for the structs returned in r3/r4. */
|
688
|
-
if (size <= 4)
|
689
|
-
{
|
690
|
-
flags |= FLAG_SYSV_SMST_R3;
|
691
|
-
flags |= 8 * (4 - size) << 8;
|
692
|
-
break;
|
693
|
-
}
|
694
|
-
/* These structs are returned in r3 and r4. See above. */
|
695
|
-
if (size <= 8)
|
696
|
-
{
|
697
|
-
flags |= FLAG_SYSV_SMST_R3 | FLAG_SYSV_SMST_R4;
|
698
|
-
flags |= 8 * (8 - size) << 8;
|
699
|
-
break;
|
700
|
-
}
|
701
|
-
}
|
702
|
-
}
|
703
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
704
|
-
byref:
|
705
|
-
#endif
|
706
|
-
intarg_count++;
|
707
|
-
flags |= FLAG_RETVAL_REFERENCE;
|
708
|
-
/* Fall through. */
|
709
|
-
case FFI_TYPE_VOID:
|
710
|
-
flags |= FLAG_RETURNS_NOTHING;
|
711
|
-
break;
|
712
|
-
|
713
|
-
default:
|
714
|
-
/* Returns 32-bit integer, or similar. Nothing to do here. */
|
715
|
-
break;
|
716
|
-
}
|
717
|
-
|
718
|
-
if (cif->abi != FFI_LINUX64)
|
719
|
-
/* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
|
720
|
-
first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
|
721
|
-
goes on the stack. Structures and long doubles (if not equivalent
|
722
|
-
to double) are passed as a pointer to a copy of the structure.
|
723
|
-
Stuff on the stack needs to keep proper alignment. */
|
724
|
-
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
|
725
|
-
{
|
726
|
-
switch ((*ptr)->type)
|
727
|
-
{
|
728
|
-
case FFI_TYPE_FLOAT:
|
729
|
-
/* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */
|
730
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
731
|
-
goto soft_float_cif;
|
732
|
-
fparg_count++;
|
733
|
-
/* floating singles are not 8-aligned on stack */
|
734
|
-
break;
|
735
|
-
|
736
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
737
|
-
case FFI_TYPE_LONGDOUBLE:
|
738
|
-
if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
|
739
|
-
goto do_struct;
|
740
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
741
|
-
{
|
742
|
-
if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
|
743
|
-
|| intarg_count < NUM_GPR_ARG_REGISTERS)
|
744
|
-
/* A long double in FFI_LINUX_SOFT_FLOAT can use only
|
745
|
-
a set of four consecutive gprs. If we have not enough,
|
746
|
-
we have to adjust the intarg_count value. */
|
747
|
-
intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
|
748
|
-
intarg_count += 4;
|
749
|
-
break;
|
750
|
-
}
|
751
|
-
else
|
752
|
-
fparg_count++;
|
753
|
-
/* Fall thru */
|
754
|
-
#endif
|
755
|
-
case FFI_TYPE_DOUBLE:
|
756
|
-
/* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */
|
757
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
758
|
-
goto soft_double_cif;
|
759
|
-
fparg_count++;
|
760
|
-
/* If this FP arg is going on the stack, it must be
|
761
|
-
8-byte-aligned. */
|
762
|
-
if (fparg_count > NUM_FPR_ARG_REGISTERS
|
763
|
-
&& intarg_count >= NUM_GPR_ARG_REGISTERS
|
764
|
-
&& intarg_count % 2 != 0)
|
765
|
-
intarg_count++;
|
766
|
-
break;
|
767
|
-
|
768
|
-
case FFI_TYPE_UINT64:
|
769
|
-
case FFI_TYPE_SINT64:
|
770
|
-
soft_double_cif:
|
771
|
-
/* 'long long' arguments are passed as two words, but
|
772
|
-
either both words must fit in registers or both go
|
773
|
-
on the stack. If they go on the stack, they must
|
774
|
-
be 8-byte-aligned.
|
775
|
-
|
776
|
-
Also, only certain register pairs can be used for
|
777
|
-
passing long long int -- specifically (r3,r4), (r5,r6),
|
778
|
-
(r7,r8), (r9,r10).
|
779
|
-
*/
|
780
|
-
if (intarg_count == NUM_GPR_ARG_REGISTERS-1
|
781
|
-
|| intarg_count % 2 != 0)
|
782
|
-
intarg_count++;
|
783
|
-
intarg_count += 2;
|
784
|
-
break;
|
785
|
-
|
786
|
-
case FFI_TYPE_STRUCT:
|
787
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
788
|
-
do_struct:
|
54
|
+
#ifdef POWERPC64
|
55
|
+
return ffi_prep_cif_linux64 (cif);
|
56
|
+
#else
|
57
|
+
return ffi_prep_cif_sysv (cif);
|
789
58
|
#endif
|
790
|
-
|
791
|
-
pass-by-value. Pad the space up to a multiple of 16
|
792
|
-
bytes (the maximum alignment required for anything under
|
793
|
-
the SYSV ABI). */
|
794
|
-
struct_copy_size += ((*ptr)->size + 15) & ~0xF;
|
795
|
-
/* Fall through (allocate space for the pointer). */
|
59
|
+
}
|
796
60
|
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
|
807
|
-
{
|
808
|
-
switch ((*ptr)->type)
|
809
|
-
{
|
810
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
811
|
-
case FFI_TYPE_LONGDOUBLE:
|
812
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
813
|
-
intarg_count += 4;
|
814
|
-
else
|
815
|
-
{
|
816
|
-
fparg_count += 2;
|
817
|
-
intarg_count += 2;
|
818
|
-
}
|
819
|
-
break;
|
61
|
+
ffi_status FFI_HIDDEN
|
62
|
+
ffi_prep_cif_machdep_var (ffi_cif *cif,
|
63
|
+
unsigned int nfixedargs MAYBE_UNUSED,
|
64
|
+
unsigned int ntotalargs MAYBE_UNUSED)
|
65
|
+
{
|
66
|
+
#ifdef POWERPC64
|
67
|
+
return ffi_prep_cif_linux64_var (cif, nfixedargs, ntotalargs);
|
68
|
+
#else
|
69
|
+
return ffi_prep_cif_sysv (cif);
|
820
70
|
#endif
|
821
|
-
case FFI_TYPE_FLOAT:
|
822
|
-
case FFI_TYPE_DOUBLE:
|
823
|
-
fparg_count++;
|
824
|
-
intarg_count++;
|
825
|
-
break;
|
826
|
-
|
827
|
-
case FFI_TYPE_STRUCT:
|
828
|
-
intarg_count += ((*ptr)->size + 7) / 8;
|
829
|
-
break;
|
830
|
-
|
831
|
-
default:
|
832
|
-
/* Everything else is passed as a 8-byte word in a GPR, either
|
833
|
-
the object itself or a pointer to it. */
|
834
|
-
intarg_count++;
|
835
|
-
break;
|
836
|
-
}
|
837
|
-
}
|
838
|
-
|
839
|
-
if (fparg_count != 0)
|
840
|
-
flags |= FLAG_FP_ARGUMENTS;
|
841
|
-
if (intarg_count > 4)
|
842
|
-
flags |= FLAG_4_GPR_ARGUMENTS;
|
843
|
-
if (struct_copy_size != 0)
|
844
|
-
flags |= FLAG_ARG_NEEDS_COPY;
|
845
|
-
|
846
|
-
if (cif->abi != FFI_LINUX64)
|
847
|
-
{
|
848
|
-
/* Space for the FPR registers, if needed. */
|
849
|
-
if (fparg_count != 0)
|
850
|
-
bytes += NUM_FPR_ARG_REGISTERS * sizeof (double);
|
851
|
-
|
852
|
-
/* Stack space. */
|
853
|
-
if (intarg_count > NUM_GPR_ARG_REGISTERS)
|
854
|
-
bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int);
|
855
|
-
if (fparg_count > NUM_FPR_ARG_REGISTERS)
|
856
|
-
bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double);
|
857
|
-
}
|
858
|
-
else
|
859
|
-
{
|
860
|
-
/* Space for the FPR registers, if needed. */
|
861
|
-
if (fparg_count != 0)
|
862
|
-
bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double);
|
863
|
-
|
864
|
-
/* Stack space. */
|
865
|
-
if (intarg_count > NUM_GPR_ARG_REGISTERS64)
|
866
|
-
bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long);
|
867
|
-
}
|
868
|
-
|
869
|
-
/* The stack space allocated needs to be a multiple of 16 bytes. */
|
870
|
-
bytes = (bytes + 15) & ~0xF;
|
871
|
-
|
872
|
-
/* Add in the space for the copied structures. */
|
873
|
-
bytes += struct_copy_size;
|
874
|
-
|
875
|
-
cif->flags = flags;
|
876
|
-
cif->bytes = bytes;
|
877
|
-
|
878
|
-
return FFI_OK;
|
879
71
|
}
|
880
72
|
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
void
|
888
|
-
ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
|
73
|
+
static void
|
74
|
+
ffi_call_int (ffi_cif *cif,
|
75
|
+
void (*fn) (void),
|
76
|
+
void *rvalue,
|
77
|
+
void **avalue,
|
78
|
+
void *closure)
|
889
79
|
{
|
80
|
+
/* The final SYSV ABI says that structures smaller or equal 8 bytes
|
81
|
+
are returned in r3/r4. A draft ABI used by linux instead returns
|
82
|
+
them in memory.
|
83
|
+
|
84
|
+
We bounce-buffer SYSV small struct return values so that sysv.S
|
85
|
+
can write r3 and r4 to memory without worrying about struct size.
|
86
|
+
|
87
|
+
For ELFv2 ABI, use a bounce buffer for homogeneous structs too,
|
88
|
+
for similar reasons. */
|
89
|
+
unsigned long smst_buffer[8];
|
890
90
|
extended_cif ecif;
|
891
91
|
|
892
92
|
ecif.cif = cif;
|
893
93
|
ecif.avalue = avalue;
|
894
94
|
|
895
|
-
|
896
|
-
|
95
|
+
ecif.rvalue = rvalue;
|
96
|
+
if ((cif->flags & FLAG_RETURNS_SMST) != 0)
|
97
|
+
ecif.rvalue = smst_buffer;
|
98
|
+
/* Ensure that we have a valid struct return value.
|
99
|
+
FIXME: Isn't this just papering over a user problem? */
|
100
|
+
else if (!rvalue && cif->rtype->type == FFI_TYPE_STRUCT)
|
101
|
+
ecif.rvalue = alloca (cif->rtype->size);
|
897
102
|
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
}
|
902
|
-
else
|
903
|
-
ecif.rvalue = rvalue;
|
904
|
-
|
905
|
-
|
906
|
-
switch (cif->abi)
|
907
|
-
{
|
908
|
-
#ifndef POWERPC64
|
909
|
-
case FFI_SYSV:
|
910
|
-
case FFI_GCC_SYSV:
|
911
|
-
case FFI_LINUX:
|
912
|
-
case FFI_LINUX_SOFT_FLOAT:
|
913
|
-
ffi_call_SYSV (&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn);
|
914
|
-
break;
|
103
|
+
#ifdef POWERPC64
|
104
|
+
ffi_call_LINUX64 (&ecif, fn, ecif.rvalue, cif->flags, closure,
|
105
|
+
-(long) cif->bytes);
|
915
106
|
#else
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
107
|
+
ffi_call_SYSV (&ecif, fn, ecif.rvalue, cif->flags, closure, -cif->bytes);
|
108
|
+
#endif
|
109
|
+
|
110
|
+
/* Check for a bounce-buffered return value */
|
111
|
+
if (rvalue && ecif.rvalue == smst_buffer)
|
112
|
+
{
|
113
|
+
unsigned int rsize = cif->rtype->size;
|
114
|
+
#ifndef __LITTLE_ENDIAN__
|
115
|
+
/* The SYSV ABI returns a structure of up to 4 bytes in size
|
116
|
+
left-padded in r3. */
|
117
|
+
# ifndef POWERPC64
|
118
|
+
if (rsize <= 4)
|
119
|
+
memcpy (rvalue, (char *) smst_buffer + 4 - rsize, rsize);
|
120
|
+
else
|
121
|
+
# endif
|
122
|
+
/* The SYSV ABI returns a structure of up to 8 bytes in size
|
123
|
+
left-padded in r3/r4, and the ELFv2 ABI similarly returns a
|
124
|
+
structure of up to 8 bytes in size left-padded in r3. */
|
125
|
+
if (rsize <= 8)
|
126
|
+
memcpy (rvalue, (char *) smst_buffer + 8 - rsize, rsize);
|
127
|
+
else
|
128
|
+
#endif
|
129
|
+
memcpy (rvalue, smst_buffer, rsize);
|
923
130
|
}
|
924
131
|
}
|
925
132
|
|
133
|
+
void
|
134
|
+
ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
|
135
|
+
{
|
136
|
+
ffi_call_int (cif, fn, rvalue, avalue, NULL);
|
137
|
+
}
|
926
138
|
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
static void
|
931
|
-
flush_icache (char *wraddr, char *xaddr, int size)
|
139
|
+
void
|
140
|
+
ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
|
141
|
+
void *closure)
|
932
142
|
{
|
933
|
-
|
934
|
-
for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
|
935
|
-
__asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
|
936
|
-
: : "r" (xaddr + i), "r" (wraddr + i) : "memory");
|
937
|
-
__asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
|
938
|
-
: : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
|
939
|
-
: "memory");
|
143
|
+
ffi_call_int (cif, fn, rvalue, avalue, closure);
|
940
144
|
}
|
941
|
-
#endif
|
942
145
|
|
943
146
|
ffi_status
|
944
147
|
ffi_prep_closure_loc (ffi_closure *closure,
|
@@ -948,501 +151,23 @@ ffi_prep_closure_loc (ffi_closure *closure,
|
|
948
151
|
void *codeloc)
|
949
152
|
{
|
950
153
|
#ifdef POWERPC64
|
951
|
-
|
952
|
-
|
953
|
-
if (cif->abi != FFI_LINUX64)
|
954
|
-
return FFI_BAD_ABI;
|
955
|
-
/* Copy function address and TOC from ffi_closure_LINUX64. */
|
956
|
-
memcpy (tramp, (char *) ffi_closure_LINUX64, 16);
|
957
|
-
tramp[2] = codeloc;
|
154
|
+
return ffi_prep_closure_loc_linux64 (closure, cif, fun, user_data, codeloc);
|
958
155
|
#else
|
959
|
-
|
960
|
-
|
961
|
-
if (! (cif->abi == FFI_GCC_SYSV
|
962
|
-
|| cif->abi == FFI_SYSV
|
963
|
-
|| cif->abi == FFI_LINUX
|
964
|
-
|| cif->abi == FFI_LINUX_SOFT_FLOAT))
|
965
|
-
return FFI_BAD_ABI;
|
966
|
-
|
967
|
-
tramp = (unsigned int *) &closure->tramp[0];
|
968
|
-
tramp[0] = 0x7c0802a6; /* mflr r0 */
|
969
|
-
tramp[1] = 0x4800000d; /* bl 10 <trampoline_initial+0x10> */
|
970
|
-
tramp[4] = 0x7d6802a6; /* mflr r11 */
|
971
|
-
tramp[5] = 0x7c0803a6; /* mtlr r0 */
|
972
|
-
tramp[6] = 0x800b0000; /* lwz r0,0(r11) */
|
973
|
-
tramp[7] = 0x816b0004; /* lwz r11,4(r11) */
|
974
|
-
tramp[8] = 0x7c0903a6; /* mtctr r0 */
|
975
|
-
tramp[9] = 0x4e800420; /* bctr */
|
976
|
-
*(void **) &tramp[2] = (void *) ffi_closure_SYSV; /* function */
|
977
|
-
*(void **) &tramp[3] = codeloc; /* context */
|
978
|
-
|
979
|
-
/* Flush the icache. */
|
980
|
-
flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
|
981
|
-
#endif
|
982
|
-
|
983
|
-
closure->cif = cif;
|
984
|
-
closure->fun = fun;
|
985
|
-
closure->user_data = user_data;
|
986
|
-
|
987
|
-
return FFI_OK;
|
988
|
-
}
|
989
|
-
|
990
|
-
typedef union
|
991
|
-
{
|
992
|
-
float f;
|
993
|
-
double d;
|
994
|
-
} ffi_dblfl;
|
995
|
-
|
996
|
-
int ffi_closure_helper_SYSV (ffi_closure *, void *, unsigned long *,
|
997
|
-
ffi_dblfl *, unsigned long *);
|
998
|
-
|
999
|
-
/* Basically the trampoline invokes ffi_closure_SYSV, and on
|
1000
|
-
* entry, r11 holds the address of the closure.
|
1001
|
-
* After storing the registers that could possibly contain
|
1002
|
-
* parameters to be passed into the stack frame and setting
|
1003
|
-
* up space for a return value, ffi_closure_SYSV invokes the
|
1004
|
-
* following helper function to do most of the work
|
1005
|
-
*/
|
1006
|
-
|
1007
|
-
int
|
1008
|
-
ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
|
1009
|
-
unsigned long *pgr, ffi_dblfl *pfr,
|
1010
|
-
unsigned long *pst)
|
1011
|
-
{
|
1012
|
-
/* rvalue is the pointer to space for return value in closure assembly */
|
1013
|
-
/* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
|
1014
|
-
/* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV */
|
1015
|
-
/* pst is the pointer to outgoing parameter stack in original caller */
|
1016
|
-
|
1017
|
-
void ** avalue;
|
1018
|
-
ffi_type ** arg_types;
|
1019
|
-
long i, avn;
|
1020
|
-
long nf; /* number of floating registers already used */
|
1021
|
-
long ng; /* number of general registers already used */
|
1022
|
-
ffi_cif * cif;
|
1023
|
-
double temp;
|
1024
|
-
unsigned size;
|
1025
|
-
|
1026
|
-
cif = closure->cif;
|
1027
|
-
avalue = alloca (cif->nargs * sizeof (void *));
|
1028
|
-
size = cif->rtype->size;
|
1029
|
-
|
1030
|
-
nf = 0;
|
1031
|
-
ng = 0;
|
1032
|
-
|
1033
|
-
/* Copy the caller's structure return value address so that the closure
|
1034
|
-
returns the data directly to the caller.
|
1035
|
-
For FFI_SYSV the result is passed in r3/r4 if the struct size is less
|
1036
|
-
or equal 8 bytes. */
|
1037
|
-
|
1038
|
-
if ((cif->rtype->type == FFI_TYPE_STRUCT
|
1039
|
-
&& !((cif->abi == FFI_SYSV) && (size <= 8)))
|
1040
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
1041
|
-
|| (cif->rtype->type == FFI_TYPE_LONGDOUBLE
|
1042
|
-
&& cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
|
1043
|
-
#endif
|
1044
|
-
)
|
1045
|
-
{
|
1046
|
-
rvalue = (void *) *pgr;
|
1047
|
-
ng++;
|
1048
|
-
pgr++;
|
1049
|
-
}
|
1050
|
-
|
1051
|
-
i = 0;
|
1052
|
-
avn = cif->nargs;
|
1053
|
-
arg_types = cif->arg_types;
|
1054
|
-
|
1055
|
-
/* Grab the addresses of the arguments from the stack frame. */
|
1056
|
-
while (i < avn)
|
1057
|
-
{
|
1058
|
-
switch (arg_types[i]->type)
|
1059
|
-
{
|
1060
|
-
case FFI_TYPE_SINT8:
|
1061
|
-
case FFI_TYPE_UINT8:
|
1062
|
-
/* there are 8 gpr registers used to pass values */
|
1063
|
-
if (ng < 8)
|
1064
|
-
{
|
1065
|
-
avalue[i] = (char *) pgr + 3;
|
1066
|
-
ng++;
|
1067
|
-
pgr++;
|
1068
|
-
}
|
1069
|
-
else
|
1070
|
-
{
|
1071
|
-
avalue[i] = (char *) pst + 3;
|
1072
|
-
pst++;
|
1073
|
-
}
|
1074
|
-
break;
|
1075
|
-
|
1076
|
-
case FFI_TYPE_SINT16:
|
1077
|
-
case FFI_TYPE_UINT16:
|
1078
|
-
/* there are 8 gpr registers used to pass values */
|
1079
|
-
if (ng < 8)
|
1080
|
-
{
|
1081
|
-
avalue[i] = (char *) pgr + 2;
|
1082
|
-
ng++;
|
1083
|
-
pgr++;
|
1084
|
-
}
|
1085
|
-
else
|
1086
|
-
{
|
1087
|
-
avalue[i] = (char *) pst + 2;
|
1088
|
-
pst++;
|
1089
|
-
}
|
1090
|
-
break;
|
1091
|
-
|
1092
|
-
case FFI_TYPE_SINT32:
|
1093
|
-
case FFI_TYPE_UINT32:
|
1094
|
-
case FFI_TYPE_POINTER:
|
1095
|
-
soft_float_closure:
|
1096
|
-
/* there are 8 gpr registers used to pass values */
|
1097
|
-
if (ng < 8)
|
1098
|
-
{
|
1099
|
-
avalue[i] = pgr;
|
1100
|
-
ng++;
|
1101
|
-
pgr++;
|
1102
|
-
}
|
1103
|
-
else
|
1104
|
-
{
|
1105
|
-
avalue[i] = pst;
|
1106
|
-
pst++;
|
1107
|
-
}
|
1108
|
-
break;
|
1109
|
-
|
1110
|
-
case FFI_TYPE_STRUCT:
|
1111
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
1112
|
-
do_struct:
|
1113
|
-
#endif
|
1114
|
-
/* Structs are passed by reference. The address will appear in a
|
1115
|
-
gpr if it is one of the first 8 arguments. */
|
1116
|
-
if (ng < 8)
|
1117
|
-
{
|
1118
|
-
avalue[i] = (void *) *pgr;
|
1119
|
-
ng++;
|
1120
|
-
pgr++;
|
1121
|
-
}
|
1122
|
-
else
|
1123
|
-
{
|
1124
|
-
avalue[i] = (void *) *pst;
|
1125
|
-
pst++;
|
1126
|
-
}
|
1127
|
-
break;
|
1128
|
-
|
1129
|
-
case FFI_TYPE_SINT64:
|
1130
|
-
case FFI_TYPE_UINT64:
|
1131
|
-
soft_double_closure:
|
1132
|
-
/* passing long long ints are complex, they must
|
1133
|
-
* be passed in suitable register pairs such as
|
1134
|
-
* (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
|
1135
|
-
* and if the entire pair aren't available then the outgoing
|
1136
|
-
* parameter stack is used for both but an alignment of 8
|
1137
|
-
* must will be kept. So we must either look in pgr
|
1138
|
-
* or pst to find the correct address for this type
|
1139
|
-
* of parameter.
|
1140
|
-
*/
|
1141
|
-
if (ng < 7)
|
1142
|
-
{
|
1143
|
-
if (ng & 0x01)
|
1144
|
-
{
|
1145
|
-
/* skip r4, r6, r8 as starting points */
|
1146
|
-
ng++;
|
1147
|
-
pgr++;
|
1148
|
-
}
|
1149
|
-
avalue[i] = pgr;
|
1150
|
-
ng += 2;
|
1151
|
-
pgr += 2;
|
1152
|
-
}
|
1153
|
-
else
|
1154
|
-
{
|
1155
|
-
if (((long) pst) & 4)
|
1156
|
-
pst++;
|
1157
|
-
avalue[i] = pst;
|
1158
|
-
pst += 2;
|
1159
|
-
ng = 8;
|
1160
|
-
}
|
1161
|
-
break;
|
1162
|
-
|
1163
|
-
case FFI_TYPE_FLOAT:
|
1164
|
-
/* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32. */
|
1165
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
1166
|
-
goto soft_float_closure;
|
1167
|
-
/* unfortunately float values are stored as doubles
|
1168
|
-
* in the ffi_closure_SYSV code (since we don't check
|
1169
|
-
* the type in that routine).
|
1170
|
-
*/
|
1171
|
-
|
1172
|
-
/* there are 8 64bit floating point registers */
|
1173
|
-
|
1174
|
-
if (nf < 8)
|
1175
|
-
{
|
1176
|
-
temp = pfr->d;
|
1177
|
-
pfr->f = (float) temp;
|
1178
|
-
avalue[i] = pfr;
|
1179
|
-
nf++;
|
1180
|
-
pfr++;
|
1181
|
-
}
|
1182
|
-
else
|
1183
|
-
{
|
1184
|
-
/* FIXME? here we are really changing the values
|
1185
|
-
* stored in the original calling routines outgoing
|
1186
|
-
* parameter stack. This is probably a really
|
1187
|
-
* naughty thing to do but...
|
1188
|
-
*/
|
1189
|
-
avalue[i] = pst;
|
1190
|
-
pst += 1;
|
1191
|
-
}
|
1192
|
-
break;
|
1193
|
-
|
1194
|
-
case FFI_TYPE_DOUBLE:
|
1195
|
-
/* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64. */
|
1196
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
1197
|
-
goto soft_double_closure;
|
1198
|
-
/* On the outgoing stack all values are aligned to 8 */
|
1199
|
-
/* there are 8 64bit floating point registers */
|
1200
|
-
|
1201
|
-
if (nf < 8)
|
1202
|
-
{
|
1203
|
-
avalue[i] = pfr;
|
1204
|
-
nf++;
|
1205
|
-
pfr++;
|
1206
|
-
}
|
1207
|
-
else
|
1208
|
-
{
|
1209
|
-
if (((long) pst) & 4)
|
1210
|
-
pst++;
|
1211
|
-
avalue[i] = pst;
|
1212
|
-
pst += 2;
|
1213
|
-
}
|
1214
|
-
break;
|
1215
|
-
|
1216
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
1217
|
-
case FFI_TYPE_LONGDOUBLE:
|
1218
|
-
if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
|
1219
|
-
goto do_struct;
|
1220
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
1221
|
-
{ /* Test if for the whole long double, 4 gprs are available.
|
1222
|
-
otherwise the stuff ends up on the stack. */
|
1223
|
-
if (ng < 5)
|
1224
|
-
{
|
1225
|
-
avalue[i] = pgr;
|
1226
|
-
pgr += 4;
|
1227
|
-
ng += 4;
|
1228
|
-
}
|
1229
|
-
else
|
1230
|
-
{
|
1231
|
-
avalue[i] = pst;
|
1232
|
-
pst += 4;
|
1233
|
-
ng = 8;
|
1234
|
-
}
|
1235
|
-
break;
|
1236
|
-
}
|
1237
|
-
if (nf < 7)
|
1238
|
-
{
|
1239
|
-
avalue[i] = pfr;
|
1240
|
-
pfr += 2;
|
1241
|
-
nf += 2;
|
1242
|
-
}
|
1243
|
-
else
|
1244
|
-
{
|
1245
|
-
if (((long) pst) & 4)
|
1246
|
-
pst++;
|
1247
|
-
avalue[i] = pst;
|
1248
|
-
pst += 4;
|
1249
|
-
nf = 8;
|
1250
|
-
}
|
1251
|
-
break;
|
1252
|
-
#endif
|
1253
|
-
|
1254
|
-
default:
|
1255
|
-
FFI_ASSERT (0);
|
1256
|
-
}
|
1257
|
-
|
1258
|
-
i++;
|
1259
|
-
}
|
1260
|
-
|
1261
|
-
|
1262
|
-
(closure->fun) (cif, rvalue, avalue, closure->user_data);
|
1263
|
-
|
1264
|
-
/* Tell ffi_closure_SYSV how to perform return type promotions.
|
1265
|
-
Because the FFI_SYSV ABI returns the structures <= 8 bytes in r3/r4
|
1266
|
-
we have to tell ffi_closure_SYSV how to treat them. We combine the base
|
1267
|
-
type FFI_SYSV_TYPE_SMALL_STRUCT - 1 with the size of the struct.
|
1268
|
-
So a one byte struct gets the return type 16. Return type 1 to 15 are
|
1269
|
-
already used and we never have a struct with size zero. That is the reason
|
1270
|
-
for the subtraction of 1. See the comment in ffitarget.h about ordering.
|
1271
|
-
*/
|
1272
|
-
if (cif->abi == FFI_SYSV && cif->rtype->type == FFI_TYPE_STRUCT
|
1273
|
-
&& size <= 8)
|
1274
|
-
return (FFI_SYSV_TYPE_SMALL_STRUCT - 1) + size;
|
1275
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
1276
|
-
else if (cif->rtype->type == FFI_TYPE_LONGDOUBLE
|
1277
|
-
&& cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
|
1278
|
-
return FFI_TYPE_STRUCT;
|
1279
|
-
#endif
|
1280
|
-
/* With FFI_LINUX_SOFT_FLOAT floats and doubles are handled like UINT32
|
1281
|
-
respectivley UINT64. */
|
1282
|
-
if (cif->abi == FFI_LINUX_SOFT_FLOAT)
|
1283
|
-
{
|
1284
|
-
switch (cif->rtype->type)
|
1285
|
-
{
|
1286
|
-
case FFI_TYPE_FLOAT:
|
1287
|
-
return FFI_TYPE_UINT32;
|
1288
|
-
break;
|
1289
|
-
case FFI_TYPE_DOUBLE:
|
1290
|
-
return FFI_TYPE_UINT64;
|
1291
|
-
break;
|
1292
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
1293
|
-
case FFI_TYPE_LONGDOUBLE:
|
1294
|
-
return FFI_TYPE_UINT128;
|
1295
|
-
break;
|
156
|
+
return ffi_prep_closure_loc_sysv (closure, cif, fun, user_data, codeloc);
|
1296
157
|
#endif
|
1297
|
-
default:
|
1298
|
-
return cif->rtype->type;
|
1299
|
-
}
|
1300
|
-
}
|
1301
|
-
else
|
1302
|
-
{
|
1303
|
-
return cif->rtype->type;
|
1304
|
-
}
|
1305
158
|
}
|
1306
159
|
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
|
1312
|
-
unsigned long *pst, ffi_dblfl *pfr)
|
160
|
+
ffi_status
|
161
|
+
ffi_prep_go_closure (ffi_go_closure *closure,
|
162
|
+
ffi_cif *cif,
|
163
|
+
void (*fun) (ffi_cif *, void *, void **, void *))
|
1313
164
|
{
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
void **avalue;
|
1320
|
-
ffi_type **arg_types;
|
1321
|
-
long i, avn;
|
1322
|
-
ffi_cif *cif;
|
1323
|
-
ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
|
1324
|
-
|
1325
|
-
cif = closure->cif;
|
1326
|
-
avalue = alloca (cif->nargs * sizeof (void *));
|
1327
|
-
|
1328
|
-
/* Copy the caller's structure return value address so that the closure
|
1329
|
-
returns the data directly to the caller. */
|
1330
|
-
if (cif->rtype->type == FFI_TYPE_STRUCT)
|
1331
|
-
{
|
1332
|
-
rvalue = (void *) *pst;
|
1333
|
-
pst++;
|
1334
|
-
}
|
1335
|
-
|
1336
|
-
i = 0;
|
1337
|
-
avn = cif->nargs;
|
1338
|
-
arg_types = cif->arg_types;
|
1339
|
-
|
1340
|
-
/* Grab the addresses of the arguments from the stack frame. */
|
1341
|
-
while (i < avn)
|
1342
|
-
{
|
1343
|
-
switch (arg_types[i]->type)
|
1344
|
-
{
|
1345
|
-
case FFI_TYPE_SINT8:
|
1346
|
-
case FFI_TYPE_UINT8:
|
1347
|
-
avalue[i] = (char *) pst + 7;
|
1348
|
-
pst++;
|
1349
|
-
break;
|
1350
|
-
|
1351
|
-
case FFI_TYPE_SINT16:
|
1352
|
-
case FFI_TYPE_UINT16:
|
1353
|
-
avalue[i] = (char *) pst + 6;
|
1354
|
-
pst++;
|
1355
|
-
break;
|
1356
|
-
|
1357
|
-
case FFI_TYPE_SINT32:
|
1358
|
-
case FFI_TYPE_UINT32:
|
1359
|
-
avalue[i] = (char *) pst + 4;
|
1360
|
-
pst++;
|
1361
|
-
break;
|
1362
|
-
|
1363
|
-
case FFI_TYPE_SINT64:
|
1364
|
-
case FFI_TYPE_UINT64:
|
1365
|
-
case FFI_TYPE_POINTER:
|
1366
|
-
avalue[i] = pst;
|
1367
|
-
pst++;
|
1368
|
-
break;
|
1369
|
-
|
1370
|
-
case FFI_TYPE_STRUCT:
|
1371
|
-
/* Structures with size less than eight bytes are passed
|
1372
|
-
left-padded. */
|
1373
|
-
if (arg_types[i]->size < 8)
|
1374
|
-
avalue[i] = (char *) pst + 8 - arg_types[i]->size;
|
1375
|
-
else
|
1376
|
-
avalue[i] = pst;
|
1377
|
-
pst += (arg_types[i]->size + 7) / 8;
|
1378
|
-
break;
|
1379
|
-
|
1380
|
-
case FFI_TYPE_FLOAT:
|
1381
|
-
/* unfortunately float values are stored as doubles
|
1382
|
-
* in the ffi_closure_LINUX64 code (since we don't check
|
1383
|
-
* the type in that routine).
|
1384
|
-
*/
|
1385
|
-
|
1386
|
-
/* there are 13 64bit floating point registers */
|
1387
|
-
|
1388
|
-
if (pfr < end_pfr)
|
1389
|
-
{
|
1390
|
-
double temp = pfr->d;
|
1391
|
-
pfr->f = (float) temp;
|
1392
|
-
avalue[i] = pfr;
|
1393
|
-
pfr++;
|
1394
|
-
}
|
1395
|
-
else
|
1396
|
-
avalue[i] = pst;
|
1397
|
-
pst++;
|
1398
|
-
break;
|
1399
|
-
|
1400
|
-
case FFI_TYPE_DOUBLE:
|
1401
|
-
/* On the outgoing stack all values are aligned to 8 */
|
1402
|
-
/* there are 13 64bit floating point registers */
|
1403
|
-
|
1404
|
-
if (pfr < end_pfr)
|
1405
|
-
{
|
1406
|
-
avalue[i] = pfr;
|
1407
|
-
pfr++;
|
1408
|
-
}
|
1409
|
-
else
|
1410
|
-
avalue[i] = pst;
|
1411
|
-
pst++;
|
1412
|
-
break;
|
1413
|
-
|
1414
|
-
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
1415
|
-
case FFI_TYPE_LONGDOUBLE:
|
1416
|
-
if (pfr + 1 < end_pfr)
|
1417
|
-
{
|
1418
|
-
avalue[i] = pfr;
|
1419
|
-
pfr += 2;
|
1420
|
-
}
|
1421
|
-
else
|
1422
|
-
{
|
1423
|
-
if (pfr < end_pfr)
|
1424
|
-
{
|
1425
|
-
/* Passed partly in f13 and partly on the stack.
|
1426
|
-
Move it all to the stack. */
|
1427
|
-
*pst = *(unsigned long *) pfr;
|
1428
|
-
pfr++;
|
1429
|
-
}
|
1430
|
-
avalue[i] = pst;
|
1431
|
-
}
|
1432
|
-
pst += 2;
|
1433
|
-
break;
|
165
|
+
#ifdef POWERPC64
|
166
|
+
closure->tramp = ffi_go_closure_linux64;
|
167
|
+
#else
|
168
|
+
closure->tramp = ffi_go_closure_sysv;
|
1434
169
|
#endif
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
}
|
1439
|
-
|
1440
|
-
i++;
|
1441
|
-
}
|
1442
|
-
|
1443
|
-
|
1444
|
-
(closure->fun) (cif, rvalue, avalue, closure->user_data);
|
1445
|
-
|
1446
|
-
/* Tell ffi_closure_LINUX64 how to perform return type promotions. */
|
1447
|
-
return cif->rtype->type;
|
170
|
+
closure->cif = cif;
|
171
|
+
closure->fun = fun;
|
172
|
+
return FFI_OK;
|
1448
173
|
}
|