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
@@ -7,7 +7,7 @@
7
7
  /* { dg-do run } */
8
8
  #include "ffitest.h"
9
9
 
10
- signed char test_func_fn(signed char a1, signed char a2)
10
+ static signed char test_func_fn(signed char a1, signed char a2)
11
11
  {
12
12
  signed char result;
13
13
 
@@ -26,6 +26,8 @@ static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
26
26
 
27
27
  a1 = *(signed char *)avals[0];
28
28
  a2 = *(signed char *)avals[1];
29
+ CHECK(a1 == 2);
30
+ CHECK(a2 == 125);
29
31
 
30
32
  *(ffi_arg *)rval = test_func_fn(a1, a2);
31
33
 
@@ -62,6 +64,7 @@ int main (void)
62
64
  /* { dg-output "2 125: 127" } */
63
65
  printf("res: %d\n", (signed char)res_call);
64
66
  /* { dg-output "\nres: 127" } */
67
+ CHECK((signed char)res_call == 127);
65
68
 
66
69
  CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
67
70
 
@@ -69,6 +72,7 @@ int main (void)
69
72
  /* { dg-output "\n2 125: 127" } */
70
73
  printf("res: %d\n", res_closure);
71
74
  /* { dg-output "\nres: 127" } */
75
+ CHECK(res_closure == 127);
72
76
 
73
77
  exit(0);
74
78
  }
@@ -7,13 +7,16 @@
7
7
  /* { dg-do run } */
8
8
  #include "ffitest.h"
9
9
 
10
- signed short test_func_fn(signed short a1, signed short a2)
10
+ static signed short test_func_fn(signed short a1, signed short a2)
11
11
  {
12
12
  signed short result;
13
13
 
14
14
  result = a1 + a2;
15
15
 
16
16
  printf("%d %d: %d\n", a1, a2, result);
17
+ CHECK(a1 == 2);
18
+ CHECK(a2 == 32765);
19
+ CHECK(result == 32767);
17
20
 
18
21
  return result;
19
22
 
@@ -62,6 +65,7 @@ int main (void)
62
65
  /* { dg-output "2 32765: 32767" } */
63
66
  printf("res: %d\n", (unsigned short)res_call);
64
67
  /* { dg-output "\nres: 32767" } */
68
+ CHECK((unsigned short)res_call == 32767);
65
69
 
66
70
  CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
67
71
 
@@ -69,6 +73,7 @@ int main (void)
69
73
  /* { dg-output "\n2 32765: 32767" } */
70
74
  printf("res: %d\n", res_closure);
71
75
  /* { dg-output "\nres: 32767" } */
76
+ CHECK(res_closure == 32767);
72
77
 
73
78
  exit(0);
74
79
  }
@@ -7,7 +7,7 @@
7
7
  /* { dg-do run } */
8
8
  #include "ffitest.h"
9
9
 
