ffi 1.15.5 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (343) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +118 -0
  4. data/Gemfile +10 -3
  5. data/README.md +4 -3
  6. data/Rakefile +25 -10
  7. data/ext/ffi_c/AbstractMemory.c +99 -74
  8. data/ext/ffi_c/AbstractMemory.h +3 -2
  9. data/ext/ffi_c/ArrayType.c +51 -15
  10. data/ext/ffi_c/ArrayType.h +1 -0
  11. data/ext/ffi_c/Buffer.c +90 -33
  12. data/ext/ffi_c/Call.c +29 -12
  13. data/ext/ffi_c/Call.h +3 -2
  14. data/ext/ffi_c/DynamicLibrary.c +90 -27
  15. data/ext/ffi_c/Function.c +244 -98
  16. data/ext/ffi_c/Function.h +1 -0
  17. data/ext/ffi_c/FunctionInfo.c +81 -25
  18. data/ext/ffi_c/LastError.c +29 -11
  19. data/ext/ffi_c/MappedType.c +66 -23
  20. data/ext/ffi_c/MappedType.h +0 -2
  21. data/ext/ffi_c/MemoryPointer.c +36 -9
  22. data/ext/ffi_c/MethodHandle.c +3 -1
  23. data/ext/ffi_c/Pointer.c +82 -40
  24. data/ext/ffi_c/Pointer.h +1 -0
  25. data/ext/ffi_c/Struct.c +166 -84
  26. data/ext/ffi_c/Struct.h +7 -4
  27. data/ext/ffi_c/StructByValue.c +48 -16
  28. data/ext/ffi_c/StructLayout.c +130 -61
  29. data/ext/ffi_c/Type.c +120 -51
  30. data/ext/ffi_c/Type.h +3 -1
  31. data/ext/ffi_c/Types.c +8 -2
  32. data/ext/ffi_c/Types.h +0 -1
  33. data/ext/ffi_c/Variadic.c +71 -26
  34. data/ext/ffi_c/compat.h +22 -22
  35. data/ext/ffi_c/extconf.rb +19 -2
  36. data/ext/ffi_c/ffi.c +4 -0
  37. data/ext/ffi_c/libffi/.allow-ai-service +0 -0
  38. data/ext/ffi_c/libffi/.appveyor/site.exp +16 -0
  39. data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +7 -0
  40. data/ext/ffi_c/libffi/.appveyor.yml +27 -9
  41. data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
  42. data/ext/ffi_c/libffi/{.travis → .ci}/build-in-container.sh +4 -6
  43. data/ext/ffi_c/libffi/.ci/build.sh +124 -0
  44. data/ext/ffi_c/libffi/{.travis → .ci}/install.sh +14 -7
  45. data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
  46. data/ext/ffi_c/libffi/{.travis → .ci}/site.exp +5 -3
  47. data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
  48. data/ext/ffi_c/libffi/.github/workflows/build.yml +479 -0
  49. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +172 -0
  50. data/ext/ffi_c/libffi/.gitignore +10 -2
  51. data/ext/ffi_c/libffi/LICENSE +1 -1
  52. data/ext/ffi_c/libffi/Makefile.am +12 -5
  53. data/ext/ffi_c/libffi/Makefile.in +118 -51
  54. data/ext/ffi_c/libffi/README.md +150 -105
  55. data/ext/ffi_c/libffi/acinclude.m4 +10 -112
  56. data/ext/ffi_c/libffi/compile +348 -0
  57. data/ext/ffi_c/libffi/config.guess +623 -556
  58. data/ext/ffi_c/libffi/config.sub +75 -34
  59. data/ext/ffi_c/libffi/configure +4571 -3830
  60. data/ext/ffi_c/libffi/configure.ac +64 -28
  61. data/ext/ffi_c/libffi/configure.host +26 -7
  62. data/ext/ffi_c/libffi/doc/Makefile.in +9 -6
  63. data/ext/ffi_c/libffi/doc/libffi.texi +82 -33
  64. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  65. data/ext/ffi_c/libffi/fficonfig.h.in +12 -47
  66. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +163 -52
  67. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  68. data/ext/ffi_c/libffi/include/Makefile.in +10 -9
  69. data/ext/ffi_c/libffi/include/ffi.h.in +55 -60
  70. data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
  71. data/ext/ffi_c/libffi/include/ffi_common.h +33 -2
  72. data/ext/ffi_c/libffi/include/tramp.h +45 -0
  73. data/ext/ffi_c/libffi/install-sh +92 -69
  74. data/ext/ffi_c/libffi/libffi.map.in +5 -0
  75. data/ext/ffi_c/libffi/libtool-version +2 -2
  76. data/ext/ffi_c/libffi/ltmain.sh +518 -333
  77. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +18 -14
  78. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
  79. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -45
  80. data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
  81. data/ext/ffi_c/libffi/man/Makefile.in +9 -6
  82. data/ext/ffi_c/libffi/missing +1 -1
  83. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +2 -2
  84. data/ext/ffi_c/libffi/msvcc.sh +1 -1
  85. data/ext/ffi_c/libffi/src/aarch64/ffi.c +172 -55
  86. data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
  87. data/ext/ffi_c/libffi/src/aarch64/sysv.S +331 -87
  88. data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
  89. data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
  90. data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
  91. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -17
  92. data/ext/ffi_c/libffi/src/arm/ffitarget.h +3 -3
  93. data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
  94. data/ext/ffi_c/libffi/src/arm/sysv.S +113 -42
  95. data/ext/ffi_c/libffi/src/closures.c +136 -50
  96. data/ext/ffi_c/libffi/src/debug.c +2 -2
  97. data/ext/ffi_c/libffi/src/dlmalloc.c +6 -1
  98. data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
  99. data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
  100. data/ext/ffi_c/libffi/src/loongarch64/ffi.c +624 -0
  101. data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
  102. data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
  103. data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
  104. data/ext/ffi_c/libffi/src/mips/ffi.c +250 -67
  105. data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
  106. data/ext/ffi_c/libffi/src/mips/n32.S +193 -33
  107. data/ext/ffi_c/libffi/src/mips/o32.S +61 -4
  108. data/ext/ffi_c/libffi/src/moxie/ffi.c +47 -22
  109. data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
  110. data/ext/ffi_c/libffi/src/pa/ffi.c +32 -33
  111. data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
  112. data/ext/ffi_c/libffi/src/pa/ffitarget.h +22 -8
  113. data/ext/ffi_c/libffi/src/pa/hpux32.S +83 -36
  114. data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
  115. data/ext/ffi_c/libffi/src/pa/linux.S +82 -35
  116. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +36 -24
  117. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1 -1
  118. data/ext/ffi_c/libffi/src/powerpc/linux64.S +2 -0
  119. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +2 -0
  120. data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
  121. data/ext/ffi_c/libffi/src/prep_cif.c +22 -2
  122. data/ext/ffi_c/libffi/src/riscv/ffi.c +37 -4
  123. data/ext/ffi_c/libffi/src/sparc/ffi64.c +23 -1
  124. data/ext/ffi_c/libffi/src/tramp.c +716 -0
  125. data/ext/ffi_c/libffi/src/types.c +4 -6
  126. data/ext/ffi_c/libffi/src/wasm32/ffi.c +947 -0
  127. data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
  128. data/ext/ffi_c/libffi/src/x86/ffi.c +99 -37
  129. data/ext/ffi_c/libffi/src/x86/ffi64.c +67 -12
  130. data/ext/ffi_c/libffi/src/x86/ffitarget.h +9 -5
  131. data/ext/ffi_c/libffi/src/x86/ffiw64.c +44 -1
  132. data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
  133. data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
  134. data/ext/ffi_c/libffi/src/x86/sysv.S +172 -38
  135. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +91 -88
  136. data/ext/ffi_c/libffi/src/x86/unix64.S +96 -6
  137. data/ext/ffi_c/libffi/src/x86/win64.S +20 -7
  138. data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
  139. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
  140. data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
  141. data/ext/ffi_c/libffi/testsuite/Makefile.am +79 -114
  142. data/ext/ffi_c/libffi/testsuite/Makefile.in +89 -121
  143. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
  144. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
  145. data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +86 -0
  146. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
  147. data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
  148. data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
  149. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +43 -21
  150. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
  151. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -0
  152. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
  154. data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +99 -0
  155. data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +108 -0
  156. data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +114 -0
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +119 -0
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
  172. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
  173. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
  174. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
  175. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
  176. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
  177. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
  179. data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
  180. data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
  181. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
  182. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
  183. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
  184. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn0.c +3 -2
  185. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +2 -0
  186. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +2 -0
  187. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +21 -1
  188. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +2 -0
  189. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +2 -0
  190. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +2 -0
  191. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +7 -6
  192. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +6 -0
  193. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +18 -0
  194. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +22 -0
  195. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +24 -0
  196. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +29 -0
  197. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +4 -0
  198. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +19 -1
  199. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +21 -1
  200. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +35 -3
  201. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +13 -0
  202. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +19 -0
  203. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +13 -0
  204. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +13 -0
  205. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +18 -0
  206. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +22 -0
  207. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +13 -0
  208. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +29 -1
  209. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +19 -1
  210. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +24 -0
  211. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +28 -1
  212. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +24 -2
  213. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +39 -1
  214. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +25 -1
  215. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +14 -0
  216. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +14 -1
  217. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +14 -2
  218. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +19 -1
  219. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +19 -1
  220. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +20 -1
  221. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +40 -25
  222. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +40 -3
  223. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +19 -1
  224. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +18 -1
  225. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +18 -3
  226. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +18 -1
  227. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +18 -1
  228. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +19 -1
  229. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +19 -1
  230. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +3 -1
  231. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +9 -1
  232. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +4 -0
  233. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +11 -1
  234. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +22 -3
  235. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +5 -1
  236. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +6 -1
  237. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +9 -1
  238. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +9 -1
  239. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +6 -2
  240. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +9 -1
  241. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +5 -0
  242. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +10 -0
  243. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +3 -0
  244. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +2 -0
  245. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +3 -0
  246. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +11 -0
  247. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +3 -0
  248. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +4 -0
  249. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +4 -0
  250. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +4 -0
  251. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +2 -0
  252. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +3 -0
  253. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -138
  254. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +21 -21
  255. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +32 -9
  256. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +1 -1
  257. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +12 -0
  258. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +21 -5
  259. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
  260. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
  261. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct2.c +10 -1
  262. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +10 -1
  263. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +9 -0
  264. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +9 -0
  265. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +11 -0
  266. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +9 -0
  267. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +11 -0
  268. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct9.c +11 -0
  269. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
  270. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
  271. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
  272. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium.c +1 -1
  273. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +1 -1
  274. data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +6 -1
  275. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -1
  276. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +1 -0
  277. data/ext/ffi_c/libffi.bsd.mk +2 -2
  278. data/ext/ffi_c/libffi.darwin.mk +2 -2
  279. data/ext/ffi_c/libffi.gnu.mk +2 -2
  280. data/ext/ffi_c/rbffi.h +1 -1
  281. data/ffi.gemspec +3 -3
  282. data/lib/ffi/autopointer.rb +8 -31
  283. data/lib/ffi/compat.rb +43 -0
  284. data/lib/ffi/data_converter.rb +2 -2
  285. data/lib/ffi/dynamic_library.rb +118 -0
  286. data/lib/ffi/enum.rb +18 -12
  287. data/lib/ffi/ffi.rb +3 -0
  288. data/lib/ffi/function.rb +71 -0
  289. data/lib/ffi/io.rb +2 -2
  290. data/lib/ffi/library.rb +72 -88
  291. data/lib/ffi/library_path.rb +109 -0
  292. data/lib/ffi/managedstruct.rb +1 -1
  293. data/lib/ffi/platform/aarch64-linux/types.conf +74 -3
  294. data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
  295. data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
  296. data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
  297. data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
  298. data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
  299. data/lib/ffi/platform.rb +15 -13
  300. data/lib/ffi/pointer.rb +6 -6
  301. data/lib/ffi/struct.rb +6 -5
  302. data/lib/ffi/struct_layout.rb +3 -3
  303. data/lib/ffi/struct_layout_builder.rb +9 -9
  304. data/lib/ffi/types.rb +65 -37
  305. data/lib/ffi/variadic.rb +19 -8
  306. data/lib/ffi/version.rb +1 -1
  307. data/samples/hello_ractor.rb +11 -0
  308. data/samples/qsort_ractor.rb +28 -0
  309. data/sig/ffi/abstract_memory.rbs +165 -0
  310. data/sig/ffi/auto_pointer.rbs +27 -0
  311. data/sig/ffi/buffer.rbs +18 -0
  312. data/sig/ffi/data_converter.rbs +10 -0
  313. data/sig/ffi/dynamic_library.rbs +9 -0
  314. data/sig/ffi/enum.rbs +38 -0
  315. data/sig/ffi/function.rbs +39 -0
  316. data/sig/ffi/library.rbs +42 -0
  317. data/sig/ffi/native_type.rbs +86 -0
  318. data/sig/ffi/pointer.rbs +42 -0
  319. data/sig/ffi/struct.rbs +76 -0
  320. data/sig/ffi/struct_by_reference.rbs +11 -0
  321. data/sig/ffi/struct_by_value.rbs +7 -0
  322. data/sig/ffi/struct_layout.rbs +9 -0
  323. data/sig/ffi/struct_layout_builder.rbs +5 -0
  324. data/sig/ffi/type.rbs +39 -0
  325. data/sig/ffi.rbs +26 -0
  326. data.tar.gz.sig +0 -0
  327. metadata +122 -28
  328. metadata.gz.sig +1 -0
  329. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
  330. data/ext/ffi_c/libffi/.travis/build.sh +0 -142
  331. data/ext/ffi_c/libffi/.travis.yml +0 -83
  332. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
  333. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
  334. /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
  335. /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
  336. /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
  337. /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
  338. /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
  339. /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
  340. /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
  341. /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
  342. /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  343. /data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +0 -0
