ffi 1.15.5 → 1.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +61 -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/compile +347 -0
  54. data/ext/ffi_c/libffi/config.guess +623 -556
  55. data/ext/ffi_c/libffi/config.sub +75 -34
  56. data/ext/ffi_c/libffi/configure +4571 -3830
  57. data/ext/ffi_c/libffi/configure.ac +64 -28
  58. data/ext/ffi_c/libffi/configure.host +25 -6
  59. data/ext/ffi_c/libffi/doc/Makefile.in +9 -6
  60. data/ext/ffi_c/libffi/doc/libffi.texi +82 -33
  61. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  62. data/ext/ffi_c/libffi/fficonfig.h.in +12 -47
  63. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +163 -52
  64. data/ext/ffi_c/libffi/include/Makefile.am +1 -1
  65. data/ext/ffi_c/libffi/include/Makefile.in +10 -9
  66. data/ext/ffi_c/libffi/include/ffi.h.in +54 -50
  67. data/ext/ffi_c/libffi/include/ffi_cfi.h +21 -0
  68. data/ext/ffi_c/libffi/include/ffi_common.h +29 -0
  69. data/ext/ffi_c/libffi/include/tramp.h +45 -0
  70. data/ext/ffi_c/libffi/install-sh +92 -69
  71. data/ext/ffi_c/libffi/libtool-version +2 -2
  72. data/ext/ffi_c/libffi/ltmain.sh +512 -315
  73. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +18 -14
  74. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +108 -72
  75. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +76 -45
  76. data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
  77. data/ext/ffi_c/libffi/man/Makefile.in +9 -6
  78. data/ext/ffi_c/libffi/missing +1 -1
  79. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +1 -1
  80. data/ext/ffi_c/libffi/msvcc.sh +1 -1
  81. data/ext/ffi_c/libffi/src/aarch64/ffi.c +146 -42
  82. data/ext/ffi_c/libffi/src/aarch64/internal.h +32 -0
  83. data/ext/ffi_c/libffi/src/aarch64/sysv.S +134 -42
  84. data/ext/ffi_c/libffi/src/arc/arcompact.S +169 -94
  85. data/ext/ffi_c/libffi/src/arc/ffi.c +325 -148
  86. data/ext/ffi_c/libffi/src/arc/ffitarget.h +14 -0
  87. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -17
  88. data/ext/ffi_c/libffi/src/arm/ffitarget.h +3 -3
  89. data/ext/ffi_c/libffi/src/arm/internal.h +10 -0
  90. data/ext/ffi_c/libffi/src/arm/sysv.S +113 -42
  91. data/ext/ffi_c/libffi/src/closures.c +133 -47
  92. data/ext/ffi_c/libffi/src/dlmalloc.c +5 -0
  93. data/ext/ffi_c/libffi/src/ia64/ffi.c +12 -0
  94. data/ext/ffi_c/libffi/src/ia64/unix.S +20 -2
  95. data/ext/ffi_c/libffi/src/loongarch64/ffi.c +621 -0
  96. data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
  97. data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
  98. data/ext/ffi_c/libffi/src/m32r/ffi.c +31 -14
  99. data/ext/ffi_c/libffi/src/mips/ffi.c +240 -65
  100. data/ext/ffi_c/libffi/src/mips/ffitarget.h +7 -0
  101. data/ext/ffi_c/libffi/src/mips/n32.S +137 -28
  102. data/ext/ffi_c/libffi/src/mips/o32.S +61 -4
  103. data/ext/ffi_c/libffi/src/moxie/ffi.c +47 -22
  104. data/ext/ffi_c/libffi/src/or1k/ffi.c +25 -12
  105. data/ext/ffi_c/libffi/src/pa/ffi.c +32 -33
  106. data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
  107. data/ext/ffi_c/libffi/src/pa/ffitarget.h +22 -8
  108. data/ext/ffi_c/libffi/src/pa/hpux32.S +83 -36
  109. data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
  110. data/ext/ffi_c/libffi/src/pa/linux.S +82 -35
  111. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1 -1
  112. data/ext/ffi_c/libffi/src/powerpc/linux64.S +2 -0
  113. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +2 -0
  114. data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
  115. data/ext/ffi_c/libffi/src/prep_cif.c +22 -2
  116. data/ext/ffi_c/libffi/src/riscv/ffi.c +37 -4
  117. data/ext/ffi_c/libffi/src/sparc/ffi64.c +16 -0
  118. data/ext/ffi_c/libffi/src/tramp.c +716 -0
  119. data/ext/ffi_c/libffi/src/wasm32/ffi.c +934 -0
  120. data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
  121. data/ext/ffi_c/libffi/src/x86/ffi.c +99 -37
  122. data/ext/ffi_c/libffi/src/x86/ffi64.c +67 -12
  123. data/ext/ffi_c/libffi/src/x86/ffitarget.h +9 -5
  124. data/ext/ffi_c/libffi/src/x86/ffiw64.c +43 -0
  125. data/ext/ffi_c/libffi/src/x86/internal.h +14 -0
  126. data/ext/ffi_c/libffi/src/x86/internal64.h +14 -0
  127. data/ext/ffi_c/libffi/src/x86/sysv.S +172 -38
  128. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +91 -88
  129. data/ext/ffi_c/libffi/src/x86/unix64.S +96 -6
  130. data/ext/ffi_c/libffi/src/x86/win64.S +20 -7
  131. data/ext/ffi_c/libffi/src/xtensa/ffi.c +16 -8
  132. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +4 -0
  133. data/ext/ffi_c/libffi/src/xtensa/sysv.S +26 -16
  134. data/ext/ffi_c/libffi/testsuite/Makefile.am +127 -114
  135. data/ext/ffi_c/libffi/testsuite/Makefile.in +137 -121
  136. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
  137. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
  138. data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +80 -0
  139. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
  140. data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
  141. data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
  142. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +43 -21
  143. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +2 -2
  144. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1 -0
  145. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +5 -1
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +28 -3
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +3 -0
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +8 -9
  154. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +2 -2
  155. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +2 -2
  156. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +2 -2
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +1 -1
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -119
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +13 -0
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +11 -0
  172. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +15 -0
  173. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn0.c +3 -2
  174. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn1.c +2 -0
  175. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn2.c +2 -0
  176. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn3.c +21 -1
  177. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn4.c +2 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn5.c +2 -0
  179. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_fn6.c +2 -0
  180. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_loc_fn0.c +7 -6
  181. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure_simple.c +6 -0
  182. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_12byte.c +18 -0
  183. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_16byte.c +22 -0
  184. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_18byte.c +24 -0
  185. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_19byte.c +29 -0
  186. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_1_1byte.c +4 -0
  187. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte.c +19 -1
  188. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_20byte1.c +21 -1
  189. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_24byte.c +35 -3
  190. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_2byte.c +13 -0
  191. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3_1byte.c +19 -0
  192. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte1.c +13 -0
  193. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3byte2.c +13 -0
  194. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +18 -0
  195. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4_1byte.c +22 -0
  196. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_4byte.c +13 -0
  197. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5_1_byte.c +29 -1
  198. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_5byte.c +19 -1
  199. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_64byte.c +24 -0
  200. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6_1_byte.c +28 -1
  201. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_6byte.c +24 -2
  202. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7_1_byte.c +39 -1
  203. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_7byte.c +25 -1
  204. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_8byte.c +14 -0
  205. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte1.c +14 -1
  206. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_9byte2.c +14 -2
  207. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_double.c +19 -1
  208. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_float.c +19 -1
  209. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble.c +20 -1
  210. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split.c +40 -25
  211. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_longdouble_split2.c +40 -3
  212. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_pointer.c +19 -1
  213. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint16.c +18 -1
  214. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint32.c +18 -3
  215. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_sint64.c +18 -1
  216. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint16.c +18 -1
  217. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint32.c +19 -1
  218. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_align_uint64.c +19 -1
  219. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_dbls_struct.c +3 -1
  220. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_double_va.c +9 -1
  221. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_float.c +4 -0
  222. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble.c +11 -1
  223. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_longdouble_va.c +22 -3
  224. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_schar.c +5 -1
  225. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshort.c +6 -1
  226. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_sshortchar.c +9 -1
  227. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_uchar.c +9 -1
  228. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushort.c +6 -2
  229. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_multi_ushortchar.c +9 -1
  230. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer.c +5 -0
  231. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_pointer_stack.c +10 -0
  232. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_schar.c +3 -0
  233. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sint.c +2 -0
  234. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_sshort.c +3 -0
  235. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +11 -0
  236. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar.c +3 -0
  237. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint.c +4 -0
  238. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +4 -0
  239. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +4 -0
  240. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulonglong.c +2 -0
  241. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort.c +3 -0
  242. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -138
  243. data/ext/ffi_c/libffi/testsuite/libffi.closures/huge_struct.c +21 -21
  244. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct.c +32 -9
  245. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct1.c +1 -1
  246. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct10.c +12 -0
  247. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +21 -5
  248. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
  249. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
  250. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct2.c +10 -1
  251. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct3.c +10 -1
  252. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct4.c +9 -0
  253. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct5.c +9 -0
  254. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct6.c +11 -0
  255. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct7.c +9 -0
  256. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct8.c +11 -0
  257. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct9.c +11 -0
  258. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
  259. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
  260. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
  261. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium.c +1 -1
  262. data/ext/ffi_c/libffi/testsuite/libffi.closures/stret_medium2.c +1 -1
  263. data/ext/ffi_c/libffi/testsuite/libffi.closures/testclosure.c +6 -1
  264. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest.cc +2 -1
  265. data/ext/ffi_c/libffi/testsuite/libffi.closures/unwindtest_ffi_call.cc +1 -0
  266. data/ext/ffi_c/libffi.bsd.mk +2 -2
  267. data/ext/ffi_c/libffi.gnu.mk +2 -2
  268. data/ext/ffi_c/rbffi.h +1 -1
  269. data/ffi.gemspec +3 -3
  270. data/lib/ffi/autopointer.rb +7 -22
  271. data/lib/ffi/compat.rb +43 -0
  272. data/lib/ffi/data_converter.rb +2 -2
  273. data/lib/ffi/dynamic_library.rb +89 -0
  274. data/lib/ffi/enum.rb +18 -11
  275. data/lib/ffi/ffi.rb +3 -0
  276. data/lib/ffi/function.rb +71 -0
  277. data/lib/ffi/library.rb +55 -71
  278. data/lib/ffi/library_path.rb +109 -0
  279. data/lib/ffi/managedstruct.rb +1 -1
  280. data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
  281. data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
  282. data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
  283. data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
  284. data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
  285. data/lib/ffi/platform.rb +15 -13
  286. data/lib/ffi/struct.rb +2 -1
  287. data/lib/ffi/struct_layout.rb +1 -1
  288. data/lib/ffi/struct_layout_builder.rb +1 -1
  289. data/lib/ffi/types.rb +30 -5
  290. data/lib/ffi/variadic.rb +19 -8
  291. data/lib/ffi/version.rb +1 -1
  292. data.tar.gz.sig +3 -0
  293. metadata +98 -25
  294. metadata.gz.sig +3 -0
  295. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +0 -14
  296. data/ext/ffi_c/libffi/.travis/build.sh +0 -142
  297. data/ext/ffi_c/libffi/.travis.yml +0 -83
  298. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uchar_va.c +0 -44
  299. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ushort_va.c +0 -44
  300. /data/ext/ffi_c/libffi/{.travis → .ci}/ar-lib +0 -0
  301. /data/ext/ffi_c/libffi/{.travis → .ci}/bfin-sim.exp +0 -0
  302. /data/ext/ffi_c/libffi/{.travis → .ci}/compile +0 -0
  303. /data/ext/ffi_c/libffi/{.travis → .ci}/m32r-sim.exp +0 -0
  304. /data/ext/ffi_c/libffi/{.travis → .ci}/moxie-sim.exp +0 -0
  305. /data/ext/ffi_c/libffi/{.travis → .ci}/or1k-sim.exp +0 -0
  306. /data/ext/ffi_c/libffi/{.travis → .ci}/powerpc-eabisim.exp +0 -0
  307. /data/ext/ffi_c/libffi/{.travis → .ci}/wine-sim.exp +0 -0
  308. /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  309. /data/lib/ffi/platform/{sparc64-linux → sparcv9-linux}/types.conf +0 -0
