ffi 1.1.2 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (706) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +456 -0
  4. data/COPYING +49 -0
  5. data/Gemfile +21 -0
  6. data/LICENSE +21 -11
  7. data/LICENSE.SPECS +22 -0
  8. data/README.md +137 -0
  9. data/Rakefile +166 -156
  10. data/ext/ffi_c/AbstractMemory.c +240 -140
  11. data/ext/ffi_c/AbstractMemory.h +25 -15
  12. data/ext/ffi_c/ArrayType.c +78 -29
  13. data/ext/ffi_c/ArrayType.h +22 -12
  14. data/ext/ffi_c/Buffer.c +121 -60
  15. data/ext/ffi_c/Call.c +184 -137
  16. data/ext/ffi_c/Call.h +46 -22
  17. data/ext/ffi_c/ClosurePool.c +101 -43
  18. data/ext/ffi_c/ClosurePool.h +24 -13
  19. data/ext/ffi_c/DynamicLibrary.c +139 -57
  20. data/ext/ffi_c/DynamicLibrary.h +70 -12
  21. data/ext/ffi_c/Function.c +372 -273
  22. data/ext/ffi_c/Function.h +25 -20
  23. data/ext/ffi_c/FunctionInfo.c +135 -49
  24. data/ext/ffi_c/LastError.c +97 -30
  25. data/ext/ffi_c/LastError.h +21 -12
  26. data/ext/ffi_c/LongDouble.c +15 -9
  27. data/ext/ffi_c/LongDouble.h +21 -16
  28. data/ext/ffi_c/MappedType.c +88 -38
  29. data/ext/ffi_c/MappedType.h +21 -14
  30. data/ext/ffi_c/MemoryPointer.c +91 -38
  31. data/ext/ffi_c/MemoryPointer.h +22 -19
  32. data/ext/ffi_c/MethodHandle.c +52 -51
  33. data/ext/ffi_c/MethodHandle.h +24 -14
  34. data/ext/ffi_c/Platform.c +28 -62
  35. data/ext/ffi_c/Platform.h +21 -12
  36. data/ext/ffi_c/Pointer.c +145 -86
  37. data/ext/ffi_c/Pointer.h +23 -19
  38. data/ext/ffi_c/Struct.c +363 -163
  39. data/ext/ffi_c/Struct.h +39 -21
  40. data/ext/ffi_c/StructByValue.c +72 -37
  41. data/ext/ffi_c/StructByValue.h +21 -12
  42. data/ext/ffi_c/StructLayout.c +308 -94
  43. data/ext/ffi_c/Thread.c +73 -270
  44. data/ext/ffi_c/Thread.h +32 -35
  45. data/ext/ffi_c/Type.c +147 -84
  46. data/ext/ffi_c/Type.h +27 -11
  47. data/ext/ffi_c/Types.c +40 -24
  48. data/ext/ffi_c/Types.h +24 -21
  49. data/ext/ffi_c/Variadic.c +148 -64
  50. data/ext/ffi_c/compat.h +45 -37
  51. data/ext/ffi_c/extconf.rb +86 -32
  52. data/ext/ffi_c/ffi.c +32 -21
  53. data/ext/ffi_c/libffi/.allow-ai-service +0 -0
  54. data/ext/ffi_c/libffi/.appveyor/site.exp +16 -0
  55. data/ext/ffi_c/libffi/.appveyor/unix-noexec.exp +7 -0
  56. data/ext/ffi_c/libffi/.appveyor.yml +84 -0
  57. data/ext/ffi_c/libffi/.ci/ar-lib +270 -0
  58. data/ext/ffi_c/libffi/.ci/bfin-sim.exp +58 -0
  59. data/ext/ffi_c/libffi/.ci/build-cross-in-container.sh +18 -0
  60. data/ext/ffi_c/libffi/.ci/build-in-container.sh +10 -0
  61. data/ext/ffi_c/libffi/.ci/build.sh +124 -0
  62. data/ext/ffi_c/libffi/.ci/compile +351 -0
  63. data/ext/ffi_c/libffi/.ci/install.sh +78 -0
  64. data/ext/ffi_c/libffi/.ci/m32r-sim.exp +58 -0
  65. data/ext/ffi_c/libffi/.ci/moxie-sim.exp +60 -0
  66. data/ext/ffi_c/libffi/.ci/msvs-detect +1103 -0
  67. data/ext/ffi_c/libffi/.ci/or1k-sim.exp +58 -0
  68. data/ext/ffi_c/libffi/.ci/powerpc-eabisim.exp +58 -0
  69. data/ext/ffi_c/libffi/.ci/site.exp +29 -0
  70. data/ext/ffi_c/libffi/.ci/wine-sim.exp +55 -0
  71. data/ext/ffi_c/libffi/.circleci/config.yml +156 -0
  72. data/ext/ffi_c/libffi/.gitattributes +4 -0
  73. data/ext/ffi_c/libffi/.github/issue_template.md +10 -0
  74. data/ext/ffi_c/libffi/.github/workflows/build.yml +479 -0
  75. data/ext/ffi_c/libffi/.github/workflows/emscripten.yml +172 -0
  76. data/ext/ffi_c/libffi/.gitignore +46 -0
  77. data/ext/ffi_c/libffi/{ChangeLog → ChangeLog.old} +6366 -3559
  78. data/ext/ffi_c/libffi/LICENSE +1 -1
  79. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +353 -0
  80. data/ext/ffi_c/libffi/Makefile.am +131 -170
  81. data/ext/ffi_c/libffi/Makefile.in +1317 -1010
  82. data/ext/ffi_c/libffi/README.md +531 -0
  83. data/ext/ffi_c/libffi/acinclude.m4 +289 -4
  84. data/ext/ffi_c/libffi/autogen.sh +2 -0
  85. data/ext/ffi_c/libffi/compile +222 -17
  86. data/ext/ffi_c/libffi/config.guess +1033 -780
  87. data/ext/ffi_c/libffi/config.sub +1393 -1206
  88. data/ext/ffi_c/libffi/configure +16340 -10740
  89. data/ext/ffi_c/libffi/configure.ac +226 -271
  90. data/ext/ffi_c/libffi/configure.host +330 -4
  91. data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
  92. data/ext/ffi_c/libffi/doc/Makefile.in +818 -0
  93. data/ext/ffi_c/libffi/doc/libffi.texi +525 -79
  94. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  95. data/ext/ffi_c/libffi/fficonfig.h.in +41 -52
  96. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +312 -0
  97. data/ext/ffi_c/libffi/include/Makefile.am +3 -3
  98. data/ext/ffi_c/libffi/include/Makefile.in +201 -79
  99. data/ext/ffi_c/libffi/include/ffi.h.in +190 -99
  100. data/ext/ffi_c/libffi/include/ffi_cfi.h +76 -0
  101. data/ext/ffi_c/libffi/include/ffi_common.h +72 -14
  102. data/ext/ffi_c/libffi/include/tramp.h +45 -0
  103. data/ext/ffi_c/libffi/install-sh +231 -210
  104. data/ext/ffi_c/libffi/libffi.map.in +81 -0
  105. data/ext/ffi_c/libffi/libffi.pc.in +3 -2
  106. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +997 -0
  107. data/ext/ffi_c/libffi/libtool-ldflags +106 -0
  108. data/ext/ffi_c/libffi/libtool-version +2 -2
  109. data/ext/ffi_c/libffi/ltmain.sh +3868 -2068
  110. data/ext/ffi_c/libffi/m4/asmcfi.m4 +13 -0
  111. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +50 -0
  112. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +47 -25
  113. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +110 -147
  114. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +53 -0
  115. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +75 -19
  116. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +8 -29
  117. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +11 -9
  118. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +104 -52
  119. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +18 -8
  120. data/ext/ffi_c/libffi/m4/ax_prepend_flag.m4 +51 -0
  121. data/ext/ffi_c/libffi/m4/ax_require_defined.m4 +37 -0
  122. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  123. data/ext/ffi_c/libffi/man/Makefile.am +2 -2
  124. data/ext/ffi_c/libffi/man/Makefile.in +156 -57
  125. data/ext/ffi_c/libffi/man/ffi.3 +10 -0
  126. data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +6 -4
  127. data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +73 -0
  128. data/ext/ffi_c/libffi/missing +153 -314
  129. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  130. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  131. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  132. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  133. data/ext/ffi_c/libffi/{include/ffi.h.vc64 → msvc_build/aarch64/aarch64_include/ffi.h} +151 -67
  134. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
  135. data/ext/ffi_c/libffi/msvcc.sh +176 -20
  136. data/ext/ffi_c/libffi/src/aarch64/ffi.c +1142 -0
  137. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +97 -0
  138. data/ext/ffi_c/libffi/src/aarch64/internal.h +100 -0
  139. data/ext/ffi_c/libffi/src/aarch64/sysv.S +695 -0
  140. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  141. data/ext/ffi_c/libffi/src/alpha/ffi.c +335 -98
  142. data/ext/ffi_c/libffi/src/alpha/ffitarget.h +10 -1
  143. data/ext/ffi_c/libffi/src/alpha/internal.h +23 -0
  144. data/ext/ffi_c/libffi/src/alpha/osf.S +161 -266
  145. data/ext/ffi_c/libffi/src/arc/arcompact.S +210 -0
  146. data/ext/ffi_c/libffi/src/arc/ffi.c +443 -0
  147. data/ext/ffi_c/libffi/src/arc/ffitarget.h +67 -0
  148. data/ext/ffi_c/libffi/src/arm/ffi.c +706 -513
  149. data/ext/ffi_c/libffi/src/arm/ffitarget.h +32 -8
  150. data/ext/ffi_c/libffi/src/arm/internal.h +17 -0
  151. data/ext/ffi_c/libffi/src/arm/sysv.S +372 -413
  152. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  153. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +6 -1
  154. data/ext/ffi_c/libffi/src/bfin/ffi.c +196 -0
  155. data/ext/ffi_c/libffi/src/bfin/ffitarget.h +43 -0
  156. data/ext/ffi_c/libffi/src/bfin/sysv.S +179 -0
  157. data/ext/ffi_c/libffi/src/closures.c +565 -73
  158. data/ext/ffi_c/libffi/src/cris/ffi.c +10 -7
  159. data/ext/ffi_c/libffi/src/cris/ffitarget.h +6 -1
  160. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  161. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  162. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  163. data/ext/ffi_c/libffi/src/debug.c +8 -3
  164. data/ext/ffi_c/libffi/src/dlmalloc.c +23 -13
  165. data/ext/ffi_c/libffi/src/frv/ffi.c +2 -2
  166. data/ext/ffi_c/libffi/src/frv/ffitarget.h +6 -1
  167. data/ext/ffi_c/libffi/src/ia64/ffi.c +47 -13
  168. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +8 -2
  169. data/ext/ffi_c/libffi/src/ia64/unix.S +28 -3
  170. data/ext/ffi_c/libffi/src/java_raw_api.c +23 -5
  171. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  172. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  173. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  174. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  175. data/ext/ffi_c/libffi/src/loongarch64/ffi.c +624 -0
  176. data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
  177. data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
  178. data/ext/ffi_c/libffi/src/m32r/ffi.c +32 -15
  179. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +6 -1
  180. data/ext/ffi_c/libffi/src/m68k/ffi.c +87 -13
  181. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +6 -1
  182. data/ext/ffi_c/libffi/src/m68k/sysv.S +119 -32
  183. data/ext/ffi_c/libffi/src/m88k/ffi.c +400 -0
  184. data/ext/ffi_c/libffi/src/m88k/ffitarget.h +49 -0
  185. data/ext/ffi_c/libffi/src/m88k/obsd.S +209 -0
  186. data/ext/ffi_c/libffi/src/metag/ffi.c +330 -0
  187. data/ext/ffi_c/libffi/{fficonfig.hw → src/metag/ffitarget.h} +22 -26
  188. data/ext/ffi_c/libffi/src/metag/sysv.S +311 -0
  189. data/ext/ffi_c/libffi/src/microblaze/ffi.c +321 -0
  190. data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +53 -0
  191. data/ext/ffi_c/libffi/src/microblaze/sysv.S +302 -0
  192. data/ext/ffi_c/libffi/src/mips/ffi.c +382 -101
  193. data/ext/ffi_c/libffi/src/mips/ffitarget.h +23 -14
  194. data/ext/ffi_c/libffi/src/mips/n32.S +321 -89
  195. data/ext/ffi_c/libffi/src/mips/o32.S +211 -31
  196. data/ext/ffi_c/libffi/src/moxie/eabi.S +55 -82
  197. data/ext/ffi_c/libffi/src/moxie/ffi.c +100 -66
  198. data/ext/ffi_c/libffi/src/moxie/ffitarget.h +52 -0
  199. data/ext/ffi_c/libffi/src/nios2/ffi.c +304 -0
  200. data/ext/ffi_c/libffi/src/nios2/ffitarget.h +52 -0
  201. data/ext/ffi_c/libffi/src/nios2/sysv.S +136 -0
  202. data/ext/ffi_c/libffi/src/or1k/ffi.c +341 -0
  203. data/ext/ffi_c/libffi/src/or1k/ffitarget.h +58 -0
  204. data/ext/ffi_c/libffi/src/or1k/sysv.S +107 -0
  205. data/ext/ffi_c/libffi/src/pa/ffi.c +62 -108
  206. data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
  207. data/ext/ffi_c/libffi/src/pa/ffitarget.h +28 -12
  208. data/ext/ffi_c/libffi/src/pa/hpux32.S +87 -38
  209. data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
  210. data/ext/ffi_c/libffi/src/pa/linux.S +109 -39
  211. data/ext/ffi_c/libffi/src/powerpc/aix.S +245 -7
  212. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +253 -4
  213. data/ext/ffi_c/libffi/src/powerpc/asm.h +2 -2
  214. data/ext/ffi_c/libffi/src/powerpc/darwin.S +2 -7
  215. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +22 -26
  216. data/ext/ffi_c/libffi/src/powerpc/ffi.c +105 -1378
  217. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +157 -52
  218. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1153 -0
  219. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +105 -0
  220. data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +923 -0
  221. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +110 -45
  222. data/ext/ffi_c/libffi/src/powerpc/linux64.S +191 -85
  223. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +438 -108
  224. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +138 -68
  225. data/ext/ffi_c/libffi/src/powerpc/sysv.S +73 -119
  226. data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
  227. data/ext/ffi_c/libffi/src/prep_cif.c +131 -25
  228. data/ext/ffi_c/libffi/src/raw_api.c +18 -5
  229. data/ext/ffi_c/libffi/src/riscv/ffi.c +514 -0
  230. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +69 -0
  231. data/ext/ffi_c/libffi/src/riscv/sysv.S +293 -0
  232. data/ext/ffi_c/libffi/src/s390/ffi.c +294 -318
  233. data/ext/ffi_c/libffi/src/s390/ffitarget.h +9 -1
  234. data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
  235. data/ext/ffi_c/libffi/src/s390/sysv.S +257 -366
  236. data/ext/ffi_c/libffi/src/sh/ffi.c +4 -3
  237. data/ext/ffi_c/libffi/src/sh/ffitarget.h +6 -1
  238. data/ext/ffi_c/libffi/src/sh64/ffi.c +3 -2
  239. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +6 -1
  240. data/ext/ffi_c/libffi/src/sparc/ffi.c +326 -527
  241. data/ext/ffi_c/libffi/src/sparc/ffi64.c +630 -0
  242. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +20 -7
  243. data/ext/ffi_c/libffi/src/sparc/internal.h +26 -0
  244. data/ext/ffi_c/libffi/src/sparc/v8.S +364 -234
  245. data/ext/ffi_c/libffi/src/sparc/v9.S +340 -207
  246. data/ext/ffi_c/libffi/src/tile/ffi.c +355 -0
  247. data/ext/ffi_c/libffi/src/tile/ffitarget.h +65 -0
  248. data/ext/ffi_c/libffi/src/tile/tile.S +360 -0
  249. data/ext/ffi_c/libffi/src/tramp.c +716 -0
  250. data/ext/ffi_c/libffi/src/types.c +48 -19
  251. data/ext/ffi_c/libffi/src/vax/elfbsd.S +195 -0
  252. data/ext/ffi_c/libffi/src/vax/ffi.c +276 -0
  253. data/ext/ffi_c/libffi/src/vax/ffitarget.h +49 -0
  254. data/ext/ffi_c/libffi/src/wasm32/ffi.c +947 -0
  255. data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
  256. data/ext/ffi_c/libffi/src/x86/asmnames.h +30 -0
  257. data/ext/ffi_c/libffi/src/x86/ffi.c +686 -498
  258. data/ext/ffi_c/libffi/src/x86/ffi64.c +444 -129
  259. data/ext/ffi_c/libffi/src/x86/ffitarget.h +79 -36
  260. data/ext/ffi_c/libffi/src/x86/ffiw64.c +361 -0
  261. data/ext/ffi_c/libffi/src/x86/internal.h +43 -0
  262. data/ext/ffi_c/libffi/src/x86/internal64.h +36 -0
  263. data/ext/ffi_c/libffi/src/x86/sysv.S +1198 -394
  264. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +998 -0
  265. data/ext/ffi_c/libffi/src/x86/unix64.S +585 -300
  266. data/ext/ffi_c/libffi/src/x86/win64.S +244 -458
  267. data/ext/ffi_c/libffi/src/x86/win64_intel.S +238 -0
  268. data/ext/ffi_c/libffi/src/xtensa/ffi.c +306 -0
  269. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +57 -0
  270. data/ext/ffi_c/libffi/src/xtensa/sysv.S +268 -0
  271. data/ext/ffi_c/libffi/stamp-h.in +1 -0
  272. data/ext/ffi_c/libffi/testsuite/Makefile.am +80 -73
  273. data/ext/ffi_c/libffi/testsuite/Makefile.in +233 -117
  274. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
  275. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
  276. data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +86 -0
  277. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
  278. data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
  279. data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
  280. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +360 -28
  281. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +22 -2
  282. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
  283. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/README +78 -0
  284. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h +50 -0
  285. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +63 -0
  286. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1746 -0
  287. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2885 -0
  288. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +747 -0
  289. data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +46 -0
  290. data/ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c +46 -0
  291. data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
  292. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +28 -6
  293. data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +99 -0
  294. data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +108 -0
  295. data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +114 -0
  296. data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +119 -0
  297. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -2
  298. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +52 -42
  299. data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +3 -1
  300. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +15 -12
  301. data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +4 -2
  302. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +110 -0
  303. data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +6 -16
  304. data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +57 -0
  305. data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +70 -0
  306. data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +78 -0
  307. data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +0 -1
  308. data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +46 -0
  309. data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +127 -0
  310. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +1 -0
  311. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
  312. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +5 -0
  313. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +1 -1
  314. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
  315. data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +1 -1
  316. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
  317. data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
  318. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +9 -10
  319. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +49 -0
  320. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +49 -0
  321. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +55 -0
  322. data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +9 -7
  323. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +57 -0
  324. data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +7 -7
  325. data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +7 -6
  326. data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +9 -8
  327. data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +9 -8
  328. data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +9 -9
  329. data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +9 -9
  330. data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +9 -8
  331. data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +9 -8
  332. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
  333. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
  334. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
  335. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
  336. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
  337. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
  338. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
  339. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
  340. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
  341. data/ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c +61 -0
  342. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +78 -0
  343. data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
  344. data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
  345. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +134 -0
  346. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +134 -0
  347. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +140 -0
  348. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  349. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +3 -2
  350. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +2 -0
  351. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +2 -0
  352. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +21 -1
  353. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +2 -0
  354. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +2 -0
  355. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +2 -0
  356. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +7 -6
  357. data/ext/ffi_c/libffi/testsuite/{libffi.call/closure_stdcall.c → libffi.closures/closure_simple.c} +13 -16
  358. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +22 -4
  359. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +26 -4
  360. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +28 -4
  361. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +33 -4
  362. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +8 -4
  363. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +23 -5
  364. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +25 -5
  365. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +40 -8
  366. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +17 -4
  367. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +23 -4
  368. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +17 -4
  369. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +17 -4
  370. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +113 -0
  371. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +26 -4
  372. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +17 -4
  373. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +33 -5
  374. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +23 -5
  375. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +29 -5
  376. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +32 -5
  377. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +28 -6
  378. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +43 -5
  379. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +29 -5
  380. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +18 -4
  381. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +18 -5
  382. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +18 -6
  383. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +23 -5
  384. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +23 -5
  385. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +24 -5
  386. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +44 -31
  387. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +44 -9
  388. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +23 -5
  389. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +22 -5
  390. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +22 -7
  391. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +22 -5
  392. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +22 -5
  393. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +23 -5
  394. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +23 -5
  395. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +7 -5
  396. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +19 -10
  397. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +4 -0
  398. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +14 -4
  399. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +32 -12
  400. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_args.c +70 -0
  401. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c +55 -0
  402. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +5 -1
  403. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +6 -1
  404. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +9 -1
  405. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +9 -1
  406. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +6 -2
  407. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +9 -1
  408. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +6 -1
  409. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +21 -9
  410. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +3 -0
  411. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +2 -0
  412. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +3 -0
  413. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +125 -0
  414. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +3 -0
  415. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +4 -0
  416. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +49 -0
  417. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +49 -0
  418. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +7 -5
  419. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +3 -0
  420. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -0
  421. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +41 -40
  422. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +38 -15
  423. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +9 -9
  424. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +19 -6
  425. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +137 -0
  426. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
  427. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
  428. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +15 -6
  429. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +15 -6
  430. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +14 -5
  431. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +14 -5
  432. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +17 -6
  433. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +14 -5
  434. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +17 -6
  435. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +17 -6
  436. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
  437. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
  438. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
  439. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +7 -7
  440. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +7 -7
  441. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +6 -6
  442. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +6 -6
  443. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +8 -3
  444. data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest.cc +4 -10
  445. data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest_ffi_call.cc +4 -2
  446. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc +91 -0
  447. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c +10 -0
  448. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c +10 -0
  449. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +10 -0
  450. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc +42 -0
  451. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c +10 -0
  452. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c +10 -0
  453. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +10 -0
  454. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc +71 -0
  455. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +10 -0
  456. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +10 -0
  457. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +10 -0
  458. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc +80 -0
  459. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c +10 -0
  460. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c +16 -0
  461. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +10 -0
  462. data/ext/ffi_c/libffi/testsuite/{libffi.special/special.exp → libffi.complex/complex.exp} +9 -8
  463. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +51 -0
  464. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +7 -0
  465. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +7 -0
  466. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +7 -0
  467. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +10 -0
  468. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +10 -0
  469. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +86 -0
  470. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +10 -0
  471. data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +1 -0
  472. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +78 -0
  473. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +10 -0
  474. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +10 -0
  475. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +10 -0
  476. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +37 -0
  477. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +41 -0
  478. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +10 -0
  479. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +10 -0
  480. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +10 -0
  481. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +44 -0
  482. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +10 -0
  483. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +10 -0
  484. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +10 -0
  485. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +10 -0
  486. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +10 -0
  487. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +10 -0
  488. data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +34 -0
  489. data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +28 -0
  490. data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +1 -0
  491. data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +36 -0
  492. data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +19 -0
  493. data/ext/ffi_c/libffi.bsd.mk +13 -7
  494. data/ext/ffi_c/libffi.darwin.mk +25 -13
  495. data/ext/ffi_c/libffi.gnu.mk +4 -3
  496. data/ext/ffi_c/libffi.mk +11 -6
  497. data/ext/ffi_c/libffi.vc.mk +1 -1
  498. data/ext/ffi_c/libffi.vc64.mk +1 -1
  499. data/ext/ffi_c/rbffi.h +23 -15
  500. data/ext/ffi_c/rbffi_endian.h +11 -2
  501. data/ffi.gemspec +42 -0
  502. data/lib/ffi/abstract_memory.rb +44 -0
  503. data/lib/ffi/autopointer.rb +65 -68
  504. data/lib/ffi/compat.rb +43 -0
  505. data/lib/ffi/data_converter.rb +67 -0
  506. data/lib/ffi/dynamic_library.rb +118 -0
  507. data/lib/ffi/enum.rb +166 -25
  508. data/lib/ffi/errno.rb +21 -11
  509. data/lib/ffi/ffi.rb +28 -11
  510. data/lib/ffi/function.rb +71 -0
  511. data/lib/ffi/io.rb +25 -15
  512. data/lib/ffi/library.rb +227 -136
  513. data/lib/ffi/library_path.rb +109 -0
  514. data/lib/ffi/managedstruct.rb +64 -35
  515. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  516. data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
  517. data/lib/ffi/platform/aarch64-freebsd12/types.conf +181 -0
  518. data/lib/ffi/platform/aarch64-linux/types.conf +175 -0
  519. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  520. data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
  521. data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
  522. data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
  523. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  524. data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
  525. data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
  526. data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
  527. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  528. data/lib/ffi/platform/i386-freebsd/types.conf +89 -89
  529. data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
  530. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  531. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  532. data/lib/ffi/platform/i386-openbsd/types.conf +89 -87
  533. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  534. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  535. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  536. data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
  537. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  538. data/lib/ffi/platform/mips64-linux/types.conf +104 -0
  539. data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
  540. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  541. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +102 -0
  542. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +102 -0
  543. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +104 -0
  544. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +104 -0
  545. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  546. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  547. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  548. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  549. data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
  550. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  551. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  552. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  553. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  554. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  555. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  556. data/lib/ffi/platform/sparcv9-linux/types.conf +102 -0
  557. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  558. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  559. data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
  560. data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
  561. data/lib/ffi/platform/x86_64-darwin/types.conf +93 -63
  562. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  563. data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -88
  564. data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
  565. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  566. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  567. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  568. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -87
  569. data/lib/ffi/platform/x86_64-openbsd/types.conf +100 -92
  570. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  571. data/lib/ffi/platform/x86_64-windows/types.conf +52 -0
  572. data/lib/ffi/platform.rb +91 -34
  573. data/lib/ffi/pointer.rb +78 -33
  574. data/lib/ffi/struct.rb +100 -66
  575. data/lib/ffi/struct_by_reference.rb +72 -0
  576. data/lib/ffi/struct_layout.rb +96 -0
  577. data/lib/ffi/struct_layout_builder.rb +84 -19
  578. data/lib/ffi/tools/const_generator.rb +11 -8
  579. data/lib/ffi/tools/generator.rb +48 -1
  580. data/lib/ffi/tools/generator_task.rb +13 -16
  581. data/lib/ffi/tools/struct_generator.rb +6 -5
  582. data/lib/ffi/tools/types_generator.rb +14 -10
  583. data/lib/ffi/types.rb +96 -51
  584. data/lib/ffi/union.rb +23 -12
  585. data/lib/ffi/variadic.rb +44 -29
  586. data/lib/ffi/version.rb +3 -0
  587. data/lib/ffi.rb +20 -8
  588. data/rakelib/ffi_gem_helper.rb +65 -0
  589. data/samples/getlogin.rb +8 -0
  590. data/samples/getpid.rb +8 -0
  591. data/samples/gettimeofday.rb +18 -0
  592. data/samples/hello.rb +8 -0
  593. data/samples/hello_ractor.rb +11 -0
  594. data/samples/inotify.rb +60 -0
  595. data/samples/pty.rb +75 -0
  596. data/samples/qsort.rb +20 -0
  597. data/samples/qsort_ractor.rb +28 -0
  598. data/sig/ffi/abstract_memory.rbs +165 -0
  599. data/sig/ffi/auto_pointer.rbs +27 -0
  600. data/sig/ffi/buffer.rbs +18 -0
  601. data/sig/ffi/data_converter.rbs +10 -0
  602. data/sig/ffi/dynamic_library.rbs +9 -0
  603. data/sig/ffi/enum.rbs +38 -0
  604. data/sig/ffi/function.rbs +39 -0
  605. data/sig/ffi/library.rbs +42 -0
  606. data/sig/ffi/native_type.rbs +86 -0
  607. data/sig/ffi/pointer.rbs +42 -0
  608. data/sig/ffi/struct.rbs +76 -0
  609. data/sig/ffi/struct_by_reference.rbs +11 -0
  610. data/sig/ffi/struct_by_value.rbs +7 -0
  611. data/sig/ffi/struct_layout.rbs +9 -0
  612. data/sig/ffi/struct_layout_builder.rbs +5 -0
  613. data/sig/ffi/type.rbs +39 -0
  614. data/sig/ffi.rbs +26 -0
  615. data.tar.gz.sig +0 -0
  616. metadata +508 -268
  617. metadata.gz.sig +1 -0
  618. data/History.txt +0 -1
  619. data/README.rdoc +0 -102
  620. data/ext/ffi_c/DataConverter.c +0 -91
  621. data/ext/ffi_c/Ffi_c.iml +0 -12
  622. data/ext/ffi_c/StructByReference.c +0 -158
  623. data/ext/ffi_c/StructByReference.h +0 -50
  624. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  625. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  626. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  627. data/ext/ffi_c/libffi/Makefile.vc +0 -141
  628. data/ext/ffi_c/libffi/Makefile.vc64 +0 -141
  629. data/ext/ffi_c/libffi/README +0 -342
  630. data/ext/ffi_c/libffi/aclocal.m4 +0 -1873
  631. data/ext/ffi_c/libffi/build-ios.sh +0 -67
  632. data/ext/ffi_c/libffi/depcomp +0 -630
  633. data/ext/ffi_c/libffi/doc/libffi.info +0 -593
  634. data/ext/ffi_c/libffi/doc/stamp-vti +0 -4
  635. data/ext/ffi_c/libffi/include/ffi.h.vc +0 -427
  636. data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +0 -76
  637. data/ext/ffi_c/libffi/m4/libtool.m4 +0 -7831
  638. data/ext/ffi_c/libffi/m4/ltoptions.m4 +0 -369
  639. data/ext/ffi_c/libffi/m4/ltsugar.m4 +0 -123
  640. data/ext/ffi_c/libffi/m4/ltversion.m4 +0 -23
  641. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +0 -98
  642. data/ext/ffi_c/libffi/mdate-sh +0 -201
  643. data/ext/ffi_c/libffi/src/arm/gentramp.sh +0 -118
  644. data/ext/ffi_c/libffi/src/arm/trampoline.S +0 -4450
  645. data/ext/ffi_c/libffi/src/x86/darwin.S +0 -444
  646. data/ext/ffi_c/libffi/src/x86/darwin64.S +0 -416
  647. data/ext/ffi_c/libffi/src/x86/freebsd.S +0 -458
  648. data/ext/ffi_c/libffi/src/x86/win32.S +0 -1065
  649. data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +0 -300
  650. data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +0 -63
  651. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +0 -44
  652. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +0 -96
  653. data/ext/ffi_c/libffi/texinfo.tex +0 -7210
  654. data/ext/ffi_c/win32/stdint.h +0 -199
  655. data/gen/Rakefile +0 -30
  656. data/lib/Lib.iml +0 -13
  657. data/spec/ffi/Ffi.iml +0 -12
  658. data/spec/ffi/async_callback_spec.rb +0 -46
  659. data/spec/ffi/bool_spec.rb +0 -40
  660. data/spec/ffi/buffer_spec.rb +0 -215
  661. data/spec/ffi/callback_spec.rb +0 -668
  662. data/spec/ffi/custom_param_type.rb +0 -47
  663. data/spec/ffi/custom_type_spec.rb +0 -85
  664. data/spec/ffi/dup_spec.rb +0 -65
  665. data/spec/ffi/enum_spec.rb +0 -227
  666. data/spec/ffi/errno_spec.rb +0 -29
  667. data/spec/ffi/ffi_spec.rb +0 -40
  668. data/spec/ffi/function_spec.rb +0 -87
  669. data/spec/ffi/library_spec.rb +0 -208
  670. data/spec/ffi/long_double.rb +0 -41
  671. data/spec/ffi/managed_struct_spec.rb +0 -72
  672. data/spec/ffi/number_spec.rb +0 -247
  673. data/spec/ffi/pointer_spec.rb +0 -214
  674. data/spec/ffi/rbx/attach_function_spec.rb +0 -28
  675. data/spec/ffi/rbx/memory_pointer_spec.rb +0 -111
  676. data/spec/ffi/rbx/spec_helper.rb +0 -1
  677. data/spec/ffi/rbx/struct_spec.rb +0 -13
  678. data/spec/ffi/spec_helper.rb +0 -35
  679. data/spec/ffi/string_spec.rb +0 -119
  680. data/spec/ffi/strptr_spec.rb +0 -61
  681. data/spec/ffi/struct_callback_spec.rb +0 -80
  682. data/spec/ffi/struct_initialize_spec.rb +0 -46
  683. data/spec/ffi/struct_packed_spec.rb +0 -62
  684. data/spec/ffi/struct_spec.rb +0 -719
  685. data/spec/ffi/typedef_spec.rb +0 -89
  686. data/spec/ffi/union_spec.rb +0 -76
  687. data/spec/ffi/variadic_spec.rb +0 -103
  688. data/spec/spec.opts +0 -4
  689. data/tasks/ann.rake +0 -80
  690. data/tasks/extension.rake +0 -32
  691. data/tasks/gem.rake +0 -199
  692. data/tasks/git.rake +0 -41
  693. data/tasks/notes.rake +0 -27
  694. data/tasks/post_load.rake +0 -34
  695. data/tasks/rdoc.rake +0 -50
  696. data/tasks/rubyforge.rake +0 -55
  697. data/tasks/setup.rb +0 -301
  698. data/tasks/spec.rake +0 -54
  699. data/tasks/svn.rake +0 -47
  700. data/tasks/test.rake +0 -40
  701. data/tasks/yard.rake +0 -11
  702. data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  703. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  704. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  705. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  706. data/lib/ffi/platform/{i486-gnu → i386-gnu}/types.conf +84 -84
