ffi 1.15.5 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +54 -0
  4. data/Gemfile +1 -1
  5. data/README.md +3 -2
  6. data/Rakefile +10 -7
  7. data/ext/ffi_c/AbstractMemory.c +56 -34
  8. data/ext/ffi_c/AbstractMemory.h +3 -2
  9. data/ext/ffi_c/ArrayType.c +49 -13
  10. data/ext/ffi_c/ArrayType.h +1 -0
  11. data/ext/ffi_c/Buffer.c +86 -29
  12. data/ext/ffi_c/Call.c +13 -5
  13. data/ext/ffi_c/DynamicLibrary.c +89 -26
  14. data/ext/ffi_c/Function.c +238 -98
  15. data/ext/ffi_c/Function.h +1 -0
  16. data/ext/ffi_c/FunctionInfo.c +78 -24
  17. data/ext/ffi_c/LastError.c +25 -7
  18. data/ext/ffi_c/MappedType.c +66 -23
  19. data/ext/ffi_c/MappedType.h +0 -2
  20. data/ext/ffi_c/MemoryPointer.c +34 -7
  21. data/ext/ffi_c/MethodHandle.c +3 -1
  22. data/ext/ffi_c/Pointer.c +68 -29
  23. data/ext/ffi_c/Pointer.h +1 -0
  24. data/ext/ffi_c/Struct.c +151 -80
  25. data/ext/ffi_c/Struct.h +7 -4
  26. data/ext/ffi_c/StructByValue.c +48 -16
  27. data/ext/ffi_c/StructLayout.c +117 -48
  28. data/ext/ffi_c/Type.c +104 -36
  29. data/ext/ffi_c/Type.h +3 -1
  30. data/ext/ffi_c/Types.c +1 -1
  31. data/ext/ffi_c/Variadic.c +65 -23
  32. data/ext/ffi_c/compat.h +22 -22
  33. data/ext/ffi_c/extconf.rb +19 -2
  34. data/ext/ffi_c/ffi.c +4 -0
  35. data/ext/ffi_c/libffi/.appveyor/site.exp +16 -0
  36. data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +7 -0
  37. data/ext/ffi_c/libffi/.appveyor.yml +27 -9
  38. data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
  39. data/ext/ffi_c/libffi/{.travis → .ci}/build-in-container.sh +4 -6
  40. data/ext/ffi_c/libffi/.ci/build.sh +124 -0
  41. data/ext/ffi_c/libffi/{.travis → .ci}/install.sh +14 -7
  42. data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
  43. data/ext/ffi_c/libffi/{.travis → .ci}/site.exp +5 -3
  44. data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
  45. data/ext/ffi_c/libffi/.github/workflows/build.yml +460 -0
  46. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +171 -0
  47. data/ext/ffi_c/libffi/.gitignore +10 -2
  48. data/ext/ffi_c/libffi/LICENSE +1 -1
  49. data/ext/ffi_c/libffi/Makefile.am +12 -5
  50. data/ext/ffi_c/libffi/Makefile.in +118 -51
  51. data/ext/ffi_c/libffi/README.md +144 -104
  52. data/ext/ffi_c/libffi/acinclude.m4 +10 -112
  53. data/ext/ffi_c/libffi/config.guess +623 -556
  54. data/ext/ffi_c/libffi/config.sub +75 -34
  55. data/ext/ffi_c/libffi/configure +4571 -3830
  56. data/ext/ffi_c/libffi/configure.ac +64 -28
  57. data/ext/ffi_c/libffi/configure.host +25 -6
  58. data/ext/ffi_c/libffi/doc/Makefile.in +9 -6
  59. data/ext/ffi_c/libffi/doc/libffi.texi +82 -33
  60. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  61. data/ext/ffi_c/libffi/fficonfig.h.in +12 -47
  62. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +163 -52
  63. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  64. data/ext/ffi_c/libffi/include/Makefile.in +10 -9
  65. data/ext/ffi_c/libffi/include/ffi.h.in +54 -50
  66. data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
  67. data/ext/ffi_c/libffi/include/ffi_common.h +29 -0
  68. data/ext/ffi_c/libffi/include/tramp.h +45 -0
  69. data/ext/ffi_c/libffi/install-sh +92 -69
  70. data/ext/ffi_c/libffi/libtool-version +2 -2
  71. data/ext/ffi_c/libffi/ltmain.sh +512 -315
  72. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +18 -14
  73. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
  74. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -45
  75. data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
  76. data/ext/ffi_c/libffi/man/Makefile.in +9 -6
  77. data/ext/ffi_c/libffi/missing +1 -1
  78. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +1 -1
  79. data/ext/ffi_c/libffi/msvcc.sh +1 -1
  80. data/ext/ffi_c/libffi/src/aarch64/ffi.c +146 -42
  81. data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
  82. data/ext/ffi_c/libffi/src/aarch64/sysv.S +134 -42
  83. data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
  84. data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
  85. data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
  86. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -17
  87. data/ext/ffi_c/libffi/src/arm/ffitarget.h +3 -3
  88. data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
  89. data/ext/ffi_c/libffi/src/arm/sysv.S +113 -42
  90. data/ext/ffi_c/libffi/src/closures.c +133 -47
  91. data/ext/ffi_c/libffi/src/dlmalloc.c +5 -0
  92. data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
  93. data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
  94. data/ext/ffi_c/libffi/src/loongarch64/ffi.c +621 -0
  95. data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
  96. data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
  97. data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
  98. data/ext/ffi_c/libffi/src/mips/ffi.c +240 -65
  99. data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
  100. data/ext/ffi_c/libffi/src/mips/n32.S +137 -28
  101. data/ext/ffi_c/libffi/src/mips/o32.S +61 -4
  102. data/ext/ffi_c/libffi/src/moxie/ffi.c +47 -22
  103. data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
  104. data/ext/ffi_c/libffi/src/pa/ffi.c +32 -33
  105. data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
  106. data/ext/ffi_c/libffi/src/pa/ffitarget.h +22 -8
  107. data/ext/ffi_c/libffi/src/pa/hpux32.S +83 -36
  108. data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
  109. data/ext/ffi_c/libffi/src/pa/linux.S +82 -35
  110. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1 -1
  111. data/ext/ffi_c/libffi/src/powerpc/linux64.S +2 -0
  112. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +2 -0
  113. data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
  114. data/ext/ffi_c/libffi/src/prep_cif.c +22 -2
  115. data/ext/ffi_c/libffi/src/riscv/ffi.c +37 -4
  116. data/ext/ffi_c/libffi/src/sparc/ffi64.c +16 -0
  117. data/ext/ffi_c/libffi/src/tramp.c +716 -0
  118. data/ext/ffi_c/libffi/src/wasm32/ffi.c +934 -0
  119. data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
  120. data/ext/ffi_c/libffi/src/x86/ffi.c +99 -37
  121. data/ext/ffi_c/libffi/src/x86/ffi64.c +67 -12
  122. data/ext/ffi_c/libffi/src/x86/ffitarget.h +9 -5
  123. data/ext/ffi_c/libffi/src/x86/ffiw64.c +43 -0
  124. data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
  125. data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
  126. data/ext/ffi_c/libffi/src/x86/sysv.S +172 -38
  127. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +91 -88
  128. data/ext/ffi_c/libffi/src/x86/unix64.S +96 -6
  129. data/ext/ffi_c/libffi/src/x86/win64.S +20 -7
  130. data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
  131. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
  132. data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
  133. data/ext/ffi_c/libffi/testsuite/Makefile.am +127 -114
  134. data/ext/ffi_c/libffi/testsuite/Makefile.in +137 -121
  135. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
  136. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
  137. data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +80 -0
  138. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
  139. data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
  140. data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
  141. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +43 -21
  142. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
  143. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -0
  144. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
  145. data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
  154. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
  155. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
  156. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
  172. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn0.c +3 -2
  173. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +2 -0
  174. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +2 -0
  175. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +21 -1
  176. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +2 -0
  177. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +2 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +2 -0
  179. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +7 -6
  180. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +6 -0
  181. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +18 -0
  182. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +22 -0
  183. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +24 -0
  184. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +29 -0
  185. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +4 -0
  186. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +19 -1
  187. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +21 -1
  188. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +35 -3
  189. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +13 -0
  190. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +19 -0
  191. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +13 -0
  192. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +13 -0
  193. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +18 -0
  194. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +22 -0
  195. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +13 -0
  196. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +29 -1
  197. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +19 -1
  198. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +24 -0
  199. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +28 -1
  200. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +24 -2
  201. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +39 -1
  202. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +25 -1
  203. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +14 -0
  204. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +14 -1
  205. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +14 -2
  206. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +19 -1
  207. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +19 -1
  208. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +20 -1
  209. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +40 -25
  210. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +40 -3
  211. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +19 -1
  212. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +18 -1
  213. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +18 -3
  214. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +18 -1
  215. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +18 -1
  216. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +19 -1
  217. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +19 -1
  218. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +3 -1
  219. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +9 -1
  220. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +4 -0
  221. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +11 -1
  222. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +22 -3
  223. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +5 -1
  224. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +6 -1
  225. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +9 -1
  226. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +9 -1
  227. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +6 -2
  228. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +9 -1
  229. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +5 -0
  230. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +10 -0
  231. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +3 -0
  232. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +2 -0
  233. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +3 -0
  234. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +11 -0
  235. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +3 -0
  236. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +4 -0
  237. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +4 -0
  238. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +4 -0
  239. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +2 -0
  240. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +3 -0
  241. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -138
  242. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +21 -21
  243. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +32 -9
  244. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +1 -1
  245. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +12 -0
  246. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +21 -5
  247. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
  248. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
  249. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct2.c +10 -1
  250. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +10 -1
  251. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +9 -0
  252. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +9 -0
  253. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +11 -0
  254. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +9 -0
  255. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +11 -0
  256. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct9.c +11 -0
  257. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
  258. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
  259. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
  260. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium.c +1 -1
  261. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +1 -1
  262. data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +6 -1
  263. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -1
  264. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +1 -0
  265. data/ext/ffi_c/libffi.bsd.mk +2 -2
  266. data/ext/ffi_c/libffi.gnu.mk +2 -2
  267. data/ext/ffi_c/rbffi.h +1 -1
  268. data/ffi.gemspec +2 -2
  269. data/lib/ffi/autopointer.rb +7 -22
  270. data/lib/ffi/compat.rb +43 -0
  271. data/lib/ffi/data_converter.rb +2 -2
  272. data/lib/ffi/dynamic_library.rb +89 -0
  273. data/lib/ffi/enum.rb +18 -11
  274. data/lib/ffi/ffi.rb +3 -0
  275. data/lib/ffi/function.rb +71 -0
  276. data/lib/ffi/library.rb +55 -71
  277. data/lib/ffi/library_path.rb +109 -0
  278. data/lib/ffi/managedstruct.rb +1 -1
  279. data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
  280. data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
  281. data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
  282. data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
  283. data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
  284. data/lib/ffi/platform.rb +15 -13
  285. data/lib/ffi/struct.rb +2 -1
  286. data/lib/ffi/struct_layout.rb +1 -1
  287. data/lib/ffi/struct_layout_builder.rb +1 -1
  288. data/lib/ffi/types.rb +30 -5
  289. data/lib/ffi/variadic.rb +19 -8
  290. data/lib/ffi/version.rb +1 -1
  291. data.tar.gz.sig +0 -0
  292. metadata +97 -25
  293. metadata.gz.sig +1 -0
  294. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
  295. data/ext/ffi_c/libffi/.travis/build.sh +0 -142
  296. data/ext/ffi_c/libffi/.travis.yml +0 -83
  297. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
  298. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
  299. /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
  300. /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
  301. /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
  302. /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
  303. /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
  304. /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
  305. /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
  306. /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
  307. /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  308. /data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +0 -0
