ffi 1.15.5 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +54 -0
  4. data/Gemfile +1 -1
  5. data/README.md +3 -2
  6. data/Rakefile +10 -7
  7. data/ext/ffi_c/AbstractMemory.c +56 -34
  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 +13 -5
  13. data/ext/ffi_c/DynamicLibrary.c +89 -26
  14. data/ext/ffi_c/Function.c +238 -98
  15. data/ext/ffi_c/Function.h +1 -0
  16. data/ext/ffi_c/FunctionInfo.c +78 -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 +151 -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/config.guess +623 -556
  54. data/ext/ffi_c/libffi/config.sub +75 -34
  55. data/ext/ffi_c/libffi/configure +4571 -3830
  56. data/ext/ffi_c/libffi/configure.ac +64 -28
  57. data/ext/ffi_c/libffi/configure.host +25 -6
  58. data/ext/ffi_c/libffi/doc/Makefile.in +9 -6
  59. data/ext/ffi_c/libffi/doc/libffi.texi +82 -33
  60. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  61. data/ext/ffi_c/libffi/fficonfig.h.in +12 -47
  62. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +163 -52
  63. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  64. data/ext/ffi_c/libffi/include/Makefile.in +10 -9
  65. data/ext/ffi_c/libffi/include/ffi.h.in +54 -50
  66. data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
  67. data/ext/ffi_c/libffi/include/ffi_common.h +29 -0
  68. data/ext/ffi_c/libffi/include/tramp.h +45 -0
  69. data/ext/ffi_c/libffi/install-sh +92 -69
  70. data/ext/ffi_c/libffi/libtool-version +2 -2
  71. data/ext/ffi_c/libffi/ltmain.sh +512 -315
  72. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +18 -14
  73. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
  74. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -45
  75. data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
  76. data/ext/ffi_c/libffi/man/Makefile.in +9 -6
  77. data/ext/ffi_c/libffi/missing +1 -1
  78. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +1 -1
  79. data/ext/ffi_c/libffi/msvcc.sh +1 -1
  80. data/ext/ffi_c/libffi/src/aarch64/ffi.c +146 -42
  81. data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
  82. data/ext/ffi_c/libffi/src/aarch64/sysv.S +134 -42
  83. data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
  84. data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
  85. data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
  86. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -17
  87. data/ext/ffi_c/libffi/src/arm/ffitarget.h +3 -3
  88. data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
  89. data/ext/ffi_c/libffi/src/arm/sysv.S +113 -42
  90. data/ext/ffi_c/libffi/src/closures.c +133 -47
  91. data/ext/ffi_c/libffi/src/dlmalloc.c +5 -0
  92. data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
  93. data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
  94. data/ext/ffi_c/libffi/src/loongarch64/ffi.c +621 -0
  95. data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
  96. data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
  97. data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
  98. data/ext/ffi_c/libffi/src/mips/ffi.c +240 -65
  99. data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
  100. data/ext/ffi_c/libffi/src/mips/n32.S +137 -28
  101. data/ext/ffi_c/libffi/src/mips/o32.S +61 -4
  102. data/ext/ffi_c/libffi/src/moxie/ffi.c +47 -22
  103. data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
  104. data/ext/ffi_c/libffi/src/pa/ffi.c +32 -33
  105. data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
  106. data/ext/ffi_c/libffi/src/pa/ffitarget.h +22 -8
  107. data/ext/ffi_c/libffi/src/pa/hpux32.S +83 -36
  108. data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
  109. data/ext/ffi_c/libffi/src/pa/linux.S +82 -35
  110. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1 -1
  111. data/ext/ffi_c/libffi/src/powerpc/linux64.S +2 -0
  112. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +2 -0
  113. data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
  114. data/ext/ffi_c/libffi/src/prep_cif.c +22 -2
  115. data/ext/ffi_c/libffi/src/riscv/ffi.c +37 -4
  116. data/ext/ffi_c/libffi/src/sparc/ffi64.c +16 -0
  117. data/ext/ffi_c/libffi/src/tramp.c +716 -0
  118. data/ext/ffi_c/libffi/src/wasm32/ffi.c +934 -0
  119. data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
  120. data/ext/ffi_c/libffi/src/x86/ffi.c +99 -37
  121. data/ext/ffi_c/libffi/src/x86/ffi64.c +67 -12
  122. data/ext/ffi_c/libffi/src/x86/ffitarget.h +9 -5
  123. data/ext/ffi_c/libffi/src/x86/ffiw64.c +43 -0
  124. data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
  125. data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
  126. data/ext/ffi_c/libffi/src/x86/sysv.S +172 -38
  127. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +91 -88
  128. data/ext/ffi_c/libffi/src/x86/unix64.S +96 -6
  129. data/ext/ffi_c/libffi/src/x86/win64.S +20 -7
  130. data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
  131. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
  132. data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
  133. data/ext/ffi_c/libffi/testsuite/Makefile.am +127 -114
  134. data/ext/ffi_c/libffi/testsuite/Makefile.in +137 -121
  135. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
  136. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
  137. data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +80 -0
  138. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
  139. data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
  140. data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
  141. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +43 -21
  142. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
  143. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -0
  144. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
  145. data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
  154. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
  155. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
  156. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
  172. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn0.c +3 -2
  173. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +2 -0
  174. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +2 -0
  175. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +21 -1
  176. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +2 -0
  177. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +2 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +2 -0
  179. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +7 -6
  180. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +6 -0
  181. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +18 -0
  182. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +22 -0
  183. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +24 -0
  184. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +29 -0
  185. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +4 -0
  186. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +19 -1
  187. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +21 -1
  188. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +35 -3
  189. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +13 -0
  190. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +19 -0
  191. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +13 -0
  192. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +13 -0
  193. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +18 -0
  194. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +22 -0
  195. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +13 -0
  196. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +29 -1
  197. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +19 -1
  198. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +24 -0
  199. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +28 -1
  200. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +24 -2
  201. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +39 -1
  202. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +25 -1
  203. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +14 -0
  204. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +14 -1
  205. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +14 -2
  206. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +19 -1
  207. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +19 -1
  208. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +20 -1
  209. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +40 -25
  210. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +40 -3
  211. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +19 -1
  212. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +18 -1
  213. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +18 -3
  214. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +18 -1
  215. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +18 -1
  216. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +19 -1
  217. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +19 -1
  218. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +3 -1
  219. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +9 -1
  220. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +4 -0
  221. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +11 -1
  222. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +22 -3
  223. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +5 -1
  224. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +6 -1
  225. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +9 -1
  226. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +9 -1
  227. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +6 -2
  228. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +9 -1
  229. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +5 -0
  230. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +10 -0
  231. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +3 -0
  232. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +2 -0
  233. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +3 -0
  234. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +11 -0
  235. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +3 -0
  236. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +4 -0
  237. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +4 -0
  238. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +4 -0
  239. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +2 -0
  240. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +3 -0
  241. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -138
  242. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +21 -21
  243. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +32 -9
  244. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +1 -1
  245. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +12 -0
  246. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +21 -5
  247. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
  248. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
  249. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct2.c +10 -1
  250. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +10 -1
  251. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +9 -0
  252. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +9 -0
  253. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +11 -0
  254. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +9 -0
  255. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +11 -0
  256. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct9.c +11 -0
  257. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
  258. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
  259. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
  260. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium.c +1 -1
  261. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +1 -1
  262. data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +6 -1
  263. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -1
  264. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +1 -0
  265. data/ext/ffi_c/libffi.bsd.mk +2 -2
  266. data/ext/ffi_c/libffi.gnu.mk +2 -2
  267. data/ext/ffi_c/rbffi.h +1 -1
  268. data/ffi.gemspec +2 -2
  269. data/lib/ffi/autopointer.rb +7 -22
  270. data/lib/ffi/compat.rb +43 -0
  271. data/lib/ffi/data_converter.rb +2 -2
  272. data/lib/ffi/dynamic_library.rb +89 -0
  273. data/lib/ffi/enum.rb +18 -11
  274. data/lib/ffi/ffi.rb +3 -0
  275. data/lib/ffi/function.rb +71 -0
  276. data/lib/ffi/library.rb +55 -71
  277. data/lib/ffi/library_path.rb +109 -0
  278. data/lib/ffi/managedstruct.rb +1 -1
  279. data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
  280. data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
  281. data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
  282. data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
  283. data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
  284. data/lib/ffi/platform.rb +15 -13
  285. data/lib/ffi/struct.rb +2 -1
  286. data/lib/ffi/struct_layout.rb +1 -1
  287. data/lib/ffi/struct_layout_builder.rb +1 -1
  288. data/lib/ffi/types.rb +30 -5
  289. data/lib/ffi/variadic.rb +19 -8
  290. data/lib/ffi/version.rb +1 -1
  291. data.tar.gz.sig +0 -0
  292. metadata +97 -25
  293. metadata.gz.sig +1 -0
  294. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
  295. data/ext/ffi_c/libffi/.travis/build.sh +0 -142
  296. data/ext/ffi_c/libffi/.travis.yml +0 -83
  297. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
  298. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
  299. /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
  300. /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
  301. /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
  302. /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
  303. /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
  304. /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
  305. /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
  306. /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
  307. /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  308. /data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +0 -0
