ffi 1.15.5 → 1.16.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +76 -0
  4. data/Gemfile +1 -1
  5. data/README.md +3 -2
  6. data/Rakefile +10 -7
  7. data/ext/ffi_c/AbstractMemory.c +60 -36
  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 +86 -29
  12. data/ext/ffi_c/Call.c +17 -6
  13. data/ext/ffi_c/DynamicLibrary.c +89 -26
  14. data/ext/ffi_c/Function.c +244 -98
  15. data/ext/ffi_c/Function.h +1 -0
  16. data/ext/ffi_c/FunctionInfo.c +80 -24
  17. data/ext/ffi_c/LastError.c +25 -7
  18. data/ext/ffi_c/MappedType.c +66 -23
  19. data/ext/ffi_c/MappedType.h +0 -2
  20. data/ext/ffi_c/MemoryPointer.c +34 -7
  21. data/ext/ffi_c/MethodHandle.c +3 -1
  22. data/ext/ffi_c/Pointer.c +68 -29
  23. data/ext/ffi_c/Pointer.h +1 -0
  24. data/ext/ffi_c/Struct.c +155 -80
  25. data/ext/ffi_c/Struct.h +7 -4
  26. data/ext/ffi_c/StructByValue.c +48 -16
  27. data/ext/ffi_c/StructLayout.c +117 -48
  28. data/ext/ffi_c/Type.c +104 -36
  29. data/ext/ffi_c/Type.h +3 -1
  30. data/ext/ffi_c/Types.c +1 -1
  31. data/ext/ffi_c/Variadic.c +65 -23
  32. data/ext/ffi_c/compat.h +22 -22
  33. data/ext/ffi_c/extconf.rb +19 -2
  34. data/ext/ffi_c/ffi.c +4 -0
  35. data/ext/ffi_c/libffi/.appveyor/site.exp +16 -0
  36. data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +7 -0
  37. data/ext/ffi_c/libffi/.appveyor.yml +27 -9
  38. data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
  39. data/ext/ffi_c/libffi/{.travis → .ci}/build-in-container.sh +4 -6
  40. data/ext/ffi_c/libffi/.ci/build.sh +124 -0
  41. data/ext/ffi_c/libffi/{.travis → .ci}/install.sh +14 -7
  42. data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
  43. data/ext/ffi_c/libffi/{.travis → .ci}/site.exp +5 -3
  44. data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
  45. data/ext/ffi_c/libffi/.github/workflows/build.yml +460 -0
  46. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +171 -0
  47. data/ext/ffi_c/libffi/.gitignore +10 -2
  48. data/ext/ffi_c/libffi/LICENSE +1 -1
  49. data/ext/ffi_c/libffi/Makefile.am +12 -5
  50. data/ext/ffi_c/libffi/Makefile.in +118 -51
  51. data/ext/ffi_c/libffi/README.md +144 -104
  52. data/ext/ffi_c/libffi/acinclude.m4 +10 -112
  53. data/ext/ffi_c/libffi/compile +348 -0
  54. data/ext/ffi_c/libffi/config.guess +623 -556
  55. data/ext/ffi_c/libffi/config.sub +75 -34
  56. data/ext/ffi_c/libffi/configure +4571 -3830
  57. data/ext/ffi_c/libffi/configure.ac +64 -28
  58. data/ext/ffi_c/libffi/configure.host +25 -6
  59. data/ext/ffi_c/libffi/doc/Makefile.in +9 -6
  60. data/ext/ffi_c/libffi/doc/libffi.texi +82 -33
  61. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  62. data/ext/ffi_c/libffi/fficonfig.h.in +12 -47
  63. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +163 -52
  64. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  65. data/ext/ffi_c/libffi/include/Makefile.in +10 -9
  66. data/ext/ffi_c/libffi/include/ffi.h.in +54 -50
  67. data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
  68. data/ext/ffi_c/libffi/include/ffi_common.h +29 -0
  69. data/ext/ffi_c/libffi/include/tramp.h +45 -0
  70. data/ext/ffi_c/libffi/install-sh +92 -69
  71. data/ext/ffi_c/libffi/libtool-version +2 -2
  72. data/ext/ffi_c/libffi/ltmain.sh +512 -315
  73. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +18 -14
  74. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
  75. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -45
  76. data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
  77. data/ext/ffi_c/libffi/man/Makefile.in +9 -6
  78. data/ext/ffi_c/libffi/missing +1 -1
  79. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +1 -1
  80. data/ext/ffi_c/libffi/msvcc.sh +1 -1
  81. data/ext/ffi_c/libffi/src/aarch64/ffi.c +146 -42
  82. data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
  83. data/ext/ffi_c/libffi/src/aarch64/sysv.S +134 -42
  84. data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
  85. data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
  86. data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
  87. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -17
  88. data/ext/ffi_c/libffi/src/arm/ffitarget.h +3 -3
  89. data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
  90. data/ext/ffi_c/libffi/src/arm/sysv.S +113 -42
  91. data/ext/ffi_c/libffi/src/closures.c +133 -47
  92. data/ext/ffi_c/libffi/src/dlmalloc.c +5 -0
  93. data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
  94. data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
  95. data/ext/ffi_c/libffi/src/loongarch64/ffi.c +621 -0
  96. data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
  97. data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
  98. data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
  99. data/ext/ffi_c/libffi/src/mips/ffi.c +240 -65
  100. data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
  101. data/ext/ffi_c/libffi/src/mips/n32.S +137 -28
  102. data/ext/ffi_c/libffi/src/mips/o32.S +61 -4
  103. data/ext/ffi_c/libffi/src/moxie/ffi.c +47 -22
  104. data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
  105. data/ext/ffi_c/libffi/src/pa/ffi.c +32 -33
  106. data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
  107. data/ext/ffi_c/libffi/src/pa/ffitarget.h +22 -8
  108. data/ext/ffi_c/libffi/src/pa/hpux32.S +83 -36
  109. data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
  110. data/ext/ffi_c/libffi/src/pa/linux.S +82 -35
  111. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1 -1
  112. data/ext/ffi_c/libffi/src/powerpc/linux64.S +2 -0
  113. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +2 -0
  114. data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
  115. data/ext/ffi_c/libffi/src/prep_cif.c +22 -2
  116. data/ext/ffi_c/libffi/src/riscv/ffi.c +37 -4
  117. data/ext/ffi_c/libffi/src/sparc/ffi64.c +16 -0
  118. data/ext/ffi_c/libffi/src/tramp.c +716 -0
  119. data/ext/ffi_c/libffi/src/wasm32/ffi.c +934 -0
  120. data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
  121. data/ext/ffi_c/libffi/src/x86/ffi.c +99 -37
  122. data/ext/ffi_c/libffi/src/x86/ffi64.c +67 -12
  123. data/ext/ffi_c/libffi/src/x86/ffitarget.h +9 -5
  124. data/ext/ffi_c/libffi/src/x86/ffiw64.c +43 -0
  125. data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
  126. data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
  127. data/ext/ffi_c/libffi/src/x86/sysv.S +172 -38
  128. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +91 -88
  129. data/ext/ffi_c/libffi/src/x86/unix64.S +96 -6
  130. data/ext/ffi_c/libffi/src/x86/win64.S +20 -7
  131. data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
  132. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
  133. data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
  134. data/ext/ffi_c/libffi/testsuite/Makefile.am +127 -114
  135. data/ext/ffi_c/libffi/testsuite/Makefile.in +137 -121
  136. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
  137. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
  138. data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +80 -0
  139. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
  140. data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
  141. data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
  142. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +43 -21
  143. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
  144. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -0
  145. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
  154. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
  155. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
  156. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
  172. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
  173. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn0.c +3 -2
  174. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +2 -0
  175. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +2 -0
  176. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +21 -1
  177. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +2 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +2 -0
  179. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +2 -0
  180. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +7 -6
  181. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +6 -0
  182. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +18 -0
  183. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +22 -0
  184. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +24 -0
  185. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +29 -0
  186. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +4 -0
  187. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +19 -1
  188. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +21 -1
  189. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +35 -3
  190. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +13 -0
  191. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +19 -0
  192. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +13 -0
  193. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +13 -0
  194. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +18 -0
  195. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +22 -0
  196. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +13 -0
  197. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +29 -1
  198. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +19 -1
  199. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +24 -0
  200. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +28 -1
  201. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +24 -2
  202. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +39 -1
  203. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +25 -1
  204. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +14 -0
  205. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +14 -1
  206. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +14 -2
  207. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +19 -1
  208. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +19 -1
  209. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +20 -1
  210. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +40 -25
  211. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +40 -3
  212. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +19 -1
  213. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +18 -1
  214. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +18 -3
  215. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +18 -1
  216. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +18 -1
  217. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +19 -1
  218. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +19 -1
  219. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +3 -1
  220. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +9 -1
  221. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +4 -0
  222. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +11 -1
  223. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +22 -3
  224. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +5 -1
  225. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +6 -1
  226. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +9 -1
  227. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +9 -1
  228. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +6 -2
  229. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +9 -1
  230. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +5 -0
  231. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +10 -0
  232. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +3 -0
  233. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +2 -0
  234. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +3 -0
  235. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +11 -0
  236. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +3 -0
  237. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +4 -0
  238. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +4 -0
  239. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +4 -0
  240. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +2 -0
  241. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +3 -0
  242. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -138
  243. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +21 -21
  244. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +32 -9
  245. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +1 -1
  246. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +12 -0
  247. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +21 -5
  248. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
  249. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
  250. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct2.c +10 -1
  251. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +10 -1
  252. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +9 -0
  253. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +9 -0
  254. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +11 -0
  255. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +9 -0
  256. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +11 -0
  257. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct9.c +11 -0
  258. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
  259. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
  260. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
  261. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium.c +1 -1
  262. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +1 -1
  263. data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +6 -1
  264. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -1
  265. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +1 -0
  266. data/ext/ffi_c/libffi.bsd.mk +2 -2
  267. data/ext/ffi_c/libffi.gnu.mk +2 -2
  268. data/ext/ffi_c/rbffi.h +1 -1
  269. data/ffi.gemspec +3 -3
  270. data/lib/ffi/autopointer.rb +7 -22
  271. data/lib/ffi/compat.rb +43 -0
  272. data/lib/ffi/data_converter.rb +2 -2
  273. data/lib/ffi/dynamic_library.rb +89 -0
  274. data/lib/ffi/enum.rb +18 -11
  275. data/lib/ffi/ffi.rb +3 -0
  276. data/lib/ffi/function.rb +71 -0
  277. data/lib/ffi/library.rb +55 -71
  278. data/lib/ffi/library_path.rb +109 -0
  279. data/lib/ffi/managedstruct.rb +1 -1
  280. data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
  281. data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
  282. data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
  283. data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
  284. data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
  285. data/lib/ffi/platform.rb +15 -13
  286. data/lib/ffi/struct.rb +2 -1
  287. data/lib/ffi/struct_layout.rb +1 -1
  288. data/lib/ffi/struct_layout_builder.rb +1 -1
  289. data/lib/ffi/types.rb +32 -6
  290. data/lib/ffi/variadic.rb +19 -8
  291. data/lib/ffi/version.rb +1 -1
  292. data/samples/hello_ractor.rb +11 -0
  293. data/samples/qsort_ractor.rb +28 -0
  294. data.tar.gz.sig +0 -0
  295. metadata +100 -25
  296. metadata.gz.sig +0 -0
  297. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
  298. data/ext/ffi_c/libffi/.travis/build.sh +0 -142
  299. data/ext/ffi_c/libffi/.travis.yml +0 -83
  300. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
  301. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
  302. /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
  303. /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
  304. /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
  305. /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
  306. /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
  307. /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
  308. /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
  309. /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
  310. /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  311. /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;
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
+ }
321
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:
@@ -539,7 +647,7 @@ static ffi_status ffi_prep_cif_machdep_int(ffi_cif *cif, unsigned nfixedargs)
539
647
 