@@ -1,6 +1,7 @@
1
1
  /* -----------------------------------------------------------------------
2
- unix64.S - Copyright (c) 2002 Bo Thorsen <bo@suse.de>
3
- Copyright (c) 2008 Red Hat, Inc
2
+ unix64.S - Copyright (c) 2013 The Written Word, Inc.
3
+ - Copyright (c) 2008 Red Hat, Inc
4
+ - Copyright (c) 2002 Bo Thorsen <bo@suse.de>
4
5
 
5
6
  x86-64 Foreign Function Interface
6
7
 
@@ -29,8 +30,23 @@
29
30
  #define LIBFFI_ASM
30
31
  #include <fficonfig.h>
31
32
  #include <ffi.h>
32
-
33
- .text
33
+ #include "internal64.h"
34
+ #include "asmnames.h"
35
+
36
+ .text
37
+
38
+ /* This macro allows the safe creation of jump tables without an
39
+ actual table. The entry points into the table are all 8 bytes.
40
+ The use of ORG asserts that we're at the correct location. */
41
+ /* ??? The clang assembler doesn't handle .org with symbolic expressions. */
42
+ #ifdef __CET__
43
+ /* Double slot size to 16 byte to add 4 bytes of ENDBR64. */
44
+ # define E(BASE, X) .balign 8; .org BASE + X * 16
45
+ #elif defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
46
+ # define E(BASE, X) .balign 8
47
+ #else
48
+ # define E(BASE, X) .balign 8; .org BASE + X * 8
49
+ #endif
34
50
 
