ffi 1.11.1 → 1.15.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (331) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +207 -0
  3. data/Gemfile +3 -4
  4. data/README.md +24 -3
  5. data/Rakefile +65 -69
  6. data/ext/ffi_c/AbstractMemory.c +29 -34
  7. data/ext/ffi_c/Buffer.c +4 -9
  8. data/ext/ffi_c/Call.c +6 -22
  9. data/ext/ffi_c/Call.h +2 -2
  10. data/ext/ffi_c/ClosurePool.c +75 -25
  11. data/ext/ffi_c/ClosurePool.h +3 -1
  12. data/ext/ffi_c/DynamicLibrary.c +2 -7
  13. data/ext/ffi_c/Function.c +43 -43
  14. data/ext/ffi_c/Function.h +0 -4
  15. data/ext/ffi_c/FunctionInfo.c +3 -8
  16. data/ext/ffi_c/LastError.c +2 -6
  17. data/ext/ffi_c/LongDouble.c +12 -10
  18. data/ext/ffi_c/LongDouble.h +0 -4
  19. data/ext/ffi_c/MemoryPointer.c +3 -8
  20. data/ext/ffi_c/MemoryPointer.h +0 -4
  21. data/ext/ffi_c/MethodHandle.c +21 -31
  22. data/ext/ffi_c/MethodHandle.h +3 -2
  23. data/ext/ffi_c/Platform.c +5 -9
  24. data/ext/ffi_c/Pointer.c +25 -26
  25. data/ext/ffi_c/Pointer.h +0 -4
  26. data/ext/ffi_c/Struct.c +49 -56
  27. data/ext/ffi_c/Struct.h +12 -6
  28. data/ext/ffi_c/StructByValue.c +2 -7
  29. data/ext/ffi_c/StructLayout.c +22 -20
  30. data/ext/ffi_c/Thread.c +0 -8
  31. data/ext/ffi_c/Thread.h +1 -9
  32. data/ext/ffi_c/Type.c +1 -1
  33. data/ext/ffi_c/Types.c +7 -8
  34. data/ext/ffi_c/Types.h +3 -4
  35. data/ext/ffi_c/Variadic.c +14 -9
  36. data/ext/ffi_c/compat.h +4 -0
  37. data/ext/ffi_c/extconf.rb +36 -24
  38. data/ext/ffi_c/libffi/.appveyor.yml +29 -13
  39. data/ext/ffi_c/libffi/.gitattributes +4 -0
  40. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  41. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  42. data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
  43. data/ext/ffi_c/libffi/.travis/build.sh +116 -8
  44. data/ext/ffi_c/libffi/.travis/install.sh +65 -16
  45. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  46. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  47. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  48. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  49. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  50. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  51. data/ext/ffi_c/libffi/.travis.yml +51 -2
  52. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  53. data/ext/ffi_c/libffi/LICENSE +1 -1
  54. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  55. data/ext/ffi_c/libffi/Makefile.am +56 -72
  56. data/ext/ffi_c/libffi/Makefile.in +458 -207
  57. data/ext/ffi_c/libffi/README.md +33 -8
  58. data/ext/ffi_c/libffi/config.guess +552 -331
  59. data/ext/ffi_c/libffi/config.sub +1321 -1306
  60. data/ext/ffi_c/libffi/configure +414 -342
  61. data/ext/ffi_c/libffi/configure.ac +32 -11
  62. data/ext/ffi_c/libffi/configure.host +56 -27
  63. data/ext/ffi_c/libffi/doc/Makefile.in +9 -5
  64. data/ext/ffi_c/libffi/doc/libffi.texi +26 -14
  65. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  66. data/ext/ffi_c/libffi/fficonfig.h.in +13 -0
  67. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
  68. data/ext/ffi_c/libffi/include/Makefile.in +10 -6
  69. data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
  70. data/ext/ffi_c/libffi/include/ffi_common.h +4 -0
  71. data/ext/ffi_c/libffi/install-sh +23 -13
  72. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  73. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  74. data/ext/ffi_c/libffi/libtool-version +1 -1
  75. data/ext/ffi_c/libffi/ltmain.sh +156 -61
  76. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  77. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  78. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  79. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  80. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  81. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  82. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  83. data/ext/ffi_c/libffi/man/Makefile.in +9 -5
  84. data/ext/ffi_c/libffi/missing +8 -8
  85. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  86. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  87. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  88. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  89. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  90. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
  91. data/ext/ffi_c/libffi/msvcc.sh +38 -13
  92. data/ext/ffi_c/libffi/src/aarch64/ffi.c +151 -67
  93. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
  94. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  95. data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
  96. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  97. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
  98. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  99. data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
  100. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  101. data/ext/ffi_c/libffi/src/closures.c +69 -14
  102. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  103. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  104. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  105. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  106. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  107. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  108. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  109. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  110. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  111. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  112. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  113. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  114. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  115. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  116. data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
  117. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  118. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  119. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  120. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  121. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  122. data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
  123. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
  124. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  125. data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
  126. data/ext/ffi_c/libffi/src/x86/ffi.c +28 -12
  127. data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
  128. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  129. data/ext/ffi_c/libffi/src/x86/ffiw64.c +21 -11
  130. data/ext/ffi_c/libffi/src/x86/sysv.S +17 -8
  131. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
  132. data/ext/ffi_c/libffi/src/x86/unix64.S +59 -4
  133. data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
  134. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  135. data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
  136. data/ext/ffi_c/libffi/testsuite/Makefile.in +124 -84
  137. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
  138. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  139. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  140. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  143. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
  144. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  145. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  146. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
  147. data/ext/ffi_c/libffi.darwin.mk +1 -1
  148. data/ffi.gemspec +5 -6
  149. data/lib/ffi/abstract_memory.rb +44 -0
  150. data/lib/ffi/autopointer.rb +1 -1
  151. data/lib/ffi/ffi.rb +2 -0
  152. data/lib/ffi/io.rb +3 -3
  153. data/lib/ffi/library.rb +13 -9
  154. data/lib/ffi/managedstruct.rb +2 -2
  155. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  156. data/lib/ffi/platform/aarch64-freebsd/types.conf +89 -89
  157. data/lib/ffi/platform/aarch64-freebsd12/types.conf +162 -109
  158. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  159. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  160. data/lib/ffi/platform/arm-freebsd/types.conf +87 -87
  161. data/lib/ffi/platform/arm-freebsd12/types.conf +87 -87
  162. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  163. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  164. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  165. data/lib/ffi/platform/i386-freebsd/types.conf +87 -87
  166. data/lib/ffi/platform/i386-freebsd12/types.conf +87 -87
  167. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  168. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  169. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  170. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  171. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  172. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  173. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  174. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  175. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  176. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  177. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  178. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  179. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  180. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  181. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  182. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  183. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  184. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  185. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  186. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  187. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  188. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  189. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  190. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  191. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  192. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  193. data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
  194. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  195. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  196. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  197. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  198. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  199. data/lib/ffi/platform/x86_64-freebsd/types.conf +89 -89
  200. data/lib/ffi/platform/x86_64-freebsd12/types.conf +139 -109
  201. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  202. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  203. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  204. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  205. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  206. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  207. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  208. data/lib/ffi/platform.rb +22 -9
  209. data/lib/ffi/pointer.rb +21 -14
  210. data/lib/ffi/struct.rb +10 -5
  211. data/lib/ffi/tools/const_generator.rb +6 -4
  212. data/lib/ffi/tools/struct_generator.rb +2 -1
  213. data/lib/ffi/tools/types_generator.rb +7 -4
  214. data/lib/ffi/variadic.rb +1 -10
  215. data/lib/ffi/version.rb +1 -1
  216. data/lib/ffi.rb +10 -3
  217. data/rakelib/ffi_gem_helper.rb +65 -0
  218. data/samples/getlogin.rb +1 -1
  219. data/samples/getpid.rb +1 -1
  220. data/samples/gettimeofday.rb +8 -8
  221. data/samples/hello.rb +2 -1
  222. data/samples/inotify.rb +1 -1
  223. data/samples/pty.rb +1 -2
  224. data/samples/qsort.rb +0 -1
  225. metadata +147 -134
  226. data/.gitignore +0 -25
  227. data/.gitmodules +0 -4
  228. data/.travis.yml +0 -42
  229. data/.yardopts +0 -5
  230. data/appveyor.yml +0 -27
  231. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  232. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  233. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  234. data/ext/ffi_c/win32/stdbool.h +0 -8
  235. data/ext/ffi_c/win32/stdint.h +0 -201
  236. data/samples/sample_helper.rb +0 -6
  237. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  238. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  239. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  240. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  241. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  242. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  243. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  244. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  245. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  246. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  247. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  248. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  249. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  250. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  251. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  252. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  253. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  254. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  255. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  256. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  257. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  258. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  259. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  260. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  261. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  262. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  263. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  264. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  265. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  266. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  267. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  268. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  269. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  270. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  271. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  272. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  273. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  274. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  275. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  276. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  277. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  278. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  279. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  280. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  281. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  282. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  283. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  284. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  285. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  286. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  287. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  288. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  289. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  290. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  291. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  292. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  293. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  294. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  295. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  296. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  297. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  298. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  299. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  300. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  301. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  302. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  303. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  304. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  305. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  306. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  307. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  308. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  309. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  310. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  311. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  312. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  313. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  314. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  315. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  316. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  317. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  318. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  319. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  320. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  321. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  322. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  323. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  324. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  325. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  326. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  327. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  328. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  329. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  330. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  331. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
@@ -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