@@ -34,9 +34,10 @@
34
34
  #include <ffi_common.h>
35
35
  #include <stdint.h>
36
36
  #include <stdlib.h>
37
+ #include <tramp.h>
37
38
  #include "internal.h"
38
39
 
39
- #if defined(_MSC_VER) && defined(_M_ARM)
40
+ #if defined(_WIN32)
40
41
  #define WIN32_LEAN_AND_MEAN
41
42
  #include <windows.h>
42
43
  #endif
@@ -48,10 +49,13 @@
48
49
  #endif
49
50
 
50
51
  #else
51
- #ifndef _M_ARM
52
+ #ifndef _WIN32
52
53
  extern unsigned int ffi_arm_trampoline[2] FFI_HIDDEN;
53
54
  #else
54
- extern unsigned int ffi_arm_trampoline[3] FFI_HIDDEN;
55
+ // Declare this as an array of char, instead of array of int,
56
+ // otherwise Clang optimizes out the "& 0xFFFFFFFE" for clearing
57
+ // the thumb bit.
58
+ extern unsigned char ffi_arm_trampoline[12] FFI_HIDDEN;
55
59
  #endif
56
60
  #endif
57
61
 
@@ -60,6 +64,10 @@ extern unsigned int ffi_arm_trampoline[3] FFI_HIDDEN;
60
64
  #include <machine/sysarch.h>
