ffi 1.9.24 → 1.16.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (457) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +348 -0
  4. data/Gemfile +4 -5
  5. data/README.md +44 -17
  6. data/Rakefile +74 -148
  7. data/ext/ffi_c/AbstractMemory.c +89 -70
  8. data/ext/ffi_c/AbstractMemory.h +3 -2
  9. data/ext/ffi_c/ArrayType.c +49 -13
  10. data/ext/ffi_c/ArrayType.h +1 -0
  11. data/ext/ffi_c/Buffer.c +90 -38
  12. data/ext/ffi_c/Call.c +55 -56
  13. data/ext/ffi_c/Call.h +12 -6
  14. data/ext/ffi_c/ClosurePool.c +333 -0
  15. data/ext/ffi_c/{Closure.h → ClosurePool.h} +25 -13
  16. data/ext/ffi_c/DynamicLibrary.c +91 -33
  17. data/ext/ffi_c/Function.c +306 -235
  18. data/ext/ffi_c/Function.h +3 -5
  19. data/ext/ffi_c/FunctionInfo.c +87 -32
  20. data/ext/ffi_c/LastError.c +74 -15
  21. data/ext/ffi_c/LongDouble.c +12 -10
  22. data/ext/ffi_c/LongDouble.h +0 -4
  23. data/ext/ffi_c/MappedType.c +66 -23
  24. data/ext/ffi_c/MappedType.h +0 -2
  25. data/ext/ffi_c/MemoryPointer.c +37 -15
  26. data/ext/ffi_c/MemoryPointer.h +0 -4
  27. data/ext/ffi_c/MethodHandle.c +265 -38
  28. data/ext/ffi_c/MethodHandle.h +3 -2
  29. data/ext/ffi_c/Platform.c +5 -56
  30. data/ext/ffi_c/Pointer.c +93 -55
  31. data/ext/ffi_c/Pointer.h +1 -4
  32. data/ext/ffi_c/Struct.c +202 -134
  33. data/ext/ffi_c/Struct.h +18 -9
  34. data/ext/ffi_c/StructByValue.c +50 -23
  35. data/ext/ffi_c/StructLayout.c +135 -64
  36. data/ext/ffi_c/Thread.c +4 -228
  37. data/ext/ffi_c/Thread.h +1 -20
  38. data/ext/ffi_c/Type.c +105 -55
  39. data/ext/ffi_c/Type.h +3 -2
  40. data/ext/ffi_c/Types.c +8 -9
  41. data/ext/ffi_c/Types.h +3 -4
  42. data/ext/ffi_c/Variadic.c +88 -47
  43. data/ext/ffi_c/compat.h +26 -22
  44. data/ext/ffi_c/extconf.rb +75 -32
  45. data/ext/ffi_c/ffi.c +9 -10
  46. data/ext/ffi_c/libffi/.appveyor/site.exp +16 -0
  47. data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +7 -0
  48. data/ext/ffi_c/libffi/.appveyor.yml +53 -19
  49. data/ext/ffi_c/libffi/.ci/bfin-sim.exp +58 -0
  50. data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
  51. data/ext/ffi_c/libffi/.ci/build-in-container.sh +10 -0
  52. data/ext/ffi_c/libffi/.ci/build.sh +124 -0
  53. data/ext/ffi_c/libffi/.ci/install.sh +78 -0
  54. data/ext/ffi_c/libffi/.ci/m32r-sim.exp +58 -0
  55. data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +1 -1
  56. data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
  57. data/ext/ffi_c/libffi/.ci/or1k-sim.exp +58 -0
  58. data/ext/ffi_c/libffi/.ci/powerpc-eabisim.exp +58 -0
  59. data/ext/ffi_c/libffi/.ci/site.exp +29 -0
  60. data/ext/ffi_c/libffi/.ci/wine-sim.exp +55 -0
  61. data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
  62. data/ext/ffi_c/libffi/.gitattributes +4 -0
  63. data/ext/ffi_c/libffi/.github/workflows/build.yml +460 -0
  64. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +171 -0
  65. data/ext/ffi_c/libffi/.gitignore +10 -2
  66. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  67. data/ext/ffi_c/libffi/LICENSE +1 -1
  68. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  69. data/ext/ffi_c/libffi/Makefile.am +64 -73
  70. data/ext/ffi_c/libffi/Makefile.in +553 -235
  71. data/ext/ffi_c/libffi/README.md +165 -100
  72. data/ext/ffi_c/libffi/acinclude.m4 +10 -112
  73. data/ext/ffi_c/libffi/compile +348 -0
  74. data/ext/ffi_c/libffi/config.guess +950 -662
  75. data/ext/ffi_c/libffi/config.sub +1362 -1306
  76. data/ext/ffi_c/libffi/configure +4909 -4096
  77. data/ext/ffi_c/libffi/configure.ac +93 -32
  78. data/ext/ffi_c/libffi/configure.host +76 -28
  79. data/ext/ffi_c/libffi/doc/Makefile.in +15 -8
  80. data/ext/ffi_c/libffi/doc/libffi.texi +107 -46
  81. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  82. data/ext/ffi_c/libffi/fficonfig.h.in +22 -44
  83. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +165 -56
  84. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  85. data/ext/ffi_c/libffi/include/Makefile.in +17 -12
  86. data/ext/ffi_c/libffi/include/ffi.h.in +64 -48
  87. data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
  88. data/ext/ffi_c/libffi/include/ffi_common.h +34 -1
  89. data/ext/ffi_c/libffi/include/tramp.h +45 -0
  90. data/ext/ffi_c/libffi/install-sh +107 -74
  91. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  92. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  93. data/ext/ffi_c/libffi/libtool-version +2 -2
  94. data/ext/ffi_c/libffi/ltmain.sh +576 -284
  95. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  96. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  97. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +18 -14
  98. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
  99. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  100. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -44
  101. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  102. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  103. data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
  104. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  105. data/ext/ffi_c/libffi/man/Makefile.in +15 -8
  106. data/ext/ffi_c/libffi/missing +8 -8
  107. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  108. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  109. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  110. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  111. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  112. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
  113. data/ext/ffi_c/libffi/msvcc.sh +39 -14
  114. data/ext/ffi_c/libffi/src/aarch64/ffi.c +286 -98
  115. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
  116. data/ext/ffi_c/libffi/src/aarch64/internal.h +33 -0
  117. data/ext/ffi_c/libffi/src/aarch64/sysv.S +142 -37
  118. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  119. data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
  120. data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
  121. data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
  122. data/ext/ffi_c/libffi/src/arm/ffi.c +112 -10
  123. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  124. data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
  125. data/ext/ffi_c/libffi/src/arm/sysv.S +117 -44
  126. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  127. data/ext/ffi_c/libffi/src/closures.c +189 -48
  128. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  129. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  130. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  131. data/ext/ffi_c/libffi/src/dlmalloc.c +6 -1
  132. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  133. data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
  134. data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
  135. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  136. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  137. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  138. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  139. data/ext/ffi_c/libffi/src/loongarch64/ffi.c +621 -0
  140. data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
  141. data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
  142. data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
  143. data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
  144. data/ext/ffi_c/libffi/src/mips/ffi.c +245 -66
  145. data/ext/ffi_c/libffi/src/mips/ffitarget.h +8 -1
  146. data/ext/ffi_c/libffi/src/mips/n32.S +137 -28
  147. data/ext/ffi_c/libffi/src/mips/o32.S +63 -4
  148. data/ext/ffi_c/libffi/src/moxie/ffi.c +48 -23
  149. data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
  150. data/ext/ffi_c/libffi/src/pa/ffi.c +62 -108
  151. data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
  152. data/ext/ffi_c/libffi/src/pa/ffitarget.h +20 -11
  153. data/ext/ffi_c/libffi/src/pa/hpux32.S +87 -38
  154. data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
  155. data/ext/ffi_c/libffi/src/pa/linux.S +109 -39
  156. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  157. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  158. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  159. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  160. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  161. data/ext/ffi_c/libffi/src/powerpc/linux64.S +93 -28
  162. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +83 -5
  163. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  164. data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
  165. data/ext/ffi_c/libffi/src/prep_cif.c +26 -4
  166. data/ext/ffi_c/libffi/src/riscv/ffi.c +79 -10
  167. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
  168. data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
  169. data/ext/ffi_c/libffi/src/sparc/ffi64.c +16 -0
  170. data/ext/ffi_c/libffi/src/tramp.c +716 -0
  171. data/ext/ffi_c/libffi/src/wasm32/ffi.c +934 -0
  172. data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
  173. data/ext/ffi_c/libffi/src/x86/ffi.c +128 -49
  174. data/ext/ffi_c/libffi/src/x86/ffi64.c +89 -23
  175. data/ext/ffi_c/libffi/src/x86/ffitarget.h +21 -4
  176. data/ext/ffi_c/libffi/src/x86/ffiw64.c +63 -10
  177. data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
  178. data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
  179. data/ext/ffi_c/libffi/src/x86/sysv.S +274 -45
  180. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +998 -0
  181. data/ext/ffi_c/libffi/src/x86/unix64.S +190 -4
  182. data/ext/ffi_c/libffi/src/x86/win64.S +32 -10
  183. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  184. data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
  185. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
  186. data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
  187. data/ext/ffi_c/libffi/testsuite/Makefile.am +127 -109
  188. data/ext/ffi_c/libffi/testsuite/Makefile.in +144 -88
  189. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
  190. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
  191. data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +80 -0
  192. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
  193. data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
  194. data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
  195. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +71 -25
  196. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
  197. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  198. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +5 -4
  199. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  200. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
  201. data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
  202. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  203. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
  204. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  205. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
  206. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
  207. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
  208. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
  209. data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
  210. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
  211. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
  212. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
  213. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
  214. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
  215. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
  216. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
  217. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
  218. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
  219. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
  220. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
  221. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
  222. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
  223. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
  224. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
  225. data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
  226. data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
  227. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
  228. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
  229. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
  230. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  231. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +3 -2
  232. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +2 -0
  233. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +2 -0
  234. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +21 -1
  235. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +2 -0
  236. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +2 -0
  237. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +2 -0
  238. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +7 -6
  239. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +6 -0
  240. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +18 -0
  241. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +22 -0
  242. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +24 -0
  243. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +29 -0
  244. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +4 -0
  245. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +19 -1
  246. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +21 -1
  247. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +35 -3
  248. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +13 -0
  249. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +19 -0
  250. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +13 -0
  251. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +13 -0
  252. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +18 -0
  253. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +22 -0
  254. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +13 -0
  255. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +29 -1
  256. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +19 -1
  257. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +24 -0
  258. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +28 -1
  259. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +24 -2
  260. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +39 -1
  261. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +25 -1
  262. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +14 -0
  263. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +14 -1
  264. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +14 -2
  265. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +19 -1
  266. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +19 -1
  267. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +20 -1
  268. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +40 -25
  269. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +40 -3
  270. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +19 -1
  271. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +18 -1
  272. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +18 -3
  273. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +18 -1
  274. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +18 -1
  275. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +19 -1
  276. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +19 -1
  277. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +3 -1
  278. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +9 -1
  279. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +4 -0
  280. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +11 -1
  281. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +22 -3
  282. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +5 -1
  283. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +6 -1
  284. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +9 -1
  285. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +9 -1
  286. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +6 -2
  287. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +9 -1
  288. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +5 -0
  289. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +10 -0
  290. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +3 -0
  291. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +2 -0
  292. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +3 -0
  293. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +11 -0
  294. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +3 -0
  295. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +4 -0
  296. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +4 -0
  297. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +4 -0
  298. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +2 -0
  299. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +3 -0
  300. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -0
  301. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +24 -22
  302. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +32 -9
  303. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +1 -1
  304. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +12 -0
  305. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +21 -5
  306. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
  307. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
  308. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +10 -1
  309. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +10 -1
  310. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +9 -0
  311. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +9 -0
  312. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +11 -0
  313. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +9 -0
  314. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +11 -0
  315. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +11 -0
  316. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
  317. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
  318. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
  319. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +1 -1
  320. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +1 -1
  321. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +6 -1
  322. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +2 -1
  323. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +1 -0
  324. data/ext/ffi_c/libffi.bsd.mk +2 -2
  325. data/ext/ffi_c/libffi.darwin.mk +1 -1
  326. data/ext/ffi_c/libffi.gnu.mk +2 -2
  327. data/ext/ffi_c/rbffi.h +1 -3
  328. data/ffi.gemspec +15 -9
  329. data/lib/ffi/abstract_memory.rb +44 -0
  330. data/lib/ffi/autopointer.rb +8 -23
  331. data/lib/ffi/compat.rb +43 -0
  332. data/lib/ffi/data_converter.rb +67 -0
  333. data/lib/ffi/dynamic_library.rb +89 -0
  334. data/lib/ffi/enum.rb +18 -11
  335. data/lib/ffi/ffi.rb +6 -0
  336. data/lib/ffi/function.rb +71 -0
  337. data/lib/ffi/io.rb +3 -3
  338. data/lib/ffi/library.rb +65 -77
  339. data/lib/ffi/library_path.rb +109 -0
  340. data/lib/ffi/managedstruct.rb +3 -3
  341. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  342. data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
  343. data/lib/ffi/platform/aarch64-freebsd12/types.conf +181 -0
  344. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  345. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  346. data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
  347. data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
  348. data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
  349. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  350. data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
  351. data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
  352. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  353. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  354. data/lib/ffi/platform/i386-freebsd/types.conf +89 -89
  355. data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
  356. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  357. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  358. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  359. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  360. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  361. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  362. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  363. data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
  364. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  365. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  366. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  367. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  368. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  369. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  370. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  371. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  372. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  373. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  374. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  375. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  376. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  377. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  378. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  379. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  380. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  381. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  382. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  383. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  384. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  385. data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
  386. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  387. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  388. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  389. data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -90
  390. data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
  391. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  392. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  393. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  394. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  395. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  396. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  397. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  398. data/lib/ffi/platform.rb +43 -20
  399. data/lib/ffi/pointer.rb +26 -20
  400. data/lib/ffi/struct.rb +14 -68
  401. data/lib/ffi/struct_by_reference.rb +72 -0
  402. data/lib/ffi/struct_layout.rb +96 -0
  403. data/lib/ffi/struct_layout_builder.rb +1 -1
  404. data/lib/ffi/tools/const_generator.rb +11 -8
  405. data/lib/ffi/tools/generator.rb +47 -2
  406. data/lib/ffi/tools/generator_task.rb +13 -17
  407. data/lib/ffi/tools/struct_generator.rb +6 -5
  408. data/lib/ffi/tools/types_generator.rb +7 -4
  409. data/lib/ffi/types.rb +33 -7
  410. data/lib/ffi/variadic.rb +20 -18
  411. data/lib/ffi/version.rb +1 -1
  412. data/lib/ffi.rb +10 -3
  413. data/rakelib/ffi_gem_helper.rb +65 -0
  414. data/samples/getlogin.rb +1 -1
  415. data/samples/getpid.rb +1 -1
  416. data/samples/gettimeofday.rb +8 -8
  417. data/samples/hello.rb +2 -1
  418. data/samples/hello_ractor.rb +11 -0
  419. data/samples/inotify.rb +1 -1
  420. data/samples/pty.rb +1 -2
  421. data/samples/qsort.rb +0 -1
  422. data/samples/qsort_ractor.rb +28 -0
  423. data.tar.gz.sig +0 -0
  424. metadata +252 -153
  425. metadata.gz.sig +0 -0
  426. data/.gitignore +0 -22
  427. data/.gitmodules +0 -3
  428. data/.travis.yml +0 -52
  429. data/.yardopts +0 -5
  430. data/appveyor.yml +0 -22
  431. data/ext/ffi_c/Closure.c +0 -54
  432. data/ext/ffi_c/DataConverter.c +0 -91
  433. data/ext/ffi_c/StructByReference.c +0 -190
  434. data/ext/ffi_c/StructByReference.h +0 -50
  435. data/ext/ffi_c/libffi/.travis/build.sh +0 -34
  436. data/ext/ffi_c/libffi/.travis/install.sh +0 -22
  437. data/ext/ffi_c/libffi/.travis/site.exp +0 -18
  438. data/ext/ffi_c/libffi/.travis.yml +0 -34
  439. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  440. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  441. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  442. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar_va.c +0 -44
  443. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort_va.c +0 -44
  444. data/ext/ffi_c/win32/stdbool.h +0 -8
  445. data/ext/ffi_c/win32/stdint.h +0 -201
  446. data/samples/sample_helper.rb +0 -6
  447. data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
  448. data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
  449. data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  450. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  451. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  452. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  453. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  454. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  455. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  456. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  457. data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +79 -79