10
- signed short test_func_fn(signed char a1, signed short a2,
10
+ static signed short test_func_fn(signed char a1, signed short a2,
11
11
  signed char a3, signed short a4)
12
12
  {
13
13
  signed short result;
@@ -16,6 +16,12 @@ signed short test_func_fn(signed char a1, signed short a2,
16
16
 
17
17
  printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
18
18
 
19
+ CHECK(a1 == 1);
20
+ CHECK(a2 == 32765);
21
+ CHECK(a3 == 127);
22
+ CHECK(a4 == -128);
23
+ CHECK(result == 32765);
24
+
19
25
  return result;
20
26
 
21
27
  }
@@ -74,6 +80,7 @@ int main (void)
74
80
  /* { dg-output "1 32765 127 -128: 32765" } */
75
81
  printf("res: %d\n", (signed short)res_call);
76
82
  /* { dg-output "\nres: 32765" } */
83
+ CHECK(res_call == 32765);
77
84
 
78
85
  CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
79
86
 
@@ -81,6 +88,7 @@ int main (void)
81
88
  /* { dg-output "\n1 32765 127 -128: 32765" } */
82
89
  printf("res: %d\n", res_closure);
83
90
  /* { dg-output "\nres: 32765" } */
91
+ CHECK(res_closure == 32765);
84
92
 
85
93
  exit(0);
86
94
  }
@@ -7,7 +7,7 @@
7
7
  /* { dg-do run } */
8
8
  #include "ffitest.h"
9
9
 
10
- unsigned char test_func_fn(unsigned char a1, unsigned char a2,
10
+ static unsigned char test_func_fn(unsigned char a1, unsigned char a2,
11
11
  unsigned char a3, unsigned char a4)
12
12
  {
13
13
  unsigned char result;
@@ -16,6 +16,12 @@ unsigned char test_func_fn(unsigned char a1, unsigned char a2,
16
16
 
17
17
  printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
18
18
 
19
+ CHECK(a1 == 1);
20
+ CHECK(a2 == 2);
21
+ CHECK(a3 == 127);
22
+ CHECK(a4 == 125);
23
+ CHECK(result == 255);
24
+
19
25
  return result;
20
26
 
21
27
  }
@@ -79,6 +85,7 @@ int main (void)
79
85
  /* { dg-output "1 2 127 125: 255" } */
80
86
  printf("res: %d\n", (unsigned char)res_call);
81
87
  /* { dg-output "\nres: 255" } */
88
+ CHECK((unsigned char)res_call == 255);
82
89
 
83
90
  CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
84
91
 
@@ -86,6 +93,7 @@ int main (void)
86
93
  /* { dg-output "\n1 2 127 125: 255" } */
87
94
  printf("res: %d\n", res_closure);
88
95
  /* { dg-output "\nres: 255" } */
96
+ CHECK(res_closure == 255);
89
97
 
90
98
  exit(0);
91
99
  }
@@ -7,7 +7,7 @@
7
7
  /* { dg-do run } */
8
8
  #include "ffitest.h"
9
9
 
10
- unsigned short test_func_fn(unsigned short a1, unsigned short a2)
10
+ static unsigned short test_func_fn(unsigned short a1, unsigned short a2)
11
11
  {
12
12
  unsigned short result;
13
13
 
@@ -15,8 +15,11 @@ unsigned short test_func_fn(unsigned short a1, unsigned short a2)
15
15
 
16
16
  printf("%d %d: %d\n", a1, a2, result);
17
17
 
18
- return result;
18
+ CHECK(a1 == 2);
19
+ CHECK(a2 == 32765);
20
+ CHECK(result == 32767);
19
21
 
22
+ return result;
20
23
  }
21
24
 
22
25
  static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
@@ -69,6 +72,7 @@ int main (void)
69
72
  /* { dg-output "\n2 32765: 32767" } */
70
73
  printf("res: %d\n", res_closure);
71
74
  /* { dg-output "\nres: 32767" } */
75
+ CHECK(res_closure == 32767);
72
76
 
73
77
  exit(0);
74
78
  }
@@ -7,7 +7,7 @@
7
7
  /* { dg-do run } */
8
8
  #include "ffitest.h"
9
9
 
10
- unsigned short test_func_fn(unsigned char a1, unsigned short a2,
10
+ static unsigned short test_func_fn(unsigned char a1, unsigned short a2,
11
11
  unsigned char a3, unsigned short a4)
12
12
  {
13
13
  unsigned short result;
@@ -16,6 +16,12 @@ unsigned short test_func_fn(unsigned char a1, unsigned short a2,
16
16
 
17
17
  printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
18
18
 
19
+ CHECK(a1 == 1);
20
+ CHECK(a2 == 2);
21
+ CHECK(a3 == 127);
22
+ CHECK(a4 == 128);
23
+ CHECK(result == 258);
24
+
19
25
  return result;
20
26
 
21
27
  }
@@ -74,6 +80,7 @@ int main (void)
74
80
  /* { dg-output "1 2 127 128: 258" } */
75
81
  printf("res: %d\n", (unsigned short)res_call);
76
82
  /* { dg-output "\nres: 258" } */
83
+ CHECK(res_call == 258);
77
84
 
78
85
  CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
79
86
 
@@ -81,6 +88,7 @@ int main (void)
81
88
  /* { dg-output "\n1 2 127 128: 258" } */
82
89
  printf("res: %d\n", res_closure);
83
90
  /* { dg-output "\nres: 258" } */
91
+ CHECK(res_closure == 258);
84
92
 
85
93
  exit(0);
86
94
  }
@@ -16,6 +16,10 @@ void* cls_pointer_fn(void* a1, void* a2)
16
16
  (unsigned int)(uintptr_t) a2,
17
17
  (unsigned int)(uintptr_t) result);
18
18
 
19
+ CHECK((unsigned int)(uintptr_t) a1 == 0x12345678);
20
+ CHECK((unsigned int)(uintptr_t) a2 == 0x89abcdef);
21
+ CHECK((unsigned int)(uintptr_t) result == 0x9be02467);
22
+
19
23
  return result;
20
24
  }