@@ -1,11 +1,11 @@
1
1
  dnl Process this with autoconf to create configure
2
2
 
3
- AC_PREREQ(2.68)
3
+ AC_PREREQ([2.71])
4
4
 
5
- AC_INIT([libffi], [3.3], [http://github.com/libffi/libffi/issues])
5
+ AC_INIT([libffi],[3.4.4],[http://github.com/libffi/libffi/issues])
6
6
  AC_CONFIG_HEADERS([fficonfig.h])
7
7
 
8
- AC_CANONICAL_SYSTEM
8
+ AC_CANONICAL_TARGET
9
9
  target_alias=${target_alias-$host_alias}
10
10
 
11
11
  case "${host}" in
@@ -38,9 +38,12 @@ AC_SUBST(CFLAGS)
38
38
 
39
39
  AM_PROG_AS
40
40
  AM_PROG_CC_C_O
41
- AC_PROG_LIBTOOL
41
+ AC_PROG_EGREP
42
+ LT_INIT
42
43
  AC_CONFIG_MACRO_DIR([m4])
43
44
 
45
+ AC_CHECK_TOOL(READELF, readelf)
46
+
44
47
  # Test for 64-bit build.
45
48
  AC_CHECK_SIZEOF([size_t])
46
49
 
@@ -59,6 +62,7 @@ fi
59
62
  cat > local.exp <<EOF
60
63
  set CC_FOR_TARGET "$CC"
61
64
  set CXX_FOR_TARGET "$CXX"
65
+ set compiler_vendor "$ax_cv_c_compiler_vendor"
62
66
  EOF
63
67
 
64
68
  AM_MAINTAINER_MODE
@@ -66,10 +70,6 @@ AM_MAINTAINER_MODE
66
70
  AC_CHECK_HEADERS(sys/memfd.h)
67
71
  AC_CHECK_FUNCS([memfd_create])
68
72
 
69
- AC_CHECK_HEADERS(sys/mman.h)
70
- AC_CHECK_FUNCS([mmap mkostemp])
71
- AC_FUNC_MMAP_BLACKLIST
72
-
73
73
  dnl The -no-testsuite modules omit the test subdir.
74
74
  AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
75
75
 
@@ -85,9 +85,17 @@ fi
85
85
  AC_SUBST(AM_RUNTESTFLAGS)
86
86
  AC_SUBST(AM_LTLDFLAGS)
87
87
 
88
- AC_HEADER_STDC
88
+ m4_warn([obsolete],
89
+ [The preprocessor macro `STDC_HEADERS' is obsolete.
90
+ Except in unusual embedded environments, you can safely include all
91
+ ISO C90 headers unconditionally.])dnl
92
+ # Autoupdate added the next two lines to ensure that your configure
93
+ # script's behavior did not change. They are probably safe to remove.
94
+ AC_CHECK_INCLUDES_DEFAULT
95
+ AC_PROG_EGREP
96
+
89
97
  AC_CHECK_FUNCS(memcpy)
90
- AC_FUNC_ALLOCA
98
+ AC_CHECK_HEADERS(alloca.h)
91
99
 
92
100
  AC_CHECK_SIZEOF(double)
93
101
  AC_CHECK_SIZEOF(long double)
@@ -122,9 +130,7 @@ case "$TARGET" in
122
130
  save_LDFLAGS="$LDFLAGS"
123
131
  CFLAGS="$CFLAGS -fpic"
124
132
  LDFLAGS="$LDFLAGS -shared"
125
- AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
126
- [libffi_cv_as_sparc_ua_pcrel=yes],
127
- [libffi_cv_as_sparc_ua_pcrel=no])
133
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");]], [[]])],[libffi_cv_as_sparc_ua_pcrel=yes],[libffi_cv_as_sparc_ua_pcrel=no])
128
134
  CFLAGS="$save_CFLAGS"
129
135
  LDFLAGS="$save_LDFLAGS"])
130
136
  if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
@@ -136,9 +142,7 @@ case "$TARGET" in
136
142
  libffi_cv_as_register_pseudo_op, [
137
143
  libffi_cv_as_register_pseudo_op=unknown
138
144
  # Check if we have .register
139
- AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
140
- [libffi_cv_as_register_pseudo_op=yes],
141
- [libffi_cv_as_register_pseudo_op=no])
145
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[asm (".register %g2, #scratch");]])],[libffi_cv_as_register_pseudo_op=yes],[libffi_cv_as_register_pseudo_op=no])
142
146
  ])
143
147
  if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
144
148
  AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
@@ -182,7 +186,7 @@ esac
182
186
  AC_CACHE_CHECK([whether compiler supports pointer authentication],
183
187
  libffi_cv_as_ptrauth, [
184
188
  libffi_cv_as_ptrauth=unknown
185
- AC_TRY_COMPILE(,[
189
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
186
190
  #ifdef __clang__
187
191
  # if __has_feature(ptrauth_calls)
188
192
  # define HAVE_PTRAUTH 1
@@ -192,21 +196,24 @@ AC_CACHE_CHECK([whether compiler supports pointer authentication],
192
196
  #ifndef HAVE_PTRAUTH
193
197
  # error Pointer authentication not supported
194
198
  #endif
195
- ],
196
- [libffi_cv_as_ptrauth=yes],
197
- [libffi_cv_as_ptrauth=no])
199
+ ]])],[libffi_cv_as_ptrauth=yes],[libffi_cv_as_ptrauth=no])
198
200
  ])
199
201
  if test "x$libffi_cv_as_ptrauth" = xyes; then
200
202
  AC_DEFINE(HAVE_PTRAUTH, 1,
201
203
  [Define if your compiler supports pointer authentication.])
202
204
  fi
203
205
 
204
- # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
206
+ # On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC;
207
+ # if EMUTRAMP is active too ffi could try mapping without PROT_EXEC,
208
+ # but the kernel needs to recognize the trampoline generated by ffi.
209
+ # Otherwise fallback to double mmap trick.
205
210
  AC_ARG_ENABLE(pax_emutramp,
206
- [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
211
+ [ --enable-pax_emutramp enable pax emulated trampolines (experimental)],
207
212
  if test "$enable_pax_emutramp" = "yes"; then
213
+ AC_MSG_WARN([EMUTRAMP is experimental only. Use --enable-pax_emutramp=experimental to enforce.])
214
+ elif test "$enable_pax_emutramp" = "experimental"; then
208
215
  AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
209
- [Define this if you want to enable pax emulated trampolines])
216
+ [Define this if you want to enable pax emulated trampolines (experimental)])
210
217
  fi)
211
218
 
212
219
  LT_SYS_SYMBOL_USCORE
@@ -270,7 +277,7 @@ if test "x$GCC" = "xyes"; then
270
277
  libffi_cv_ro_eh_frame=yes
271
278
  echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
272
279
  if $CC $CFLAGS -c -fpic -fexceptions $libffi_cv_no_lto -o conftest.o conftest.c > /dev/null 2>&1; then
273
- if readelf -WS conftest.o | grep -q -n 'eh_frame .* WA'; then
280
+ if $READELF -WS conftest.o 2>/dev/null | grep -q -n 'eh_frame .* WA'; then
274
281
  libffi_cv_ro_eh_frame=no
275
282
  fi
276
283
  fi
@@ -291,7 +298,7 @@ if test "x$GCC" = "xyes"; then
291
298
  echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c
292
299
  libffi_cv_hidden_visibility_attribute=no
293
300
  if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
294
- if egrep '(\.hidden|\.private_extern).*foo' conftest.s >/dev/null; then
301
+ if $EGREP '(\.hidden|\.private_extern).*foo' conftest.s >/dev/null; then
295
302
  libffi_cv_hidden_visibility_attribute=yes
296
303
  fi
297
304
  fi
@@ -304,8 +311,7 @@ if test "x$GCC" = "xyes"; then
304
311
  fi
305
312
 
306
313
  AC_ARG_ENABLE(docs,
307
- AC_HELP_STRING([--disable-docs],
308
- [Disable building of docs (default: no)]),
314
+ AS_HELP_STRING([--disable-docs],[Disable building of docs (default: no)]),
309
315
  [enable_docs=no],
310
316
  [enable_docs=yes])
311
317
  AM_CONDITIONAL(BUILD_DOCS, [test x$enable_docs = xyes])
@@ -363,6 +369,26 @@ AC_ARG_ENABLE(raw-api,
363
369
  AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
364
370
  fi)
365
371
 
372
+ AC_ARG_ENABLE(exec-static-tramp,
373
+ [ --disable-exec-static-tramp disable use of static exec trampolines (enabled by default)])
374
+
375
+ if test "$enable_exec_static_tramp" != no; then
376
+ case "$target" in
377
+ *-cygwin* | *-msys*)
378
+ # Only define static trampolines if we are using the cygwin runtime.
379
+ # Will this need to be changed for mingw?
380
+ if test "x$GCC" = "xyes"; then
381
+ AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1,
382
+ [Define this if you want statically defined trampolines])
383
+ fi
384
+ ;;
385
+ *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-* | loongarch*-*-linux-*)
386
+ AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1,
387
+ [Define this if you want statically defined trampolines])
388
+ ;;
389
+ esac
390
+ fi
391
+
366
392
  AC_ARG_ENABLE(purify-safety,
367
393
  [ --enable-purify-safety purify-safe mode],
368
394
  if test "$enable_purify_safety" = "yes"; then
@@ -372,7 +398,7 @@ AC_ARG_ENABLE(purify-safety,
372
398
  AC_ARG_ENABLE(multi-os-directory,
373
399
  [ --disable-multi-os-directory
374
400
  disable use of gcc --print-multi-os-directory to change the library installation directory])
375
-
401
+
376
402
  # These variables are only ever used when we cross-build to X86_WIN32.
377
403
  # And we only support this with GCC, so...
378
404
  if test "x$GCC" = "xyes"; then
@@ -397,6 +423,16 @@ else
397
423
  fi
398
424
  AC_SUBST(toolexeclibdir)
399
425
 
426
+ # Conditionalize the makefile for this target machine.
427
+ tmake_file_=
428
+ for f in ${tmake_file}; do
429
+ if test -f ${srcdir}/src/$TARGETDIR/$f; then
430
+ tmake_file_="${tmake_file_} \$(srcdir)/src/$TARGETDIR/$f"
431
+ fi
432
+ done
433
+ tmake_file="${tmake_file_}"
434
+ AC_SUBST(tmake_file)
435
+
400
436
  # Check linker support.
401
437
  LIBFFI_ENABLE_SYMVERS
402
438
 
@@ -6,7 +6,7 @@
6
6
  # THIS TABLE IS SORTED. KEEP IT THAT WAY.
7
7
  # Most of the time we can define all the variables all at once...
8
8
  case "${host}" in
9
- aarch64*-*-cygwin* | aarch64*-*-mingw* | aarch64*-*-win* )
9
+ aarch64*-*-cygwin* | aarch64*-*-msys* | aarch64*-*-mingw* | aarch64*-*-win* )
10
10
  TARGET=ARM_WIN64; TARGETDIR=aarch64
11
11
  if test "${ax_cv_c_compiler_vendor}" = "microsoft"; then
12
12
  MSVC=1
@@ -30,9 +30,11 @@ case "${host}" in
30
30
  SOURCES="ffi.c arcompact.S"
31
31
  ;;
32
32
 
33
- arm*-*-cygwin* | arm*-*-mingw* | arm*-*-win* )
33
+ arm*-*-cygwin* | arm*-*-msys* | arm*-*-mingw* | arm*-*-win* )
34
34
  TARGET=ARM_WIN32; TARGETDIR=arm
35
- MSVC=1
35
+ if test "${ax_cv_c_compiler_vendor}" = "microsoft"; then
36
+ MSVC=1
37
+ fi
36
38
  ;;
37
39
 
38
40
  arm*-*-*)
@@ -71,6 +73,7 @@ case "${host}" in
71
73
  ;;
72
74
  hppa*64-*-hpux*)
73
75
  TARGET=PA64_HPUX; TARGETDIR=pa
76
+ SOURCES="ffi64.c hpux64.S"
74
77
  ;;
75
78
  hppa*-*-hpux*)
76
79
  TARGET=PA_HPUX; TARGETDIR=pa
@@ -81,8 +84,8 @@ case "${host}" in
81
84
  TARGET=X86_FREEBSD; TARGETDIR=x86
82
85
  ;;
83
86
 
84
- i?86-*-cygwin* | i?86-*-mingw* | i?86-*-win* | i?86-*-os2* | i?86-*-interix* \
85
- | x86_64-*-cygwin* | x86_64-*-mingw* | x86_64-*-win* )
87
+ i?86-*-cygwin* | i?86-*-msys* | i?86-*-mingw* | i?86-*-win* | i?86-*-os2* | i?86-*-interix* \
88
+ | x86_64-*-cygwin* | x86_64-*-msys* | x86_64-*-mingw* | x86_64-*-win* )
86
89
  TARGETDIR=x86
87
90
  if test $ac_cv_sizeof_size_t = 4; then
88
91
  TARGET=X86_WIN32
@@ -138,6 +141,11 @@ case "${host}" in
138
141
  SOURCES="ffi.c sysv.S"
139
142
  ;;
140
143
 
144
+ loongarch64-*-*)
145
+ TARGET=LOONGARCH64; TARGETDIR=loongarch64
146
+ SOURCES="ffi.c sysv.S"
147
+ ;;
148
+
141
149
  m32r*-*-*)
142
150
  TARGET=M32R; TARGETDIR=m32r
143
151
  SOURCES="ffi.c sysv.S"
@@ -205,6 +213,8 @@ case "${host}" in
205
213
  ;;
206
214
  powerpc-*-aix* | rs6000-*-aix*)
207
215
  TARGET=POWERPC_AIX; TARGETDIR=powerpc
216
+ # Create AIX-style "FAT" libraries.
217
+ tmake_file="t-aix"
208
218
  ;;
209
219
  powerpc-*-freebsd* | powerpc-*-openbsd* | powerpc-*-netbsd*)
210
220
  TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
@@ -255,6 +265,11 @@ case "${host}" in
255
265
  SOURCES="ffi.c elfbsd.S"
256
266
  ;;
257
267
 
268
+ wasm32-*-*)
269
+ TARGET=wasm32; TARGETDIR=wasm32
270
+ SOURCES="ffi.c"
271
+ ;;
272
+
258
273
  xtensa*-*)
259
274
  TARGET=XTENSA; TARGETDIR=xtensa
260
275
  SOURCES="ffi.c sysv.S"
@@ -264,7 +279,11 @@ esac
264
279
  # ... but some of the cases above share configury.
265
280
  case "${TARGET}" in
266
281
  ARM_WIN32)
267
- SOURCES="ffi.c sysv_msvc_arm32.S"
282
+ if test "$MSVC" = 1; then
283
+ SOURCES="ffi.c sysv_msvc_arm32.S"
284
+ else
285
+ SOURCES="ffi.c sysv.S"
286
+ fi
268
287
  ;;
269
288
  ARM_WIN64)
270
289
  if test "$MSVC" = 1; then
@@ -1,7 +1,7 @@
1
- # Makefile.in generated by automake 1.16.1 from Makefile.am.
1
+ # Makefile.in generated by automake 1.16.5 from Makefile.am.
2
2
  # @configure_input@
3
3
 
4
- # Copyright (C) 1994-2018 Free Software Foundation, Inc.
4
+ # Copyright (C) 1994-2021 Free Software Foundation, Inc.
5
5
 
6
6
  # This Makefile.in is free software; the Free Software Foundation
7
7
  # gives unlimited permission to copy and/or distribute it,
@@ -91,7 +91,6 @@ target_triplet = @target@
91
91
  subdir = doc
92
92
  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
93
93
  am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
94
- $(top_srcdir)/m4/ax_append_flag.m4 \
95
94
  $(top_srcdir)/m4/ax_cc_maxopt.m4 \
96
95
  $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
97
96
  $(top_srcdir)/m4/ax_check_compile_flag.m4 \
@@ -100,6 +99,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
100
99
  $(top_srcdir)/m4/ax_enable_builddir.m4 \
101
100
  $(top_srcdir)/m4/ax_gcc_archflag.m4 \
102
101
  $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
102
+ $(top_srcdir)/m4/ax_prepend_flag.m4 \
103
103
  $(top_srcdir)/m4/ax_require_defined.m4 \
104
104
  $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
105
105
  $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
@@ -204,7 +204,6 @@ am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
204
204
  am__DIST_COMMON = $(srcdir)/Makefile.in mdate-sh texinfo.tex
205
205
  DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
206
206
  ACLOCAL = @ACLOCAL@
207
- ALLOCA = @ALLOCA@
208
207
  AMTAR = @AMTAR@
209
208
  AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
210
209
  AM_LTLDFLAGS = @AM_LTLDFLAGS@
@@ -220,8 +219,9 @@ CCASDEPMODE = @CCASDEPMODE@
220
219
  CCASFLAGS = @CCASFLAGS@
221
220
  CCDEPMODE = @CCDEPMODE@
222
221
  CFLAGS = @CFLAGS@
223
- CPP = @CPP@
224
222
  CPPFLAGS = @CPPFLAGS@
223
+ CSCOPE = @CSCOPE@
224
+ CTAGS = @CTAGS@
225
225
  CXX = @CXX@
226
226
  CXXCPP = @CXXCPP@
227
227
  CXXDEPMODE = @CXXDEPMODE@
@@ -236,9 +236,11 @@ ECHO_C = @ECHO_C@
236
236
  ECHO_N = @ECHO_N@
237
237
  ECHO_T = @ECHO_T@
238
238
  EGREP = @EGREP@
239
+ ETAGS = @ETAGS@
239
240
  EXEEXT = @EXEEXT@
240
241
  FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
241
242
  FGREP = @FGREP@
243
+ FILECMD = @FILECMD@
242
244
  GREP = @GREP@
243
245
  HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
244
246
  HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
@@ -277,6 +279,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
277
279
  PATH_SEPARATOR = @PATH_SEPARATOR@
278
280
  PRTDIAG = @PRTDIAG@
279
281
  RANLIB = @RANLIB@
282
+ READELF = @READELF@
280
283
  SECTION_LDFLAGS = @SECTION_LDFLAGS@
281
284
  SED = @SED@
282
285
  SET_MAKE = @SET_MAKE@
@@ -343,6 +346,7 @@ target_alias = @target_alias@
343
346
  target_cpu = @target_cpu@
344
347
  target_os = @target_os@
345
348
  target_vendor = @target_vendor@
349
+ tmake_file = @tmake_file@
346
350
  toolexecdir = @toolexecdir@
347
351
  toolexeclibdir = @toolexeclibdir@
348
352
  top_build_prefix = @top_build_prefix@
@@ -555,7 +559,6 @@ ctags CTAGS:
555
559
 
556
560
  cscope cscopelist:
557
561
 
558
-
559
562
  distdir: $(BUILT_SOURCES)
560
563
  $(MAKE) $(AM_MAKEFLAGS) distdir-am
561
564
 
@@ -18,7 +18,7 @@
18
18
  This manual is for libffi, a portable foreign function interface
19
19
  library.
20
20
 
21
- Copyright @copyright{} 2008--2019 Anthony Green and Red Hat, Inc.
21
+ Copyright @copyright{} 2008--2019, 2021, 2022 Anthony Green and Red Hat, Inc.
22
22
 
23
23
  Permission is hereby granted, free of charge, to any person obtaining
24
24
  a copy of this software and associated documentation files (the
@@ -65,6 +65,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65
65
  @menu
66
66
  * Introduction:: What is libffi?
67
67
  * Using libffi:: How to use libffi.
68
+ * Memory Usage:: Where memory for closures comes from.
68
69
  * Missing Features:: Things libffi can't do.
69
70
  * Index:: Index.
70
71
  @end menu
@@ -90,10 +91,10 @@ sometimes called the @dfn{ABI} or @dfn{Application Binary Interface}.
90
91
  Some programs may not know at the time of compilation what arguments
91
92
  are to be passed to a function. For instance, an interpreter may be
92
93
  told at run-time about the number and types of arguments used to call
93
- a given function. @samp{Libffi} can be used in such programs to
94
+ a given function. @code{libffi} can be used in such programs to
94
95
  provide a bridge from the interpreter program to compiled code.
95
96
 
96
- The @samp{libffi} library provides a portable, high level programming
97
+ The @code{libffi} library provides a portable, high level programming
97
98
  interface to various calling conventions. This allows a programmer to
98
99
  call any function specified by a call interface description at run
99
100
  time.
@@ -101,9 +102,9 @@ time.
101
102
  @acronym{FFI} stands for Foreign Function Interface. A foreign
102
103
  function interface is the popular name for the interface that allows
103
104
  code written in one language to call code written in another language.
104
- The @samp{libffi} library really only provides the lowest, machine
105
+ The @code{libffi} library really only provides the lowest, machine
105
106
  dependent layer of a fully featured foreign function interface. A
106
- layer must exist above @samp{libffi} that handles type conversions for
107
+ layer must exist above @code{libffi} that handles type conversions for
107
108
  values passed between the two languages.
108
109
  @cindex FFI
109
110
  @cindex Foreign Function Interface
@@ -126,7 +127,7 @@ values passed between the two languages.
126
127
  @node The Basics
127
128
  @section The Basics
128
129
 
129
- @samp{Libffi} assumes that you have a pointer to the function you wish
130
+ @code{libffi} assumes that you have a pointer to the function you wish
130
131
  to call and that you know the number and types of arguments to pass
131
132
  it, as well as the return type of the function.
132
133
 
@@ -176,6 +177,11 @@ variadic arguments. It must be greater than zero.
176
177
  @var{ntotalargs} the total number of arguments, including variadic
177
178
  and fixed arguments. @var{argtypes} must have this many elements.
178
179
 
180
+ @code{ffi_prep_cif_var} will return @code{FFI_BAD_ARGTYPE} if any of
181
+ the variable argument types are @code{ffi_type_float} (promote to
182
+ @code{ffi_type_double} first), or any integer type small than an int
183
+ (promote to an int-sized type first).
184
+
179
185
  Note that, different cif's must be prepped for calls to the same
180
186
  function when different numbers of arguments are passed.
181
187
 
@@ -207,22 +213,20 @@ to ensure this. If @var{cif} declares that the function returns
207
213
  @code{void} (using @code{ffi_type_void}), then @var{rvalue} is
208
214
  ignored.
209
215
 
210
- In most situations, @samp{libffi} will handle promotion according to
216
+ In most situations, @code{libffi} will handle promotion according to
211
217
  the ABI. However, for historical reasons, there is a special case
212
218
  with return values that must be handled by your code. In particular,
213
219
  for integral (not @code{struct}) types that are narrower than the
214
220
  system register size, the return value will be widened by
215
- @samp{libffi}. @samp{libffi} provides a type, @code{ffi_arg}, that
221
+ @code{libffi}. @code{libffi} provides a type, @code{ffi_arg}, that
216
222
  can be used as the return type. For example, if the CIF was defined
217
- with a return type of @code{char}, @samp{libffi} will try to store a
223
+ with a return type of @code{char}, @code{libffi} will try to store a
218
224
  full @code{ffi_arg} into the return value.
219
225
 
220
226
  @var{avalues} is a vector of @code{void *} pointers that point to the
221
227
  memory locations holding the argument values for a call. If @var{cif}
222
228
  declares that the function has no arguments (i.e., @var{nargs} was 0),
223
- then @var{avalues} is ignored. Note that argument values may be
224
- modified by the callee (for instance, structs passed by value); the
225
- burden of copying pass-by-value arguments is placed on the caller.
229
+ then @var{avalues} is ignored.
226
230
 
227
231
  Note that while the return value must be register-sized, arguments
228
232
  should exactly match their declared type. For example, if an argument
@@ -249,26 +253,26 @@ int main()
249
253
  void *values[1];
250
254
  char *s;
251
255
  ffi_arg rc;
252
-
253
- /* Initialize the argument info vectors */
256
+
257
+ /* Initialize the argument info vectors */
254
258
  args[0] = &ffi_type_pointer;
255
259
  values[0] = &s;
256
-
260
+
257
261
  /* Initialize the cif */
258
- if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
262
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
259
263
  &ffi_type_sint, args) == FFI_OK)
260
264
  @{
261
265
  s = "Hello World!";
262
266
  ffi_call(&cif, puts, &rc, values);
263
267
  /* rc now holds the result of the call to puts */
264
-
265
- /* values holds a pointer to the function's arg, so to
266
- call puts() again all we need to do is change the
268
+
269
+ /* values holds a pointer to the function's arg, so to
270
+ call puts() again all we need to do is change the
267
271
  value of s */
268
272
  s = "This is cool!";
269
273
  ffi_call(&cif, puts, &rc, values);
270
274
  @}
271
-
275
+
272
276
  return 0;
273
277
  @}
274
278
  @end example
@@ -406,8 +410,8 @@ when passing to @code{ffi_prep_cif}.
406
410
  @node Structures
407
411
  @subsection Structures
408
412
 
409
- @samp{libffi} is perfectly happy passing structures back and forth.
410
- You must first describe the structure to @samp{libffi} by creating a
413
+ @code{libffi} is perfectly happy passing structures back and forth.
414
+ You must first describe the structure to @code{libffi} by creating a
411
415
  new @code{ffi_type} object for it.
412
416
 
413
417
  @tindex ffi_type
@@ -427,7 +431,7 @@ For a structure, this should be set to @code{FFI_TYPE_STRUCT}.
427
431
  This is a @samp{NULL}-terminated array of pointers to @code{ffi_type}
428
432
  objects. There is one element per field of the struct.
429
433
 
430
- Note that @samp{libffi} has no special support for bit-fields. You
434
+ Note that @code{libffi} has no special support for bit-fields. You
431
435
  must manage these manually.
432
436
  @end table
433
437
  @end deftp
@@ -504,7 +508,7 @@ valid here.
504
508
 
505
509
  @subsubsection Arrays
506
510
 
507
- @samp{libffi} does not have direct support for arrays or unions.
511
+ @code{libffi} does not have direct support for arrays or unions.
508
512
  However, they can be emulated using structures.
509
513
 
510
514
  To emulate an array, simply create an @code{ffi_type} using
@@ -531,7 +535,7 @@ structure types created like this should only be used to refer to
531
535
  members of real @code{FFI_TYPE_STRUCT} objects.
532
536
 
533
537
  However, a phony array type like this will not cause any errors from
534
- @samp{libffi} if you use it as an argument or return type. This may
538
+ @code{libffi} if you use it as an argument or return type. This may
535
539
  be confusing.
536
540
 
537
541
  @subsubsection Unions
@@ -624,7 +628,7 @@ Here is the corresponding code to describe this struct to
624
628
  tm_type.size = tm_type.alignment = 0;
625
629
  tm_type.type = FFI_TYPE_STRUCT;
626
630
  tm_type.elements = &tm_type_elements;
627
-
631
+
628
632
  for (i = 0; i < 9; i++)
629
633
  tm_type_elements[i] = &ffi_type_sint;
630
634
 
@@ -640,7 +644,7 @@ Here is the corresponding code to describe this struct to
640
644
  @node Complex
641
645
  @subsection Complex Types
642
646
 
643
- @samp{libffi} supports the complex types defined by the C99
647
+ @code{libffi} supports the complex types defined by the C99
644
648
  standard (@code{_Complex float}, @code{_Complex double} and
645
649
  @code{_Complex long double} with the built-in type descriptors
646
650
  @code{ffi_type_complex_float}, @code{ffi_type_complex_double} and
@@ -648,7 +652,7 @@ standard (@code{_Complex float}, @code{_Complex double} and
648
652
 
649
653
  Custom complex types like @code{_Complex int} can also be used.
650
654
  An @code{ffi_type} object has to be defined to describe the
651
- complex type to @samp{libffi}.
655
+ complex type to @code{libffi}.
652
656
 
653
657
  @tindex ffi_type
654
658
  @deftp {Data type} ffi_type
@@ -815,7 +819,6 @@ Free memory allocated using @code{ffi_closure_alloc}. The argument is
815
819
  the writable address that was returned.
816
820
  @end defun
817
821
 
818
-
819
822
  Once you have allocated the memory for a closure, you must construct a
820
823
  @code{ffi_cif} describing the function call. Finally you can prepare
821
824
  the closure function:
@@ -887,7 +890,7 @@ writable and executable addresses.
887
890
  @node Closure Example
888
891
  @section Closure Example
889
892
 
890
- A trivial example that creates a new @code{puts} by binding
893
+ A trivial example that creates a new @code{puts} by binding
891
894
  @code{fputs} with @code{stdout}.
892
895
 
893
896
  @example
@@ -965,6 +968,55 @@ Currently the only affected platform is PowerPC and the only affected
965
968
  type is @code{long double}.
966
969
  @end itemize
967
970
 
971
+ @node Memory Usage
972
+ @chapter Memory Usage
973
+
974
+ Note that memory allocated by @code{ffi_closure_alloc} and freed by
975
+ @code{ffi_closure_free} does not come from the same general pool of
976
+ memory that @code{malloc} and @code{free} use. To accomodate security
977
+ settings, @code{libffi} may aquire memory, for example, by mapping
978
+ temporary files into multiple places in the address space (once to
979
+ write out the closure, a second to execute it). The search follows
980
+ this list, using the first that works:
981
+
982
+ @itemize @bullet
983
+
984
+ @item
985
+ A anonymous mapping (i.e. not file-backed)
986
+
987
+ @item
988
+ @code{memfd_create()}, if the kernel supports it.
989
+
990
+ @item
991
+ A file created in the directory referenced by the environment variable
992
+ @code{LIBFFI_TMPDIR}.
993
+
994
+ @item
995
+ Likewise for the environment variable @code{TMPDIR}.
996
+
997
+ @item
998
+ A file created in @code{/tmp}.
999
+
1000
+ @item
1001
+ A file created in @code{/var/tmp}.
1002
+
1003
+ @item
1004
+ A file created in @code{/dev/shm}.
1005
+
1006
+ @item
1007
+ A file created in the user's home directory (@code{$HOME}).
1008
+
1009
+ @item
1010
+ A file created in any directory listed in @code{/etc/mtab}.
1011
+
1012
+ @item
1013
+ A file created in any directory listed in @code{/proc/mounts}.
1014
+
1015
+ @end itemize
1016
+
1017
+ If security settings prohibit using any of these for closures,
1018
+ @code{ffi_closure_alloc} will fail.
1019
+
968
1020
  @node Missing Features
969
1021
  @chapter Missing Features
970
1022
 
@@ -986,9 +1038,6 @@ The ``raw'' API is undocumented.
986
1038
  The Go API is undocumented.
987
1039
  @end itemize
988
1040
 
989
- Note that variadic support is very new and tested on a relatively
990
- small number of platforms.
991
-
992
1041
  @node Index
993
1042
  @unnumbered Index
994
1043
 
@@ -1,4 +1,4 @@
1
- @set UPDATED 22 November 2019
2
- @set UPDATED-MONTH November 2019
3
- @set EDITION 3.3
4
- @set VERSION 3.3
1
+ @set UPDATED 23 October 2022
2
+ @set UPDATED-MONTH October 2022
3
+ @set EDITION 3.4.4
4
+ @set VERSION 3.4.4