540
648
  case FFI_TYPE_POINTER:
541
649
  if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32)
542
- cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
650
+ cif->flags += FFI_TYPE_UINT32 << (FFI_FLAG_BITS * 8);
543
651
  else
544
652
  cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
545
653
  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,44 @@ 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
+ }
577
718
  default:
578
719
  cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
579
720
  break;
580
721
  }
581
722
  }
582
723
  #endif
583
-
584
724
  return FFI_OK;
585
725
  }
586
726
 
@@ -618,7 +758,7 @@ void ffi_call_int(ffi_cif *cif, void (*fn)(void), void *rvalue,
618
758
  /* value address then we need to make one */
619
759
 
620
760
  if ((rvalue == NULL) &&
621
- (cif->rtype->type == FFI_TYPE_STRUCT))
761
+ (cif->rtype->type == FFI_TYPE_STRUCT || cif->rtype->type == FFI_TYPE_COMPLEX))
622
762
  ecif.rvalue = alloca(cif->rtype->size);
623
763
  else
624
764
  ecif.rvalue = rvalue;
@@ -830,6 +970,11 @@ ffi_closure_mips_inner_O32 (ffi_cif *cif,
830
970
  argn = 1;
831
971
  seen_int = 1;
832
972
  }
973
+ if ((cif->flags >> (FFI_FLAG_BITS * 2)) == FFI_TYPE_COMPLEX)
974
+ {
975
+ rvalue = fpr;
976
+ argn = 1;
977
+ }
833
978
 
