ffi 1.11.2 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.appveyor.yml +3 -0
- data/.github/workflows/ci.yml +64 -0
- data/.travis.yml +21 -5
- data/CHANGELOG.md +64 -0
- data/Gemfile +6 -4
- data/README.md +10 -1
- data/Rakefile +24 -43
- data/ext/ffi_c/AbstractMemory.c +5 -9
- data/ext/ffi_c/Buffer.c +2 -2
- data/ext/ffi_c/Call.c +1 -11
- data/ext/ffi_c/ClosurePool.c +11 -14
- data/ext/ffi_c/DynamicLibrary.c +1 -1
- data/ext/ffi_c/Function.c +9 -24
- data/ext/ffi_c/FunctionInfo.c +1 -2
- data/ext/ffi_c/LongDouble.c +5 -3
- data/ext/ffi_c/LongDouble.h +0 -4
- data/ext/ffi_c/MemoryPointer.c +1 -1
- data/ext/ffi_c/MethodHandle.c +18 -24
- data/ext/ffi_c/MethodHandle.h +3 -2
- data/ext/ffi_c/Platform.c +1 -0
- data/ext/ffi_c/Pointer.c +1 -1
- data/ext/ffi_c/Struct.c +47 -51
- data/ext/ffi_c/Struct.h +12 -6
- data/ext/ffi_c/StructLayout.c +20 -14
- data/ext/ffi_c/Thread.c +0 -3
- data/ext/ffi_c/Thread.h +0 -3
- data/ext/ffi_c/Types.c +1 -1
- data/ext/ffi_c/compat.h +4 -0
- data/ext/ffi_c/extconf.rb +13 -16
- data/ext/ffi_c/libffi/.travis.yml +32 -12
- data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
- data/ext/ffi_c/libffi/.travis/build-in-container.sh +2 -12
- data/ext/ffi_c/libffi/.travis/build.sh +62 -30
- data/ext/ffi_c/libffi/.travis/install.sh +65 -37
- data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
- data/ext/ffi_c/libffi/.travis/site.exp +10 -1
- data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
- data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
- data/ext/ffi_c/libffi/LICENSE +1 -1
- data/ext/ffi_c/libffi/Makefile.am +6 -4
- data/ext/ffi_c/libffi/README.md +18 -6
- data/ext/ffi_c/libffi/configure.ac +26 -10
- data/ext/ffi_c/libffi/configure.host +5 -2
- data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +1 -3
- data/ext/ffi_c/libffi/include/ffi.h.in +15 -7
- data/ext/ffi_c/libffi/libffi.map.in +8 -12
- data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
- data/ext/ffi_c/libffi/libtool-version +1 -1
- data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
- data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
- data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
- data/ext/ffi_c/libffi/src/aarch64/ffi.c +6 -0
- data/ext/ffi_c/libffi/src/aarch64/sysv.S +13 -2
- data/ext/ffi_c/libffi/src/closures.c +20 -6
- data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
- data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
- data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
- data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
- data/ext/ffi_c/libffi/src/pa/linux.S +4 -2
- data/ext/ffi_c/libffi/src/powerpc/ffi.c +3 -2
- data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +154 -8
- data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
- data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
- data/ext/ffi_c/libffi/src/powerpc/linux64.S +83 -28
- data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +67 -3
- data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
- data/ext/ffi_c/libffi/src/x86/ffi.c +7 -4
- data/ext/ffi_c/libffi/src/x86/ffi64.c +10 -8
- data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
- data/ext/ffi_c/libffi/src/x86/ffiw64.c +10 -8
- data/ext/ffi_c/libffi/src/x86/sysv.S +13 -4
- data/ext/ffi_c/libffi/src/x86/unix64.S +58 -2
- data/ext/ffi_c/libffi/src/x86/win64.S +4 -1
- data/ext/ffi_c/libffi/testsuite/Makefile.am +78 -75
- data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +1 -18
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +1 -1
- data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
- data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
- data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +1 -1
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
- data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
- data/ffi.gemspec +3 -3
- data/lib/ffi.rb +10 -2
- data/lib/ffi/ffi.rb +1 -0
- data/lib/ffi/library.rb +5 -1
- data/lib/ffi/platform.rb +2 -2
- data/lib/ffi/platform/arm-linux/types.conf +32 -4
- data/lib/ffi/platform/i386-windows/types.conf +26 -79
- data/lib/ffi/platform/powerpc-linux/types.conf +32 -2
- data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
- data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
- data/lib/ffi/platform/x86_64-darwin/types.conf +4 -0
- data/lib/ffi/platform/x86_64-linux/types.conf +21 -0
- data/lib/ffi/platform/x86_64-windows/types.conf +10 -78
- data/lib/ffi/pointer.rb +19 -12
- data/lib/ffi/struct.rb +10 -5
- data/lib/ffi/tools/types_generator.rb +2 -0
- data/lib/ffi/version.rb +1 -1
- data/samples/getlogin.rb +1 -1
- data/samples/getpid.rb +1 -1
- data/samples/gettimeofday.rb +8 -8
- data/samples/hello.rb +2 -1
- data/samples/inotify.rb +1 -1
- data/samples/pty.rb +1 -2
- data/samples/qsort.rb +0 -1
- metadata +116 -110
- data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
- data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
- data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
- data/samples/sample_helper.rb +0 -6
@@ -68,12 +68,7 @@ typedef enum ffi_abi {
|
|
68
68
|
|
69
69
|
#define FFI_CLOSURES 1
|
70
70
|
#define FFI_NATIVE_RAW_API 0
|
71
|
-
|
72
|
-
#ifdef PA_LINUX
|
73
|
-
#define FFI_TRAMPOLINE_SIZE 32
|
74
|
-
#else
|
75
|
-
#define FFI_TRAMPOLINE_SIZE 40
|
76
|
-
#endif
|
71
|
+
#define FFI_TRAMPOLINE_SIZE 12
|
77
72
|
|
78
73
|
#define FFI_TYPE_SMALL_STRUCT2 -1
|
79
74
|
#define FFI_TYPE_SMALL_STRUCT3 -2
|
@@ -259,7 +259,7 @@ L$done
|
|
259
259
|
L$FE1
|
260
260
|
|
261
261
|
/* void ffi_closure_pa32(void);
|
262
|
-
Called with closure argument in %
|
262
|
+
Called with closure argument in %r19 */
|
263
263
|
|
264
264
|
.SPACE $TEXT$
|
265
265
|
.SUBSPA $CODE$
|
@@ -285,7 +285,9 @@ L$CFI22
|
|
285
285
|
stw %arg2, -44(%r3)
|
286
286
|
stw %arg3, -48(%r3)
|
287
287
|
|
288
|
-
|
288
|
+
/* Retrieve closure pointer and real gp. */
|
289
|
+
copy %r19, %arg0
|
290
|
+
ldw 8(%r19), %r19
|
289
291
|
bl ffi_closure_inner_pa32, %r2
|
290
292
|
copy %r3, %arg1
|
291
293
|
ldwm -64(%sp), %r3
|
@@ -252,7 +252,7 @@ ffi_call_pa32:
|
|
252
252
|
.LFE1:
|
253
253
|
|
254
254
|
/* void ffi_closure_pa32(void);
|
255
|
-
Called with closure argument in %
|
255
|
+
Called with closure argument in %r19 */
|
256
256
|
.export ffi_closure_pa32,code
|
257
257
|
.import ffi_closure_inner_pa32,code
|
258
258
|
|
@@ -277,7 +277,9 @@ ffi_closure_pa32:
|
|
277
277
|
stw %arg2, -44(%r3)
|
278
278
|
stw %arg3, -48(%r3)
|
279
279
|
|
280
|
-
|
280
|
+
/* Retrieve closure pointer and real gp. */
|
281
|
+
copy %r19, %arg0
|
282
|
+
ldw 8(%r19), %r19
|
281
283
|
bl ffi_closure_inner_pa32, %r2
|
282
284
|
copy %r3, %arg1
|
283
285
|
|
@@ -85,8 +85,9 @@ ffi_call_int (ffi_cif *cif,
|
|
85
85
|
can write r3 and r4 to memory without worrying about struct size.
|
86
86
|
|
87
87
|
For ELFv2 ABI, use a bounce buffer for homogeneous structs too,
|
88
|
-
for similar reasons.
|
89
|
-
|
88
|
+
for similar reasons. This bounce buffer must be aligned to 16
|
89
|
+
bytes for use with homogeneous structs of vectors (float128). */
|
90
|
+
float128 smst_buffer[8];
|
90
91
|
extended_cif ecif;
|
91
92
|
|
92
93
|
ecif.cif = cif;
|
@@ -38,7 +38,8 @@
|
|
38
38
|
/* About the LINUX64 ABI. */
|
39
39
|
enum {
|
40
40
|
NUM_GPR_ARG_REGISTERS64 = 8,
|
41
|
-
NUM_FPR_ARG_REGISTERS64 = 13
|
41
|
+
NUM_FPR_ARG_REGISTERS64 = 13,
|
42
|
+
NUM_VEC_ARG_REGISTERS64 = 12,
|
42
43
|
};
|
43
44
|
enum { ASM_NEEDS_REGISTERS64 = 4 };
|
44
45
|
|
@@ -81,11 +82,12 @@ discover_homogeneous_aggregate (ffi_abi abi,
|
|
81
82
|
of FPRs, but according to the ABI must be considered
|
82
83
|
distinct from doubles. They are also limited to a
|
83
84
|
maximum of four members in a homogeneous aggregate. */
|
84
|
-
else
|
85
|
+
else if ((abi & FFI_LINUX_LONG_DOUBLE_IEEE128) == 0)
|
85
86
|
{
|
86
87
|
*elnum = 2;
|
87
88
|
return FFI_TYPE_LONGDOUBLE;
|
88
89
|
}
|
90
|
+
/* Fall through. */
|
89
91
|
#endif
|
90
92
|
case FFI_TYPE_FLOAT:
|
91
93
|
case FFI_TYPE_DOUBLE:
|
@@ -130,13 +132,23 @@ ffi_prep_cif_linux64_core (ffi_cif *cif)
|
|
130
132
|
{
|
131
133
|
ffi_type **ptr;
|
132
134
|
unsigned bytes;
|
133
|
-
unsigned i, fparg_count = 0, intarg_count = 0;
|
135
|
+
unsigned i, fparg_count = 0, intarg_count = 0, vecarg_count = 0;
|
134
136
|
unsigned flags = cif->flags;
|
135
137
|
unsigned elt, elnum, rtype;
|
136
138
|
|
137
139
|
#if FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE
|
138
|
-
/* If compiled without long double support
|
139
|
-
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0
|
140
|
+
/* If compiled without long double support... */
|
141
|
+
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0 ||
|
142
|
+
(cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
143
|
+
return FFI_BAD_ABI;
|
144
|
+
#elif !defined(__VEC__)
|
145
|
+
/* If compiled without vector register support (used by assembly)... */
|
146
|
+
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
147
|
+
return FFI_BAD_ABI;
|
148
|
+
#else
|
149
|
+
/* If the IEEE128 flag is set, but long double is only 64 bits wide... */
|
150
|
+
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) == 0 &&
|
151
|
+
(cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
140
152
|
return FFI_BAD_ABI;
|
141
153
|
#endif
|
142
154
|
|
@@ -166,6 +178,11 @@ homogeneous:
|
|
166
178
|
{
|
167
179
|
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
168
180
|
case FFI_TYPE_LONGDOUBLE:
|
181
|
+
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
182
|
+
{
|
183
|
+
flags |= FLAG_RETURNS_VEC;
|
184
|
+
break;
|
185
|
+
}
|
169
186
|
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
|
170
187
|
flags |= FLAG_RETURNS_128BITS;
|
171
188
|
/* Fall through. */
|
@@ -221,6 +238,15 @@ homogeneous:
|
|
221
238
|
{
|
222
239
|
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
223
240
|
case FFI_TYPE_LONGDOUBLE:
|
241
|
+
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
242
|
+
{
|
243
|
+
vecarg_count++;
|
244
|
+
/* Align to 16 bytes, plus the 16-byte argument. */
|
245
|
+
intarg_count = (intarg_count + 3) & ~0x1;
|
246
|
+
if (vecarg_count > NUM_VEC_ARG_REGISTERS64)
|
247
|
+
flags |= FLAG_ARG_NEEDS_PSAVE;
|
248
|
+
break;
|
249
|
+
}
|
224
250
|
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
|
225
251
|
{
|
226
252
|
fparg_count++;
|
@@ -248,6 +274,17 @@ homogeneous:
|
|
248
274
|
}
|
249
275
|
intarg_count += ((*ptr)->size + 7) / 8;
|
250
276
|
elt = discover_homogeneous_aggregate (cif->abi, *ptr, &elnum);
|
277
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
278
|
+
if (elt == FFI_TYPE_LONGDOUBLE &&
|
279
|
+
(cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
280
|
+
{
|
281
|
+
vecarg_count += elnum;
|
282
|
+
if (vecarg_count > NUM_VEC_ARG_REGISTERS64)
|
283
|
+
flags |= FLAG_ARG_NEEDS_PSAVE;
|
284
|
+
break;
|
285
|
+
}
|
286
|
+
else
|
287
|
+
#endif
|
251
288
|
if (elt)
|
252
289
|
{
|
253
290
|
fparg_count += elnum;
|
@@ -286,10 +323,17 @@ homogeneous:
|
|
286
323
|
flags |= FLAG_FP_ARGUMENTS;
|
287
324
|
if (intarg_count > 4)
|
288
325
|
flags |= FLAG_4_GPR_ARGUMENTS;
|
326
|
+
if (vecarg_count != 0)
|
327
|
+
flags |= FLAG_VEC_ARGUMENTS;
|
289
328
|
|
290
329
|
/* Space for the FPR registers, if needed. */
|
291
330
|
if (fparg_count != 0)
|
292
331
|
bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double);
|
332
|
+
/* Space for the vector registers, if needed, aligned to 16 bytes. */
|
333
|
+
if (vecarg_count != 0) {
|
334
|
+
bytes = (bytes + 15) & ~0xF;
|
335
|
+
bytes += NUM_VEC_ARG_REGISTERS64 * sizeof (float128);
|
336
|
+
}
|
293
337
|
|
294
338
|
/* Stack space. */
|
295
339
|
#if _CALL_ELF == 2
|
@@ -372,6 +416,8 @@ ffi_prep_cif_linux64_var (ffi_cif *cif,
|
|
372
416
|
|--------------------------------------------| |
|
373
417
|
| FPR registers f1-f13 (optional) 13*8 | |
|
374
418
|
|--------------------------------------------| |
|
419
|
+
| VEC registers v2-v13 (optional) 12*16 | |
|
420
|
+
|--------------------------------------------| |
|
375
421
|
| Parameter save area | |
|
376
422
|
|--------------------------------------------| |
|
377
423
|
| TOC save area 8 | |
|
@@ -401,6 +447,7 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
|
|
401
447
|
unsigned long *ul;
|
402
448
|
float *f;
|
403
449
|
double *d;
|
450
|
+
float128 *f128;
|
404
451
|
size_t p;
|
405
452
|
} valp;
|
406
453
|
|
@@ -419,6 +466,11 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
|
|
419
466
|
valp fpr_base;
|
420
467
|
unsigned int fparg_count;
|
421
468
|
|
469
|
+
/* 'vec_base' points at the space for v2, and grows upwards as
|
470
|
+
we use vector registers. */
|
471
|
+
valp vec_base;
|
472
|
+
unsigned int vecarg_count;
|
473
|
+
|
422
474
|
unsigned int i, words, nargs, nfixedargs;
|
423
475
|
ffi_type **ptr;
|
424
476
|
double double_tmp;
|
@@ -435,6 +487,7 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
|
|
435
487
|
unsigned long **ul;
|
436
488
|
float **f;
|
437
489
|
double **d;
|
490
|
+
float128 **f128;
|
438
491
|
} p_argv;
|
439
492
|
unsigned long gprvalue;
|
440
493
|
unsigned long align;
|
@@ -449,11 +502,21 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
|
|
449
502
|
#endif
|
450
503
|
fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
|
451
504
|
fparg_count = 0;
|
505
|
+
/* Place the vector args below the FPRs, if used, else the GPRs. */
|
506
|
+
if (ecif->cif->flags & FLAG_FP_ARGUMENTS)
|
507
|
+
vec_base.p = fpr_base.p & ~0xF;
|
508
|
+
else
|
509
|
+
vec_base.p = gpr_base.p;
|
510
|
+
vec_base.f128 -= NUM_VEC_ARG_REGISTERS64;
|
511
|
+
vecarg_count = 0;
|
452
512
|
next_arg.ul = gpr_base.ul;
|
453
513
|
|
454
514
|
/* Check that everything starts aligned properly. */
|
455
515
|
FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
|
456
516
|
FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
|
517
|
+
FFI_ASSERT (((unsigned long) gpr_base.c & 0xF) == 0);
|
518
|
+
FFI_ASSERT (((unsigned long) gpr_end.c & 0xF) == 0);
|
519
|
+
FFI_ASSERT (((unsigned long) vec_base.c & 0xF) == 0);
|
457
520
|
FFI_ASSERT ((bytes & 0xF) == 0);
|
458
521
|
|
459
522
|
/* Deal with return values that are actually pass-by-reference. */
|
@@ -478,6 +541,22 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
|
|
478
541
|
{
|
479
542
|
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
480
543
|
case FFI_TYPE_LONGDOUBLE:
|
544
|
+
if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
545
|
+
{
|
546
|
+
next_arg.p = FFI_ALIGN (next_arg.p, 16);
|
547
|
+
if (next_arg.ul == gpr_end.ul)
|
548
|
+
next_arg.ul = rest.ul;
|
549
|
+
if (vecarg_count < NUM_VEC_ARG_REGISTERS64 && i < nfixedargs)
|
550
|
+
memcpy (vec_base.f128++, *p_argv.f128, sizeof (float128));
|
551
|
+
else
|
552
|
+
memcpy (next_arg.f128, *p_argv.f128, sizeof (float128));
|
553
|
+
if (++next_arg.f128 == gpr_end.f128)
|
554
|
+
next_arg.f128 = rest.f128;
|
555
|
+
vecarg_count++;
|
556
|
+
FFI_ASSERT (__LDBL_MANT_DIG__ == 113);
|
557
|
+
FFI_ASSERT (flags & FLAG_VEC_ARGUMENTS);
|
558
|
+
break;
|
559
|
+
}
|
481
560
|
if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
|
482
561
|
{
|
483
562
|
double_tmp = (*p_argv.d)[0];
|
@@ -589,9 +668,29 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
|
|
589
668
|
void *v;
|
590
669
|
float *f;
|
591
670
|
double *d;
|
671
|
+
float128 *f128;
|
592
672
|
} arg;
|
593
673
|
|
594
674
|
arg.v = *p_argv.v;
|
675
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
676
|
+
if (elt == FFI_TYPE_LONGDOUBLE &&
|
677
|
+
(ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
678
|
+
{
|
679
|
+
do
|
680
|
+
{
|
681
|
+
if (vecarg_count < NUM_VEC_ARG_REGISTERS64
|
682
|
+
&& i < nfixedargs)
|
683
|
+
memcpy (vec_base.f128++, arg.f128, sizeof (float128));
|
684
|
+
else
|
685
|
+
memcpy (next_arg.f128, arg.f128++, sizeof (float128));
|
686
|
+
if (++next_arg.f128 == gpr_end.f128)
|
687
|
+
next_arg.f128 = rest.f128;
|
688
|
+
vecarg_count++;
|
689
|
+
}
|
690
|
+
while (--elnum != 0);
|
691
|
+
}
|
692
|
+
else
|
693
|
+
#endif
|
595
694
|
if (elt == FFI_TYPE_FLOAT)
|
596
695
|
{
|
597
696
|
do
|
@@ -762,17 +861,20 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
|
|
762
861
|
void *user_data,
|
763
862
|
void *rvalue,
|
764
863
|
unsigned long *pst,
|
765
|
-
|
864
|
+
ffi_dblfl *pfr,
|
865
|
+
float128 *pvec)
|
766
866
|
{
|
767
867
|
/* rvalue is the pointer to space for return value in closure assembly */
|
768
868
|
/* pst is the pointer to parameter save area
|
769
869
|
(r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */
|
770
870
|
/* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */
|
871
|
+
/* pvec is the pointer to where v2-v13 are stored in ffi_closure_LINUX64 */
|
771
872
|
|
772
873
|
void **avalue;
|
773
874
|
ffi_type **arg_types;
|
774
875
|
unsigned long i, avn, nfixedargs;
|
775
876
|
ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
|
877
|
+
float128 *end_pvec = pvec + NUM_VEC_ARG_REGISTERS64;
|
776
878
|
unsigned long align;
|
777
879
|
|
778
880
|
avalue = alloca (cif->nargs * sizeof (void *));
|
@@ -851,6 +953,7 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
|
|
851
953
|
unsigned long *ul;
|
852
954
|
float *f;
|
853
955
|
double *d;
|
956
|
+
float128 *f128;
|
854
957
|
size_t p;
|
855
958
|
} to, from;
|
856
959
|
|
@@ -858,6 +961,17 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
|
|
858
961
|
aggregate size is not greater than the space taken by
|
859
962
|
the registers so store back to the register/parameter
|
860
963
|
save arrays. */
|
964
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
965
|
+
if (elt == FFI_TYPE_LONGDOUBLE &&
|
966
|
+
(cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
967
|
+
{
|
968
|
+
if (pvec + elnum <= end_pvec)
|
969
|
+
to.v = pvec;
|
970
|
+
else
|
971
|
+
to.v = pst;
|
972
|
+
}
|
973
|
+
else
|
974
|
+
#endif
|
861
975
|
if (pfr + elnum <= end_pfr)
|
862
976
|
to.v = pfr;
|
863
977
|
else
|
@@ -865,6 +979,23 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
|
|
865
979
|
|
866
980
|
avalue[i] = to.v;
|
867
981
|
from.ul = pst;
|
982
|
+
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
983
|
+
if (elt == FFI_TYPE_LONGDOUBLE &&
|
984
|
+
(cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
985
|
+
{
|
986
|
+
do
|
987
|
+
{
|
988
|
+
if (pvec < end_pvec && i < nfixedargs)
|
989
|
+
memcpy (to.f128, pvec++, sizeof (float128));
|
990
|
+
else
|
991
|
+
memcpy (to.f128, from.f128, sizeof (float128));
|
992
|
+
to.f128++;
|
993
|
+
from.f128++;
|
994
|
+
}
|
995
|
+
while (--elnum != 0);
|
996
|
+
}
|
997
|
+
else
|
998
|
+
#endif
|
868
999
|
if (elt == FFI_TYPE_FLOAT)
|
869
1000
|
{
|
870
1001
|
do
|
@@ -920,7 +1051,18 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
|
|
920
1051
|
|
921
1052
|
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|
922
1053
|
case FFI_TYPE_LONGDOUBLE:
|
923
|
-
|
1054
|
+
if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
|
1055
|
+
{
|
1056
|
+
if (((unsigned long) pst & 0xF) != 0)
|
1057
|
+
++pst;
|
1058
|
+
if (pvec < end_pvec && i < nfixedargs)
|
1059
|
+
avalue[i] = pvec++;
|
1060
|
+
else
|
1061
|
+
avalue[i] = pst;
|
1062
|
+
pst += 2;
|
1063
|
+
break;
|
1064
|
+
}
|
1065
|
+
else if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
|
924
1066
|
{
|
925
1067
|
if (pfr + 1 < end_pfr && i + 1 < nfixedargs)
|
926
1068
|
{
|
@@ -995,13 +1137,17 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
|
|
995
1137
|
/* Tell ffi_closure_LINUX64 how to perform return type promotions. */
|
996
1138
|
if ((cif->flags & FLAG_RETURNS_SMST) != 0)
|
997
1139
|
{
|
998
|
-
if ((cif->flags & FLAG_RETURNS_FP) == 0)
|
1140
|
+
if ((cif->flags & (FLAG_RETURNS_FP | FLAG_RETURNS_VEC)) == 0)
|
999
1141
|
return FFI_V2_TYPE_SMALL_STRUCT + cif->rtype->size - 1;
|
1142
|
+
else if ((cif->flags & FLAG_RETURNS_VEC) != 0)
|
1143
|
+
return FFI_V2_TYPE_VECTOR_HOMOG;
|
1000
1144
|
else if ((cif->flags & FLAG_RETURNS_64BITS) != 0)
|
1001
1145
|
return FFI_V2_TYPE_DOUBLE_HOMOG;
|
1002
1146
|
else
|
1003
1147
|
return FFI_V2_TYPE_FLOAT_HOMOG;
|
1004
1148
|
}
|
1149
|
+
if ((cif->flags & FLAG_RETURNS_VEC) != 0)
|
1150
|
+
return FFI_V2_TYPE_VECTOR;
|
1005
1151
|
return cif->rtype->type;
|
1006
1152
|
}
|
1007
1153
|
#endif
|
@@ -31,22 +31,24 @@
|
|
31
31
|
enum {
|
32
32
|
/* The assembly depends on these exact flags. */
|
33
33
|
/* These go in cr7 */
|
34
|
-
FLAG_RETURNS_SMST
|
34
|
+
FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */
|
35
35
|
FLAG_RETURNS_NOTHING = 1 << (31-30),
|
36
36
|
FLAG_RETURNS_FP = 1 << (31-29),
|
37
|
-
|
37
|
+
FLAG_RETURNS_VEC = 1 << (31-28),
|
38
38
|
|
39
|
-
/*
|
40
|
-
|
39
|
+
/* These go in cr6 */
|
40
|
+
FLAG_RETURNS_64BITS = 1 << (31-27),
|
41
|
+
FLAG_RETURNS_128BITS = 1 << (31-26),
|
41
42
|
|
42
|
-
FLAG_COMPAT
|
43
|
+
FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */
|
43
44
|
|
44
45
|
/* These go in cr1 */
|
45
46
|
FLAG_ARG_NEEDS_COPY = 1 << (31- 7), /* Used by sysv code */
|
46
47
|
FLAG_ARG_NEEDS_PSAVE = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */
|
47
48
|
FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
|
48
49
|
FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
|
49
|
-
FLAG_RETVAL_REFERENCE = 1 << (31- 4)
|
50
|
+
FLAG_RETVAL_REFERENCE = 1 << (31- 4),
|
51
|
+
FLAG_VEC_ARGUMENTS = 1 << (31- 3),
|
50
52
|
};
|
51
53
|
|
52
54
|
typedef union
|
@@ -55,6 +57,14 @@ typedef union
|
|
55
57
|
double d;
|
56
58
|
} ffi_dblfl;
|
57
59
|
|
60
|
+
#if defined(__FLOAT128_TYPE__)
|
61
|
+
typedef _Float128 float128;
|
62
|
+
#elif defined(__FLOAT128__)
|
63
|
+
typedef __float128 float128;
|
64
|
+
#else
|
65
|
+
typedef char float128[16] __attribute__((aligned(16)));
|
66
|
+
#endif
|
67
|
+
|
58
68
|
void FFI_HIDDEN ffi_closure_SYSV (void);
|
59
69
|
void FFI_HIDDEN ffi_go_closure_sysv (void);
|
60
70
|
void FFI_HIDDEN ffi_call_SYSV(extended_cif *, void (*)(void), void *,
|
@@ -91,4 +101,5 @@ int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_cif *,
|
|
91
101
|
void (*) (ffi_cif *, void *,
|
92
102
|
void **, void *),
|
93
103
|
void *, void *,
|
94
|
-
unsigned long *, ffi_dblfl
|
104
|
+
unsigned long *, ffi_dblfl *,
|
105
|
+
float128 *);
|
@@ -91,15 +91,19 @@ typedef enum ffi_abi {
|
|
91
91
|
/* This and following bits can reuse FFI_COMPAT values. */
|
92
92
|
FFI_LINUX_STRUCT_ALIGN = 1,
|
93
93
|
FFI_LINUX_LONG_DOUBLE_128 = 2,
|
94
|
+
FFI_LINUX_LONG_DOUBLE_IEEE128 = 4,
|
94
95
|
FFI_DEFAULT_ABI = (FFI_LINUX
|
95
96
|
# ifdef __STRUCT_PARM_ALIGN__
|
96
97
|
| FFI_LINUX_STRUCT_ALIGN
|
97
98
|
# endif
|
98
99
|
# ifdef __LONG_DOUBLE_128__
|
99
100
|
| FFI_LINUX_LONG_DOUBLE_128
|
101
|
+
# ifdef __LONG_DOUBLE_IEEE128__
|
102
|
+
| FFI_LINUX_LONG_DOUBLE_IEEE128
|
103
|
+
# endif
|
100
104
|
# endif
|
101
105
|
),
|
102
|
-
FFI_LAST_ABI =
|
106
|
+
FFI_LAST_ABI = 16
|
103
107
|
|
104
108
|
# else
|
105
109
|
/* This bit, always set in new code, must not be set in any of the
|
@@ -167,9 +171,11 @@ typedef enum ffi_abi {
|
|
167
171
|
#define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 2)
|
168
172
|
|
169
173
|
/* Used by ELFv2 for homogenous structure returns. */
|
170
|
-
#define
|
171
|
-
#define
|
172
|
-
#define
|
174
|
+
#define FFI_V2_TYPE_VECTOR (FFI_PPC_TYPE_LAST + 1)
|
175
|
+
#define FFI_V2_TYPE_VECTOR_HOMOG (FFI_PPC_TYPE_LAST + 2)
|
176
|
+
#define FFI_V2_TYPE_FLOAT_HOMOG (FFI_PPC_TYPE_LAST + 3)
|
177
|
+
#define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_PPC_TYPE_LAST + 4)
|
178
|
+
#define FFI_V2_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 5)
|
173
179
|
|
174
180
|
#if _CALL_ELF == 2
|
175
181
|
# define FFI_TRAMPOLINE_SIZE 32
|