35
51
  /* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
36
52
  void *raddr, void (*fnaddr)(void));
@@ -39,12 +55,13 @@
39
55
  for this function. This has been allocated by ffi_call. We also
40
56
  deallocate some of the stack that has been alloca'd. */
41
57
 
42
- .align 2
43
- .globl ffi_call_unix64
44
- .type ffi_call_unix64,@function
58
+ .balign 8
59
+ .globl C(ffi_call_unix64)
60
+ FFI_HIDDEN(C(ffi_call_unix64))
45
61
 
46
- ffi_call_unix64:
47
- .LUW0:
62
+ C(ffi_call_unix64):
63
+ L(UW0):
64
+ _CET_ENDBR
48
65
  movq (%rsp), %r10 /* Load return address. */
49
66
  leaq (%rdi, %rsi), %rax /* Find local stack base. */
50
67
  movq %rdx, (%rax) /* Save flags. */
@@ -52,24 +69,36 @@ ffi_call_unix64:
52
69
  movq %rbp, 16(%rax) /* Save old frame pointer. */
53
70
  movq %r10, 24(%rax) /* Relocate return address. */
54
71
  movq %rax, %rbp /* Finalize local stack frame. */
55
- .LUW1:
72
+
73
+ /* New stack frame based off rbp. This is a itty bit of unwind
74
+ trickery in that the CFA *has* changed. There is no easy way
75
+ to describe it correctly on entry to the function. Fortunately,
76
+ it doesn't matter too much since at all points we can correctly
77
+ unwind back to ffi_call. Note that the location to which we
78
+ moved the return address is (the new) CFA-8, so from the
79
+ perspective of the unwind info, it hasn't moved. */
80
+ L(UW1):
81
+ /* cfi_def_cfa(%rbp, 32) */
82
+ /* cfi_rel_offset(%rbp, 16) */
83
+
56
84
  movq %rdi, %r10 /* Save a copy of the register area. */