834
979
  i = 0;
835
980
  avn = cif->nargs;
@@ -902,6 +1047,9 @@ ffi_closure_mips_inner_O32 (ffi_cif *cif,
902
1047
  }
903
1048
  else
904
1049
  {
1050
+ if (cif->rtype->type == FFI_TYPE_COMPLEX) {
1051
+ __asm__ volatile ("move $v1, %0" : : "r"(cif->rtype->size));
1052
+ }
905
1053
  return cif->rtype->type;
906
1054
  }
907
1055
  }
@@ -991,6 +1139,8 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
991
1139
  #endif
992
1140
  argn = 1;
993
1141
  }
1142
+ if (cif->rtype->type == FFI_TYPE_COMPLEX && cif->rtype->elements[0]->type == FFI_TYPE_LONGDOUBLE)
1143
+ argn = 2;
994
1144
 
995
1145
  i = 0;
996
1146
  avn = cif->nargs;
@@ -1015,6 +1165,31 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
1015
1165
  #endif
1016
1166
  avaluep[i] = (char *) argp;
1017
1167
  }
1168
+ else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
1169
+ {
1170
+ argp = (argn >= 8 || i >= cif->mips_nfixedargs || soft_float) ? ar + argn : fpr + argn;
1171
+ avaluep[i] = (char *) argp;
1172
+ }
1173
+ else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_LONGDOUBLE)
1174
+ {
1175
+ /* align long double */
1176
+ argn += ((argn & 0x1)? 1 : 0);
1177
+ argp = (argn >= 8 || i >= cif->mips_nfixedargs || soft_float) ? ar + argn : fpr + argn;
1178
+ avaluep[i] = (char *) argp;
1179
+ }
1180
+ else if (arg_types[i]->type == FFI_TYPE_COMPLEX && arg_types[i]->elements[0]->type == FFI_TYPE_FLOAT)
1181
+ {
1182
+ if (argn >= 8 || i >= cif->mips_nfixedargs || soft_float)
1183
+ argp = ar + argn;
1184
+ else
1185
+ {
1186
+ argp = fpr + argn;
1187
+ /* the normal args for function holds 8bytes, while here we convert it to ptr */
1188
+ uint32_t *tmp = (uint32_t *)argp;
1189
+ tmp[1] = tmp[2];
1190
+ }
1191
+ avaluep[i] = (char *) argp;
1192
+ }
1018
1193
  else
1019
1194
  {
1020
1195
  unsigned type = arg_types[i]->type;
@@ -1027,10 +1202,10 @@ ffi_closure_mips_inner_N32 (ffi_cif *cif,
1027
1202
  /* The size of a pointer depends on the ABI */
1028
1203
  if (type == FFI_TYPE_POINTER)
1029
1204
  type = (cif->abi == FFI_N64 || cif->abi == FFI_N64_SOFT_FLOAT)
1030
- ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
1205
+ ? FFI_TYPE_SINT64 : FFI_TYPE_UINT32;
1031
1206
 
1032
1207
  if (soft_float && type == FFI_TYPE_FLOAT)
1033
- type = FFI_TYPE_UINT32;
1208
+ type = FFI_TYPE_SINT32;
1034
1209
 
1035
1210
  switch (type)
1036
1211
  {
@@ -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