61
65
  #endif
62
66
 
67
+ #if defined(__QNX__)
68
+ #include <sys/mman.h>
69
+ #endif
70
+
63
71
  /* Forward declares. */
64
72
  static int vfp_type_p (const ffi_type *);
65
73
  static void layout_vfp_args (ffi_cif *);
@@ -103,13 +111,13 @@ ffi_put_arg (ffi_type *ty, void *src, void *dst)
103
111
  case FFI_TYPE_SINT32:
104
112
  case FFI_TYPE_UINT32:
105
113
  case FFI_TYPE_POINTER:
106
- #ifndef _MSC_VER
114
+ #ifndef _WIN32
107
115
  case FFI_TYPE_FLOAT:
108
116
  #endif
109
117
  *(UINT32 *)dst = *(UINT32 *)src;
110
118
  break;
111
119
 
112
- #ifdef _MSC_VER
120
+ #ifdef _WIN32
113
121
  // casting a float* to a UINT32* doesn't work on Windows
114
122
  case FFI_TYPE_FLOAT:
115
123
  *(uintptr_t *)dst = 0;
@@ -536,6 +544,8 @@ ffi_prep_incoming_args_VFP (ffi_cif *cif, void *rvalue, char *stack,
536
544
  return rvalue;
537
545
  }