57
85
  movq %r8, %r11 /* Save a copy of the target fn. */
58
- movl %r9d, %eax /* Set number of SSE registers. */
59
86
 
60
87
  /* Load up all argument registers. */
61
88
  movq (%r10), %rdi
62
- movq 8(%r10), %rsi
63
- movq 16(%r10), %rdx
64
- movq 24(%r10), %rcx
65
- movq 32(%r10), %r8
66
- movq 40(%r10), %r9
89
+ movq 0x08(%r10), %rsi
90
+ movq 0x10(%r10), %rdx
91
+ movq 0x18(%r10), %rcx
92
+ movq 0x20(%r10), %r8
93
+ movq 0x28(%r10), %r9
94
+ movl 0xb0(%r10), %eax /* Set number of SSE registers. */
67
95
  testl %eax, %eax
68
- jnz .Lload_sse
69
- .Lret_from_load_sse:
96
+ jnz L(load_sse)
97
+ L(ret_from_load_sse):
70
98
 
71
- /* Deallocate the reg arg area. */
72
- leaq 176(%r10), %rsp
99
+ /* Deallocate the reg arg area, except for r10, then load via pop. */
100
+ leaq 0xb8(%r10), %rsp
101
+ popq %r10
73
102
 
74
103
  /* Call the user function. */
75
104
  call *%r11
@@ -80,347 +109,603 @@ ffi_call_unix64:
80
109
  movq 0(%rbp), %rcx /* Reload flags. */
81
110
  movq 8(%rbp), %rdi /* Reload raddr. */
82
111
  movq 16(%rbp), %rbp /* Reload old frame pointer. */
83
- .LUW2:
112
+ L(UW2):
113
+ /* cfi_remember_state */
114
+ /* cfi_def_cfa(%rsp, 8) */
115
+ /* cfi_restore(%rbp) */
84
116
 
85
117
  /* The first byte of the flags contains the FFI_TYPE. */
118
+ cmpb $UNIX64_RET_LAST, %cl
86
119
  movzbl %cl, %r10d
87
- leaq .Lstore_table(%rip), %r11
88
- movslq (%r11, %r10, 4), %r10
89
- addq %r11, %r10
120
+ leaq L(store_table)(%rip), %r11
121
+ ja L(sa)
122
+ #ifdef __CET__
123
+ /* NB: Originally, each slot is 8 byte. 4 bytes of ENDBR64 +
124
+ 4 bytes NOP padding double slot size to 16 bytes. */
125
+ addl %r10d, %r10d
126
+ #endif
127
+ leaq (%r11, %r10, 8), %r10
128
+
129
+ /* Prep for the structure cases: scratch area in redzone. */
130
+ leaq -20(%rsp), %rsi
90
131
  jmp *%r10