@@ -31,6 +31,7 @@
31
31
 
32
32
  #include <stdint.h>
33
33
  #include <stdlib.h>
34
+ #include <stdio.h>
34
35
 
35
36
  #ifdef __GNUC__
36
37
  # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
@@ -77,22 +78,39 @@ static void ffi_prep_args(char *stack,
77
78
  {
78
79
  int i;
79
80
  void **p_argv;
80
- char *argp;
81
+ char *argp, *argp_f;
81
82
  ffi_type **p_arg;
82
83
 
84
+ memset(stack, 0, bytes);
85
+
83
86
  #ifdef FFI_MIPS_N32
87
+ int soft_float = (ecif->cif->abi == FFI_N32_SOFT_FLOAT
88
+ || ecif->cif->abi == FFI_N64_SOFT_FLOAT);
84
89
  /* If more than 8 double words are used, the remainder go
85
90
  on the stack. We reorder stuff on the stack here to
86
91
  support this easily. */
87
- if (bytes > 8 * sizeof(ffi_arg))
88
- argp = &stack[bytes - (8 * sizeof(ffi_arg))];
92
+ /* if ret is _Complex long double, args reg shift2, and a0 should holds pointer to rvalue */
93
+ if (ecif->cif->rtype->type == FFI_TYPE_COMPLEX && ecif->cif->rtype->elements[0]->type == FFI_TYPE_LONGDOUBLE)
94
+ {
95
+ if (bytes + 16 > 8 * sizeof(ffi_arg))
96
+ argp = &stack[bytes - (8 * sizeof(ffi_arg))];
97
+ else
98
+ argp = stack;
99
+ * (unsigned long *) argp = (unsigned long) ecif->rvalue;
100
+ argp += 16;
101
+ }
89
102
  else
90
- argp = stack;
103
+ {
104
+ if (bytes > 8 * sizeof(ffi_arg))
105
+ argp = &stack[bytes - (8 * sizeof(ffi_arg))];
106
+ else
107
+ argp = stack;
108
+ }
91
109
  #else
92
110
  argp = stack;
93
111
  #endif
94
112
 
95
- memset(stack, 0, bytes);
113
+ argp_f = argp;
96
114
 
97
115
  #ifdef FFI_MIPS_N32
98
116
  if ( ecif->cif->rstruct_flag != 0 )
@@ -133,7 +151,7 @@ static void ffi_prep_args(char *stack,
133
151
  if (type == FFI_TYPE_POINTER)
134
152
  type = (ecif->cif->abi == FFI_N64
135
153
  || ecif->cif->abi == FFI_N64_SOFT_FLOAT)
136
- ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
154
+ ? FFI_TYPE_SINT64 : FFI_TYPE_UINT32;
137
155
 
138
156
  if (i < 8 && (ecif->cif->abi == FFI_N32_SOFT_FLOAT
139
157
  || ecif->cif->abi == FFI_N64_SOFT_FLOAT))
@@ -183,6 +201,25 @@ static void ffi_prep_args(char *stack,
183
201
  #endif
184
202
  break;
185
203
 
204
+ #ifdef FFI_MIPS_N32
205
+ case FFI_TYPE_COMPLEX:
206
+ /* expand from 4+4 to 8+8 if pass with fpr reg */
207
+ /* argp will wind back to stack when we process all of reg args */
208
+ /* all var_args passed with gpr, should be expand */
209
+ if(!soft_float
210
+ && (*p_arg)->elements[0]->type == FFI_TYPE_FLOAT
211
+ && argp>=argp_f
212
+ && i < ecif->cif->mips_nfixedargs)
213
+ {
214
+ *(float *) argp = *(float *)(* p_argv);
215
+ argp += z;
216
+ char *tmp = (void *) (*p_argv);
217
+ *(float *) argp = *(float *)(tmp+4);
218
+ }
219
+ else
220
+ memcpy(argp, *p_argv, (*p_arg)->size);
221
+ break;
222
+ #endif
186
223
  /* This can only happen with 64bit slots. */
187
224
  case FFI_TYPE_FLOAT:
188
225
  *(float *) argp = *(float *)(* p_argv);
@@ -235,6 +272,24 @@ static void ffi_prep_args(char *stack,
235
272
  passed in an integer register". This code traverses structure
236
273
  definitions and generates the appropriate flags. */
237
274
 
275
+ static int
276
+ calc_n32_struct_flags_element(unsigned *flags, ffi_type *e,
277
+ unsigned *loc, unsigned *arg_reg)
278
+ {
279
+ /* Align this object. */
280
+ *loc = FFI_ALIGN(*loc, e->alignment);
281
+ if (e->type == FFI_TYPE_DOUBLE)
282
+ {
283
+ /* Already aligned to FFI_SIZEOF_ARG. */
284
+ *arg_reg = *loc / FFI_SIZEOF_ARG;
285
+ if (*arg_reg > 7)
286
+ return 1;
287
+ *flags += (FFI_TYPE_DOUBLE << (*arg_reg * FFI_FLAG_BITS));
288
+ }
289
+ *loc += e->size;
290
+ return 0;
291
+ }
292
+
238
293
  static unsigned
239
294
  calc_n32_struct_flags(int soft_float, ffi_type *arg,
240
295
  unsigned *loc, unsigned *arg_reg)
@@ -249,19 +304,16 @@ calc_n32_struct_flags(int soft_float, ffi_type *arg,
249
304
 
250
305
  while ((e = arg->elements[index]))
251
306
  {
252
- /* Align this object. */
253
- *loc = FFI_ALIGN(*loc, e->alignment);
254
- if (e->type == FFI_TYPE_DOUBLE)
307
+ if (e->type == FFI_TYPE_COMPLEX)
255
308
  {
256
- /* Already aligned to FFI_SIZEOF_ARG. */
257
- *arg_reg = *loc / FFI_SIZEOF_ARG;
258
- if (*arg_reg > 7)
259
- break;
260
- flags += (FFI_TYPE_DOUBLE << (*arg_reg * FFI_FLAG_BITS));
261
- *loc += e->size;
309
+ if (calc_n32_struct_flags_element(&flags, e->elements[0], loc, arg_reg))
310
+ break;
311
+ if (calc_n32_struct_flags_element(&flags, e->elements[0], loc, arg_reg))
312
+ break;
262
313
  }
263
314
  else
264
- *loc += e->size;
315
+ if (calc_n32_struct_flags_element(&flags, e, loc, arg_reg))
316
+ break;
265
317
  index++;
266
318
  }
267
319
  /* Next Argument register at alignment of FFI_SIZEOF_ARG. */
@@ -273,7 +325,7 @@ calc_n32_struct_flags(int soft_float, ffi_type *arg,
273
325
  static unsigned
274
326
  calc_n32_return_struct_flags(int soft_float, ffi_type *arg)
275
327
  {
276
- unsigned flags = 0;
328
+ unsigned flags;
277
329
  unsigned small = FFI_TYPE_SMALLSTRUCT;
278
330
  ffi_type *e;
279
331
 
@@ -292,33 +344,48 @@ calc_n32_return_struct_flags(int soft_float, ffi_type *arg)
292
344
 
293
345
  e = arg->elements[0];
294
346
 
295
- if (e->type == FFI_TYPE_DOUBLE)
296
- flags = FFI_TYPE_DOUBLE;
297
- else if (e->type == FFI_TYPE_FLOAT)
298
- flags = FFI_TYPE_FLOAT;
299
-
300
- if (flags && (e = arg->elements[1]))
347
+ if (e->type == FFI_TYPE_COMPLEX)
301
348
  {
302
- if (e->type == FFI_TYPE_DOUBLE)
303
- flags += FFI_TYPE_DOUBLE << FFI_FLAG_BITS;
304
- else if (e->type == FFI_TYPE_FLOAT)
305
- flags += FFI_TYPE_FLOAT << FFI_FLAG_BITS;
306
- else
349
+ int type = e->elements[0]->type;
350
+
351
+ if (type != FFI_TYPE_DOUBLE && type != FFI_TYPE_FLOAT)
307
352
  return small;
308
353
 
309
- if (flags && (arg->elements[2]))
354
+ if (arg->elements[1])
310
355
  {
311
- /* There are three arguments and the first two are
312
- floats! This must be passed the old way. */
356
+ /* Two floating point fields with more fields!
357
+ This must be passed the old way. */
313
358
  return small;
314
359
  }
315
- if (soft_float)
316
- flags += FFI_TYPE_STRUCT_SOFT;
360
+
361
+ flags = (type << FFI_FLAG_BITS) + type;
317
362
  }
318
363
  else
319
- if (!flags)
320
- return small;
364
+ {
365
+ if (e->type != FFI_TYPE_DOUBLE && e->type != FFI_TYPE_FLOAT)
366
+ return small;
367
+
368
+ flags = e->type;
321
369
 
370
+ if (arg->elements[1])
371
+ {
372
+ e = arg->elements[1];
373
+ if (e->type != FFI_TYPE_DOUBLE && e->type != FFI_TYPE_FLOAT)
374
+ return small;
375
+
376
+ if (arg->elements[2])
377
+ {
378
+ /* There are three arguments and the first two are
379
+ floats! This must be passed the old way. */
380
+ return small;
381
+ }
382
+
383
+ flags += e->type << FFI_FLAG_BITS;
384
+ }
385
+ }
386
+
387
+ if (soft_float)
388
+ flags += FFI_TYPE_STRUCT_SOFT;
322
389
  return flags;
323
390
  }
324
391
 
@@ -335,7 +402,7 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
335
402
  * does not have special handling for floating point args.
336
403
  */
337
404
 
338
- if (cif->rtype->type != FFI_TYPE_STRUCT && cif->abi == FFI_O32)
405
+ if (cif->rtype->type != FFI_TYPE_STRUCT && cif->rtype->type != FFI_TYPE_COMPLEX && cif->abi == FFI_O32)
339
406
  {
340
407
  if (cif->nargs > 0 && cif->nargs == nfixedargs)
341
408
  {
@@ -403,7 +470,10 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
403
470
  case FFI_TYPE_STRUCT:
404
471
  case FFI_TYPE_FLOAT:
405
472
  case FFI_TYPE_DOUBLE:
473
+ case FFI_TYPE_COMPLEX:
406
474
  cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2);
475
+ if (cif->rtype->type == FFI_TYPE_COMPLEX)
476
+ cif->flags += ((*cif->rtype->elements[0]).type) << (FFI_FLAG_BITS * 4);
407
477
  break;
408
478
 
409
479
  case FFI_TYPE_SINT64:
@@ -421,7 +491,6 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
421
491
  #ifdef FFI_MIPS_N32
422
492
  /* Set the flags necessary for N32 processing */
423
493
  {
424
- int type;
425
494
  unsigned arg_reg = 0;
426
495
  unsigned loc = 0;
427
496
  unsigned count = (cif->nargs < 8) ? cif->nargs : 8;
@@ -453,29 +522,14 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
453
522
 
454
523
  while (count-- > 0 && arg_reg < 8)
455
524
  {
456
- type = (cif->arg_types)[index]->type;
525
+ ffi_type *t = cif->arg_types[index];
457
526
 
458
- // Pass variadic arguments in integer registers even if they're floats
459
- if (soft_float || index >= nfixedargs)
460
- {
461
- switch (type)
462
- {
463
- case FFI_TYPE_FLOAT:
464
- type = FFI_TYPE_UINT32;
465
- break;
466
- case FFI_TYPE_DOUBLE:
467
- type = FFI_TYPE_UINT64;
468
- break;
469
- default:
470
- break;
471
- }
472
- }
473
- switch (type)
527
+ switch (t->type)
474
528
  {
475
529
  case FFI_TYPE_FLOAT:
476
530
  case FFI_TYPE_DOUBLE:
477
- cif->flags +=
478
- ((cif->arg_types)[index]->type << (arg_reg * FFI_FLAG_BITS));
531
+ if (!soft_float && index < nfixedargs)
532
+ cif->flags += t->type << (arg_reg * FFI_FLAG_BITS);
479
533
  arg_reg++;
480
534
  break;
481
535
  case FFI_TYPE_LONGDOUBLE:
@@ -491,17 +545,71 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
491
545
  cif->flags +=
492
546
  (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
493
547
  arg_reg++;
548
+ if (arg_reg >= 8)
549
+ continue;
494
550
  cif->flags +=
495
551
  (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
496
552
  arg_reg++;
497
553
  }
498
554
  break;
499
555
 
556
+ case FFI_TYPE_COMPLEX:
557
+ switch (t->elements[0]->type)
558
+ {
559
+ case FFI_TYPE_LONGDOUBLE:
560
+ arg_reg = FFI_ALIGN(arg_reg, 2);
561
+ if (soft_float || index >= nfixedargs)
562
+ {
563
+ arg_reg += 2;
564
+ }
565
+ else
566
+ {
567
+ cif->flags +=
568
+ (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
569
+ arg_reg++;
570
+ if (arg_reg >= 8)
571
+ continue;
572
+ cif->flags +=
573
+ (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
574
+ arg_reg++;
575
+ if (arg_reg >= 8)
576
+ continue;
577
+ }
578
+ /* passthrough */
579
+ case FFI_TYPE_FLOAT:
580
+ // one fpr can only holds one arg even it is single
581
+ cif->bytes += 16;
582
+ /* passthrough */
583
+ case FFI_TYPE_SINT32:
584
+ case FFI_TYPE_UINT32:
585
+ case FFI_TYPE_DOUBLE:
586
+ if (soft_float || index >= nfixedargs)
587
+ {
588
+ arg_reg += 2;
589
+ }
590
+ else
591
+ {
592
+ uint32_t type = t->elements[0]->type != FFI_TYPE_LONGDOUBLE? t->elements[0]->type: FFI_TYPE_DOUBLE;
593
+ cif->flags +=
594
+ (type << (arg_reg * FFI_FLAG_BITS));
595
+ arg_reg++;
596
+ if (arg_reg >= 8)
597
+ continue;
598
+ cif->flags +=
599
+ (type << (arg_reg * FFI_FLAG_BITS));
600
+ arg_reg++;
601
+ }
602
+ break;
603
+ default:
604
+ arg_reg += 2;
605
+ break;
606
+ }
607
+ break;
608
+
500
609
  case FFI_TYPE_STRUCT:
501
610
  loc = arg_reg * FFI_SIZEOF_ARG;
502
611
  cif->flags += calc_n32_struct_flags(soft_float || index >= nfixedargs,
503
- (cif->arg_types)[index],
504
- &loc, &arg_reg);
612
+ t, &loc, &arg_reg);
505
613
  break;
506
614
 
507
615
  default:
@@ -541,7 +649,7 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
541
649
  if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32)
542
650
  cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
543
651
  else
544
- cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
652
+ cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
545
653
  break;
546
654
 
547
655
  case FFI_TYPE_FLOAT:
@@ -553,7 +661,7 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
553
661
  /* else fall through */
554
662
  case FFI_TYPE_DOUBLE:
555
663
  if (soft_float)
556
- cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
664
+ cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
557
665
  else
558
666
  cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
559
667
  break;
@@ -563,8 +671,9 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
563
671
  two doubles. */
564
672
  if (soft_float)
565
673
  {
566
- cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
567
- cif->flags += FFI_TYPE_SMALLSTRUCT2 << (4 + (FFI_FLAG_BITS * 8));
674
+ /* if ret is long double, the ret is given by v0 and a0, no idea why
675
+ * Let's us VOID | VOID | LONGDOUBLE for it*/
676
+ cif->flags += FFI_TYPE_LONGDOUBLE << (FFI_FLAG_BITS * 8);
568
677
  }
569
678
  else
570
679
  {
@@ -574,13 +683,52 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
574
683
  << (4 + (FFI_FLAG_BITS * 8));
575
684
  }
576
685
  break;
686
+ case FFI_TYPE_COMPLEX:
687
+ {
688
+ int type = cif->rtype->elements[0]->type;
689
+
690
+ cif->flags += (FFI_TYPE_COMPLEX << (FFI_FLAG_BITS * 8));
691
+ if (soft_float || (type != FFI_TYPE_FLOAT && type != FFI_TYPE_DOUBLE && type != FFI_TYPE_LONGDOUBLE))
692
+ {
693
+ switch (type)
694
+ {
695
+ case FFI_TYPE_DOUBLE:
696
+ case FFI_TYPE_SINT64:
697
+ case FFI_TYPE_UINT64:
698
+ case FFI_TYPE_INT:
699
+ type = FFI_TYPE_SMALLSTRUCT2;
700
+ break;
701
+ case FFI_TYPE_LONGDOUBLE:
702
+ type = FFI_TYPE_LONGDOUBLE;
703
+ break;
704
+ case FFI_TYPE_FLOAT:
705
+ default:
706
+ type = FFI_TYPE_SMALLSTRUCT;
707
+ }
708
+ cif->flags += type << (4 + (FFI_FLAG_BITS * 8));
709
+ }
710
+ else
711
+ {
712
+ //cif->flags += (type + (type << FFI_FLAG_BITS))
713
+ // << (4 + (FFI_FLAG_BITS * 8));
714
+ cif->flags += type << (4 + (FFI_FLAG_BITS * 8));
715
+ }
716
+ break;
717
+ }
718
+ case FFI_TYPE_UINT32:
719
+ /* In the N32 or N64 ABI unsigned 32-bit integer should be
720
+ *sign*-extended. */
721
+ cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
722
+ break;
723
+ case FFI_TYPE_SINT64:
724
+ cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 8);
725
+ break;
577
726
  default:
578
- cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
727
+ cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
579
728
  break;
580
729
  }
581
730
  }
582
731
  #endif
583
-
584
732
  return FFI_OK;
585
733
  }
586
734
 
@@ -618,7 +766,7 @@ void ffi_call_int(ffi_cif *cif, void (*fn)(void), void *rvalue,
618
766
  /* value address then we need to make one */
619
767
 
620
768
  if ((rvalue == NULL) &&
621
- (cif->rtype->type == FFI_TYPE_STRUCT))
769
+ (cif->rtype->type == FFI_TYPE_STRUCT || cif->rtype->type == FFI_TYPE_COMPLEX))
622
770
  ecif.rvalue = alloca(cif->rtype->size);
623
771
  else
624
772
  ecif.rvalue = rvalue;
@@ -830,6 +978,11 @@ ffi_closure_mips_inner_O32 (ffi_cif *cif,
830
978
  argn = 1;
831
979
  seen_int = 1;
832
980
  }
981
+ if ((cif->flags >> (FFI_FLAG_BITS * 2)) == FFI_TYPE_COMPLEX)
982
+ {
983
+ rvalue = fpr;
984
+ argn = 1;
985
+ }
833
986
 
834
987
  i = 0;
835
988
  avn = cif->nargs;
@@ -902,6 +1055,9 @@ ffi_closure_mips_inner_O32 (ffi_cif *cif,
902
1055
  }
903
1056
  else
904
1057
  {
1058
+ if (cif->rtype->type == FFI_TYPE_COMPLEX) {
1059
+ __asm__ volatile ("move $v1, %0" : : "r"(cif->rtype->size));
1060
+ }
905
1061
  return cif->rtype->type;
906
1062
  }
907
1063
  }
@@ -991,6 +1147,8 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
991
1147
  #endif
992
1148
  argn = 1;
993
1149
  }
1150
+ if (cif->rtype->type == FFI_TYPE_COMPLEX && cif->rtype->elements[0]->type == FFI_TYPE_LONGDOUBLE)
1151
+ argn = 2;
994
1152
 
995
1153
  i = 0;
996
1154
  avn = cif->nargs;
@@ -1015,6 +1173,31 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
1015
1173
  #endif
1016
1174
  avaluep[i] = (char *) argp;
1017
1175
  }
1176
+ else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
1177
+ {
1178
+ argp = (argn >= 8 || i >= cif->mips_nfixedargs || soft_float) ? ar + argn : fpr + argn;
1179
+ avaluep[i] = (char *) argp;
1180
+ }
1181
+ else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_LONGDOUBLE)
1182
+ {
1183
+ /* align long double */
1184
+ argn += ((argn & 0x1)? 1 : 0);
1185
+ argp = (argn >= 8 || i >= cif->mips_nfixedargs || soft_float) ? ar + argn : fpr + argn;
1186
+ avaluep[i] = (char *) argp;
1187
+ }
1188
+ else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_FLOAT)
1189
+ {
1190
+ if (argn >= 8 || i >= cif->mips_nfixedargs || soft_float)
1191
+ argp = ar + argn;
1192
+ else
1193
+ {
1194
+ argp = fpr + argn;
1195
+ /* the normal args for function holds 8bytes, while here we convert it to ptr */
1196
+ uint32_t *tmp = (uint32_t *)argp;
1197
+ tmp[1] = tmp[2];
1198
+ }
1199
+ avaluep[i] = (char *) argp;
1200
+ }
1018
1201
  else
1019
1202
  {
1020
1203
  unsigned type = arg_types[i]->type;
@@ -1027,10 +1210,10 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
1027
1210
  /* The size of a pointer depends on the ABI */
1028
1211
  if (type == FFI_TYPE_POINTER)
1029
1212
  type = (cif->abi == FFI_N64 || cif->abi == FFI_N64_SOFT_FLOAT)
1030
- ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
1213
+ ? FFI_TYPE_SINT64 : FFI_TYPE_UINT32;
1031
1214
 
1032
1215
  if (soft_float && type == FFI_TYPE_FLOAT)
1033
- type = FFI_TYPE_UINT32;
1216
+ type = FFI_TYPE_SINT32;
1034
1217
 
1035
1218
  switch (type)
1036
1219
  {
@@ -80,6 +80,7 @@
80
80
  # endif
81
81
  #endif
82
82
 
83
+ #define FFI_TARGET_HAS_COMPLEX_TYPE 1
83
84
  #define FFI_FLAG_BITS 2
84
85
 
85
86
  /* SGI's strange assembler requires that we multiply by 4 rather
@@ -111,6 +112,12 @@
111
112
  #define FFI_TYPE_STRUCT_SMALL 93
112
113
  #define FFI_TYPE_STRUCT_SMALL2 109
113
114
 
115
+ #define FFI_TYPE_COMPLEX_SMALL 95
116
+ #define FFI_TYPE_COMPLEX_SMALL2 111
117
+ #define FFI_TYPE_COMPLEX_FF 47
118
+ #define FFI_TYPE_COMPLEX_DD 63
119
+ #define FFI_TYPE_COMPLEX_LDLD 79
120
+
114
121
  /* and for n32 soft float, add 16 * 2^4 */
115
122
  #define FFI_TYPE_STRUCT_D_SOFT 317
116
123
  #define FFI_TYPE_STRUCT_F_SOFT 301