538
546
 
547
+ #if FFI_CLOSURES
548
+
539
549
  struct closure_frame
540
550
  {
541
551
  char vfp_space[8*8] __attribute__((aligned(8)));
@@ -571,6 +581,10 @@ ffi_closure_inner_VFP (ffi_cif *cif,
571
581
 
572
582
  void ffi_closure_SYSV (void) FFI_HIDDEN;
573
583
  void ffi_closure_VFP (void) FFI_HIDDEN;
584
+ #if defined(FFI_EXEC_STATIC_TRAMP)
585
+ void ffi_closure_SYSV_alt (void) FFI_HIDDEN;
586
+ void ffi_closure_VFP_alt (void) FFI_HIDDEN;
587
+ #endif
574
588
 
575
589
  #ifdef FFI_GO_CLOSURES
576
590
  void ffi_go_closure_SYSV (void) FFI_HIDDEN;
@@ -612,27 +626,44 @@ ffi_prep_closure_loc (ffi_closure * closure,
612
626
  config[1] = closure_func;
613
627
  #else
614
628
 
615
- #ifndef _M_ARM
629
+ # if defined(FFI_EXEC_STATIC_TRAMP)
630
+ if (ffi_tramp_is_present(closure))
631
+ {
632
+ /* Initialize the static trampoline's parameters. */
633
+ if (closure_func == ffi_closure_SYSV)
634
+ closure_func = ffi_closure_SYSV_alt;
635
+ else
636
+ closure_func = ffi_closure_VFP_alt;
637
+ ffi_tramp_set_parms (closure->ftramp, closure_func, closure);
638
+ goto out;
639
+ }
640
+ # endif
641
+
642
+ /* Initialize the dynamic trampoline. */
643
+ # ifndef _WIN32
616
644
  memcpy(closure->tramp, ffi_arm_trampoline, 8);
617
- #else
645
+ # else
618
646
  // cast away function type so MSVC doesn't set the lower bit of the function pointer
619
647
  memcpy(closure->tramp, (void*)((uintptr_t)ffi_arm_trampoline & 0xFFFFFFFE), FFI_TRAMPOLINE_CLOSURE_OFFSET);
620
- #endif
648
+ # endif
621
649
 
622
- #if defined (__QNX__)
623
- msync(closure->tramp, 8, 0x1000000); /* clear data map */
624
- msync(codeloc, 8, 0x1000000); /* clear insn map */
625
- #elif defined(_MSC_VER)
650
+ # if defined(__QNX__)
651
+ msync (closure->tramp, 8, MS_INVALIDATE_ICACHE); /* clear data map */
652
+ msync (codeloc, 8, MS_INVALIDATE_ICACHE); /* clear insn map */
653
+ # elif defined(_WIN32)
626
654
  FlushInstructionCache(GetCurrentProcess(), closure->tramp, FFI_TRAMPOLINE_SIZE);
627
- #else
655
+ # else
628
656
  __clear_cache(closure->tramp, closure->tramp + 8); /* clear data map */
629
657
  __clear_cache(codeloc, codeloc + 8); /* clear insn map */
630
- #endif
631
- #ifdef _M_ARM
658
+ # endif
659
+ # ifdef _WIN32
632
660
  *(void(**)(void))(closure->tramp + FFI_TRAMPOLINE_CLOSURE_FUNCTION) = closure_func;
633
- #else
661
+ # else
634
662
  *(void (**)(void))(closure->tramp + 8) = closure_func;
635
- #endif
663
+ # endif
664
+ # if defined(FFI_EXEC_STATIC_TRAMP)
665
+ out:
666
+ # endif
636
667
  #endif
637
668
 
638
669
  closure->cif = cif;
@@ -666,6 +697,8 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif,
666
697
  }
667
698
  #endif
668
699
 
700
+ #endif /* FFI_CLOSURES */
701
+
669
702
  /* Below are routines for VFP hard-float support. */
670
703
 
671
704
  /* A subroutine of vfp_type_p. Given a structure type, return the type code
@@ -873,4 +906,16 @@ layout_vfp_args (ffi_cif * cif)
873
906
  }
874
907
  }
875
908
 
909
+ #if defined(FFI_EXEC_STATIC_TRAMP)
910
+ void *
911
+ ffi_tramp_arch (size_t *tramp_size, size_t *map_size)
912
+ {
913
+ extern void *trampoline_code_table;
914
+
915
+ *tramp_size = ARM_TRAMP_SIZE;
916
+ *map_size = ARM_TRAMP_MAP_SIZE;
917
+ return &trampoline_code_table;
918
+ }
919
+ #endif
920
+
876
921
  #endif /* __arm__ or _M_ARM */
@@ -43,7 +43,7 @@ typedef enum ffi_abi {
43
43
  FFI_SYSV,
44
44
  FFI_VFP,
45
45
  FFI_LAST_ABI,
46
- #if defined(__ARM_PCS_VFP) || defined(_M_ARM)
46
+ #if defined(__ARM_PCS_VFP) || defined(_WIN32)
47
47
  FFI_DEFAULT_ABI = FFI_VFP,
48
48
  #else
49
49
  FFI_DEFAULT_ABI = FFI_SYSV,
@@ -57,7 +57,7 @@ typedef enum ffi_abi {
57
57
  signed char vfp_args[16] \
58
58
 
59
59
  #define FFI_TARGET_SPECIFIC_VARIADIC
60
- #ifndef _M_ARM
60
+ #ifndef _WIN32
61
61
  #define FFI_TARGET_HAS_COMPLEX_TYPE
62
62
  #endif
63
63
 
@@ -77,7 +77,7 @@ typedef enum ffi_abi {
77
77
  #endif
78
78
 
79
79
  #else
80
- #ifdef _MSC_VER
80
+ #ifdef _WIN32
81
81
  #define FFI_TRAMPOLINE_SIZE 16
82
82
  #define FFI_TRAMPOLINE_CLOSURE_FUNCTION 12
83
83
  #else
@@ -5,3 +5,13 @@
5
5
  #define ARM_TYPE_INT 4
6
6
  #define ARM_TYPE_VOID 5
7
7
  #define ARM_TYPE_STRUCT 6
8
+
9
+ #if defined(FFI_EXEC_STATIC_TRAMP)
10
+ /*
11
+ * For the trampoline table mapping, a mapping size of 4K (base page size)
12
+ * is chosen.
13
+ */
14
+ #define ARM_TRAMP_MAP_SHIFT 12
15
+ #define ARM_TRAMP_MAP_SIZE (1 << ARM_TRAMP_MAP_SHIFT)
16
+ #define ARM_TRAMP_SIZE 20
17
+ #endif
@@ -92,9 +92,25 @@
92
92
  #define ARM_FUNC_END(name) \
93
93
  SIZE(name)
94
94
 
95
+ .text
96
+ .syntax unified
97
+ #if defined(_WIN32)
98
+ /* Windows on ARM is thumb-only */
99
+ .thumb
100
+ #else
101
+ /* Keep the assembly in ARM mode in other cases, for simplicity
102
+ * (to avoid interworking issues). */
103
+ #undef __thumb__
104
+ .arm
105
+ #endif
106
+
95
107
  /* Aid in defining a jump table with 8 bytes between entries. */
108
+ #ifdef __thumb__
109
+ /* In thumb mode, instructions can be shorter than expected in arm mode, so
110
+ * we need to align the start of each case. */
111
+ # define E(index) .align 3
112
+ #elif defined(__clang__)
96
113
  /* ??? The clang assembler doesn't handle .if with symbolic expressions. */
97
- #ifdef __clang__
98
114
  # define E(index)
99
115
  #else
100
116
  # define E(index) \
@@ -103,9 +119,6 @@
103
119
  .endif
104
120
  #endif
105
121
 
106
- .text
107
- .syntax unified
108
- .arm
109
122
 
110
123
  #ifndef __clang__
111
124
  /* We require interworking on LDM, which implies ARMv5T,
@@ -128,13 +141,9 @@ ARM_FUNC_START(ffi_call_VFP)
128
141
  cfi_startproc
129
142
 
130
143
  cmp r3, #3 @ load only d0 if possible
131
- #ifdef __clang__
132
- vldrle d0, [r0]
133
- vldmgt r0, {d0-d7}
134
- #else
144
+ ite le
135
145
  ldcle p11, cr0, [r0] @ vldrle d0, [r0]
136
146
  ldcgt p11, cr0, [r0], {16} @ vldmgt r0, {d0-d7}
137
- #endif
138
147
  add r0, r0, #64 @ discard the vfp register args
139
148
  /* FALLTHRU */
140
149
  ARM_FUNC_END(ffi_call_VFP)
@@ -167,30 +176,25 @@ ARM_FUNC_START(ffi_call_SYSV)
167
176
  cfi_def_cfa_register(sp)
168
177
 
169
178
  @ Store values stored in registers.
179
+ #ifndef __thumb__
170
180
  .align 3
171
181
  add pc, pc, r3, lsl #3
172
182
  nop
183
+ #else
184
+ adr ip, 0f
185
+ add ip, ip, r3, lsl #3
186
+ mov pc, ip
187
+ .align 3
188
+ #endif
173
189
  0:
174
190
  E(ARM_TYPE_VFP_S)
175
- #ifdef __clang__
176
- vstr s0, [r2]
177
- #else
178
191
  stc p10, cr0, [r2] @ vstr s0, [r2]
179
- #endif
180
192
  pop {fp,pc}
181
193
  E(ARM_TYPE_VFP_D)
182
- #ifdef __clang__
183
- vstr d0, [r2]
184
- #else
185
194
  stc p11, cr0, [r2] @ vstr d0, [r2]
186
- #endif
187
195
  pop {fp,pc}
188
196
  E(ARM_TYPE_VFP_N)
189
- #ifdef __clang__
190
- vstm r2, {d0-d3}
191
- #else
192
197
  stc p11, cr0, [r2], {8} @ vstm r2, {d0-d3}
193
- #endif
194
198
  pop {fp,pc}
195
199
  E(ARM_TYPE_INT64)
196
200
  str r1, [r2, #4]
@@ -208,6 +212,7 @@ E(ARM_TYPE_STRUCT)
208
212
  UNWIND(.fnend)
209
213
  ARM_FUNC_END(ffi_call_SYSV)
210
214
 
215
+ #if FFI_CLOSURES
211
216
 
212
217
  /*
213
218
  int ffi_closure_inner_* (cif, fun, user_data, frame)
@@ -227,6 +232,9 @@ ARM_FUNC_END(ffi_go_closure_SYSV)
227
232
  ARM_FUNC_START(ffi_closure_SYSV)
228
233
  UNWIND(.fnstart)
229
234
  cfi_startproc
235
+ #ifdef _WIN32
236
+ ldmfd sp!, {r0, ip} @ restore fp (r0 is used for stack alignment)
237
+ #endif
230
238
  stmdb sp!, {r0-r3} @ save argument regs
231
239
  cfi_adjust_cfa_offset(16)
232
240
 
@@ -255,7 +263,12 @@ ARM_FUNC_START(ffi_closure_SYSV)
255
263
  @ Load values returned in registers.
256
264
  add r2, sp, #8+64 @ load result
257
265
  adr r3, CNAME(ffi_closure_ret)
266
+ #ifndef __thumb__
258
267
  add pc, r3, r0, lsl #3
268
+ #else
269
+ add r3, r3, r0, lsl #3
270
+ mov pc, r3
271
+ #endif
259
272
  cfi_endproc
260
273
  UNWIND(.fnend)
261
274
  ARM_FUNC_END(ffi_closure_SYSV)
@@ -274,6 +287,9 @@ ARM_FUNC_END(ffi_go_closure_VFP)
274
287
  ARM_FUNC_START(ffi_closure_VFP)
275
288
  UNWIND(.fnstart)
276
289
  cfi_startproc
290
+ #ifdef _WIN32
291
+ ldmfd sp!, {r0, ip} @ restore fp (r0 is used for stack alignment)
292
+ #endif
277
293
  stmdb sp!, {r0-r3} @ save argument regs
278
294
  cfi_adjust_cfa_offset(16)
279
295
 
@@ -287,11 +303,7 @@ ARM_FUNC_START(ffi_closure_VFP)
287
303
  add ip, sp, #16
288
304
  sub sp, sp, #64+32 @ allocate frame
289
305
  cfi_adjust_cfa_offset(64+32)
290
- #ifdef __clang__
291
- vstm sp, {d0-d7}
292
- #else
293
306
  stc p11, cr0, [sp], {16} @ vstm sp, {d0-d7}
294
- #endif
295
307
  stmdb sp!, {ip,lr}
296
308
 
297
309
  /* See above. */
@@ -305,7 +317,12 @@ ARM_FUNC_START(ffi_closure_VFP)
305
317
  @ Load values returned in registers.
306
318
  add r2, sp, #8+64 @ load result
307
319
  adr r3, CNAME(ffi_closure_ret)
320
+ #ifndef __thumb__
308
321
  add pc, r3, r0, lsl #3
322
+ #else
323
+ add r3, r3, r0, lsl #3
324
+ mov pc, r3
325
+ #endif
309
326
  cfi_endproc
310
327
  UNWIND(.fnend)
311
328
  ARM_FUNC_END(ffi_closure_VFP)
@@ -320,40 +337,85 @@ ARM_FUNC_START_LOCAL(ffi_closure_ret)
320
337
  cfi_rel_offset(lr, 4)
321
338
  0:
322
339
  E(ARM_TYPE_VFP_S)
323
- #ifdef __clang__
324
- vldr s0, [r2]
325
- #else
326
340
  ldc p10, cr0, [r2] @ vldr s0, [r2]
327
- #endif
328
- ldm sp, {sp,pc}
341
+ b call_epilogue
329
342
  E(ARM_TYPE_VFP_D)
330
- #ifdef __clang__
331
- vldr d0, [r2]
332
- #else
333
343
  ldc p11, cr0, [r2] @ vldr d0, [r2]
334
- #endif
335
- ldm sp, {sp,pc}
344
+ b call_epilogue
336
345
  E(ARM_TYPE_VFP_N)
337
- #ifdef __clang__
338
- vldm r2, {d0-d3}
339
- #else
340
346
  ldc p11, cr0, [r2], {8} @ vldm r2, {d0-d3}
341
- #endif
342
- ldm sp, {sp,pc}
347
+ b call_epilogue
343
348
  E(ARM_TYPE_INT64)
344
349
  ldr r1, [r2, #4]
345
350
  nop
346
351
  E(ARM_TYPE_INT)
347
352
  ldr r0, [r2]
348
- ldm sp, {sp,pc}
353
+ b call_epilogue
349
354
  E(ARM_TYPE_VOID)
350
- ldm sp, {sp,pc}
355
+ b call_epilogue
351
356
  nop
352
357
  E(ARM_TYPE_STRUCT)
358
+ b call_epilogue
359
+ call_epilogue:
360
+ #ifndef __thumb__
353
361
  ldm sp, {sp,pc}
362
+ #else
363
+ ldm sp, {ip,lr}
364
+ mov sp, ip
365
+ bx lr
366
+ #endif
354
367
  cfi_endproc
355
368
  ARM_FUNC_END(ffi_closure_ret)
356
369
 
370
+ #if defined(FFI_EXEC_STATIC_TRAMP)
371
+ ARM_FUNC_START(ffi_closure_SYSV_alt)
372
+ /* See the comments above trampoline_code_table. */
373
+ ldr ip, [sp, #4] /* Load closure in ip */
374
+ add sp, sp, 8 /* Restore the stack */
375
+ b CNAME(ffi_closure_SYSV)
376
+ ARM_FUNC_END(ffi_closure_SYSV_alt)
377
+
378
+ ARM_FUNC_START(ffi_closure_VFP_alt)
379
+ /* See the comments above trampoline_code_table. */
380
+ ldr ip, [sp, #4] /* Load closure in ip */
381
+ add sp, sp, 8 /* Restore the stack */
382
+ b CNAME(ffi_closure_VFP)
383
+ ARM_FUNC_END(ffi_closure_VFP_alt)
384
+
385
+ /*
386
+ * Below is the definition of the trampoline code table. Each element in
387
+ * the code table is a trampoline.
388
+ */
389
+ /*
390
+ * The trampoline uses register ip (r12). It saves the original value of ip
391
+ * on the stack.
392
+ *
393
+ * The trampoline has two parameters - target code to jump to and data for
394
+ * the target code. The trampoline extracts the parameters from its parameter
395
+ * block (see tramp_table_map()). The trampoline saves the data address on
396
+ * the stack. Finally, it jumps to the target code.
397
+ *
398
+ * The target code can choose to:
399
+ *
400
+ * - restore the value of ip
401
+ * - load the data address in a register
402
+ * - restore the stack pointer to what it was when the trampoline was invoked.
403
+ */
404
+ .align ARM_TRAMP_MAP_SHIFT
405
+ ARM_FUNC_START(trampoline_code_table)
406
+ .rept ARM_TRAMP_MAP_SIZE / ARM_TRAMP_SIZE
407
+ sub sp, sp, #8 /* Make space on the stack */
408
+ str ip, [sp] /* Save ip on stack */
409
+ ldr ip, [pc, #4080] /* Copy data into ip */
410
+ str ip, [sp, #4] /* Save data on stack */
411
+ ldr pc, [pc, #4076] /* Copy code into PC */
412
+ .endr
413
+ ARM_FUNC_END(trampoline_code_table)
414
+ .align ARM_TRAMP_MAP_SHIFT
415
+ #endif /* FFI_EXEC_STATIC_TRAMP */
416
+
417
+ #endif /* FFI_CLOSURES */
418
+
357
419
  #if FFI_EXEC_TRAMPOLINE_TABLE
358
420
 
359
421
  #ifdef __MACH__
@@ -369,6 +431,15 @@ ARM_FUNC_START(ffi_closure_trampoline_table_page)
369
431
  ARM_FUNC_END(ffi_closure_trampoline_table_page)
370
432
  #endif
371
433
 
434
+ #elif defined(_WIN32)
435
+
436
+ ARM_FUNC_START(ffi_arm_trampoline)
437
+ 0: adr ip, 0b
438
+ stmdb sp!, {r0, ip}
439
+ ldr pc, 1f
440
+ 1: .long 0
441
+ ARM_FUNC_END(ffi_arm_trampoline)
442
+
372
443
  #else
373
444
 
374
445
  ARM_FUNC_START(ffi_arm_trampoline)