21
25
 
@@ -69,6 +73,7 @@ int main (void)
69
73
  /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */
70
74
  printf("res: 0x%08x\n", (unsigned int) res);
71
75
  /* { dg-output "\nres: 0x9be02467" } */
76
+ CHECK(res == 0x9be02467);
72
77
 
73
78
  exit(0);
74
79
  }
@@ -40,6 +40,10 @@ void* cls_pointer_fn2(void* a1, void* a2)
40
40
  (unsigned int)(uintptr_t) a2,
41
41
  (unsigned int)(uintptr_t) result);
42
42
 
43
+ CHECK((unsigned int)(uintptr_t) a1 == 0x8acf1356);
44
+ CHECK((unsigned int)(uintptr_t) a2 == 0x01234567);
45
+ CHECK((unsigned int)(uintptr_t) result == 0x8bf258bd);
46
+
43
47
  return result;
44
48
  }
45
49
 
@@ -65,6 +69,10 @@ void* cls_pointer_fn1(void* a1, void* a2)
65
69
  (unsigned int)(intptr_t) a2,
66
70
  (unsigned int)(intptr_t) result);
67
71
 
72
+ CHECK((unsigned int)(uintptr_t) a1 == 0x01234567);
73
+ CHECK((unsigned int)(uintptr_t) a2 == 0x89abcdef);
74
+ CHECK((unsigned int)(uintptr_t) result == 0x8acf1356);
75
+
68
76
  result = cls_pointer_fn2(result, a1);
69
77
 
70
78
  return result;
@@ -128,6 +136,7 @@ int main (void)
128
136
  /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */
129
137
  /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */
130
138
  /* { dg-output "\nres: 0x8bf258bd" } */
139
+ CHECK(res == 0x8bf258bd);
131
140
 
132
141
  CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
133
142
 
@@ -137,6 +146,7 @@ int main (void)
137
146
  /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */
138
147
  /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */
139
148
  /* { dg-output "\nres: 0x8bf258bd" } */
149
+ CHECK(res == 0x8bf258bd);
140
150
 
141
151
  exit(0);
142
152
  }
@@ -15,6 +15,8 @@ static void cls_ret_schar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
15
15
  *(ffi_arg*)resp = *(signed char *)args[0];
16
16
  printf("%d: %d\n",*(signed char *)args[0],
17
17
  (int)*(ffi_arg *)(resp));
18
+ CHECK(*(signed char *)args[0] == 127);
19
+ CHECK((int)*(ffi_arg *)(resp) == 127);
18
20
  }
19
21
  typedef signed char (*cls_ret_schar)(signed char);
20
22
 
@@ -39,6 +41,7 @@ int main (void)
39
41
  /* { dg-output "127: 127" } */
40
42
  printf("res: %d\n", res);
41
43
  /* { dg-output "\nres: 127" } */
44
+ CHECK(res == 127);
42
45
 
43
46
  exit(0);
44
47
  }
@@ -13,6 +13,8 @@ static void cls_ret_sint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
13
13
  *(ffi_arg*)resp = *(signed int *)args[0];
14
14
  printf("%d: %d\n",*(signed int *)args[0],
15
15
  (int)*(ffi_arg *)(resp));
16
+ CHECK(*(signed int *)args[0] == 65534);
17
+ CHECK((int)*(ffi_arg *)(resp) == 65534);
16
18
  }
17
19
  typedef signed int (*cls_ret_sint)(signed int);
18
20
 
@@ -13,6 +13,8 @@ static void cls_ret_sshort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
13
13
  *(ffi_arg*)resp = *(signed short *)args[0];
14
14
  printf("%d: %d\n",*(signed short *)args[0],
15
15
  (int)*(ffi_arg *)(resp));
16
+ CHECK(*(signed short *)args[0] == 255);
17
+ CHECK((int)*(ffi_arg *)(resp) == 255);
16
18
  }
17
19
  typedef signed short (*cls_ret_sshort)(signed short);
18
20
 