91
132
 
92
- .Lstore_table:
93
- .long .Lst_void-.Lstore_table /* FFI_TYPE_VOID */
94
- .long .Lst_sint32-.Lstore_table /* FFI_TYPE_INT */
95
- .long .Lst_float-.Lstore_table /* FFI_TYPE_FLOAT */
96
- .long .Lst_double-.Lstore_table /* FFI_TYPE_DOUBLE */
97
- .long .Lst_ldouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
98
- .long .Lst_uint8-.Lstore_table /* FFI_TYPE_UINT8 */
99
- .long .Lst_sint8-.Lstore_table /* FFI_TYPE_SINT8 */
100
- .long .Lst_uint16-.Lstore_table /* FFI_TYPE_UINT16 */
101
- .long .Lst_sint16-.Lstore_table /* FFI_TYPE_SINT16 */
102
- .long .Lst_uint32-.Lstore_table /* FFI_TYPE_UINT32 */
103
- .long .Lst_sint32-.Lstore_table /* FFI_TYPE_SINT32 */
104
- .long .Lst_int64-.Lstore_table /* FFI_TYPE_UINT64 */
105
- .long .Lst_int64-.Lstore_table /* FFI_TYPE_SINT64 */
106
- .long .Lst_struct-.Lstore_table /* FFI_TYPE_STRUCT */
107
- .long .Lst_int64-.Lstore_table /* FFI_TYPE_POINTER */
108
-
109
- .align 2
110
- .Lst_void:
133
+ .balign 8
134
+ L(store_table):
135
+ E(L(store_table), UNIX64_RET_VOID)
136
+ _CET_ENDBR
111
137
  ret
112
- .align 2
113
-
114
- .Lst_uint8:
115
- movzbq %al, %rax
138
+ E(L(store_table), UNIX64_RET_UINT8)
139
+ _CET_ENDBR
140
+ movzbl %al, %eax
116
141
  movq %rax, (%rdi)
117
142
  ret
118
- .align 2
119
- .Lst_sint8:
120
- movsbq %al, %rax
143
+ E(L(store_table), UNIX64_RET_UINT16)
144
+ _CET_ENDBR
145
+ movzwl %ax, %eax
121
146
  movq %rax, (%rdi)
122
147
  ret
123
- .align 2
124
- .Lst_uint16:
125
- movzwq %ax, %rax
148
+ E(L(store_table), UNIX64_RET_UINT32)
149
+ _CET_ENDBR
150
+ movl %eax, %eax
126
151
  movq %rax, (%rdi)
127
- .align 2
128
- .Lst_sint16:
129
- movswq %ax, %rax
152
+ ret
153
+ E(L(store_table), UNIX64_RET_SINT8)
154
+ _CET_ENDBR
155
+ movsbq %al, %rax
130
156
  movq %rax, (%rdi)
131
157
  ret
132
- .align 2
133
- .Lst_uint32:
134
- movl %eax, %eax
158
+ E(L(store_table), UNIX64_RET_SINT16)
159
+ _CET_ENDBR
160
+ movswq %ax, %rax
135
161
  movq %rax, (%rdi)
136
- .align 2
137
- .Lst_sint32:
162
+ ret
163
+ E(L(store_table), UNIX64_RET_SINT32)
164
+ _CET_ENDBR
138
165
  cltq
139
166
  movq %rax, (%rdi)
140
167
  ret
141
- .align 2
142
- .Lst_int64:
168
+ E(L(store_table), UNIX64_RET_INT64)
169
+ _CET_ENDBR
143
170
  movq %rax, (%rdi)
144
171
  ret
145
-
146
- .align 2
147
- .Lst_float:
148
- movss %xmm0, (%rdi)
172
+ E(L(store_table), UNIX64_RET_XMM32)
173
+ _CET_ENDBR
174
+ movd %xmm0, (%rdi)
149
175
  ret
150
- .align 2
151
- .Lst_double:
152
- movsd %xmm0, (%rdi)
176
+ E(L(store_table), UNIX64_RET_XMM64)
177
+ _CET_ENDBR
178
+ movq %xmm0, (%rdi)
153
179
  ret
154
- .Lst_ldouble:
180
+ E(L(store_table), UNIX64_RET_X87)
181
+ _CET_ENDBR
155
182
  fstpt (%rdi)
156
183
  ret
157
-
158
- .align 2
159
- .Lst_struct:
160
- leaq -20(%rsp), %rsi /* Scratch area in redzone. */
161
-
162
- /* We have to locate the values now, and since we don't want to
163
- write too much data into the user's return value, we spill the
164
- value to a 16 byte scratch area first. Bits 8, 9, and 10
165
- control where the values are located. Only one of the three
166
- bits will be set; see ffi_prep_cif_machdep for the pattern. */
167
- movd %xmm0, %r10
168
- movd %xmm1, %r11
169
- testl $0x100, %ecx
170
- cmovnz %rax, %rdx
171
- cmovnz %r10, %rax
172
- testl $0x200, %ecx
173
- cmovnz %r10, %rdx
174
- testl $0x400, %ecx
175
- cmovnz %r10, %rax
176
- cmovnz %r11, %rdx
177
- movq %rax, (%rsi)
184
+ E(L(store_table), UNIX64_RET_X87_2)
185
+ _CET_ENDBR
186
+ fstpt (%rdi)
187
+ fstpt 16(%rdi)
188
+ ret
189
+ E(L(store_table), UNIX64_RET_ST_XMM0_RAX)
190
+ _CET_ENDBR
191
+ movq %rax, 8(%rsi)
192
+ jmp L(s3)
193
+ E(L(store_table), UNIX64_RET_ST_RAX_XMM0)
194
+ _CET_ENDBR
195
+ movq %xmm0, 8(%rsi)
196
+ jmp L(s2)
197
+ E(L(store_table), UNIX64_RET_ST_XMM0_XMM1)
198
+ _CET_ENDBR
199
+ movq %xmm1, 8(%rsi)
200
+ jmp L(s3)
201
+ E(L(store_table), UNIX64_RET_ST_RAX_RDX)
202
+ _CET_ENDBR
178
203
  movq %rdx, 8(%rsi)
179
-
180
- /* Bits 12-31 contain the true size of the structure. Copy from
181
- the scratch area to the true destination. */
182
- shrl $12, %ecx
204
+ L(s2):
205
+ movq %rax, (%rsi)
206
+ shrl $UNIX64_SIZE_SHIFT, %ecx
207
+ rep movsb
208
+ ret
209
+ .balign 8
210
+ L(s3):
211
+ movq %xmm0, (%rsi)
212
+ shrl $UNIX64_SIZE_SHIFT, %ecx
183
213
  rep movsb
184
214
  ret
185
215
 
216
+ L(sa): call PLT(C(abort))
217
+
186
218
  /* Many times we can avoid loading any SSE registers at all.
187
219
  It's not worth an indirect jump to load the exact set of
188
220
  SSE registers needed; zero or all is a good compromise. */