@@ -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
 
@@ -63,10 +64,31 @@ ffi_prep_types_linux64 (ffi_abi abi)
63
64
 
64
65
 
65
66
  static unsigned int
66
- discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum)
67
+ discover_homogeneous_aggregate (ffi_abi abi,
68
+ const ffi_type *t,
69
+ unsigned int *elnum)
67
70
  {
68
71
  switch (t->type)
69
72
  {
73
+ #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
74
+ case FFI_TYPE_LONGDOUBLE:
75
+ /* 64-bit long doubles are equivalent to doubles. */
76
+ if ((abi & FFI_LINUX_LONG_DOUBLE_128) == 0)
77
+ {
78
+ *elnum = 1;
79
+ return FFI_TYPE_DOUBLE;
80
+ }
81
+ /* IBM extended precision values use unaligned pairs
82
+ of FPRs, but according to the ABI must be considered
83
+ distinct from doubles. They are also limited to a
84
+ maximum of four members in a homogeneous aggregate. */
85
+ else if ((abi & FFI_LINUX_LONG_DOUBLE_IEEE128) == 0)
86
+ {
87
+ *elnum = 2;
88
+ return FFI_TYPE_LONGDOUBLE;
89
+ }
90
+ /* Fall through. */
91
+ #endif
70
92
  case FFI_TYPE_FLOAT:
71
93
  case FFI_TYPE_DOUBLE:
72
94
  *elnum = 1;
@@ -79,7 +101,7 @@ discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum)
79
101
  while (*el)
80
102
  {
81
103
  unsigned int el_elt, el_elnum = 0;
82
- el_elt = discover_homogeneous_aggregate (*el, &el_elnum);
104
+ el_elt = discover_homogeneous_aggregate (abi, *el, &el_elnum);
83
105
  if (el_elt == 0
84
106
  || (base_elt && base_elt != el_elt))
85
107
  return 0;
@@ -110,13 +132,23 @@ ffi_prep_cif_linux64_core (ffi_cif *cif)
110
132
  {
111
133
  ffi_type **ptr;
112
134
  unsigned bytes;
113
- unsigned i, fparg_count = 0, intarg_count = 0;
135
+ unsigned i, fparg_count = 0, intarg_count = 0, vecarg_count = 0;
114
136
  unsigned flags = cif->flags;
115
- unsigned int elt, elnum;
137
+ unsigned elt, elnum, rtype;
116
138
 
117
139
  #if FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE
118
- /* If compiled without long double support.. */
119
- 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)
120
152
  return FFI_BAD_ABI;
121
153
  #endif
122
154
 
@@ -138,10 +170,19 @@ ffi_prep_cif_linux64_core (ffi_cif *cif)
138
170
  #endif
139
171
 
140
172
  /* Return value handling. */
141
- switch (cif->rtype->type)
173
+ rtype = cif->rtype->type;
174
+ #if _CALL_ELF == 2
175
+ homogeneous:
176
+ #endif
177
+ switch (rtype)
142
178
  {
143
179
  #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
144
180
  case FFI_TYPE_LONGDOUBLE:
181
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_IEEE128) != 0)
182
+ {
183
+ flags |= FLAG_RETURNS_VEC;
184
+ break;
185
+ }
145
186
  if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
146
187
  flags |= FLAG_RETURNS_128BITS;
147
188
  /* Fall through. */
@@ -164,19 +205,18 @@ ffi_prep_cif_linux64_core (ffi_cif *cif)
164
205
 
165
206
  case FFI_TYPE_STRUCT:
166
207
  #if _CALL_ELF == 2
167
- elt = discover_homogeneous_aggregate (cif->rtype, &elnum);
208
+ elt = discover_homogeneous_aggregate (cif->abi, cif->rtype, &elnum);
168
209
  if (elt)
169
- {
170
- if (elt == FFI_TYPE_DOUBLE)
171
- flags |= FLAG_RETURNS_64BITS;
172
- flags |= FLAG_RETURNS_FP | FLAG_RETURNS_SMST;
173
- break;
174
- }
210
+ {
211
+ flags |= FLAG_RETURNS_SMST;
212
+ rtype = elt;
213
+ goto homogeneous;
214
+ }
175
215
  if (cif->rtype->size <= 16)
176
- {
177
- flags |= FLAG_RETURNS_SMST;
178
- break;
179
- }
216
+ {
217
+ flags |= FLAG_RETURNS_SMST;
218
+ break;
219
+ }
180
220
  #endif
181
221
  intarg_count++;
182
222
  flags |= FLAG_RETVAL_REFERENCE;
@@ -198,6 +238,15 @@ ffi_prep_cif_linux64_core (ffi_cif *cif)
198
238
  {
199
239
  #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
200
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
+ }
201
250
  if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
202
251
  {
203
252
  fparg_count++;
@@ -224,7 +273,18 @@ ffi_prep_cif_linux64_core (ffi_cif *cif)
224
273
  intarg_count = FFI_ALIGN (intarg_count, align);
225
274
  }
226
275
  intarg_count += ((*ptr)->size + 7) / 8;
227
- elt = discover_homogeneous_aggregate (*ptr, &elnum);
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
228
288
  if (elt)
229
289
  {
230
290
  fparg_count += elnum;
@@ -263,10 +323,17 @@ ffi_prep_cif_linux64_core (ffi_cif *cif)
263
323
  flags |= FLAG_FP_ARGUMENTS;
264
324
  if (intarg_count > 4)
265
325
  flags |= FLAG_4_GPR_ARGUMENTS;
326
+ if (vecarg_count != 0)
327
+ flags |= FLAG_VEC_ARGUMENTS;
266
328
 
267
329
  /* Space for the FPR registers, if needed. */
268
330
  if (fparg_count != 0)
269
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
+ }
270
337
 
271
338
  /* Stack space. */
272
339
  #if _CALL_ELF == 2
@@ -349,6 +416,8 @@ ffi_prep_cif_linux64_var (ffi_cif *cif,
349
416
  |--------------------------------------------| |
350
417
  | FPR registers f1-f13 (optional) 13*8 | |
351
418
  |--------------------------------------------| |
419
+ | VEC registers v2-v13 (optional) 12*16 | |
420
+ |--------------------------------------------| |
352
421
  | Parameter save area | |
353
422
  |--------------------------------------------| |
354
423
  | TOC save area 8 | |
@@ -378,6 +447,7 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
378
447
  unsigned long *ul;
379
448
  float *f;
380
449
  double *d;
450
+ float128 *f128;
381
451
  size_t p;
382
452
  } valp;
383
453
 
@@ -391,11 +461,16 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
391
461
  valp rest;
392
462
  valp next_arg;
393
463
 
394
- /* 'fpr_base' points at the space for fpr3, and grows upwards as
464
+ /* 'fpr_base' points at the space for f1, and grows upwards as
395
465
  we use FPR registers. */
396
466
  valp fpr_base;
397
467
  unsigned int fparg_count;
398
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
+
399
474
  unsigned int i, words, nargs, nfixedargs;
400
475
  ffi_type **ptr;
401
476
  double double_tmp;
@@ -412,6 +487,7 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
412
487
  unsigned long **ul;
413
488
  float **f;
414
489
  double **d;
490
+ float128 **f128;
415
491
  } p_argv;