@@ -37,6 +39,7 @@ int main (void)
37
39
  /* { dg-output "255: 255" } */
38
40
  printf("res: %d\n",res);
39
41
  /* { dg-output "\nres: 255" } */
42
+ CHECK(res == 255);
40
43
 
41
44
  exit(0);
42
45
  }
@@ -35,6 +35,16 @@ test_fn (ffi_cif* cif __UNUSED__, void* resp,
35
35
  printf ("%d %d %d %d %d %d %d %d %d %d\n", n, s1.a, s1.b,
36
36
  l1.a, l1.b, l1.c, l1.d, l1.e,
37
37
  s2.a, s2.b);
38
+ CHECK(n == 4);
39
+ CHECK(s1.a == 5);
40
+ CHECK(s1.b == 6);
41
+ CHECK(l1.a == 10);
42
+ CHECK(l1.b == 11);
43
+ CHECK(l1.c == 12);
44
+ CHECK(l1.d == 13);
45
+ CHECK(l1.e == 14);
46
+ CHECK(s2.a == 20);
47
+ CHECK(s2.b == 21);
38
48
  * (ffi_arg*) resp = 42;
39
49
  }
40
50
 
@@ -109,6 +119,7 @@ main (void)
109
119
  /* { dg-output "4 5 6 10 11 12 13 14 20 21" } */
110
120
  printf("res: %d\n", (int) res);
111
121
  /* { dg-output "\nres: 42" } */
122
+ CHECK(res == 42);
112
123
 
113
124
  exit(0);
114
125
  }
@@ -13,6 +13,8 @@ static void cls_ret_uchar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
13
13
  *(ffi_arg*)resp = *(unsigned char *)args[0];
14
14
  printf("%d: %d\n",*(unsigned char *)args[0],
15
15
  (int)*(ffi_arg *)(resp));
16
+ CHECK(*(unsigned char *)args[0] == 127);
17
+ CHECK((int)*(ffi_arg *)(resp) == 127);
16
18
  }
17
19
  typedef unsigned char (*cls_ret_uchar)(unsigned char);
18
20
 
@@ -37,6 +39,7 @@ int main (void)
37
39
  /* { dg-output "127: 127" } */
38
40
  printf("res: %d\n",res);
39
41
  /* { dg-output "\nres: 127" } */
42
+ CHECK(res == 127);
40
43
 
41
44
  exit(0);
42
45
  }
@@ -14,6 +14,9 @@ static void cls_ret_uint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
14
14
 
15
15
  printf("%d: %d\n",*(unsigned int *)args[0],
16
16
  (int)*(ffi_arg *)(resp));
17
+
18
+ CHECK(*(unsigned int *)args[0] == 2147483647);
19
+ CHECK((int)*(ffi_arg *)(resp) == 2147483647);
17
20
  }
18
21
  typedef unsigned int (*cls_ret_uint)(unsigned int);
19
22
 
@@ -38,6 +41,7 @@ int main (void)
38
41
  /* { dg-output "2147483647: 2147483647" } */
39
42
  printf("res: %d\n",res);
40
43
  /* { dg-output "\nres: 2147483647" } */
44
+ CHECK(res == 2147483647);
41
45
 
42
46
  exit(0);
43
47
  }
@@ -16,6 +16,9 @@ static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
16
16
  *(ffi_arg *)resp = *(T *)args[0];
17
17
 
18
18
  printf("%d: %d %d\n", (int)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]);
19
+ CHECK(*(T *)args[0] == 67);
20
+ CHECK(*(T *)args[1] == 4);
21
+ CHECK((int)*(ffi_arg *)resp == 67);
19
22
  }
20
23
 
21
24
  typedef T (*cls_ret_T)(T, ...);
@@ -41,5 +44,6 @@ int main (void)
41
44
  /* { dg-output "67: 67 4" } */
42
45
  printf("res: %d\n", res);
43
46
  /* { dg-output "\nres: 67" } */
47
+ CHECK(res == 67);
44
48
  exit(0);
45
49
  }
@@ -16,6 +16,9 @@ static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
16
16
  *(T *)resp = *(T *)args[0];
17
17
 
18
18
  printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]);
19
+ CHECK(*(T *)args[0] == 67);
20
+ CHECK(*(T *)args[1] == 4);
21
+ CHECK(*(T *)resp == 67);
19
22
  }