@@ -0,0 +1,716 @@
1
+ /* -----------------------------------------------------------------------
2
+ tramp.c - Copyright (c) 2020 Madhavan T. Venkataraman
3
+ Copyright (c) 2022 Anthony Green
4
+
5
+ API and support functions for managing statically defined closure
6
+ trampolines.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining
9
+ a copy of this software and associated documentation files (the
10
+ ``Software''), to deal in the Software without restriction, including
11
+ without limitation the rights to use, copy, modify, merge, publish,
12
+ distribute, sublicense, and/or sell copies of the Software, and to
13
+ permit persons to whom the Software is furnished to do so, subject to
14
+ the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included
17
+ in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
20
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
+ DEALINGS IN THE SOFTWARE.
27
+ ----------------------------------------------------------------------- */
28
+
29
+ #include <fficonfig.h>
30
+
31
+ #ifdef FFI_EXEC_STATIC_TRAMP
32
+
33
+ /* -------------------------- Headers and Definitions ---------------------*/
34
+ /*
35
+ * Add support for other OSes later. For now, it is just Linux and Cygwin.
36
+ */
37
+
38
+ #if defined (__linux__) || defined (__CYGWIN__)
39
+ #ifdef __linux__
40
+ #define _GNU_SOURCE 1
41
+ #endif
42
+
43
+ #include <ffi.h>
44
+ #include <ffi_common.h>
45
+
46
+ #include <stdio.h>
47
+ #include <unistd.h>
48
+ #include <stdlib.h>
49
+ #include <stdint.h>
50
+ #include <fcntl.h>
51
+ #include <pthread.h>
52
+ #include <sys/mman.h>
53
+ #include <tramp.h>
54
+ #ifdef __linux__
55
+ #include <linux/limits.h>
56
+ #include <linux/types.h>
57
+ #endif
58
+ #ifdef __CYGWIN__
59
+ #include <limits.h>
60
+ #endif
61
+ #endif
62
+
63
+ /*
64
+ * Each architecture defines static code for a trampoline code table. The
65
+ * trampoline code table is mapped into the address space of a process.
66
+ *
67
+ * The following architecture specific function returns:
68
+ *
69
+ * - the address of the trampoline code table in the text segment
70
+ * - the size of each trampoline in the trampoline code table
71
+ * - the size of the mapping for the whole trampoline code table
72
+ */
73
+ void __attribute__((weak)) *ffi_tramp_arch (size_t *tramp_size,
74
+ size_t *map_size);
75
+
76
+ /* ------------------------- Trampoline Data Structures --------------------*/
77
+
78
+ struct tramp;
79
+
80
+ /*
81
+ * Trampoline table. Manages one trampoline code table and one trampoline
82
+ * parameter table.
83
+ *
84
+ * prev, next Links in the global trampoline table list.
85
+ * code_table Trampoline code table mapping.
86
+ * parm_table Trampoline parameter table mapping.
87
+ * array Array of trampolines malloced.
88
+ * free List of free trampolines.
89
+ * nfree Number of free trampolines.
90
+ */
91
+ struct tramp_table
92
+ {
93
+ struct tramp_table *prev;
94
+ struct tramp_table *next;
95
+ void *code_table;
96
+ void *parm_table;
97
+ struct tramp *array;
98
+ struct tramp *free;
99
+ int nfree;
100
+ };
101
+
102
+ /*
103
+ * Parameters for each trampoline.
104
+ *
105
+ * data
106
+ * Data for the target code that the trampoline jumps to.
107
+ * target
108
+ * Target code that the trampoline jumps to.
109
+ */
110
+ struct tramp_parm
111
+ {
112
+ void *data;
113
+ void *target;
114
+ };
115
+
116
+ /*
117
+ * Trampoline structure for each trampoline.
118
+ *
119
+ * prev, next Links in the trampoline free list of a trampoline table.
120
+ * table Trampoline table to which this trampoline belongs.
121
+ * code Address of this trampoline in the code table mapping.
122
+ * parm Address of this trampoline's parameters in the parameter
123
+ * table mapping.
124
+ */
125
+ struct tramp
126
+ {
127
+ struct tramp *prev;
128
+ struct tramp *next;
129
+ struct tramp_table *table;
130
+ void *code;
131
+ struct tramp_parm *parm;
132
+ };
133
+
134
+ enum tramp_globals_status {
135
+ TRAMP_GLOBALS_UNINITIALIZED = 0,
136
+ TRAMP_GLOBALS_PASSED,
137
+ TRAMP_GLOBALS_FAILED,
138
+ };
139
+
140
+ /*
141
+ * Trampoline globals.
142
+ *
143
+ * fd
144
+ * File descriptor of binary file that contains the trampoline code table.
145
+ * offset
146
+ * Offset of the trampoline code table in that file.
147
+ * text
148
+ * Address of the trampoline code table in the text segment.
149
+ * map_size
150
+ * Size of the trampoline code table mapping.
151
+ * size
152
+ * Size of one trampoline in the trampoline code table.
153
+ * ntramp
154
+ * Total number of trampolines in the trampoline code table.
155
+ * free_tables
156
+ * List of trampoline tables that contain free trampolines.
157
+ * nfree_tables
158
+ * Number of trampoline tables that contain free trampolines.
159
+ * status
160
+ * Initialization status.
161
+ */
162
+ struct tramp_globals
163
+ {
164
+ int fd;
165
+ off_t offset;
166
+ void *text;
167
+ size_t map_size;
168
+ size_t size;
169
+ int ntramp;
170
+ struct tramp_table *free_tables;
171
+ int nfree_tables;
172
+ enum tramp_globals_status status;
173
+ };
174
+
175
+ static struct tramp_globals tramp_globals;
176
+
177
+ /* --------------------- Trampoline File Initialization --------------------*/
178
+
179
+ /*
180
+ * The trampoline file is the file used to map the trampoline code table into
181
+ * the address space of a process. There are two ways to get this file:
182
+ *
183
+ * - From the OS. E.g., on Linux, /proc/<pid>/maps lists all the memory
184
+ * mappings for <pid>. For file-backed mappings, maps supplies the file name
185
+ * and the file offset. Using this, we can locate the mapping that maps
186
+ * libffi and get the path to the libffi binary. And, we can compute the
187
+ * offset of the trampoline code table within that binary.
188
+ *
189
+ * - Else, if we can create a temporary file, we can write the trampoline code
190
+ * table from the text segment into the temporary file.
191
+ *
192
+ * The first method is the preferred one. If the OS security subsystem
193
+ * disallows mapping unsigned files with PROT_EXEC, then the second method
194
+ * will fail.
195
+ *
196
+ * If an OS allows the trampoline code table in the text segment to be
197
+ * directly remapped (e.g., MACH vm_remap ()), then we don't need the
198
+ * trampoline file.
199
+ */
200
+ static int tramp_table_alloc (void);
201
+
202
+ #if defined (__linux__) || defined (__CYGWIN__)
203
+
204
+ static int
205
+ ffi_tramp_get_libffi (void)
206
+ {
207
+ FILE *fp;
208
+ char file[PATH_MAX], line[PATH_MAX+100], perm[10], dev[10];
209
+ unsigned long start, end, offset, inode;
210
+ uintptr_t addr = (uintptr_t) tramp_globals.text;
211
+ int nfields, found;
212
+
213
+ snprintf (file, PATH_MAX, "/proc/%d/maps", getpid());
214
+ fp = fopen (file, "r");
215
+ if (fp == NULL)
216
+ return 0;
217
+
218
+ found = 0;
219
+ while (feof (fp) == 0) {
220
+ if (fgets (line, sizeof (line), fp) == 0)
221
+ break;
222
+
223
+ nfields = sscanf (line, "%lx-%lx %9s %lx %9s %ld %s",
224
+ &start, &end, perm, &offset, dev, &inode, file);
225
+ if (nfields != 7)
226
+ continue;
227
+
228
+ if (addr >= start && addr < end) {
229
+ tramp_globals.offset = offset + (addr - start);
230
+ found = 1;
231
+ break;
232
+ }
233
+ }
234
+ fclose (fp);
235
+
236
+ if (!found)
237
+ return 0;
238
+
239
+ tramp_globals.fd = open (file, O_RDONLY);
240
+ if (tramp_globals.fd == -1)
241
+ return 0;
242
+
243
+ /*
244
+ * Allocate a trampoline table just to make sure that the trampoline code
245
+ * table can be mapped.
246
+ */
247
+ if (!tramp_table_alloc ())
248
+ {
249
+ close (tramp_globals.fd);
250
+ tramp_globals.fd = -1;
251
+ return 0;
252
+ }
253
+ return 1;
254
+ }
255
+
256
+ #endif /* defined (__linux__) || defined (__CYGWIN__) */
257
+
258
+ #if defined (__linux__) || defined (__CYGWIN__)
259
+
260
+ static int
261
+ ffi_tramp_get_temp_file (void)
262
+ {
263
+ ssize_t count;
264
+
265
+ tramp_globals.offset = 0;
266
+ tramp_globals.fd = open_temp_exec_file ();
267
+
268
+ /*
269
+ * Write the trampoline code table into the temporary file and allocate a
270
+ * trampoline table to make sure that the temporary file can be mapped.
271
+ */
272
+ count = write(tramp_globals.fd, tramp_globals.text, tramp_globals.map_size);
273
+ if (count >=0 && (size_t)count == tramp_globals.map_size && tramp_table_alloc ())
274
+ return 1;
275
+
276
+ close (tramp_globals.fd);
277
+ tramp_globals.fd = -1;
278
+ return 0;
279
+ }
280
+
281
+ #endif /* defined (__linux__) || defined (__CYGWIN__) */
282
+
283
+ /* ------------------------ OS-specific Initialization ----------------------*/
284
+
285
+ #if defined (__linux__) || defined (__CYGWIN__)
286
+
287
+ static int
288
+ ffi_tramp_init_os (void)
289
+ {
290
+ if (ffi_tramp_get_libffi ())
291
+ return 1;
292
+ return ffi_tramp_get_temp_file ();
293
+ }
294
+
295
+ #endif /* defined (__linux__) || defined (__CYGWIN__) */
296
+
297
+ /* --------------------------- OS-specific Locking -------------------------*/
298
+
299
+ #if defined (__linux__) || defined (__CYGWIN__)
300
+
301
+ static pthread_mutex_t tramp_globals_mutex = PTHREAD_MUTEX_INITIALIZER;
302
+
303
+ static void
304
+ ffi_tramp_lock(void)
305
+ {
306
+ pthread_mutex_lock (&tramp_globals_mutex);
307
+ }
308
+
309
+ static void
310
+ ffi_tramp_unlock()
311
+ {
312
+ pthread_mutex_unlock (&tramp_globals_mutex);
313
+ }
314
+
315
+ #endif /* defined (__linux__) || defined (__CYGWIN__) */
316
+
317
+ /* ------------------------ OS-specific Memory Mapping ----------------------*/
318
+
319
+ /*
320
+ * Create a trampoline code table mapping and a trampoline parameter table
321
+ * mapping. The two mappings must be adjacent to each other for PC-relative
322
+ * access.
323
+ *
324
+ * For each trampoline in the code table, there is a corresponding parameter
325
+ * block in the parameter table. The size of the parameter block is the same
326
+ * as the size of the trampoline. This means that the parameter block is at
327
+ * a fixed offset from its trampoline making it easy for a trampoline to find
328
+ * its parameters using PC-relative access.
329
+ *
330
+ * The parameter block will contain a struct tramp_parm. This means that
331
+ * sizeof (struct tramp_parm) cannot exceed the size of a parameter block.
332
+ */
333
+
334
+ #if defined (__linux__) || defined (__CYGWIN__)
335
+
336
+ static int
337
+ tramp_table_map (struct tramp_table *table)
338
+ {
339
+ char *addr;
340
+
341
+ /*
342
+ * Create an anonymous mapping twice the map size. The top half will be used
343
+ * for the code table. The bottom half will be used for the parameter table.
344
+ */
345
+ addr = mmap (NULL, tramp_globals.map_size * 2, PROT_READ | PROT_WRITE,
346
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
347
+ if (addr == MAP_FAILED)
348
+ return 0;
349
+
350
+ /*
351
+ * Replace the top half of the anonymous mapping with the code table mapping.
352
+ */
353
+ table->code_table = mmap (addr, tramp_globals.map_size, PROT_READ | PROT_EXEC,
354
+ MAP_PRIVATE | MAP_FIXED, tramp_globals.fd, tramp_globals.offset);
355
+ if (table->code_table == MAP_FAILED)
356
+ {
357
+ (void) munmap (addr, tramp_globals.map_size * 2);
358
+ return 0;
359
+ }
360
+ table->parm_table = table->code_table + tramp_globals.map_size;
361
+ return 1;
362
+ }
363
+
364
+ static void
365
+ tramp_table_unmap (struct tramp_table *table)
366
+ {
367
+ (void) munmap (table->code_table, tramp_globals.map_size);
368
+ (void) munmap (table->parm_table, tramp_globals.map_size);
369
+ }
370
+
371
+ #endif /* defined (__linux__) || defined (__CYGWIN__) */
372
+
373
+ /* ------------------------ Trampoline Initialization ----------------------*/
374
+
375
+ /*
376
+ * Initialize the static trampoline feature.
377
+ */
378
+ static int
379
+ ffi_tramp_init (void)
380
+ {
381
+ long page_size;
382
+
383
+ if (tramp_globals.status == TRAMP_GLOBALS_PASSED)
384
+ return 1;
385
+
386
+ if (tramp_globals.status == TRAMP_GLOBALS_FAILED)
387
+ return 0;
388
+
389
+ if (ffi_tramp_arch == NULL)
390
+ {
391
+ tramp_globals.status = TRAMP_GLOBALS_FAILED;
392
+ return 0;
393
+ }
394
+
395
+ tramp_globals.free_tables = NULL;
396
+ tramp_globals.nfree_tables = 0;
397
+
398
+ /*
399
+ * Get trampoline code table information from the architecture.
400
+ */
401
+ tramp_globals.text = ffi_tramp_arch (&tramp_globals.size,
402
+ &tramp_globals.map_size);
403
+ tramp_globals.ntramp = tramp_globals.map_size / tramp_globals.size;
404
+
405
+ page_size = sysconf (_SC_PAGESIZE);
406
+ if (page_size >= 0 && (size_t)page_size > tramp_globals.map_size)
407
+ return 0;
408
+
409
+ if (ffi_tramp_init_os ())
410
+ {
411
+ tramp_globals.status = TRAMP_GLOBALS_PASSED;
412
+ return 1;
413
+ }
414
+
415
+ tramp_globals.status = TRAMP_GLOBALS_FAILED;
416
+ return 0;
417
+ }
418
+
419
+ /* ---------------------- Trampoline Table functions ---------------------- */
420
+
421
+ /* This code assumes that malloc () is available on all OSes. */
422
+
423
+ static void tramp_add (struct tramp *tramp);
424
+
425
+ /*
426
+ * Allocate and initialize a trampoline table.
427
+ */
428
+ static int
429
+ tramp_table_alloc (void)
430
+ {
431
+ struct tramp_table *table;
432
+ struct tramp *tramp_array, *tramp;
433
+ size_t size;
434
+ char *code, *parm;
435
+ int i;
436
+
437
+ /*
438
+ * If we already have tables with free trampolines, there is no need to
439
+ * allocate a new table.
440
+ */
441
+ if (tramp_globals.nfree_tables > 0)
442
+ return 1;
443
+
444
+ /*
445
+ * Allocate a new trampoline table structure.
446
+ */
447
+ table = malloc (sizeof (*table));
448
+ if (table == NULL)
449
+ return 0;
450
+
451
+ /*
452
+ * Allocate new trampoline structures.
453
+ */
454
+ tramp_array = malloc (sizeof (*tramp) * tramp_globals.ntramp);
455
+ if (tramp_array == NULL)
456
+ goto free_table;
457
+
458
+ /*
459
+ * Map a code table and a parameter table into the caller's address space.
460
+ */
461
+ if (!tramp_table_map (table))
462
+ {
463
+ /*
464
+ * Failed to map the code and parameter tables.
465
+ */
466
+ goto free_tramp_array;
467
+ }
468
+
469
+ /*
470
+ * Initialize the trampoline table.
471
+ */
472
+ table->array = tramp_array;
473
+ table->free = NULL;
474
+ table->nfree = 0;
475
+
476
+ /*
477
+ * Populate the trampoline table free list. This will also add the trampoline
478
+ * table to the global list of trampoline tables.
479
+ */
480
+ size = tramp_globals.size;
481
+ code = table->code_table;
482
+ parm = table->parm_table;
483
+ for (i = 0; i < tramp_globals.ntramp; i++)
484
+ {
485
+ tramp = &tramp_array[i];
486
+ tramp->table = table;
487
+ tramp->code = code;
488
+ tramp->parm = (struct tramp_parm *) parm;
489
+ tramp_add (tramp);
490
+
491
+ code += size;
492
+ parm += size;
493
+ }
494
+ /* Success */
495
+ return 1;
496
+
497
+ /* Failure */
498
+ free_tramp_array:
499
+ free (tramp_array);
500
+ free_table:
501
+ free (table);
502
+ return 0;
503
+ }
504
+
505
+ /*
506
+ * Free a trampoline table.
507
+ */
508
+ static void
509
+ tramp_table_free (struct tramp_table *table)
510
+ {
511
+ tramp_table_unmap (table);
512
+ free (table->array);
513
+ free (table);
514
+ }
515
+
516
+ /*
517
+ * Add a new trampoline table to the global table list.
518
+ */
519
+ static void
520
+ tramp_table_add (struct tramp_table *table)
521
+ {
522
+ table->next = tramp_globals.free_tables;
523
+ table->prev = NULL;
524
+ if (tramp_globals.free_tables != NULL)
525
+ tramp_globals.free_tables->prev = table;
526
+ tramp_globals.free_tables = table;
527
+ tramp_globals.nfree_tables++;
528
+ }
529
+
530
+ /*
531
+ * Delete a trampoline table from the global table list.
532
+ */
533
+ static void
534
+ tramp_table_del (struct tramp_table *table)
535
+ {
536
+ tramp_globals.nfree_tables--;
537
+ if (table->prev != NULL)
538
+ table->prev->next = table->next;
539
+ if (table->next != NULL)
540
+ table->next->prev = table->prev;
541
+ if (tramp_globals.free_tables == table)
542
+ tramp_globals.free_tables = table->next;
543
+ }
544
+
545
+ /* ------------------------- Trampoline functions ------------------------- */
546
+
547
+ /*
548
+ * Add a trampoline to its trampoline table.
549
+ */
550
+ static void
551
+ tramp_add (struct tramp *tramp)
552
+ {
553
+ struct tramp_table *table = tramp->table;
554
+
555
+ tramp->next = table->free;
556
+ tramp->prev = NULL;
557
+ if (table->free != NULL)
558
+ table->free->prev = tramp;
559
+ table->free = tramp;
560
+ table->nfree++;
561
+
562
+ if (table->nfree == 1)
563
+ tramp_table_add (table);
564
+
565
+ /*
566
+ * We don't want to keep too many free trampoline tables lying around.
567
+ */
568
+ if (table->nfree == tramp_globals.ntramp &&
569
+ tramp_globals.nfree_tables > 1)
570
+ {
571
+ tramp_table_del (table);
572
+ tramp_table_free (table);
573
+ }
574
+ }
575
+
576
+ /*
577
+ * Remove a trampoline from its trampoline table.
578
+ */
579
+ static void
580
+ tramp_del (struct tramp *tramp)
581
+ {
582
+ struct tramp_table *table = tramp->table;
583
+
584
+ table->nfree--;
585
+ if (tramp->prev != NULL)
586
+ tramp->prev->next = tramp->next;
587
+ if (tramp->next != NULL)
588
+ tramp->next->prev = tramp->prev;
589
+ if (table->free == tramp)
590
+ table->free = tramp->next;
591
+
592
+ if (table->nfree == 0)
593
+ tramp_table_del (table);
594
+ }
595
+
596
+ /* ------------------------ Trampoline API functions ------------------------ */
597
+
598
+ int
599
+ ffi_tramp_is_supported(void)
600
+ {
601
+ int ret;
602
+
603
+ ffi_tramp_lock();
604
+ ret = ffi_tramp_init ();
605
+ ffi_tramp_unlock();
606
+ return ret;
607
+ }
608
+
609
+ /*
610
+ * Allocate a trampoline and return its opaque address.
611
+ */
612
+ void *
613
+ ffi_tramp_alloc (int flags)
614
+ {
615
+ struct tramp *tramp;
616
+
617
+ ffi_tramp_lock();
618
+
619
+ if (!ffi_tramp_init () || flags != 0)
620
+ {
621
+ ffi_tramp_unlock();
622
+ return NULL;
623
+ }
624
+
625
+ if (!tramp_table_alloc ())
626
+ {
627
+ ffi_tramp_unlock();
628
+ return NULL;
629
+ }
630
+
631
+ tramp = tramp_globals.free_tables->free;
632
+ tramp_del (tramp);
633
+
634
+ ffi_tramp_unlock();
635
+
636
+ return tramp;
637
+ }
638
+
639
+ /*
640
+ * Set the parameters for a trampoline.
641
+ */
642
+ void
643
+ ffi_tramp_set_parms (void *arg, void *target, void *data)
644
+ {
645
+ struct tramp *tramp = arg;
646
+
647
+ ffi_tramp_lock();
648
+ tramp->parm->target = target;
649
+ tramp->parm->data = data;
650
+ ffi_tramp_unlock();
651
+ }
652
+
653
+ /*
654
+ * Get the invocation address of a trampoline.
655
+ */
656
+ void *
657
+ ffi_tramp_get_addr (void *arg)
658
+ {
659
+ struct tramp *tramp = arg;
660
+ void *addr;
661
+
662
+ ffi_tramp_lock();
663
+ addr = tramp->code;
664
+ ffi_tramp_unlock();
665
+
666
+ return addr;
667
+ }
668
+
669
+ /*
670
+ * Free a trampoline.
671
+ */
672
+ void
673
+ ffi_tramp_free (void *arg)
674
+ {
675
+ struct tramp *tramp = arg;
676
+
677
+ ffi_tramp_lock();
678
+ tramp_add (tramp);
679
+ ffi_tramp_unlock();
680
+ }
681
+
682
+ /* ------------------------------------------------------------------------- */
683
+
684
+ #else /* !FFI_EXEC_STATIC_TRAMP */
685
+
686
+ #include <stddef.h>
687
+
688
+ int
689
+ ffi_tramp_is_supported(void)
690
+ {
691
+ return 0;
692
+ }
693
+
694
+ void *
695
+ ffi_tramp_alloc (int flags)
696
+ {
697
+ return NULL;
698
+ }
699
+
700
+ void
701
+ ffi_tramp_set_parms (void *arg, void *target, void *data)
702
+ {
703
+ }
704
+
705
+ void *
706
+ ffi_tramp_get_addr (void *arg)
707
+ {
708
+ return NULL;
709
+ }
710
+
711
+ void
712
+ ffi_tramp_free (void *arg)
713
+ {
714
+ }
715
+
716
+ #endif /* FFI_EXEC_STATIC_TRAMP */