416
492
  unsigned long gprvalue;
417
493
  unsigned long align;
@@ -426,11 +502,21 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
426
502
  #endif
427
503
  fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
428
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;
429
512
  next_arg.ul = gpr_base.ul;
430
513
 
431
514
  /* Check that everything starts aligned properly. */
432
515
  FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
433
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);
434
520
  FFI_ASSERT ((bytes & 0xF) == 0);
435
521
 
436
522
  /* Deal with return values that are actually pass-by-reference. */
@@ -455,6 +541,22 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
455
541
  {
456
542
  #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
457
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
+ }
458
560
  if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
459
561
  {
460
562
  double_tmp = (*p_argv.d)[0];
@@ -492,7 +594,9 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
492
594
  /* Fall through. */
493
595
  #endif
494
596
  case FFI_TYPE_DOUBLE:
597
+ #if _CALL_ELF != 2
495
598
  do_double:
599
+ #endif
496
600
  double_tmp = **p_argv.d;
497
601
  if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
498
602
  {
@@ -511,7 +615,9 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
511
615
  break;
512
616
 
513
617
  case FFI_TYPE_FLOAT:
618
+ #if _CALL_ELF != 2
514
619
  do_float:
620
+ #endif
515
621
  double_tmp = **p_argv.f;
516
622
  if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
517
623
  {
@@ -548,9 +654,13 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
548
654
  if (align > 16)
549
655
  align = 16;
550
656
  if (align > 1)
551
- next_arg.p = FFI_ALIGN (next_arg.p, align);
657
+ {
658
+ next_arg.p = FFI_ALIGN (next_arg.p, align);
659
+ if (next_arg.ul == gpr_end.ul)
660
+ next_arg.ul = rest.ul;
661
+ }
552
662
  }
553
- elt = discover_homogeneous_aggregate (*ptr, &elnum);
663
+ elt = discover_homogeneous_aggregate (ecif->cif->abi, *ptr, &elnum);
554
664
  if (elt)
555
665
  {
556
666
  #if _CALL_ELF == 2
@@ -558,9 +668,29 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
558
668
  void *v;
559
669
  float *f;
560
670
  double *d;
671
+ float128 *f128;
561
672
  } arg;
562
673
 
563
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
564
694
  if (elt == FFI_TYPE_FLOAT)
565
695
  {
566
696
  do
@@ -576,11 +706,9 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
576
706
  fparg_count++;
577
707
  }
578
708
  while (--elnum != 0);
579
- if ((next_arg.p & 3) != 0)
580
- {
581
- if (++next_arg.f == gpr_end.f)
582
- next_arg.f = rest.f;
583
- }
709
+ if ((next_arg.p & 7) != 0)
710
+ if (++next_arg.f == gpr_end.f)
711
+ next_arg.f = rest.f;
584
712
  }
585
713
  else
586
714
  do
@@ -733,17 +861,20 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
733
861
  void *user_data,
734
862
  void *rvalue,
735
863
  unsigned long *pst,
736
- ffi_dblfl *pfr)
864
+ ffi_dblfl *pfr,
865
+ float128 *pvec)
737
866
  {
738
867
  /* rvalue is the pointer to space for return value in closure assembly */
739
868
  /* pst is the pointer to parameter save area
740
869
  (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */
741
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 */
742
872
 
743
873
  void **avalue;
744
874
  ffi_type **arg_types;
745
875
  unsigned long i, avn, nfixedargs;
746
876
  ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
877
+ float128 *end_pvec = pvec + NUM_VEC_ARG_REGISTERS64;
747
878
  unsigned long align;
748
879
 
749
880
  avalue = alloca (cif->nargs * sizeof (void *));
@@ -813,7 +944,7 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
813
944
  if (align > 1)
814
945
  pst = (unsigned long *) FFI_ALIGN ((size_t) pst, align);
815
946
  }