20
23
 
21
24
  typedef T (*cls_ret_T)(T, ...);
@@ -41,5 +44,6 @@ int main (void)
41
44
  /* { dg-output "67: 67 4" } */
42
45
  printf("res: %ld\n", res);
43
46
  /* { dg-output "\nres: 67" } */
47
+ CHECK(res == 67);
44
48
  exit(0);
45
49
  }
@@ -37,11 +37,13 @@ int main (void)
37
37
  /* { dg-output "214: 1152921504606846761" } */
38
38
  printf("res: %" PRIdLL "\n", res);
39
39
  /* { dg-output "\nres: 1152921504606846761" } */
40
+ CHECK(res == 1152921504606846761LL);
40
41
 
41
42
  res = (*((cls_ret_ulonglong)code))(9223372035854775808LL);
42
43
  /* { dg-output "\n9223372035854775808: 8070450533247928831" } */
43
44
  printf("res: %" PRIdLL "\n", res);
44
45
  /* { dg-output "\nres: 8070450533247928831" } */
46
+ CHECK(res == 8070450533247928831LL);
45
47
 
46
48
  exit(0);
47
49
  }
@@ -14,6 +14,8 @@ static void cls_ret_ushort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
14
14
 
15
15
  printf("%d: %d\n",*(unsigned short *)args[0],
16
16
  (int)*(ffi_arg *)(resp));
17
+ CHECK(*(unsigned short *)args[0] == 65535);
18
+ CHECK((int)*(ffi_arg *)(resp) == 65535);
17
19
  }
18
20
  typedef unsigned short (*cls_ret_ushort)(unsigned short);
19
21
 
@@ -38,6 +40,7 @@ int main (void)
38
40
  /* { dg-output "65535: 65535" } */
39
41
  printf("res: %d\n",res);
40
42
  /* { dg-output "\nres: 65535" } */
43
+ CHECK(res == 65535);
41
44
 
42
45
  exit(0);
43
46
  }
