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
@@ -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;
@@ -25,7 +25,7 @@ typedef struct cls_struct_combined {
25
25
  cls_struct_16byte2 e;
26
26
  } cls_struct_combined;
27
27
 
28
- cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0,
28
+ static cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0,
29
29
  struct cls_struct_16byte2 b1,
30
30
  struct cls_struct_combined b2)
31
31
  {
@@ -46,6 +46,29 @@ cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0,
46
46
  result.d.a, result.d.b, result.d.c,
47
47
  result.e.ii, result.e.dd, result.e.ff);
48
48
 
49
+ CHECK_DOUBLE_EQ(b0.a, 9);
50
+ CHECK_FLOAT_EQ(b0.b, 2);
51
+ CHECK(b0.c == 6);
52
+
53
+ CHECK(b1.ii == 1);
54
+ CHECK_DOUBLE_EQ(b1.dd, 2);
55
+ CHECK_FLOAT_EQ(b1.ff, 3);
56
+
57
+ CHECK_DOUBLE_EQ(b2.d.a, 4);
58
+ CHECK_FLOAT_EQ(b2.d.b, 5);
59
+ CHECK(b2.d.c == 6);
60
+
61
+ CHECK(b2.e.ii == 3);
62
+ CHECK_DOUBLE_EQ(b2.e.dd, 1);
63
+ CHECK_FLOAT_EQ(b2.e.ff, 8);
64
+
65
+ CHECK_DOUBLE_EQ(result.d.a, 15);
66
+ CHECK_FLOAT_EQ(result.d.b, 10);
67
+ CHECK(result.d.c == 13);
68
+ CHECK(result.e.ii == 10);
69
+ CHECK_DOUBLE_EQ(result.e.dd, 12);
70
+ CHECK_FLOAT_EQ(result.e.ff, 13);
71
+
49
72
  return result;
50
73
  }
51
74
 
@@ -128,12 +151,12 @@ int main (void)
128
151
 
129
152
  ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl);
130
153
  /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */
131
- CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
132
- CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
154
+ CHECK_DOUBLE_EQ( res_dbl.d.a, (e_dbl.a + f_dbl.dd + g_dbl.d.a));
155
+ CHECK_FLOAT_EQ( res_dbl.d.b, (e_dbl.b + f_dbl.ff + g_dbl.d.b));
133
156
  CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c));
134
157
  CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii));
135
- CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
136
- CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
158
+ CHECK_DOUBLE_EQ( res_dbl.e.dd, (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
159
+ CHECK_FLOAT_EQ( res_dbl.e.ff, (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
137
160
 
138
161
  CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);
139
162
 
@@ -142,11 +165,11 @@ int main (void)
142
165
  cls_struct_combined))
143
166
  (code))(e_dbl, f_dbl, g_dbl);
144
167
  /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */
145
- CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
146
- CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
168
+ CHECK_DOUBLE_EQ( res_dbl.d.a, (e_dbl.a + f_dbl.dd + g_dbl.d.a));
169
+ CHECK_FLOAT_EQ( res_dbl.d.b, (e_dbl.b + f_dbl.ff + g_dbl.d.b));
147
170
  CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c));
148
171
  CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii));
149
- CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
150
- CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
172
+ CHECK_DOUBLE_EQ( res_dbl.e.dd, (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
173
+ CHECK_FLOAT_EQ( res_dbl.e.ff, (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
151
174
  exit(0);
152
175
  }
@@ -25,7 +25,7 @@ typedef struct cls_struct_combined {
25
25
  cls_struct_16byte2 e;
26
26
  } cls_struct_combined;
27
27
 
28
- cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0,
28
+ static cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0,
29
29
  struct cls_struct_16byte2 b1,
30
30
  struct cls_struct_combined b2,
31
31
  struct cls_struct_16byte1 b3)
@@ -38,6 +38,18 @@ static B B_fn(struct A b2, struct B b3, struct C b4)
38
38
  (int)b3.x.a, b3.x.b, b3.y, b3.z, (int)b4.d, b4.e,
39
39
  (int)result.x.a, result.x.b, result.y);
40
40
 
41
+ CHECK((int)b2.a == 1);
42
+ CHECK(b2.b == 7);
43
+ CHECK((int)b3.x.a == 12);
44
+ CHECK(b3.x.b == 127);
45
+ CHECK(b3.y == 99);
46
+ CHECK(b3.z == 255);
47
+ CHECK((int)b4.d == 2);
48
+ CHECK(b4.e == 9);
49
+ CHECK((int)result.x.a == 270);
50
+ CHECK(result.x.b == 242);
51
+ CHECK(result.y == 143);
52
+
41
53
  return result;
42
54
  }
43
55