816
- elt = discover_homogeneous_aggregate (arg_types[i], &elnum);
947
+ elt = discover_homogeneous_aggregate (cif->abi, arg_types[i], &elnum);
817
948
  if (elt)
818
949
  {
819
950
  #if _CALL_ELF == 2
@@ -822,6 +953,7 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
822
953
  unsigned long *ul;
823
954
  float *f;
824
955
  double *d;
956
+ float128 *f128;
825
957
  size_t p;
826
958
  } to, from;
827
959
 
@@ -829,6 +961,17 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
829
961
  aggregate size is not greater than the space taken by
830
962
  the registers so store back to the register/parameter
831
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
832
975
  if (pfr + elnum <= end_pfr)
833
976
  to.v = pfr;
834
977
  else
@@ -836,6 +979,23 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
836
979
 
837
980
  avalue[i] = to.v;
838
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
839
999
  if (elt == FFI_TYPE_FLOAT)
840
1000
  {
841
1001
  do
@@ -891,7 +1051,18 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
891
1051
 
892
1052
  #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
893
1053
  case FFI_TYPE_LONGDOUBLE:
894
- if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
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)
895
1066
  {
896
1067
  if (pfr + 1 < end_pfr && i + 1 < nfixedargs)
897
1068
  {
@@ -915,7 +1086,9 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
915
1086
  /* Fall through. */
916
1087
  #endif
917
1088
  case FFI_TYPE_DOUBLE:
1089
+ #if _CALL_ELF != 2
918
1090
  do_double:
1091
+ #endif
919
1092
  /* On the outgoing stack all values are aligned to 8 */
920
1093
  /* there are 13 64bit floating point registers */
921
1094
 
@@ -930,7 +1103,9 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
930
1103
  break;
931
1104
 
932
1105
  case FFI_TYPE_FLOAT:
1106
+ #if _CALL_ELF != 2
933
1107
  do_float:
1108
+ #endif
934
1109
  if (pfr < end_pfr && i < nfixedargs)
935
1110
  {
936
1111
  /* Float values are stored as doubles in the
@@ -962,13 +1137,17 @@ ffi_closure_helper_LINUX64 (ffi_cif *cif,
962
1137
  /* Tell ffi_closure_LINUX64 how to perform return type promotions. */
963
1138
  if ((cif->flags & FLAG_RETURNS_SMST) != 0)
964
1139
  {
965
- if ((cif->flags & FLAG_RETURNS_FP) == 0)
1140
+ if ((cif->flags & (FLAG_RETURNS_FP | FLAG_RETURNS_VEC)) == 0)
966
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;
967
1144
  else if ((cif->flags & FLAG_RETURNS_64BITS) != 0)
968
1145
  return FFI_V2_TYPE_DOUBLE_HOMOG;
969
1146
  else
970
1147
  return FFI_V2_TYPE_FLOAT_HOMOG;
971
1148
  }
1149
+ if ((cif->flags & FLAG_RETURNS_VEC) != 0)
1150
+ return FFI_V2_TYPE_VECTOR;
972
1151
  return cif->rtype->type;
973
1152
  }
974
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 = 1 << (31-31), /* Used for FFI_SYSV small structs. */
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
- FLAG_RETURNS_64BITS = 1 << (31-28),
37
+ FLAG_RETURNS_VEC = 1 << (31-28),
38
38
 
39
- /* This goes in cr6 */
40
- FLAG_RETURNS_128BITS = 1 << (31-27),
39
+ /* These go in cr6 */
40
+ FLAG_RETURNS_64BITS = 1 << (31-27),
41
+ FLAG_RETURNS_128BITS = 1 << (31-26),
41
42
 
42
- FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */
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__) && defined(__HAVE_FLOAT128)
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 = 12
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 FFI_V2_TYPE_FLOAT_HOMOG (FFI_PPC_TYPE_LAST + 1)
171
- #define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_PPC_TYPE_LAST + 2)
172
- #define FFI_V2_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 3)
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