189
- .align 2
190
- .LUW3:
191
- .Lload_sse:
192
- movdqa 48(%r10), %xmm0
193
- movdqa 64(%r10), %xmm1
194
- movdqa 80(%r10), %xmm2
195
- movdqa 96(%r10), %xmm3
196
- movdqa 112(%r10), %xmm4
197
- movdqa 128(%r10), %xmm5
198
- movdqa 144(%r10), %xmm6
199
- movdqa 160(%r10), %xmm7
200
- jmp .Lret_from_load_sse
201
-
202
- .LUW4:
203
- .size ffi_call_unix64,.-ffi_call_unix64
204
-
205
- .align 2
206
- .globl ffi_closure_unix64
207
- .type ffi_closure_unix64,@function
208
-
209
- ffi_closure_unix64:
210
- .LUW5:
211
- /* The carry flag is set by the trampoline iff SSE registers
212
- are used. Don't clobber it before the branch instruction. */
213
- leaq -200(%rsp), %rsp
214
- .LUW6:
215
- movq %rdi, (%rsp)
216
- movq %rsi, 8(%rsp)
217
- movq %rdx, 16(%rsp)
218
- movq %rcx, 24(%rsp)
219
- movq %r8, 32(%rsp)
220
- movq %r9, 40(%rsp)
221
- jc .Lsave_sse
222
- .Lret_from_save_sse:
223
-
224
- movq %r10, %rdi
225
- leaq 176(%rsp), %rsi
226
- movq %rsp, %rdx
227
- leaq 208(%rsp), %rcx
228
- call ffi_closure_unix64_inner@PLT
221
+ .balign 2
222
+ L(UW3):
223
+ /* cfi_restore_state */
224
+ L(load_sse):
225
+ movdqa 0x30(%r10), %xmm0
226
+ movdqa 0x40(%r10), %xmm1
227
+ movdqa 0x50(%r10), %xmm2
228
+ movdqa 0x60(%r10), %xmm3
229
+ movdqa 0x70(%r10), %xmm4
230
+ movdqa 0x80(%r10), %xmm5
231
+ movdqa 0x90(%r10), %xmm6
232
+ movdqa 0xa0(%r10), %xmm7
233
+ jmp L(ret_from_load_sse)
234
+
235
+ L(UW4):
236
+ ENDF(C(ffi_call_unix64))
237
+
238
+ /* 6 general registers, 8 vector registers,
239
+ 32 bytes of rvalue, 8 bytes of alignment. */
240
+ #define ffi_closure_OFS_G 0
241
+ #define ffi_closure_OFS_V (6*8)
242
+ #define ffi_closure_OFS_RVALUE (ffi_closure_OFS_V + 8*16)
243
+ #define ffi_closure_FS (ffi_closure_OFS_RVALUE + 32 + 8)
244
+
245
+ /* The location of rvalue within the red zone after deallocating the frame. */
246
+ #define ffi_closure_RED_RVALUE (ffi_closure_OFS_RVALUE - ffi_closure_FS)
247
+
248
+ .balign 2
249
+ .globl C(ffi_closure_unix64_sse)
250
+ FFI_HIDDEN(C(ffi_closure_unix64_sse))
251
+
252
+ C(ffi_closure_unix64_sse):
253
+ L(UW5):
254
+ _CET_ENDBR
255
+ subq $ffi_closure_FS, %rsp
256
+ L(UW6):
257
+ /* cfi_adjust_cfa_offset(ffi_closure_FS) */
258
+
259
+ movdqa %xmm0, ffi_closure_OFS_V+0x00(%rsp)
260
+ movdqa %xmm1, ffi_closure_OFS_V+0x10(%rsp)
261
+ movdqa %xmm2, ffi_closure_OFS_V+0x20(%rsp)
262
+ movdqa %xmm3, ffi_closure_OFS_V+0x30(%rsp)
263
+ movdqa %xmm4, ffi_closure_OFS_V+0x40(%rsp)
264
+ movdqa %xmm5, ffi_closure_OFS_V+0x50(%rsp)
265
+ movdqa %xmm6, ffi_closure_OFS_V+0x60(%rsp)
266
+ movdqa %xmm7, ffi_closure_OFS_V+0x70(%rsp)
267
+ jmp L(sse_entry1)
268
+
269
+ L(UW7):
270
+ ENDF(C(ffi_closure_unix64_sse))
271
+
272
+ .balign 2
273
+ .globl C(ffi_closure_unix64)
274
+ FFI_HIDDEN(C(ffi_closure_unix64))
275
+
276
+ C(ffi_closure_unix64):
277
+ L(UW8):
278
+ _CET_ENDBR
279
+ subq $ffi_closure_FS, %rsp
280
+ L(UW9):
281
+ /* cfi_adjust_cfa_offset(ffi_closure_FS) */
282
+ L(sse_entry1):
283
+ movq %rdi, ffi_closure_OFS_G+0x00(%rsp)
284
+ movq %rsi, ffi_closure_OFS_G+0x08(%rsp)
285
+ movq %rdx, ffi_closure_OFS_G+0x10(%rsp)
286
+ movq %rcx, ffi_closure_OFS_G+0x18(%rsp)
287
+ movq %r8, ffi_closure_OFS_G+0x20(%rsp)
288
+ movq %r9, ffi_closure_OFS_G+0x28(%rsp)
289
+
290
+ #ifdef __ILP32__
291
+ movl FFI_TRAMPOLINE_SIZE(%r10), %edi /* Load cif */
292
+ movl FFI_TRAMPOLINE_SIZE+4(%r10), %esi /* Load fun */
293
+ movl FFI_TRAMPOLINE_SIZE+8(%r10), %edx /* Load user_data */
294
+ #else
295
+ movq FFI_TRAMPOLINE_SIZE(%r10), %rdi /* Load cif */
296
+ movq FFI_TRAMPOLINE_SIZE+8(%r10), %rsi /* Load fun */
297
+ movq FFI_TRAMPOLINE_SIZE+16(%r10), %rdx /* Load user_data */
298
+ #endif
299
+ L(do_closure):
300
+ leaq ffi_closure_OFS_RVALUE(%rsp), %rcx /* Load rvalue */
301
+ movq %rsp, %r8 /* Load reg_args */
302
+ leaq ffi_closure_FS+8(%rsp), %r9 /* Load argp */
303
+ call PLT(C(ffi_closure_unix64_inner))
229
304
 
230
305
  /* Deallocate stack frame early; return value is now in redzone. */
231
- addq $200, %rsp
232
- .LUW7:
306
+ addq $ffi_closure_FS, %rsp
307
+ L(UW10):
308
+ /* cfi_adjust_cfa_offset(-ffi_closure_FS) */
233
309
 
234
310
  /* The first byte of the return value contains the FFI_TYPE. */
311
+ cmpb $UNIX64_RET_LAST, %al
235
312
  movzbl %al, %r10d
236
- leaq .Lload_table(%rip), %r11
237
- movslq (%r11, %r10, 4), %r10
238
- addq %r11, %r10
313
+ leaq L(load_table)(%rip), %r11
314
+ ja L(la)
315
+ #ifdef __CET__
316
+ /* NB: Originally, each slot is 8 byte. 4 bytes of ENDBR64 +
317
+ 4 bytes NOP padding double slot size to 16 bytes. */
318
+ addl %r10d, %r10d
319
+ #endif
320
+ leaq (%r11, %r10, 8), %r10
321
+ leaq ffi_closure_RED_RVALUE(%rsp), %rsi
239
322
  jmp *%r10
240
323
 
241
- .Lload_table:
242
- .long .Lld_void-.Lload_table /* FFI_TYPE_VOID */
243
- .long .Lld_int32-.Lload_table /* FFI_TYPE_INT */
244
- .long .Lld_float-.Lload_table /* FFI_TYPE_FLOAT */
245
- .long .Lld_double-.Lload_table /* FFI_TYPE_DOUBLE */
246
- .long .Lld_ldouble-.Lload_table /* FFI_TYPE_LONGDOUBLE */
247
- .long .Lld_int8-.Lload_table /* FFI_TYPE_UINT8 */
248
- .long .Lld_int8-.Lload_table /* FFI_TYPE_SINT8 */
249
- .long .Lld_int16-.Lload_table /* FFI_TYPE_UINT16 */
250
- .long .Lld_int16-.Lload_table /* FFI_TYPE_SINT16 */
251
- .long .Lld_int32-.Lload_table /* FFI_TYPE_UINT32 */
252
- .long .Lld_int32-.Lload_table /* FFI_TYPE_SINT32 */
253
- .long .Lld_int64-.Lload_table /* FFI_TYPE_UINT64 */
254
- .long .Lld_int64-.Lload_table /* FFI_TYPE_SINT64 */
255
- .long .Lld_struct-.Lload_table /* FFI_TYPE_STRUCT */
256
- .long .Lld_int64-.Lload_table /* FFI_TYPE_POINTER */
257
-
258
- .align 2
259
- .Lld_void:
324
+ .balign 8
325
+ L(load_table):
326
+ E(L(load_table), UNIX64_RET_VOID)
327
+ _CET_ENDBR
260
328
  ret
261
-
262
- .align 2
263
- .Lld_int8:
264
- movzbl -24(%rsp), %eax
329
+ E(L(load_table), UNIX64_RET_UINT8)
330
+ _CET_ENDBR
331
+ movzbl (%rsi), %eax
265
332
  ret
266
- .align 2
267
- .Lld_int16:
268
- movzwl -24(%rsp), %eax
333
+ E(L(load_table), UNIX64_RET_UINT16)
334
+ _CET_ENDBR
335
+ movzwl (%rsi), %eax
269
336
  ret
270
- .align 2
271
- .Lld_int32:
272
- movl -24(%rsp), %eax
337
+ E(L(load_table), UNIX64_RET_UINT32)
338
+ _CET_ENDBR
339
+ movl (%rsi), %eax
273
340
  ret
274
- .align 2
275
- .Lld_int64:
276
- movq -24(%rsp), %rax
341
+ E(L(load_table), UNIX64_RET_SINT8)
342
+ _CET_ENDBR
343
+ movsbl (%rsi), %eax
277
344
  ret
278
-
279
- .align 2
280
- .Lld_float:
281
- movss -24(%rsp), %xmm0
345
+ E(L(load_table), UNIX64_RET_SINT16)
346
+ _CET_ENDBR
347
+ movswl (%rsi), %eax
282
348
  ret
283
- .align 2
284
- .Lld_double:
285
- movsd -24(%rsp), %xmm0
349
+ E(L(load_table), UNIX64_RET_SINT32)
350
+ _CET_ENDBR
351
+ movl (%rsi), %eax
286
352
  ret
287
- .align 2
288
- .Lld_ldouble:
289
- fldt -24(%rsp)
353
+ E(L(load_table), UNIX64_RET_INT64)
354
+ _CET_ENDBR
355
+ movq (%rsi), %rax
290
356
  ret
291
-
292
- .align 2
293
- .Lld_struct:
294
- /* There are four possibilities here, %rax/%rdx, %xmm0/%rax,
295
- %rax/%xmm0, %xmm0/%xmm1. We collapse two by always loading
296
- both rdx and xmm1 with the second word. For the remaining,
297
- bit 8 set means xmm0 gets the second word, and bit 9 means
298
- that rax gets the second word. */
299
- movq -24(%rsp), %rcx
300
- movq -16(%rsp), %rdx
301
- movq -16(%rsp), %xmm1
302
- testl $0x100, %eax
303
- cmovnz %rdx, %rcx
304
- movd %rcx, %xmm0
305
- testl $0x200, %eax
306
- movq -24(%rsp), %rax
307
- cmovnz %rdx, %rax
357
+ E(L(load_table), UNIX64_RET_XMM32)
358
+ _CET_ENDBR
359
+ movd (%rsi), %xmm0
360
+ ret
361
+ E(L(load_table), UNIX64_RET_XMM64)
362
+ _CET_ENDBR
363
+ movq (%rsi), %xmm0
364
+ ret
365
+ E(L(load_table), UNIX64_RET_X87)
366
+ _CET_ENDBR
367
+ fldt (%rsi)
368
+ ret
369
+ E(L(load_table), UNIX64_RET_X87_2)
370
+ _CET_ENDBR
371
+ fldt 16(%rsi)
372
+ fldt (%rsi)
373
+ ret
374
+ E(L(load_table), UNIX64_RET_ST_XMM0_RAX)
375
+ _CET_ENDBR
376
+ movq 8(%rsi), %rax
377
+ jmp L(l3)
378
+ E(L(load_table), UNIX64_RET_ST_RAX_XMM0)
379
+ _CET_ENDBR
380
+ movq 8(%rsi), %xmm0
381
+ jmp L(l2)
382
+ E(L(load_table), UNIX64_RET_ST_XMM0_XMM1)
383
+ _CET_ENDBR
384
+ movq 8(%rsi), %xmm1
385
+ jmp L(l3)
386
+ E(L(load_table), UNIX64_RET_ST_RAX_RDX)
387
+ _CET_ENDBR
388
+ movq 8(%rsi), %rdx
389
+ L(l2):
390
+ movq (%rsi), %rax
391
+ ret
392
+ .balign 8
393
+ L(l3):
394
+ movq (%rsi), %xmm0
308
395
  ret