@@ -1,138 +1 @@
1
- #include <stdlib.h>
2
- #include <stdio.h>
3
- #include <string.h>
4
- #include <fcntl.h>
5
- #include <ffi.h>
6
- #include "fficonfig.h"
7
-
8
- #if defined HAVE_STDINT_H
9
- #include <stdint.h>
10
- #endif
11
-
12
- #if defined HAVE_INTTYPES_H
13
- #include <inttypes.h>
14
- #endif
15
-
16
- #define MAX_ARGS 256
17
-
18
- #define CHECK(x) (void)(!(x) ? (abort(), 1) : 0)
19
-
20
- /* Define macros so that compilers other than gcc can run the tests. */
21
- #undef __UNUSED__
22
- #if defined(__GNUC__)
23
- #define __UNUSED__ __attribute__((__unused__))
24
- #define __STDCALL__ __attribute__((stdcall))
25
- #define __THISCALL__ __attribute__((thiscall))
26
- #define __FASTCALL__ __attribute__((fastcall))
27
- #define __MSABI__ __attribute__((ms_abi))
28
- #else
29
- #define __UNUSED__
30
- #define __STDCALL__ __stdcall
31
- #define __THISCALL__ __thiscall
32
- #define __FASTCALL__ __fastcall
33
- #endif
34
-
35
- #ifndef ABI_NUM
36
- #define ABI_NUM FFI_DEFAULT_ABI
37
- #define ABI_ATTR
38
- #endif
39
-
40
- /* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
41
- file open. */
42
- #ifdef HAVE_MMAP_ANON
43
- # undef HAVE_MMAP_DEV_ZERO
44
-
45
- # include <sys/mman.h>
46
- # ifndef MAP_FAILED
47
- # define MAP_FAILED -1
48
- # endif
49
- # if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
50
- # define MAP_ANONYMOUS MAP_ANON
51
- # endif
52
- # define USING_MMAP
53
-
54
- #endif
55
-
56
- #ifdef HAVE_MMAP_DEV_ZERO
57
-
58
- # include <sys/mman.h>
59
- # ifndef MAP_FAILED
60
- # define MAP_FAILED -1
61
- # endif
62
- # define USING_MMAP
63
-
64
- #endif
65
-
66
- /* MinGW kludge. */
67
- #if defined(_WIN64) | defined(_WIN32)
68
- #define PRIdLL "I64d"
69
- #define PRIuLL "I64u"
70
- #else
71
- #define PRIdLL "lld"
72
- #define PRIuLL "llu"
73
- #endif
74
-
75
- /* Tru64 UNIX kludge. */
76
- #if defined(__alpha__) && defined(__osf__)
77
- /* Tru64 UNIX V4.0 doesn't support %lld/%lld, but long is 64-bit. */
78
- #undef PRIdLL
79
- #define PRIdLL "ld"
80
- #undef PRIuLL
81
- #define PRIuLL "lu"
82
- #define PRId8 "hd"
83
- #define PRIu8 "hu"
84
- #define PRId64 "ld"
85
- #define PRIu64 "lu"
86
- #define PRIuPTR "lu"
87
- #endif
88
-
89
- /* PA HP-UX kludge. */
90
- #if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR)
91
- #define PRIuPTR "lu"
92
- #endif
93
-
94
- /* IRIX kludge. */
95
- #if defined(__sgi)
96
- /* IRIX 6.5 <inttypes.h> provides all definitions, but only for C99
97
- compilations. */
98
- #define PRId8 "hhd"
99
- #define PRIu8 "hhu"
100
- #if (_MIPS_SZLONG == 32)
101
- #define PRId64 "lld"
102
- #define PRIu64 "llu"
103
- #endif
104
- /* This doesn't match <inttypes.h>, which always has "lld" here, but the
105
- arguments are uint64_t, int64_t, which are unsigned long, long for
106
- 64-bit in <sgidefs.h>. */
107
- #if (_MIPS_SZLONG == 64)
108
- #define PRId64 "ld"
109
- #define PRIu64 "lu"
110
- #endif
111
- /* This doesn't match <inttypes.h>, which has "u" here, but the arguments
112
- are uintptr_t, which is always unsigned long. */
113
- #define PRIuPTR "lu"
114
- #endif
115
-
116
- /* Solaris < 10 kludge. */
117
- #if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR)
118
- #if defined(__arch64__) || defined (__x86_64__)
119
- #define PRIuPTR "lu"
120
- #else
121
- #define PRIuPTR "u"
122
- #endif
123
- #endif
124
-
125
- /* MSVC kludge. */
126
- #if defined _MSC_VER
127
- #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
128
- #define PRIuPTR "lu"
129
- #define PRIu8 "u"
130
- #define PRId8 "d"
131
- #define PRIu64 "I64u"
132
- #define PRId64 "I64d"
133
- #endif
134
- #endif
135
-
136
- #ifndef PRIuPTR
137
- #define PRIuPTR "u"
138
- #endif
1
+ #include "../libffi.call/ffitest.h"
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
9
- /* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
9
+ /* { dg-options -mlong-double-128 { target powerpc64*-*-linux-gnu* } } */
10
10
  /* { dg-options -Wformat=0 { target moxie*-*-elf or1k-*-* } } */
11
11
 
12
12
  #include <inttypes.h>
