ffi 1.15.4 → 1.16.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (312) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +90 -0
  4. data/Gemfile +1 -1
  5. data/README.md +3 -2
  6. data/Rakefile +28 -11
  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 +18 -7
  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 +92 -34
  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 +4567 -3822
  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/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 +136 -120
  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 +3 -3
  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/tools/const_generator.rb +5 -4
  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/rakelib/ffi_gem_helper.rb +1 -1
  293. data/samples/hello_ractor.rb +11 -0
  294. data/samples/qsort_ractor.rb +28 -0
  295. data.tar.gz.sig +0 -0
  296. metadata +103 -28
  297. metadata.gz.sig +0 -0
  298. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
  299. data/ext/ffi_c/libffi/.travis/build.sh +0 -142
  300. data/ext/ffi_c/libffi/.travis.yml +0 -83
  301. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
  302. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
  303. /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
  304. /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
  305. /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
  306. /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
  307. /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
  308. /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
  309. /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
  310. /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
  311. /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  312. /data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +0 -0
@@ -40,6 +40,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
40
40
  #endif
41
41
  #endif
42
42
 
43
+ #ifdef __APPLE__
44
+ # define L(X) CONCAT1(L, X)
45
+ #else
46
+ # define L(X) CONCAT1(.L, X)
47
+ #endif
48
+
43
49
  #ifdef __AARCH64EB__
44
50
  # define BE(X) X
45
51
  #else
@@ -56,14 +62,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
56
62
  #define PTR_SIZE 4
57
63
  #else
58
64
  #define PTR_SIZE 8
59
- #endif
60
-
61
- #if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH)
62
- # define BR(r) braaz r
63
- # define BLR(r) blraaz r
64
- #else
65
- # define BR(r) br r
66
- # define BLR(r) blr r
67
65
  #endif
68
66
 
69
67
  .text
@@ -86,9 +84,22 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
86
84
 
87
85
  cfi_startproc
88
86
  CNAME(ffi_call_SYSV):
87
+ /* Sign the lr with x1 since that is where it will be stored */
88
+ SIGN_LR_WITH_REG(x1)
89
+
89
90
  /* Use a stack frame allocated by our caller. */
90
- cfi_def_cfa(x1, 32);
91
+ #if defined(HAVE_PTRAUTH) && defined(__APPLE__)
92
+ /* darwin's libunwind assumes that the cfa is the sp and that's the data
93
+ * used to sign the lr. In order to allow unwinding through this
94
+ * function it is necessary to point the cfa at the signing register.
95
+ */
96
+ cfi_def_cfa(x1, 0);
97
+ #else
98
+ cfi_def_cfa(x1, 40);
99
+ #endif
91
100
  stp x29, x30, [x1]
