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
@@ -30,6 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
30
30
  #ifdef _WIN32
31
31
  #include <windows.h> /* FlushInstructionCache */
32
32
  #endif
33
+ #include <tramp.h>
33
34
 
34
35
  /* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
35
36
  all further uses in this file will refer to the 128-bit type. */
@@ -247,13 +248,18 @@ is_vfp_type (const ffi_type *ty)
247
248
  state.
248
249
 
249
250
  The terse state variable names match the names used in the AARCH64
250
- PCS. */
251
+ PCS.
252
+
253
+ The struct area is allocated downwards from the top of the argument
254
+ area. It is used to hold copies of structures passed by value that are
255
+ bigger than 16 bytes. */
251
256
 
252
257
  struct arg_state
253
258
  {
254
259
  unsigned ngrn; /* Next general-purpose register number. */
255
260
  unsigned nsrn; /* Next vector register number. */
256
261
  size_t nsaa; /* Next stack offset. */
262
+ size_t next_struct_area; /* Place to allocate big structs. */
257
263
 
258
264
  #if defined (__APPLE__)
259
265
  unsigned allocating_variadic;
@@ -262,11 +268,12 @@ struct arg_state
262
268
 
263
269
  /* Initialize a procedure call argument marshalling state. */
264
270
  static void
265
- arg_init (struct arg_state *state)
271
+ arg_init (struct arg_state *state, size_t size)
266
272
  {
267
273
  state->ngrn = 0;
268
274
  state->nsrn = 0;
269
275
  state->nsaa = 0;
276
+ state->next_struct_area = size;
270
277
  #if defined (__APPLE__)
271
278
  state->allocating_variadic = 0;
272
279
  #endif
@@ -288,37 +295,83 @@ allocate_to_stack (struct arg_state *state, void *stack,
288
295
  if (alignment < 8)
289
296
  alignment = 8;
290
297
  #endif
291
-
298
+
292
299
  nsaa = FFI_ALIGN (nsaa, alignment);
293
300
  state->nsaa = nsaa + size;
294
301
 
295
302
  return (char *)stack + nsaa;
296
303
  }
297
304
 
305
+ /* Allocate and copy a structure that is passed by value on the stack and
306
+ return a pointer to it. */
307
+ static void *
308
+ allocate_and_copy_struct_to_stack (struct arg_state *state, void *stack,
309
+ size_t alignment, size_t size, void *value)
310
+ {
311
+ size_t dest = state->next_struct_area - size;
312
+
313
+ /* Round down to the natural alignment of the value. */
314
+ dest = FFI_ALIGN_DOWN (dest, alignment);
315
+ state->next_struct_area = dest;
316
+
317
+ return memcpy ((char *) stack + dest, value, size);
318
+ }
319
+
298
320
  static ffi_arg
299
321
  extend_integer_type (void *source, int type)
300
322
  {
301
323
  switch (type)
302
324
  {
303
325
  case FFI_TYPE_UINT8:
304
- return *(UINT8 *) source;
326
+ {
327
+ UINT8 u8;
328
+ memcpy (&u8, source, sizeof (u8));
329
+ return u8;
330
+ }
305
331
  case FFI_TYPE_SINT8:
306
- return *(SINT8 *) source;
332
+ {
333
+ SINT8 s8;
334
+ memcpy (&s8, source, sizeof (s8));
335
+ return s8;
336
+ }
307
337
  case FFI_TYPE_UINT16:
308
- return *(UINT16 *) source;
338
+ {
339
+ UINT16 u16;
340
+ memcpy (&u16, source, sizeof (u16));
341
+ return u16;
342
+ }
309
343
  case FFI_TYPE_SINT16:
310
- return *(SINT16 *) source;
344
+ {
345
+ SINT16 s16;
346
+ memcpy (&s16, source, sizeof (s16));
347
+ return s16;
348
+ }
311
349
  case FFI_TYPE_UINT32:
312
- return *(UINT32 *) source;
350
+ {
351
+ UINT32 u32;
352
+ memcpy (&u32, source, sizeof (u32));
353
+ return u32;
354
+ }
313
355
  case FFI_TYPE_INT:
314
356
  case FFI_TYPE_SINT32:
315
- return *(SINT32 *) source;
357
+ {
358
+ SINT32 s32;
359
+ memcpy (&s32, source, sizeof (s32));
360
+ return s32;
361
+ }
316
362
  case FFI_TYPE_UINT64:
317
363
  case FFI_TYPE_SINT64:
318
- return *(UINT64 *) source;
319
- break;
364
+ {
365
+ UINT64 u64;
366
+ memcpy (&u64, source, sizeof (u64));
367
+ return u64;
368
+ }
320
369
  case FFI_TYPE_POINTER:
321
- return *(uintptr_t *) source;
370
+ {
371
+ uintptr_t uptr;
372
+ memcpy (&uptr, source, sizeof (uptr));
373
+ return uptr;
374
+ }
322
375
  default:
323
376
  abort();
324
377
  }
@@ -333,51 +386,64 @@ extend_hfa_type (void *dest, void *src, int h)
333
386
  ssize_t f = h - AARCH64_RET_S4;
334
387
  void *x0;
335
388
 
389
+ #define BTI_J "hint #36"
336
390
  asm volatile (
337
391
  "adr %0, 0f\n"
338
392
  " add %0, %0, %1\n"
339
393
  " br %0\n"
340
- "0: ldp s16, s17, [%3]\n" /* S4 */
394
+ "0: "BTI_J"\n" /* S4 */
395
+ " ldp s16, s17, [%3]\n"
341
396
  " ldp s18, s19, [%3, #8]\n"
342
397
  " b 4f\n"
343
- " ldp s16, s17, [%3]\n" /* S3 */
398
+ " "BTI_J"\n" /* S3 */
399
+ " ldp s16, s17, [%3]\n"
344
400
  " ldr s18, [%3, #8]\n"
345
401
  " b 3f\n"
346
- " ldp s16, s17, [%3]\n" /* S2 */
402
+ " "BTI_J"\n" /* S2 */
403
+ " ldp s16, s17, [%3]\n"
347
404
  " b 2f\n"
348
405
  " nop\n"
349
- " ldr s16, [%3]\n" /* S1 */
406
+ " "BTI_J"\n" /* S1 */
407
+ " ldr s16, [%3]\n"
350
408
  " b 1f\n"
351
409
  " nop\n"
352
- " ldp d16, d17, [%3]\n" /* D4 */
410
+ " "BTI_J"\n" /* D4 */
411
+ " ldp d16, d17, [%3]\n"
353
412
  " ldp d18, d19, [%3, #16]\n"
354
413
  " b 4f\n"
355
- " ldp d16, d17, [%3]\n" /* D3 */
414
+ " "BTI_J"\n" /* D3 */
415
+ " ldp d16, d17, [%3]\n"
356
416
  " ldr d18, [%3, #16]\n"
357
417
  " b 3f\n"
358
- " ldp d16, d17, [%3]\n" /* D2 */
418
+ " "BTI_J"\n" /* D2 */
419
+ " ldp d16, d17, [%3]\n"
359
420
  " b 2f\n"
360
421
  " nop\n"
361
- " ldr d16, [%3]\n" /* D1 */
422
+ " "BTI_J"\n" /* D1 */
423
+ " ldr d16, [%3]\n"
362
424
  " b 1f\n"
363
425
  " nop\n"
364
- " ldp q16, q17, [%3]\n" /* Q4 */
426
+ " "BTI_J"\n" /* Q4 */
427
+ " ldp q16, q17, [%3]\n"
365
428
  " ldp q18, q19, [%3, #32]\n"
366
429
  " b 4f\n"
367
- " ldp q16, q17, [%3]\n" /* Q3 */
430
+ " "BTI_J"\n" /* Q3 */
431
+ " ldp q16, q17, [%3]\n"
368
432
  " ldr q18, [%3, #32]\n"
369
433
  " b 3f\n"
370
- " ldp q16, q17, [%3]\n" /* Q2 */
434
+ " "BTI_J"\n" /* Q2 */
435
+ " ldp q16, q17, [%3]\n"
371
436
  " b 2f\n"
372
437
  " nop\n"
373
- " ldr q16, [%3]\n" /* Q1 */
438
+ " "BTI_J"\n" /* Q1 */
439
+ " ldr q16, [%3]\n"
374
440
  " b 1f\n"
375
441
  "4: str q19, [%2, #48]\n"
376
442
  "3: str q18, [%2, #32]\n"
377
443
  "2: str q17, [%2, #16]\n"
378
444
  "1: str q16, [%2]"
379
445
  : "=&r"(x0)
380
- : "r"(f * 12), "r"(dest), "r"(src)
446
+ : "r"(f * 16), "r"(dest), "r"(src)
381
447
  : "memory", "v16", "v17", "v18", "v19");
382
448
  }
383
449
  #endif
@@ -616,19 +682,21 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
616
682
  else if (flags & AARCH64_RET_NEED_COPY)
617
683
  rsize = 16;
618
684
 
619
- /* Allocate consectutive stack for everything we'll need. */
620
- context = alloca (sizeof(struct call_context) + stack_bytes + 32 + rsize);
685
+ /* Allocate consectutive stack for everything we'll need.
686
+ The frame uses 40 bytes for: lr, fp, rvalue, flags, sp */
687
+ context = alloca (sizeof(struct call_context) + stack_bytes + 40 + rsize);
621
688
  stack = context + 1;
622
689
  frame = (void*)((uintptr_t)stack + (uintptr_t)stack_bytes);
623
- rvalue = (rsize ? (void*)((uintptr_t)frame + 32) : orig_rvalue);
690
+ rvalue = (rsize ? (void*)((uintptr_t)frame + 40) : orig_rvalue);
624
691
 
625
- arg_init (&state);
692
+ arg_init (&state, stack_bytes);
626
693
  for (i = 0, nargs = cif->nargs; i < nargs; i++)
627
694
  {
628
695
  ffi_type *ty = cif->arg_types[i];
629
696
  size_t s = ty->size;
630
697
  void *a = avalue[i];
631
698
  int h, t;
699
+ void *dest;
632
700
 
633
701
  t = ty->type;
634
702
  switch (t)
@@ -676,8 +744,6 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
676
744
  case FFI_TYPE_STRUCT:
677
745
  case FFI_TYPE_COMPLEX:
678
746
  {
679
- void *dest;
680
-
681
747
  h = is_vfp_type (ty);
682
748
  if (h)
683
749
  {
@@ -710,9 +776,12 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
710
776
  else if (s > 16)
711
777
  {
712
778
  /* If the argument is a composite type that is larger than 16
713
- bytes, then the argument has been copied to memory, and
779
+ bytes, then the argument is copied to memory, and
714
780
  the argument is replaced by a pointer to the copy. */
715
- a = &avalue[i];
781
+ dest = allocate_and_copy_struct_to_stack (&state, stack,
782
+ ty->alignment, s,
783
+ avalue[i]);
784
+ a = &dest;
716
785
  t = FFI_TYPE_POINTER;
717
786
  s = sizeof (void *);
718
787
  goto do_pointer;
@@ -769,6 +838,8 @@ ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
769
838
  ffi_call_int (cif, fn, rvalue, avalue, NULL);
770
839
  }
771
840
 
841
+ #if FFI_CLOSURES
842
+
772
843
  #ifdef FFI_GO_CLOSURES
773
844
  void
774
845
  ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
@@ -782,6 +853,10 @@ ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
782
853
 
783
854
  extern void ffi_closure_SYSV (void) FFI_HIDDEN;
784
855
  extern void ffi_closure_SYSV_V (void) FFI_HIDDEN;
856
+ #if defined(FFI_EXEC_STATIC_TRAMP)
857
+ extern void ffi_closure_SYSV_alt (void) FFI_HIDDEN;
858
+ extern void ffi_closure_SYSV_V_alt (void) FFI_HIDDEN;
859
+ #endif
785
860
 
786
861
  ffi_status
787
862
  ffi_prep_closure_loc (ffi_closure *closure,
@@ -790,25 +865,25 @@ ffi_prep_closure_loc (ffi_closure *closure,
790
865
  void *user_data,
791
866
  void *codeloc)
792
867
  {
793
- if (cif->abi != FFI_SYSV)
868
+ if (cif->abi != FFI_SYSV && cif->abi != FFI_WIN64)
794
869
  return FFI_BAD_ABI;
795
870
 
796
871
  void (*start)(void);
797
-
872
+
798
873
  if (cif->flags & AARCH64_FLAG_ARG_V)
799
874
  start = ffi_closure_SYSV_V;
800
875
  else
801
876
  start = ffi_closure_SYSV;
802
877
 
803
878
  #if FFI_EXEC_TRAMPOLINE_TABLE
804
- #ifdef __MACH__
805
- #ifdef HAVE_PTRAUTH
806
- codeloc = ptrauth_strip (codeloc, ptrauth_key_asia);
807
- #endif
879
+ # ifdef __MACH__
880
+ # ifdef HAVE_PTRAUTH
881
+ codeloc = ptrauth_auth_data(codeloc, ptrauth_key_function_pointer, 0);
882
+ # endif
808
883
  void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE);
809
884
  config[0] = closure;
810
885
  config[1] = start;
811
- #endif
886
+ # endif
812
887
  #else
813
888
  static const unsigned char trampoline[16] = {
814
889
  0x90, 0x00, 0x00, 0x58, /* ldr x16, tramp+16 */
@@ -816,22 +891,39 @@ ffi_prep_closure_loc (ffi_closure *closure,
816
891
  0x00, 0x02, 0x1f, 0xd6 /* br x16 */
817
892
  };
818
893
  char *tramp = closure->tramp;
819
-
894
+
895
+ # if defined(FFI_EXEC_STATIC_TRAMP)
896
+ if (ffi_tramp_is_present(closure))
897
+ {
898
+ /* Initialize the static trampoline's parameters. */
899
+ if (start == ffi_closure_SYSV_V)
900
+ start = ffi_closure_SYSV_V_alt;
901
+ else
902
+ start = ffi_closure_SYSV_alt;
903
+ ffi_tramp_set_parms (closure->ftramp, start, closure);
904
+ goto out;
905
+ }
906
+ # endif
907
+
908
+ /* Initialize the dynamic trampoline. */
820
909
  memcpy (tramp, trampoline, sizeof(trampoline));
821
-
910
+
822
911
  *(UINT64 *)(tramp + 16) = (uintptr_t)start;
823
912
 
824
913
  ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
825
914
 
826
915
  /* Also flush the cache for code mapping. */
827
- #ifdef _WIN32
916
+ # ifdef _WIN32
828
917
  // Not using dlmalloc.c for Windows ARM64 builds
829
918
  // so calling ffi_data_to_code_pointer() isn't necessary
830
919
  unsigned char *tramp_code = tramp;
831
- #else
920
+ # else
832
921
  unsigned char *tramp_code = ffi_data_to_code_pointer (tramp);
833
- #endif
922
+ # endif
834
923
  ffi_clear_cache (tramp_code, tramp_code + FFI_TRAMPOLINE_SIZE);
924
+ # if defined(FFI_EXEC_STATIC_TRAMP)
925
+ out:
926
+ # endif
835
927
  #endif
836
928
 
837
929
  closure->cif = cif;
@@ -851,7 +943,7 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif* cif,
851
943
  {
852
944
  void (*start)(void);
853
945
 
854
- if (cif->abi != FFI_SYSV)
946
+ if (cif->abi != FFI_SYSV && cif->abi != FFI_WIN64)
855
947
  return FFI_BAD_ABI;
856
948
 
857
949
  if (cif->flags & AARCH64_FLAG_ARG_V)
@@ -891,10 +983,17 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
891
983
  void *stack, void *rvalue, void *struct_rvalue)
892
984
  {
893
985
  void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
894
- int i, h, nargs, flags;
986
+ int i, h, nargs, flags, isvariadic = 0;
895
987
  struct arg_state state;
896
988
 
897
- arg_init (&state);
989
+ arg_init (&state, cif->bytes);
990
+
991
+ flags = cif->flags;
992
+ if (flags & AARCH64_FLAG_VARARG)
993
+ {
994
+ isvariadic = 1;
995
+ flags &= ~AARCH64_FLAG_VARARG;
996
+ }
898
997
 
899
998
  for (i = 0, nargs = cif->nargs; i < nargs; i++)
900
999
  {
@@ -930,14 +1029,13 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
930
1029
  if (h)
931
1030
  {
932
1031
  n = 4 - (h & 3);
933
- #ifdef _WIN32 /* for handling armasm calling convention */
934
- if (cif->is_variadic)
1032
+ if (cif->abi == FFI_WIN64 && isvariadic)
935
1033
  {
936
1034
  if (state.ngrn + n <= N_X_ARG_REG)
937
1035
  {
938
1036
  void *reg = &context->x[state.ngrn];
939
1037
  state.ngrn += (unsigned int)n;
940
-
1038
+
941
1039
  /* Eeek! We need a pointer to the structure, however the
942
1040
  homogeneous float elements are being passed in individual
943
1041
  registers, therefore for float and double the structure
@@ -957,7 +1055,6 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
957
1055
  }
958
1056
  else
959
1057
  {
960
- #endif /* for handling armasm calling convention */
961
1058
  if (state.nsrn + n <= N_V_ARG_REG)
962
1059
  {
963
1060
  void *reg = &context->v[state.nsrn];
@@ -970,17 +1067,24 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
970
1067
  avalue[i] = allocate_to_stack(&state, stack,
971
1068
  ty->alignment, s);
972
1069
  }
973
- #ifdef _WIN32 /* for handling armasm calling convention */
974
1070
  }
975
- #endif /* for handling armasm calling convention */
976
1071
  }
977
1072
  else if (s > 16)
978
1073
  {
979
1074
  /* Replace Composite type of size greater than 16 with a
980
1075
  pointer. */
1076
+ #ifdef __ILP32__
1077
+ UINT64 avalue_tmp;
1078
+ memcpy (&avalue_tmp,
1079
+ allocate_int_to_reg_or_stack (context, &state,
1080
+ stack, sizeof (void *)),
1081
+ sizeof (UINT64));
1082
+ avalue[i] = (void *)(UINT32)avalue_tmp;
1083
+ #else
981
1084
  avalue[i] = *(void **)
982
1085
  allocate_int_to_reg_or_stack (context, &state, stack,
983
1086
  sizeof (void *));
1087
+ #endif
984
1088
  }
985
1089
  else
986
1090
  {
@@ -1013,7 +1117,6 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
1013
1117
  #endif
1014
1118
  }
1015
1119
 
1016
- flags = cif->flags;
1017
1120
  if (flags & AARCH64_RET_IN_MEM)
1018
1121
  rvalue = struct_rvalue;
1019
1122
 
@@ -1022,4 +1125,18 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
1022
1125
  return flags;
1023
1126
  }
1024
1127
 
1128
+ #if defined(FFI_EXEC_STATIC_TRAMP)
1129
+ void *
1130
+ ffi_tramp_arch (size_t *tramp_size, size_t *map_size)
1131
+ {
1132
+ extern void *trampoline_code_table;
1133
+
1134
+ *tramp_size = AARCH64_TRAMP_SIZE;
1135
+ *map_size = AARCH64_TRAMP_MAP_SIZE;
1136
+ return &trampoline_code_table;
1137
+ }
1138
+ #endif
1139
+
1140
+ #endif /* FFI_CLOSURES */
1141
+
1025
1142
  #endif /* (__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)*/
@@ -66,3 +66,35 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
66
66
  #define N_X_ARG_REG 8
67
67
  #define N_V_ARG_REG 8
68
68
  #define CALL_CONTEXT_SIZE (N_V_ARG_REG * 16 + N_X_ARG_REG * 8)
69
+
70
+ #if defined(FFI_EXEC_STATIC_TRAMP)
71
+ /*
72
+ * For the trampoline code table mapping, a mapping size of 16K is chosen to
73
+ * cover the base page sizes of 4K and 16K.
74
+ */
75
+ #define AARCH64_TRAMP_MAP_SHIFT 14
76
+ #define AARCH64_TRAMP_MAP_SIZE (1 << AARCH64_TRAMP_MAP_SHIFT)
77
+ #define AARCH64_TRAMP_SIZE 32
78
+
79
+ #endif
80
+
81
+ /* Helpers for writing assembly compatible with arm ptr auth */
82
+ #ifdef LIBFFI_ASM
83
+
84
+ #ifdef HAVE_PTRAUTH
85
+ #define SIGN_LR pacibsp
86
+ #define SIGN_LR_WITH_REG(x) pacib lr, x
87
+ #define AUTH_LR_AND_RET retab
88
+ #define AUTH_LR_WITH_REG(x) autib lr, x
89
+ #define BRANCH_AND_LINK_TO_REG blraaz
90
+ #define BRANCH_TO_REG braaz
91
+ #else
92
+ #define SIGN_LR
93
+ #define SIGN_LR_WITH_REG(x)
94
+ #define AUTH_LR_AND_RET ret
95
+ #define AUTH_LR_WITH_REG(x)
96
+ #define BRANCH_AND_LINK_TO_REG blr
97
+ #define BRANCH_TO_REG br
98
+ #endif
99
+
100
+ #endif