@@ -121,13 +121,13 @@ test_large_fn(
121
121
  {
122
122
  BigStruct retVal = {
123
123
  ui8_1 + 1, si8_1 + 1, ui16_1 + 1, si16_1 + 1, ui32_1 + 1, si32_1 + 1,
124
- ui64_1 + 1, si64_1 + 1, f_1 + 1, d_1 + 1, ld_1 + 1, (char*)((intptr_t)p_1 + 1),
124
+ ui64_1 + 1, si64_1 + 1, f_1 + 1, d_1 + 1, ld_1 + 1, (char*)((intptr_t)p_1 + 1),
125
125
  ui8_2 + 2, si8_2 + 2, ui16_2 + 2, si16_2 + 2, ui32_2 + 2, si32_2 + 2,
126
- ui64_2 + 2, si64_2 + 2, f_2 + 2, d_2 + 2, ld_2 + 2, (char*)((intptr_t)p_2 + 2),
126
+ ui64_2 + 2, si64_2 + 2, f_2 + 2, d_2 + 2, ld_2 + 2, (char*)((intptr_t)p_2 + 2),
127
127
  ui8_3 + 3, si8_3 + 3, ui16_3 + 3, si16_3 + 3, ui32_3 + 3, si32_3 + 3,
128
- ui64_3 + 3, si64_3 + 3, f_3 + 3, d_3 + 3, ld_3 + 3, (char*)((intptr_t)p_3 + 3),
128
+ ui64_3 + 3, si64_3 + 3, f_3 + 3, d_3 + 3, ld_3 + 3, (char*)((intptr_t)p_3 + 3),
129
129
  ui8_4 + 4, si8_4 + 4, ui16_4 + 4, si16_4 + 4, ui32_4 + 4, si32_4 + 4,
130
- ui64_4 + 4, si64_4 + 4, f_4 + 4, d_4 + 4, ld_4 + 4, (char*)((intptr_t)p_4 + 4),
130
+ ui64_4 + 4, si64_4 + 4, f_4 + 4, d_4 + 4, ld_4 + 4, (char*)((intptr_t)p_4 + 4),
131
131
  ui8_5 + 5, si8_5 + 5};
132
132
 
133
133
  printf("%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
@@ -138,18 +138,18 @@ test_large_fn(
138
138
  "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
139
139
  "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
140
140
  "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
141
- ui8_1, si8_1, ui16_1, si16_1, ui32_1, si32_1, ui64_1, si64_1, f_1, d_1, ld_1, (unsigned long)p_1,
142
- ui8_2, si8_2, ui16_2, si16_2, ui32_2, si32_2, ui64_2, si64_2, f_2, d_2, ld_2, (unsigned long)p_2,
143
- ui8_3, si8_3, ui16_3, si16_3, ui32_3, si32_3, ui64_3, si64_3, f_3, d_3, ld_3, (unsigned long)p_3,
144
- ui8_4, si8_4, ui16_4, si16_4, ui32_4, si32_4, ui64_4, si64_4, f_4, d_4, ld_4, (unsigned long)p_4, ui8_5, si8_5,
141
+ ui8_1, si8_1, ui16_1, si16_1, ui32_1, si32_1, ui64_1, si64_1, f_1, d_1, ld_1, (long)(intptr_t)p_1,
142
+ ui8_2, si8_2, ui16_2, si16_2, ui32_2, si32_2, ui64_2, si64_2, f_2, d_2, ld_2, (long)(intptr_t)p_2,
143
+ ui8_3, si8_3, ui16_3, si16_3, ui32_3, si32_3, ui64_3, si64_3, f_3, d_3, ld_3, (long)(intptr_t)p_3,
144
+ ui8_4, si8_4, ui16_4, si16_4, ui32_4, si32_4, ui64_4, si64_4, f_4, d_4, ld_4, (long)(intptr_t)p_4, ui8_5, si8_5,
145
145
  retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
146
- retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
146
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (long)(intptr_t)retVal.l,
147
147
  retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
148
- retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
148
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (long)(intptr_t)retVal.x,
149
149
  retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
150
- retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
150
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (long)(intptr_t)retVal.jj,
151
151
  retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
152
- retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
152
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (long)(intptr_t)retVal.vv, retVal.ww, retVal.xx);
153
153
 
154
154
  return retVal;
155
155
  }
@@ -302,13 +302,13 @@ main(int argc __UNUSED__, const char** argv __UNUSED__)
302
302
  "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
303
303
  "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
304
304
  retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
305
- retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
305
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (long)(intptr_t)retVal.l,
306
306
  retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
307
- retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
307
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (long)(intptr_t)retVal.x,
308
308
  retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
309
- retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
309
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (long)(intptr_t)retVal.jj,
310
310
  retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
311
- retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
311
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (long)(intptr_t)retVal.vv, retVal.ww, retVal.xx);
312
312
  /* { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
313
313
 
314
314
  CHECK(ffi_prep_closure_loc(pcl, &cif, cls_large_fn, NULL, code) == FFI_OK);
@@ -330,13 +330,13 @@ main(int argc __UNUSED__, const char** argv __UNUSED__)
330
330
  "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
331
331
  "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
332
332
  retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
333
- retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
333
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (long)(intptr_t)retVal.l,
334
334
  retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
335
- retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
335
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (long)(intptr_t)retVal.x,
336
336
  retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
337
- retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
337
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (long)(intptr_t)retVal.jj,
338
338
  retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
339
- retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
339
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (long)(intptr_t)retVal.vv, retVal.ww, retVal.xx);
340
340
  /* { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
341
341
 
342
342
  return 0;