101
+ mov x9, sp
102
+ str x9, [x1, #32]
92
103
  mov x29, x1
93
104
  mov sp, x0
94
105
  cfi_def_cfa_register(x29)
@@ -119,13 +130,15 @@ CNAME(ffi_call_SYSV):
119
130
  /* Deallocate the context, leaving the stacked arguments. */
120
131
  add sp, sp, #CALL_CONTEXT_SIZE
121
132
 
122
- BLR(x9) /* call fn */
133
+ BRANCH_AND_LINK_TO_REG x9 /* call fn */
123
134
 
124
135
  ldp x3, x4, [x29, #16] /* reload rvalue and flags */
125
136
 
126
137
  /* Partially deconstruct the stack frame. */
127
- mov sp, x29
138
+ ldr x9, [x29, #32]
139
+ mov sp, x9
128
140
  cfi_def_cfa_register (sp)
141
+ mov x2, x29 /* Preserve for auth */
129
142
  ldp x29, x30, [x29]
130
143
 
131
144
  /* Save the return value as directed. */
@@ -139,71 +152,76 @@ CNAME(ffi_call_SYSV):
139
152
  and therefore we want to extend to 64 bits; these types
140
153
  have two consecutive entries allocated for them. */
141
154
  .align 4
142
- 0: ret /* VOID */
155
+ 0: b 99f /* VOID */
143
156
  nop
144
157
  1: str x0, [x3] /* INT64 */
145
- ret
158
+ b 99f
146
159
  2: stp x0, x1, [x3] /* INT128 */
147
- ret
160
+ b 99f
148
161
  3: brk #1000 /* UNUSED */
149
- ret
162
+ b 99f
150
163
  4: brk #1000 /* UNUSED */
151
- ret
164
+ b 99f
152
165
  5: brk #1000 /* UNUSED */
153
- ret
166
+ b 99f
154
167
  6: brk #1000 /* UNUSED */
155
- ret
168
+ b 99f
156
169
  7: brk #1000 /* UNUSED */
157
- ret
170
+ b 99f
158
171
  8: st4 { v0.s, v1.s, v2.s, v3.s }[0], [x3] /* S4 */
159
- ret
172
+ b 99f
160
173
  9: st3 { v0.s, v1.s, v2.s }[0], [x3] /* S3 */
161
- ret
174
+ b 99f
162
175
  10: stp s0, s1, [x3] /* S2 */
163
- ret
176
+ b 99f
164
177
  11: str s0, [x3] /* S1 */
165
- ret
178
+ b 99f
166
179
  12: st4 { v0.d, v1.d, v2.d, v3.d }[0], [x3] /* D4 */
167
- ret
180
+ b 99f
168
181
  13: st3 { v0.d, v1.d, v2.d }[0], [x3] /* D3 */
169
- ret
182
+ b 99f
170
183
  14: stp d0, d1, [x3] /* D2 */
171
- ret
184
+ b 99f
172
185
  15: str d0, [x3] /* D1 */
173
- ret
186
+ b 99f
174
187
  16: str q3, [x3, #48] /* Q4 */
175
188
  nop
176
189
  17: str q2, [x3, #32] /* Q3 */
177
190
  nop
178
191
  18: stp q0, q1, [x3] /* Q2 */
179
- ret
192
+ b 99f
180
193
  19: str q0, [x3] /* Q1 */
181
- ret
194
+ b 99f
182
195
  20: uxtb w0, w0 /* UINT8 */
183
196
  str x0, [x3]
184
- 21: ret /* reserved */
197
+ 21: b 99f /* reserved */
185
198
  nop
186
199
  22: uxth w0, w0 /* UINT16 */
187
200
  str x0, [x3]
188
- 23: ret /* reserved */
201
+ 23: b 99f /* reserved */
189
202
  nop
190
203
  24: mov w0, w0 /* UINT32 */
191
204
  str x0, [x3]
192
- 25: ret /* reserved */
205
+ 25: b 99f /* reserved */
193
206
  nop
194
207
  26: sxtb x0, w0 /* SINT8 */
195
208
  str x0, [x3]
196
- 27: ret /* reserved */
209
+ 27: b 99f /* reserved */
197
210
  nop
198
211
  28: sxth x0, w0 /* SINT16 */
199
212
  str x0, [x3]
200
- 29: ret /* reserved */
213
+ 29: b 99f /* reserved */
201
214
  nop
202
215
  30: sxtw x0, w0 /* SINT32 */
203
216
  str x0, [x3]
204
- 31: ret /* reserved */
217
+ 31: b 99f /* reserved */
205
218
  nop
206
219
 
220
+ /* Return now that result has been populated. */
221
+ 99:
222
+ AUTH_LR_WITH_REG(x2)
223
+ ret
224
+
207
225
  cfi_endproc
208
226
 
209
227
  .globl CNAME(ffi_call_SYSV)
@@ -213,6 +231,8 @@ CNAME(ffi_call_SYSV):
213
231
  .size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV)
214
232
  #endif
215
233
 
234
+ #if FFI_CLOSURES
235
+
216
236
  /* ffi_closure_SYSV
217
237
 
218
238
  Closure invocation glue. This is the low level code invoked directly by
@@ -232,6 +252,7 @@ CNAME(ffi_call_SYSV):
232
252
  .align 4
233
253
  CNAME(ffi_closure_SYSV_V):
234
254
  cfi_startproc
255
+ SIGN_LR
235
256
  stp x29, x30, [sp, #-ffi_closure_SYSV_FS]!
236
257
  cfi_adjust_cfa_offset (ffi_closure_SYSV_FS)
237
258
  cfi_rel_offset (x29, 0)
@@ -255,6 +276,7 @@ CNAME(ffi_closure_SYSV_V):
255
276
  .align 4
256
277
  cfi_startproc
257
278
  CNAME(ffi_closure_SYSV):
279
+ SIGN_LR
258
280
  stp x29, x30, [sp, #-ffi_closure_SYSV_FS]!
259
281
  cfi_adjust_cfa_offset (ffi_closure_SYSV_FS)
260
282
  cfi_rel_offset (x29, 0)
@@ -271,7 +293,9 @@ CNAME(ffi_closure_SYSV):
271
293
  /* Load ffi_closure_inner arguments. */
272
294
  ldp PTR_REG(0), PTR_REG(1), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET] /* load cif, fn */
273
295
  ldr PTR_REG(2), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET+PTR_SIZE*2] /* load user_data */
274
- .Ldo_closure:
296
+ #ifdef FFI_GO_CLOSURES
297
+ L(do_closure):
298
+ #endif
275
299
  add x3, sp, #16 /* load context */
276
300
  add x4, sp, #ffi_closure_SYSV_FS /* load stack */
277
301
  add x5, sp, #16+CALL_CONTEXT_SIZE /* load rvalue */
@@ -279,9 +303,6 @@ CNAME(ffi_closure_SYSV):
279
303
  bl CNAME(ffi_closure_SYSV_inner)
280
304
 
281
305
  /* Load the return value as directed. */
282
- #if FFI_EXEC_TRAMPOLINE_TABLE && defined(__MACH__) && defined(HAVE_PTRAUTH)
283
- autiza x1
284
- #endif
285
306
  adr x1, 0f
286
307
  and w0, w0, #AARCH64_RET_MASK
287
308
  add x1, x1, x0, lsl #3
@@ -357,7 +378,7 @@ CNAME(ffi_closure_SYSV):
357
378
  cfi_adjust_cfa_offset (-ffi_closure_SYSV_FS)
358
379
  cfi_restore (x29)
359
380
  cfi_restore (x30)
360
- ret
381
+ AUTH_LR_AND_RET
361
382
  cfi_endproc
362
383
 
363
384
  .globl CNAME(ffi_closure_SYSV)
@@ -367,6 +388,76 @@ CNAME(ffi_closure_SYSV):
367
388
  .size CNAME(ffi_closure_SYSV), . - CNAME(ffi_closure_SYSV)
368
389
  #endif
369
390
 
391
+ #if defined(FFI_EXEC_STATIC_TRAMP)
392
+ .align 4
393
+ CNAME(ffi_closure_SYSV_V_alt):
394
+ /* See the comments above trampoline_code_table. */
395
+ ldr x17, [sp, #8] /* Load closure in x17 */
396
+ add sp, sp, #16 /* Restore the stack */
397
+ b CNAME(ffi_closure_SYSV_V)
398
+
399
+ .globl CNAME(ffi_closure_SYSV_V_alt)
400
+ FFI_HIDDEN(CNAME(ffi_closure_SYSV_V_alt))
401
+ #ifdef __ELF__
402
+ .type CNAME(ffi_closure_SYSV_V_alt), #function
403
+ .size CNAME(ffi_closure_SYSV_V_alt), . - CNAME(ffi_closure_SYSV_V_alt)
404
+ #endif
405
+
406
+ .align 4
407
+ CNAME(ffi_closure_SYSV_alt):
408
+ /* See the comments above trampoline_code_table. */
409
+ ldr x17, [sp, #8] /* Load closure in x17 */
410
+ add sp, sp, #16 /* Restore the stack */
411
+ b CNAME(ffi_closure_SYSV)
412
+
413
+ .globl CNAME(ffi_closure_SYSV_alt)
414
+ FFI_HIDDEN(CNAME(ffi_closure_SYSV_alt))
415
+ #ifdef __ELF__
416
+ .type CNAME(ffi_closure_SYSV_alt), #function
417
+ .size CNAME(ffi_closure_SYSV_alt), . - CNAME(ffi_closure_SYSV_alt)
418
+ #endif
419
+
420
+ /*
421
+ * Below is the definition of the trampoline code table. Each element in
422
+ * the code table is a trampoline.
423
+ */
424
+ /*
425
+ * The trampoline uses register x17. It saves the original value of x17 on
426
+ * the stack.
427
+ *
428
+ * The trampoline has two parameters - target code to jump to and data for
429
+ * the target code. The trampoline extracts the parameters from its parameter
430
+ * block (see tramp_table_map()). The trampoline saves the data address on
431
+ * the stack. Finally, it jumps to the target code.
432
+ *
433
+ * The target code can choose to:
434
+ *
435
+ * - restore the value of x17
436
+ * - load the data address in a register
437
+ * - restore the stack pointer to what it was when the trampoline was invoked.
438
+ */
439
+ .align AARCH64_TRAMP_MAP_SHIFT
440
+ CNAME(trampoline_code_table):
441
+ .rept AARCH64_TRAMP_MAP_SIZE / AARCH64_TRAMP_SIZE
442
+ sub sp, sp, #16 /* Make space on the stack */
443
+ str x17, [sp] /* Save x17 on stack */
444
+ adr x17, #16376 /* Get data address */
445
+ ldr x17, [x17] /* Copy data into x17 */
446
+ str x17, [sp, #8] /* Save data on stack */
447
+ adr x17, #16372 /* Get code address */
448
+ ldr x17, [x17] /* Load code address into x17 */
449
+ br x17 /* Jump to code */
450
+ .endr
451
+
452
+ .globl CNAME(trampoline_code_table)
453
+ FFI_HIDDEN(CNAME(trampoline_code_table))
454
+ #ifdef __ELF__
455
+ .type CNAME(trampoline_code_table), #function
456
+ .size CNAME(trampoline_code_table), . - CNAME(trampoline_code_table)
457
+ #endif
458
+ .align AARCH64_TRAMP_MAP_SHIFT
459
+ #endif /* FFI_EXEC_STATIC_TRAMP */
460
+
370
461
  #if FFI_EXEC_TRAMPOLINE_TABLE
371
462
 
372
463
  #ifdef __MACH__
@@ -376,7 +467,7 @@ CNAME(ffi_closure_trampoline_table_page):
376
467
  .rept PAGE_MAX_SIZE / FFI_TRAMPOLINE_SIZE
377
468
  adr x16, -PAGE_MAX_SIZE
378
469
  ldp x17, x16, [x16]
379
- BR(x16)
470
+ br x16
380
471
  nop /* each entry in the trampoline config page is 2*sizeof(void*) so the trampoline itself cannot be smaller than 16 bytes */
381
472
  .endr
382
473
 
@@ -433,7 +524,7 @@ CNAME(ffi_go_closure_SYSV):
433
524
  /* Load ffi_closure_inner arguments. */
434
525
  ldp PTR_REG(0), PTR_REG(1), [x18, #PTR_SIZE]/* load cif, fn */
435
526
  mov x2, x18 /* load user_data */
436
- b .Ldo_closure
527
+ b L(do_closure)
437
528
  cfi_endproc
438
529
 
439
530
  .globl CNAME(ffi_go_closure_SYSV)
@@ -443,6 +534,7 @@ CNAME(ffi_go_closure_SYSV):
443
534
  .size CNAME(ffi_go_closure_SYSV), . - CNAME(ffi_go_closure_SYSV)
444
535
  #endif
445
536
  #endif /* FFI_GO_CLOSURES */
537
+ #endif /* FFI_CLOSURES */
446
538
  #endif /* __arm64__ */
447
539
 
448
540
  #if defined __ELF__ && defined __linux__
@@ -33,103 +33,178 @@
33
33
  #define ENTRY(x) .globl CNAME(x)` .type CNAME(x),%function` CNAME(x):
34
34
  #endif
35
35
 
36
+ #if __SIZEOF_POINTER__ == 8
37
+ #define PTRS 8
38
+ #define FLTS 8
39
+ #define LARG ldl
40
+ #define SARG stl
41
+ #define ADDPTR addl
42
+ #define MOVPTR movl_s
43
+ #else
44
+ #define PTRS 4
45
+ #define FLTS 4
46
+ #define LARG ld
47
+ #define SARG st
48
+ #define ADDPTR add
49
+ #define MOVPTR mov_s
50
+ #endif
51
+
52
+ #define FRAME_LEN (8 * PTRS + 16)
53
+
36
54
  .text
37
55
 
38
- /* R0: ffi_prep_args */
39
- /* R1: &ecif */
40
- /* R2: cif->bytes */
41
- /* R3: fig->flags */
42
- /* R4: ecif.rvalue */
43
- /* R5: fn */
44
- ENTRY(ffi_call_ARCompact)
56
+ ENTRY(ffi_call_asm)
57
+ .cfi_startproc
58
+
45
59
  /* Save registers. */
46
- st.a fp, [sp, -4] /* fp + 20, fp */
47
- push_s blink /* fp + 16, blink */
48
- st.a r4, [sp, -4] /* fp + 12, ecif.rvalue */
49
- push_s r3 /* fp + 8, fig->flags */
50
- st.a r5, [sp, -4] /* fp + 4, fn */
51
- push_s r2 /* fp + 0, cif->bytes */
52
- mov fp, sp
53
-
54
- /* Make room for all of the new args. */
55
- sub sp, sp, r2
56
-
57
- /* Place all of the ffi_prep_args in position. */
58
- /* ffi_prep_args(char *stack, extended_cif *ecif) */
59
- /* R1 already set. */
60
-
61
- /* And call. */
62
- jl_s.d [r0]
63
- mov_s r0, sp
64
-
65
- ld.ab r12, [fp, 4] /* cif->bytes */
66
- ld.ab r11, [fp, 4] /* fn */
67
-
68
- /* Move first 8 parameters in registers... */
69
- ld_s r0, [sp]
70
- ld_s r1, [sp, 4]
71
- ld_s r2, [sp, 8]
72
- ld_s r3, [sp, 12]
73
- ld r4, [sp, 16]
74
- ld r5, [sp, 20]
75
- ld r6, [sp, 24]
76
- ld r7, [sp, 28]
77
-
78
- /* ...and adjust the stack. */
79
- min r12, r12, 32
60
+ .cfi_def_cfa r1, FRAME_LEN
61
+ SARG fp, [r1, FRAME_LEN - 2*PTRS]
62
+ .cfi_offset fp, -2*PTRS
63
+ SARG blink, [r1, FRAME_LEN - 1*PTRS]
64
+ .cfi_offset blink, -1*PTRS
65
+ ADDPTR fp, r1, FRAME_LEN
66
+ MOVPTR sp, r0
67
+ .cfi_def_cfa fp, 0
68
+
69
+ /* Load arguments. */
70
+ MOVPTR r11, r2 /* fn */
71
+ MOVPTR r12, r3 /* closure */
72
+
73
+ /* Save arguments. */
74
+ LARG r0, [fp, -FRAME_LEN+0*PTRS]
75
+ LARG r1, [fp, -FRAME_LEN+1*PTRS]
76
+ LARG r2, [fp, -FRAME_LEN+2*PTRS]
77
+ LARG r3, [fp, -FRAME_LEN+3*PTRS]
78
+ LARG r4, [fp, -FRAME_LEN+4*PTRS]
79
+ LARG r5, [fp, -FRAME_LEN+5*PTRS]
80
+ LARG r6, [fp, -FRAME_LEN+6*PTRS]
81
+ LARG r7, [fp, -FRAME_LEN+7*PTRS]
80
82
 
81
83
  /* Call the function. */
82
- jl.d [r11]
83
- add sp, sp, r12
84
-
85
- mov sp, fp
86
- pop_s r3 /* fig->flags, return type */
87
- pop_s r2 /* ecif.rvalue, pointer for return value */
88
-
89
- /* If the return value pointer is NULL, assume no return value. */
90
- breq.d r2, 0, epilogue
91
- pop_s blink
92
-
93
- /* Return INT. */
94
- brne r3, FFI_TYPE_INT, return_double
95
- b.d epilogue
96
- st_s r0, [r2]
97
-
98
- return_double:
99
- brne r3, FFI_TYPE_DOUBLE, epilogue
100
- st_s r0, [r2]
101
- st_s r1, [r2,4]
102
-
103
- epilogue:
104
- j_s.d [blink]
105
- ld.ab fp, [sp, 4]
106
-
107
- ENTRY(ffi_closure_ARCompact)
108
- st.a r0, [sp, -32]
109
- st_s r1, [sp, 4]
110
- st_s r2, [sp, 8]
111
- st_s r3, [sp, 12]
112
- st r4, [sp, 16]
113
- st r5, [sp, 20]
114
- st r6, [sp, 24]
115
- st r7, [sp, 28]
116
-
117
- /* pointer to arguments */
118
- mov_s r2, sp
119
-
120
- /* return value goes here */
121
- sub sp, sp, 8
122
- mov_s r1, sp
123
-
124
- push_s blink
84
+ jl [r11]
85
+
86
+ /* Save return value (r0/r1) */
87
+ SARG r0, [fp, -FRAME_LEN+0*PTRS]
88
+ SARG r1, [fp, -FRAME_LEN+1*PTRS]
89
+
90
+ /* Restore and return. */
91
+ add sp, fp, -FRAME_LEN
92
+ .cfi_def_cfa sp, FRAME_LEN
93
+ LARG blink, [fp, -1*PTRS]
94
+ .cfi_restore blink
95
+ LARG fp, [fp, -2*PTRS]
96
+ .cfi_restore fp
97
+ j_s [blink]
98
+ .cfi_endproc
99
+ .size ffi_call_asm, .-ffi_call_asm
100
+
101
+ /*
102
+ ffi_closure_asm. Expects address of the passed-in ffi_closure in r8.
103
+ void ffi_closure_inner (ffi_cif *cif,
104
+ void (*fun) (ffi_cif *, void *, void **, void *),
105
+ void *user_data,
106
+ size_t *stackargs, struct call_context *regargs)
107
+ */
108
+
109
+ ENTRY(ffi_closure_asm)
110
+ .cfi_startproc
111
+
112
+ ADDPTR sp, sp, -FRAME_LEN
113
+ .cfi_def_cfa_offset FRAME_LEN
114
+
115
+ /* Make a frame. */
116
+ SARG fp, [sp, FRAME_LEN-2*PTRS]
117
+ .cfi_offset fp, -2*PTRS
118
+ SARG blink, [sp, FRAME_LEN-1*PTRS]
119
+ .cfi_offset blink, -1*PTRS
120
+ ADDPTR fp, sp, FRAME_LEN
121
+
122
+ /* Save arguments. */
123
+ SARG r0, [sp, 0*PTRS]
124
+ SARG r1, [sp, 1*PTRS]
125
+ SARG r2, [sp, 2*PTRS]
126
+ SARG r3, [sp, 3*PTRS]
127
+ SARG r4, [sp, 4*PTRS]
128
+ SARG r5, [sp, 5*PTRS]
129
+ SARG r6, [sp, 6*PTRS]
130
+ SARG r7, [sp, 7*PTRS]
131
+
132
+ /* Enter C. */
133
+ LARG r0, [r8, FFI_TRAMPOLINE_SIZE+0*PTRS]
134
+ LARG r1, [r8, FFI_TRAMPOLINE_SIZE+1*PTRS]
135
+ LARG r2, [r8, FFI_TRAMPOLINE_SIZE+2*PTRS]
136
+ ADDPTR r3, sp, FRAME_LEN
137
+ MOVPTR r4, sp
138
+
139
+ /* Call the C code. */
140
+ bl ffi_closure_inner
125
141
 
126
- bl.d ffi_closure_inner_ARCompact
127
- mov_s r0, r8 /* codeloc, set by trampoline */
128
-
129
- pop_s blink
130
-
131
- /* set return value to r1:r0 */
132
- pop_s r0
133
- pop_s r1
134
- j_s.d [blink]
135
- add_s sp, sp, 32
142
+ /* Return values. */
143
+ LARG r0, [sp, 0*PTRS]
144
+ LARG r1, [sp, 1*PTRS]
145
+
146
+ /* Restore and return. */
147
+ LARG blink, [sp, FRAME_LEN-1*PTRS]
148
+ .cfi_restore blink
149
+ LARG fp, [sp, FRAME_LEN-2*PTRS]
150
+ .cfi_restore fp
151
+ ADDPTR sp, sp, FRAME_LEN
152
+ .cfi_def_cfa_offset 0
153
+ j_s [blink]
154
+ .cfi_endproc
155
+ .size ffi_closure_asm, .-ffi_closure_asm
156
+
157
+ /*
158
+ ffi_go_closure_asm. Expects address of the passed-in ffi_go_closure in r12.
159
+ void ffi_closure_inner (ffi_cif *cif,
160
+ void (*fun) (ffi_cif *, void *, void **, void *),
161
+ void *user_data,
162
+ size_t *stackargs, struct call_context *regargs)
163
+ */
164
+
165
+ ENTRY(ffi_go_closure_asm)
166
+ .cfi_startproc
167
+
168
+ ADDPTR sp, sp, -FRAME_LEN
169
+ .cfi_def_cfa_offset FRAME_LEN
170
+
171
+ /* make a frame */
172
+ SARG fp, [sp, FRAME_LEN-2*PTRS]
173
+ .cfi_offset fp, -2*PTRS
174
+ SARG blink, [sp, FRAME_LEN-1*PTRS]
175
+ .cfi_offset blink, -1*PTRS
176
+ ADDPTR fp, sp, FRAME_LEN
177
+
178
+ /* save arguments */
179
+ SARG r0, [sp, 0*PTRS]
180
+ SARG r1, [sp, 1*PTRS]
181
+ SARG r2, [sp, 2*PTRS]
182
+ SARG r3, [sp, 3*PTRS]
183
+ SARG r4, [sp, 4*PTRS]
184
+ SARG r5, [sp, 5*PTRS]
185
+ SARG r6, [sp, 6*PTRS]
186
+ SARG r7, [sp, 7*PTRS]
187
+
188
+ /* enter C */
189
+ LARG r0, [r12, 1*PTRS]
190
+ LARG r1, [r12, 2*PTRS]
191
+ MOVPTR r2, r12
192
+ ADDPTR r3, sp, FRAME_LEN
193
+ MOVPTR r4, sp
194
+
195
+ bl ffi_closure_inner
196
+
197
+ /* Return values. */
198
+ LARG r0, [sp, 0*PTRS]
199
+ LARG r1, [sp, 1*PTRS]
200
+
201
+
202
+ LARG blink, [sp, FRAME_LEN-1*PTRS]
203
+ .cfi_restore blink
204
+ LARG fp, [sp, FRAME_LEN-2*PTRS]
205
+ .cfi_restore fp
206
+ ADDPTR sp, sp, FRAME_LEN
207
+ .cfi_def_cfa_offset 0
208
+ j_s [blink]
209
+ .cfi_endproc
210
+ .size ffi_go_closure_asm, .-ffi_go_closure_asm