309
396
 
310
- /* See the comment above .Lload_sse; the same logic applies here. */
311
- .align 2
312
- .LUW8:
313
- .Lsave_sse:
314
- movdqa %xmm0, 48(%rsp)
315
- movdqa %xmm1, 64(%rsp)
316
- movdqa %xmm2, 80(%rsp)
317
- movdqa %xmm3, 96(%rsp)
318
- movdqa %xmm4, 112(%rsp)
319
- movdqa %xmm5, 128(%rsp)
320
- movdqa %xmm6, 144(%rsp)
321
- movdqa %xmm7, 160(%rsp)
322
- jmp .Lret_from_save_sse
323
-
324
- .LUW9:
325
- .size ffi_closure_unix64,.-ffi_closure_unix64
326
-
327
- #ifdef HAVE_AS_X86_64_UNWIND_SECTION_TYPE
328
- .section .eh_frame,"a",@unwind
397
+ L(la): call PLT(C(abort))
398
+
399
+ L(UW11):
400
+ ENDF(C(ffi_closure_unix64))
401
+
402
+ .balign 2
403
+ .globl C(ffi_go_closure_unix64_sse)
404
+ FFI_HIDDEN(C(ffi_go_closure_unix64_sse))
405
+
406
+ C(ffi_go_closure_unix64_sse):
407
+ L(UW12):
408
+ _CET_ENDBR
409
+ subq $ffi_closure_FS, %rsp
410
+ L(UW13):
411
+ /* cfi_adjust_cfa_offset(ffi_closure_FS) */
412
+
413
+ movdqa %xmm0, ffi_closure_OFS_V+0x00(%rsp)
414
+ movdqa %xmm1, ffi_closure_OFS_V+0x10(%rsp)
415
+ movdqa %xmm2, ffi_closure_OFS_V+0x20(%rsp)
416
+ movdqa %xmm3, ffi_closure_OFS_V+0x30(%rsp)
417
+ movdqa %xmm4, ffi_closure_OFS_V+0x40(%rsp)
418
+ movdqa %xmm5, ffi_closure_OFS_V+0x50(%rsp)
419
+ movdqa %xmm6, ffi_closure_OFS_V+0x60(%rsp)
420
+ movdqa %xmm7, ffi_closure_OFS_V+0x70(%rsp)
421
+ jmp L(sse_entry2)
422
+
423
+ L(UW14):
424
+ ENDF(C(ffi_go_closure_unix64_sse))
425
+
426
+ .balign 2
427
+ .globl C(ffi_go_closure_unix64)
428
+ FFI_HIDDEN(C(ffi_go_closure_unix64))
429
+
430
+ C(ffi_go_closure_unix64):
431
+ L(UW15):
432
+ _CET_ENDBR
433
+ subq $ffi_closure_FS, %rsp
434
+ L(UW16):
435
+ /* cfi_adjust_cfa_offset(ffi_closure_FS) */
436
+ L(sse_entry2):
437
+ movq %rdi, ffi_closure_OFS_G+0x00(%rsp)
438
+ movq %rsi, ffi_closure_OFS_G+0x08(%rsp)
439
+ movq %rdx, ffi_closure_OFS_G+0x10(%rsp)
440
+ movq %rcx, ffi_closure_OFS_G+0x18(%rsp)
441
+ movq %r8, ffi_closure_OFS_G+0x20(%rsp)
442
+ movq %r9, ffi_closure_OFS_G+0x28(%rsp)
443
+
444
+ #ifdef __ILP32__
445
+ movl 4(%r10), %edi /* Load cif */
446
+ movl 8(%r10), %esi /* Load fun */
447
+ movl %r10d, %edx /* Load closure (user_data) */
329
448
  #else
330
- .section .eh_frame,"a",@progbits
449
+ movq 8(%r10), %rdi /* Load cif */
450
+ movq 16(%r10), %rsi /* Load fun */
451
+ movq %r10, %rdx /* Load closure (user_data) */
331
452
  #endif
332
- .Lframe1:
333
- .long .LECIE1-.LSCIE1 /* CIE Length */
334
- .LSCIE1:
335
- .long 0 /* CIE Identifier Tag */
336
- .byte 1 /* CIE Version */
337
- .ascii "zR\0" /* CIE Augmentation */
338
- .uleb128 1 /* CIE Code Alignment Factor */
339
- .sleb128 -8 /* CIE Data Alignment Factor */
340
- .byte 0x10 /* CIE RA Column */
341
- .uleb128 1 /* Augmentation size */
342
- .byte 0x1b /* FDE Encoding (pcrel sdata4) */
343
- .byte 0xc /* DW_CFA_def_cfa, %rsp offset 8 */
344
- .uleb128 7
345
- .uleb128 8
346
- .byte 0x80+16 /* DW_CFA_offset, %rip offset 1*-8 */
347
- .uleb128 1
348
- .align 8
349
- .LECIE1:
350
- .LSFDE1:
351
- .long .LEFDE1-.LASFDE1 /* FDE Length */
352
- .LASFDE1:
353
- .long .LASFDE1-.Lframe1 /* FDE CIE offset */
354
- #if HAVE_AS_X86_PCREL
355
- .long .LUW0-. /* FDE initial location */
453
+ jmp L(do_closure)
454
+
455
+ L(UW17):
456
+ ENDF(C(ffi_go_closure_unix64))
457
+
458
+ #if defined(FFI_EXEC_STATIC_TRAMP)
459
+ .balign 8
460
+ .globl C(ffi_closure_unix64_sse_alt)
461
+ FFI_HIDDEN(C(ffi_closure_unix64_sse_alt))
462
+
463
+ C(ffi_closure_unix64_sse_alt):
464
+ /* See the comments above trampoline_code_table. */
465
+ _CET_ENDBR
466
+ movq 8(%rsp), %r10 /* Load closure in r10 */
467
+ addq $16, %rsp /* Restore the stack */
468
+ jmp C(ffi_closure_unix64_sse)
469
+ ENDF(C(ffi_closure_unix64_sse_alt))
470
+
471
+ .balign 8
472
+ .globl C(ffi_closure_unix64_alt)
473
+ FFI_HIDDEN(C(ffi_closure_unix64_alt))
474
+
475
+ C(ffi_closure_unix64_alt):
476
+ /* See the comments above trampoline_code_table. */
477
+ _CET_ENDBR
478
+ movq 8(%rsp), %r10 /* Load closure in r10 */
479
+ addq $16, %rsp /* Restore the stack */
480
+ jmp C(ffi_closure_unix64)
481
+ ENDF(C(ffi_closure_unix64_alt))
482
+
483
+ /*
484
+ * Below is the definition of the trampoline code table. Each element in
485
+ * the code table is a trampoline.
486
+ *
487
+ * Because we jump to the trampoline, we place a _CET_ENDBR at the
488
+ * beginning of the trampoline to mark it as a valid branch target. This is
489
+ * part of the the Intel CET (Control Flow Enforcement Technology).
490
+ */
491
+ /*
492
+ * The trampoline uses register r10. It saves the original value of r10 on
493
+ * the stack.
494
+ *
495
+ * The trampoline has two parameters - target code to jump to and data for
496
+ * the target code. The trampoline extracts the parameters from its parameter
497
+ * block (see tramp_table_map()). The trampoline saves the data address on
498
+ * the stack. Finally, it jumps to the target code.
499
+ *
500
+ * The target code can choose to:
501
+ *
502
+ * - restore the value of r10
503
+ * - load the data address in a register
504
+ * - restore the stack pointer to what it was when the trampoline was invoked.
505
+ */
506
+ #ifdef ENDBR_PRESENT
507
+ # define X86_DATA_OFFSET 4077
508
+ # ifdef __ILP32__
509
+ # define X86_CODE_OFFSET 4069
510
+ # else
511
+ # define X86_CODE_OFFSET 4073
512
+ # endif
356
513
  #else
357
- .long .LUW0@rel
514
+ # define X86_DATA_OFFSET 4081
515
+ # ifdef __ILP32__
516
+ # define X86_CODE_OFFSET 4073
517
+ # else
518
+ # define X86_CODE_OFFSET 4077
519
+ # endif
358
520
  #endif
359
- .long .LUW4-.LUW0 /* FDE address range */
360
- .uleb128 0x0 /* Augmentation size */
361
521
 
362
- .byte 0x4 /* DW_CFA_advance_loc4 */
363
- .long .LUW1-.LUW0
364
-
365
- /* New stack frame based off rbp. This is a itty bit of unwind
366
- trickery in that the CFA *has* changed. There is no easy way
367
- to describe it correctly on entry to the function. Fortunately,
368
- it doesn't matter too much since at all points we can correctly
369
- unwind back to ffi_call. Note that the location to which we
370
- moved the return address is (the new) CFA-8, so from the
371
- perspective of the unwind info, it hasn't moved. */
372
- .byte 0xc /* DW_CFA_def_cfa, %rbp offset 32 */
373
- .uleb128 6
374
- .uleb128 32
375
- .byte 0x80+6 /* DW_CFA_offset, %rbp offset 2*-8 */
376
- .uleb128 2
377
- .byte 0xa /* DW_CFA_remember_state */
378
-
379
- .byte 0x4 /* DW_CFA_advance_loc4 */
380
- .long .LUW2-.LUW1
381
- .byte 0xc /* DW_CFA_def_cfa, %rsp offset 8 */
382
- .uleb128 7
383
- .uleb128 8
384
- .byte 0xc0+6 /* DW_CFA_restore, %rbp */
522
+ .align UNIX64_TRAMP_MAP_SIZE
523
+ .globl trampoline_code_table
524
+ FFI_HIDDEN(C(trampoline_code_table))
525
+
526
+ C(trampoline_code_table):
527
+ .rept UNIX64_TRAMP_MAP_SIZE / UNIX64_TRAMP_SIZE
528
+ _CET_ENDBR
529
+ subq $16, %rsp /* Make space on the stack */
530
+ movq %r10, (%rsp) /* Save %r10 on stack */
531
+ #ifdef __ILP32__
532
+ movl X86_DATA_OFFSET(%rip), %r10d /* Copy data into %r10 */
533
+ #else
534
+ movq X86_DATA_OFFSET(%rip), %r10 /* Copy data into %r10 */
535
+ #endif
536
+ movq %r10, 8(%rsp) /* Save data on stack */
537
+ #ifdef __ILP32__
538
+ movl X86_CODE_OFFSET(%rip), %r10d /* Copy code into %r10 */
539
+ #else
540
+ movq X86_CODE_OFFSET(%rip), %r10 /* Copy code into %r10 */
541
+ #endif
542
+ jmp *%r10 /* Jump to code */
543
+ .align 8
544
+ .endr
545
+ ENDF(C(trampoline_code_table))
546
+ .align UNIX64_TRAMP_MAP_SIZE
547
+ #endif /* FFI_EXEC_STATIC_TRAMP */
548
+
549
+ /* Sadly, OSX cctools-as doesn't understand .cfi directives at all. */
550
+
551
+ #ifdef __APPLE__
552
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
553
+ EHFrame0:
554
+ #elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE)
555
+ .section .eh_frame,"a",@unwind
556
+ #else
557
+ .section .eh_frame,"a",@progbits
558
+ #endif
385
559
 
386
- .byte 0x4 /* DW_CFA_advance_loc4 */
387
- .long .LUW3-.LUW2
388
- .byte 0xb /* DW_CFA_restore_state */
560
+ #ifdef HAVE_AS_X86_PCREL
561
+ # define PCREL(X) X - .
562
+ #else
563
+ # define PCREL(X) X@rel
564
+ #endif
389
565
 
390
- .align 8
391
- .LEFDE1:
392
- .LSFDE3:
393
- .long .LEFDE3-.LASFDE3 /* FDE Length */
394
- .LASFDE3:
395
- .long .LASFDE3-.Lframe1 /* FDE CIE offset */
396
- #if HAVE_AS_X86_PCREL
397
- .long .LUW5-. /* FDE initial location */
566
+ /* Simplify advancing between labels. Assume DW_CFA_advance_loc1 fits. */
567
+ #ifdef __CET__
568
+ /* Use DW_CFA_advance_loc2 when IBT is enabled. */
569
+ # define ADV(N, P) .byte 3; .2byte L(N)-L(P)
398
570
  #else
399
- .long .LUW5@rel
571
+ # define ADV(N, P) .byte 2, L(N)-L(P)
400
572
  #endif
401
- .long .LUW9-.LUW5 /* FDE address range */
402
- .uleb128 0x0 /* Augmentation size */
403
573
 
404
- .byte 0x4 /* DW_CFA_advance_loc4 */
405
- .long .LUW6-.LUW5
406
- .byte 0xe /* DW_CFA_def_cfa_offset */
407
- .uleb128 208
574
+ .balign 8
575
+ L(CIE):
576
+ .set L(set0),L(ECIE)-L(SCIE)
577
+ .long L(set0) /* CIE Length */
578
+ L(SCIE):
579
+ .long 0 /* CIE Identifier Tag */
580
+ .byte 1 /* CIE Version */
581
+ .ascii "zR\0" /* CIE Augmentation */
582
+ .byte 1 /* CIE Code Alignment Factor */
583
+ .byte 0x78 /* CIE Data Alignment Factor */
584
+ .byte 0x10 /* CIE RA Column */
585
+ .byte 1 /* Augmentation size */
586
+ .byte 0x1b /* FDE Encoding (pcrel sdata4) */
587
+ .byte 0xc, 7, 8 /* DW_CFA_def_cfa, %rsp offset 8 */
588
+ .byte 0x80+16, 1 /* DW_CFA_offset, %rip offset 1*-8 */
589
+ .balign 8
590
+ L(ECIE):
591
+
592
+ .set L(set1),L(EFDE1)-L(SFDE1)
593
+ .long L(set1) /* FDE Length */
594
+ L(SFDE1):
595
+ .long L(SFDE1)-L(CIE) /* FDE CIE offset */
596
+ .long PCREL(L(UW0)) /* Initial location */
597
+ .long L(UW4)-L(UW0) /* Address range */
598
+ .byte 0 /* Augmentation size */
599
+ ADV(UW1, UW0)
600
+ .byte 0xc, 6, 32 /* DW_CFA_def_cfa, %rbp 32 */
601
+ .byte 0x80+6, 2 /* DW_CFA_offset, %rbp 2*-8 */
602
+ ADV(UW2, UW1)
408
603
  .byte 0xa /* DW_CFA_remember_state */
409
-
410
- .byte 0x4 /* DW_CFA_advance_loc4 */
411
- .long .LUW7-.LUW6
412
- .byte 0xe /* DW_CFA_def_cfa_offset */
413
- .uleb128 8
414
-
415
- .byte 0x4 /* DW_CFA_advance_loc4 */
416
- .long .LUW8-.LUW7
604
+ .byte 0xc, 7, 8 /* DW_CFA_def_cfa, %rsp 8 */
605
+ .byte 0xc0+6 /* DW_CFA_restore, %rbp */
606
+ ADV(UW3, UW2)
417
607
  .byte 0xb /* DW_CFA_restore_state */
418
-
419
- .align 8
420
- .LEFDE3:
608
+ .balign 8
609
+ L(EFDE1):
610
+
611
+ .set L(set2),L(EFDE2)-L(SFDE2)
612
+ .long L(set2) /* FDE Length */
613
+ L(SFDE2):
614
+ .long L(SFDE2)-L(CIE) /* FDE CIE offset */
615
+ .long PCREL(L(UW5)) /* Initial location */
616
+ .long L(UW7)-L(UW5) /* Address range */
617
+ .byte 0 /* Augmentation size */
618
+ ADV(UW6, UW5)
619
+ .byte 0xe /* DW_CFA_def_cfa_offset */
620
+ .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */
621
+ .balign 8
622
+ L(EFDE2):
623
+
624
+ .set L(set3),L(EFDE3)-L(SFDE3)
625
+ .long L(set3) /* FDE Length */
626
+ L(SFDE3):
627
+ .long L(SFDE3)-L(CIE) /* FDE CIE offset */
628
+ .long PCREL(L(UW8)) /* Initial location */
629
+ .long L(UW11)-L(UW8) /* Address range */
630
+ .byte 0 /* Augmentation size */
631
+ ADV(UW9, UW8)
632
+ .byte 0xe /* DW_CFA_def_cfa_offset */
633
+ .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */
634
+ ADV(UW10, UW9)
635
+ .byte 0xe, 8 /* DW_CFA_def_cfa_offset 8 */
636
+ L(EFDE3):
637
+
638
+ .set L(set4),L(EFDE4)-L(SFDE4)
639
+ .long L(set4) /* FDE Length */
640
+ L(SFDE4):
641
+ .long L(SFDE4)-L(CIE) /* FDE CIE offset */
642
+ .long PCREL(L(UW12)) /* Initial location */
643
+ .long L(UW14)-L(UW12) /* Address range */
644
+ .byte 0 /* Augmentation size */
645
+ ADV(UW13, UW12)
646
+ .byte 0xe /* DW_CFA_def_cfa_offset */
647
+ .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */
648
+ .balign 8
649
+ L(EFDE4):
650
+
651
+ .set L(set5),L(EFDE5)-L(SFDE5)
652
+ .long L(set5) /* FDE Length */
653
+ L(SFDE5):
654
+ .long L(SFDE5)-L(CIE) /* FDE CIE offset */
655
+ .long PCREL(L(UW15)) /* Initial location */
656
+ .long L(UW17)-L(UW15) /* Address range */
657
+ .byte 0 /* Augmentation size */
658
+ ADV(UW16, UW15)
659
+ .byte 0xe /* DW_CFA_def_cfa_offset */
660
+ .byte ffi_closure_FS + 8, 1 /* uleb128, assuming 128 <= FS < 255 */
661
+ .balign 8
662
+ L(EFDE5):
663
+ #ifdef __APPLE__
664
+ .subsections_via_symbols
665
+ .section __LD,__compact_unwind,regular,debug
666
+
667
+ /* compact unwind for ffi_call_unix64 */
668
+ .quad C(ffi_call_unix64)
669
+ .set L1,L(UW4)-L(UW0)
670
+ .long L1
671
+ .long 0x04000000 /* use dwarf unwind info */
672
+ .quad 0
673
+ .quad 0
674
+
675
+ /* compact unwind for ffi_closure_unix64_sse */
676
+ .quad C(ffi_closure_unix64_sse)
677
+ .set L2,L(UW7)-L(UW5)
678
+ .long L2
679
+ .long 0x04000000 /* use dwarf unwind info */
680
+ .quad 0
681
+ .quad 0
682
+
683
+ /* compact unwind for ffi_closure_unix64 */
684
+ .quad C(ffi_closure_unix64)
685
+ .set L3,L(UW11)-L(UW8)
686
+ .long L3
687
+ .long 0x04000000 /* use dwarf unwind info */
688
+ .quad 0
689
+ .quad 0
690
+
691
+ /* compact unwind for ffi_go_closure_unix64_sse */
692
+ .quad C(ffi_go_closure_unix64_sse)
693
+ .set L4,L(UW14)-L(UW12)
694
+ .long L4
695
+ .long 0x04000000 /* use dwarf unwind info */
696
+ .quad 0
697
+ .quad 0
698
+
699
+ /* compact unwind for ffi_go_closure_unix64 */
700
+ .quad C(ffi_go_closure_unix64)
701
+ .set L5,L(UW17)-L(UW15)
702
+ .long L5
703
+ .long 0x04000000 /* use dwarf unwind info */
704
+ .quad 0
705
+ .quad 0
706
+ #endif
421
707
 
422
708
  #endif /* __x86_64__ */
423
-
424
709
  #if defined __ELF__ && defined __linux__
425
710
  .section .note.GNU-stack,"",@progbits
426
711
  #endif