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,5 +1,7 @@
1
1
  /* -----------------------------------------------------------------------
2
- sysv.S - Copyright (c) 1996, 1998, 2001-2003, 2005, 2008, 2010 Red Hat, Inc.
2
+ sysv.S - Copyright (c) 2017 Anthony Green
3
+ - Copyright (c) 2013 The Written Word, Inc.
4
+ - Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc.
3
5
 
4
6
  X86 Foreign Function Interface
5
7
 
@@ -24,444 +26,1246 @@
24
26
  DEALINGS IN THE SOFTWARE.
25
27
  ----------------------------------------------------------------------- */
26
28
 
27
- #ifndef __x86_64__
29
+ #ifdef __i386__
30
+ #ifndef _MSC_VER
28
31
 
29
32
  #define LIBFFI_ASM
30
33
  #include <fficonfig.h>
31
34
  #include <ffi.h>
35
+ #include "internal.h"
32
36
 
33
- .text
34
-
35
- .globl ffi_prep_args
36
-
37
- .align 4
38
- .globl ffi_call_SYSV
39
- .type ffi_call_SYSV,@function
40
-
41
- ffi_call_SYSV:
42
- .LFB1:
43
- pushl %ebp
44
- .LCFI0:
45
- movl %esp,%ebp
46
- .LCFI1:
47
- /* Make room for all of the new args. */
48
- movl 16(%ebp),%ecx
49
- subl %ecx,%esp
50
-
51
- /* Align the stack pointer to 16-bytes */
52
- andl $0xfffffff0, %esp
53
-
54
- movl %esp,%eax
55
-
56
- /* Place all of the ffi_prep_args in position */
57
- pushl 12(%ebp)
58
- pushl %eax
59
- call *8(%ebp)
60
-
61
- /* Return stack to previous state and call the function */
62
- addl $8,%esp
63
-
64
- call *28(%ebp)
65
-
66
- /* Load %ecx with the return type code */
67
- movl 20(%ebp),%ecx
68
-
69
- /* Protect %esi. We're going to pop it in the epilogue. */
70
- pushl %esi
71
-
72
- /* If the return value pointer is NULL, assume no return value. */
73
- cmpl $0,24(%ebp)
74
- jne 0f
75
-
76
- /* Even if there is no space for the return value, we are
77
- obliged to handle floating-point values. */
78
- cmpl $FFI_TYPE_FLOAT,%ecx
79
- jne noretval
80
- fstp %st(0)
81
-
82
- jmp epilogue
83
-
84
- 0:
85
- call 1f
86
-
87
- .Lstore_table:
88
- .long noretval-.Lstore_table /* FFI_TYPE_VOID */
89
- .long retint-.Lstore_table /* FFI_TYPE_INT */
90
- .long retfloat-.Lstore_table /* FFI_TYPE_FLOAT */
91
- .long retdouble-.Lstore_table /* FFI_TYPE_DOUBLE */
92
- .long retlongdouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
93
- .long retuint8-.Lstore_table /* FFI_TYPE_UINT8 */
94
- .long retsint8-.Lstore_table /* FFI_TYPE_SINT8 */
95
- .long retuint16-.Lstore_table /* FFI_TYPE_UINT16 */
96
- .long retsint16-.Lstore_table /* FFI_TYPE_SINT16 */
97
- .long retint-.Lstore_table /* FFI_TYPE_UINT32 */
98
- .long retint-.Lstore_table /* FFI_TYPE_SINT32 */
99
- .long retint64-.Lstore_table /* FFI_TYPE_UINT64 */
100
- .long retint64-.Lstore_table /* FFI_TYPE_SINT64 */
101
- .long retstruct-.Lstore_table /* FFI_TYPE_STRUCT */
102
- .long retint-.Lstore_table /* FFI_TYPE_POINTER */
37
+ #define C2(X, Y) X ## Y
38
+ #define C1(X, Y) C2(X, Y)
39
+ #ifdef __USER_LABEL_PREFIX__
40
+ # define C(X) C1(__USER_LABEL_PREFIX__, X)
41
+ #else
42
+ # define C(X) X
43
+ #endif
103
44
 
104
- 1:
105
- pop %esi
106
- add (%esi, %ecx, 4), %esi
107
- jmp *%esi
45
+ #ifdef X86_DARWIN
46
+ # define L(X) C1(L, X)
47
+ #else
48
+ # define L(X) C1(.L, X)
49
+ #endif
108
50
 
109
- /* Sign/zero extend as appropriate. */
110
- retsint8:
111
- movsbl %al, %eax
112
- jmp retint
51
+ #ifdef __ELF__
52
+ # define ENDF(X) .type X,@function; .size X, . - X
53
+ #else
54
+ # define ENDF(X)
55
+ #endif
113
56
 
114
- retsint16:
115
- movswl %ax, %eax
116
- jmp retint
57
+ /* Handle win32 fastcall name mangling. */
58
+ #ifdef X86_WIN32
59
+ # define ffi_call_i386 "@ffi_call_i386@8"
60
+ # define ffi_closure_inner "@ffi_closure_inner@8"
61
+ #else
62
+ # define ffi_call_i386 C(ffi_call_i386)
63
+ # define ffi_closure_inner C(ffi_closure_inner)
64
+ #endif
117
65
 
118
- retuint8:
119
- movzbl %al, %eax
120
- jmp retint
66
+ /* This macro allows the safe creation of jump tables without an
67
+ actual table. The entry points into the table are all 8 bytes.
68
+ The use of ORG asserts that we're at the correct location. */
69
+ /* ??? The clang assembler doesn't handle .org with symbolic expressions. */
70
+ #if defined(__clang__) || defined(__APPLE__) || (defined (__sun__) && defined(__svr4__))
71
+ # define E(BASE, X) .balign 8
72
+ #else
73
+ # define E(BASE, X) .balign 8; .org BASE + X * 8
74
+ #endif
121
75
 
122
- retuint16:
123
- movzwl %ax, %eax
124
- jmp retint
125
-
126
- retfloat:
127
- /* Load %ecx with the pointer to storage for the return value */
128
- movl 24(%ebp),%ecx
129
- fstps (%ecx)
130
- jmp epilogue
131
-
132
- retdouble:
133
- /* Load %ecx with the pointer to storage for the return value */
134
- movl 24(%ebp),%ecx
135
- fstpl (%ecx)
136
- jmp epilogue
137
-
138
- retlongdouble:
139
- /* Load %ecx with the pointer to storage for the return value */
140
- movl 24(%ebp),%ecx
141
- fstpt (%ecx)
142
- jmp epilogue
143
-
144
- retint64:
145
- /* Load %ecx with the pointer to storage for the return value */
146
- movl 24(%ebp),%ecx
147
- movl %eax,0(%ecx)
148
- movl %edx,4(%ecx)
149
- jmp epilogue
150
-
151
- retint:
152
- /* Load %ecx with the pointer to storage for the return value */
153
- movl 24(%ebp),%ecx
154
- movl %eax,0(%ecx)
155
-
156
- retstruct:
157
- /* Nothing to do! */
158
-
159
- noretval:
160
- epilogue:
161
- popl %esi
162
- movl %ebp,%esp
163
- popl %ebp
164
- ret
165
- .LFE1:
166
- .ffi_call_SYSV_end:
167
- .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
76
+ .text
77
+ .balign 16
78
+ .globl ffi_call_i386
79
+ FFI_HIDDEN(ffi_call_i386)
168
80
 
169
- .align 4
170
- FFI_HIDDEN (ffi_closure_SYSV)
171
- .globl ffi_closure_SYSV
172
- .type ffi_closure_SYSV, @function
173
-
174
- ffi_closure_SYSV:
175
- .LFB2:
176
- pushl %ebp
177
- .LCFI2:
178
- movl %esp, %ebp
179
- .LCFI3:
180
- subl $40, %esp
181
- leal -24(%ebp), %edx
182
- movl %edx, -12(%ebp) /* resp */
183
- leal 8(%ebp), %edx
184
- movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
185
- leal -12(%ebp), %edx
186
- movl %edx, (%esp) /* &resp */
187
- #if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__
188
- call ffi_closure_SYSV_inner
81
+ /* This is declared as
82
+
83
+ void ffi_call_i386(struct call_frame *frame, char *argp)
84
+ __attribute__((fastcall));
85
+
86
+ Thus the arguments are present in
87
+
88
+ ecx: frame
89
+ edx: argp
90
+ */
91
+
92
+ ffi_call_i386:
93
+ L(UW0):
94
+ # cfi_startproc
95
+ _CET_ENDBR
96
+ #if !HAVE_FASTCALL
97
+ movl 4(%esp), %ecx
98
+ movl 8(%esp), %edx
99
+ #endif
100
+ movl (%esp), %eax /* move the return address */
101
+ movl %ebp, (%ecx) /* store %ebp into local frame */
102
+ movl %eax, 4(%ecx) /* store retaddr into local frame */
103
+
104
+ /* New stack frame based off ebp. This is a itty bit of unwind
105
+ trickery in that the CFA *has* changed. There is no easy way
106
+ to describe it correctly on entry to the function. Fortunately,
107
+ it doesn't matter too much since at all points we can correctly
108
+ unwind back to ffi_call. Note that the location to which we
109
+ moved the return address is (the new) CFA-4, so from the
110
+ perspective of the unwind info, it hasn't moved. */
111
+ movl %ecx, %ebp
112
+ L(UW1):
113
+ # cfi_def_cfa(%ebp, 8)
114
+ # cfi_rel_offset(%ebp, 0)
115
+
116
+ movl %edx, %esp /* set outgoing argument stack */
117
+ movl 20+R_EAX*4(%ebp), %eax /* set register arguments */
118
+ movl 20+R_EDX*4(%ebp), %edx
119
+ movl 20+R_ECX*4(%ebp), %ecx
120
+
121
+ call *8(%ebp)
122
+
123
+ movl 12(%ebp), %ecx /* load return type code */
124
+ movl %ebx, 8(%ebp) /* preserve %ebx */
125
+ L(UW2):
126
+ # cfi_rel_offset(%ebx, 8)
127
+
128
+ andl $X86_RET_TYPE_MASK, %ecx
129
+ #ifdef __PIC__
130
+ call C(__x86.get_pc_thunk.bx)
131
+ L(pc1):
132
+ leal L(store_table)-L(pc1)(%ebx, %ecx, 8), %ebx
189
133
  #else
190
- movl %ebx, 8(%esp)
191
- .LCFI7:
192
- call 1f
193
- 1: popl %ebx
194
- addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
195
- call ffi_closure_SYSV_inner@PLT
196
- movl 8(%esp), %ebx
134
+ leal L(store_table)(,%ecx, 8), %ebx
197
135
  #endif
198
- movl -12(%ebp), %ecx
199
- cmpl $FFI_TYPE_INT, %eax
200
- je .Lcls_retint
201
-
202
- /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
203
- FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
204
- cmpl $FFI_TYPE_UINT64, %eax
205
- jge 0f
206
- cmpl $FFI_TYPE_UINT8, %eax
207
- jge .Lcls_retint
208
-
209
- 0: cmpl $FFI_TYPE_FLOAT, %eax
210
- je .Lcls_retfloat
211
- cmpl $FFI_TYPE_DOUBLE, %eax
212
- je .Lcls_retdouble
213
- cmpl $FFI_TYPE_LONGDOUBLE, %eax
214
- je .Lcls_retldouble
215
- cmpl $FFI_TYPE_SINT64, %eax
216
- je .Lcls_retllong
217
- cmpl $FFI_TYPE_STRUCT, %eax
218
- je .Lcls_retstruct
219
- .Lcls_epilogue:
136
+ movl 16(%ebp), %ecx /* load result address */
137
+ _CET_NOTRACK jmp *%ebx
138
+
139
+ .balign 8
140
+ L(store_table):
141
+ E(L(store_table), X86_RET_FLOAT)
142
+ fstps (%ecx)
143
+ jmp L(e1)
144
+ E(L(store_table), X86_RET_DOUBLE)
145
+ fstpl (%ecx)
146
+ jmp L(e1)
147
+ E(L(store_table), X86_RET_LDOUBLE)
148
+ fstpt (%ecx)
149
+ jmp L(e1)
150
+ E(L(store_table), X86_RET_SINT8)
151
+ movsbl %al, %eax
152
+ mov %eax, (%ecx)
153
+ jmp L(e1)
154
+ E(L(store_table), X86_RET_SINT16)
155
+ movswl %ax, %eax
156
+ mov %eax, (%ecx)
157
+ jmp L(e1)
158
+ E(L(store_table), X86_RET_UINT8)
159
+ movzbl %al, %eax
160
+ mov %eax, (%ecx)
161
+ jmp L(e1)
162
+ E(L(store_table), X86_RET_UINT16)
163
+ movzwl %ax, %eax
164
+ mov %eax, (%ecx)
165
+ jmp L(e1)
166
+ E(L(store_table), X86_RET_INT64)
167
+ movl %edx, 4(%ecx)
168
+ /* fallthru */
169
+ E(L(store_table), X86_RET_INT32)
170
+ movl %eax, (%ecx)
171
+ /* fallthru */
172
+ E(L(store_table), X86_RET_VOID)
173
+ L(e1):
174
+ movl 8(%ebp), %ebx
220
175
  movl %ebp, %esp
221
176
  popl %ebp
177
+ L(UW3):
178
+ # cfi_remember_state
179
+ # cfi_def_cfa(%esp, 4)
180
+ # cfi_restore(%ebx)
181
+ # cfi_restore(%ebp)
222
182
  ret
223
- .Lcls_retint:
224
- movl (%ecx), %eax
225
- jmp .Lcls_epilogue
226
- .Lcls_retfloat:
227
- flds (%ecx)
228
- jmp .Lcls_epilogue
229
- .Lcls_retdouble:
230
- fldl (%ecx)
231
- jmp .Lcls_epilogue
232
- .Lcls_retldouble:
233
- fldt (%ecx)
234
- jmp .Lcls_epilogue
235
- .Lcls_retllong:
236
- movl (%ecx), %eax
237
- movl 4(%ecx), %edx
238
- jmp .Lcls_epilogue
239
- .Lcls_retstruct:
240
- movl %ebp, %esp
241
- popl %ebp
242
- ret $4
243
- .LFE2:
244
- .size ffi_closure_SYSV, .-ffi_closure_SYSV
183
+ L(UW4):
184
+ # cfi_restore_state
245
185
 
246
- #if !FFI_NO_RAW_API
186
+ E(L(store_table), X86_RET_STRUCTPOP)
187
+ jmp L(e1)
188
+ E(L(store_table), X86_RET_STRUCTARG)
189
+ jmp L(e1)
190
+ E(L(store_table), X86_RET_STRUCT_1B)
191
+ movb %al, (%ecx)
192
+ jmp L(e1)
193
+ E(L(store_table), X86_RET_STRUCT_2B)
194
+ movw %ax, (%ecx)
195
+ jmp L(e1)
196
+
197
+ /* Fill out the table so that bad values are predictable. */
198
+ E(L(store_table), X86_RET_UNUSED14)
199
+ ud2
200
+ E(L(store_table), X86_RET_UNUSED15)
201
+ ud2
202
+
203
+ L(UW5):
204
+ # cfi_endproc
205
+ ENDF(ffi_call_i386)
206
+
207
+ /* The inner helper is declared as
208
+
209
+ void ffi_closure_inner(struct closure_frame *frame, char *argp)
210
+ __attribute_((fastcall))
247
211
 
248
- /* Precalculate for e.g. the Solaris 10/x86 assembler. */
249
- #if FFI_TRAMPOLINE_SIZE == 10
250
- #define RAW_CLOSURE_CIF_OFFSET 12
251
- #define RAW_CLOSURE_FUN_OFFSET 16
252
- #define RAW_CLOSURE_USER_DATA_OFFSET 20
253
- #elif FFI_TRAMPOLINE_SIZE == 24
254
- #define RAW_CLOSURE_CIF_OFFSET 24
255
- #define RAW_CLOSURE_FUN_OFFSET 28
256
- #define RAW_CLOSURE_USER_DATA_OFFSET 32
212
+ Thus the arguments are placed in
213
+
214
+ ecx: frame
215
+ edx: argp
216
+ */
217
+
218
+ /* Macros to help setting up the closure_data structure. */
219
+
220
+ #if HAVE_FASTCALL
221
+ # define closure_FS (40 + 4)
222
+ # define closure_CF 0
257
223
  #else
258
- #define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
259
- #define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
260
- #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
224
+ # define closure_FS (8 + 40 + 12)
225
+ # define closure_CF 8
261
226
  #endif
262
- #define CIF_FLAGS_OFFSET 20
263
227
 
264
- .align 4
265
- FFI_HIDDEN (ffi_closure_raw_SYSV)
266
- .globl ffi_closure_raw_SYSV
267
- .type ffi_closure_raw_SYSV, @function
268
-
269
- ffi_closure_raw_SYSV:
270
- .LFB3:
271
- pushl %ebp
272
- .LCFI4:
273
- movl %esp, %ebp
274
- .LCFI5:
275
- pushl %esi
276
- .LCFI6:
277
- subl $36, %esp
278
- movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
279
- movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
280
- movl %edx, 12(%esp) /* user_data */
281
- leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
282
- movl %edx, 8(%esp) /* raw_args */
283
- leal -24(%ebp), %edx
284
- movl %edx, 4(%esp) /* &res */
285
- movl %esi, (%esp) /* cif */
286
- call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
287
- movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
288
- cmpl $FFI_TYPE_INT, %eax
289
- je .Lrcls_retint
290
-
291
- /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
292
- FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
293
- cmpl $FFI_TYPE_UINT64, %eax
294
- jge 0f
295
- cmpl $FFI_TYPE_UINT8, %eax
296
- jge .Lrcls_retint
297
- 0:
298
- cmpl $FFI_TYPE_FLOAT, %eax
299
- je .Lrcls_retfloat
300
- cmpl $FFI_TYPE_DOUBLE, %eax
301
- je .Lrcls_retdouble
302
- cmpl $FFI_TYPE_LONGDOUBLE, %eax
303
- je .Lrcls_retldouble
304
- cmpl $FFI_TYPE_SINT64, %eax
305
- je .Lrcls_retllong
306
- .Lrcls_epilogue:
307
- addl $36, %esp
308
- popl %esi
309
- popl %ebp
310
- ret
311
- .Lrcls_retint:
312
- movl -24(%ebp), %eax
313
- jmp .Lrcls_epilogue
314
- .Lrcls_retfloat:
315
- flds -24(%ebp)
316
- jmp .Lrcls_epilogue
317
- .Lrcls_retdouble:
318
- fldl -24(%ebp)
319
- jmp .Lrcls_epilogue
320
- .Lrcls_retldouble:
321
- fldt -24(%ebp)
322
- jmp .Lrcls_epilogue
323
- .Lrcls_retllong:
324
- movl -24(%ebp), %eax
325
- movl -20(%ebp), %edx
326
- jmp .Lrcls_epilogue
327
- .LFE3:
328
- .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
228
+ #define FFI_CLOSURE_SAVE_REGS \
229
+ movl %eax, closure_CF+16+R_EAX*4(%esp); \
230
+ movl %edx, closure_CF+16+R_EDX*4(%esp); \
231
+ movl %ecx, closure_CF+16+R_ECX*4(%esp)
232
+
233
+ #define FFI_CLOSURE_COPY_TRAMP_DATA \
234
+ movl FFI_TRAMPOLINE_SIZE(%eax), %edx; /* copy cif */ \
235
+ movl FFI_TRAMPOLINE_SIZE+4(%eax), %ecx; /* copy fun */ \
236
+ movl FFI_TRAMPOLINE_SIZE+8(%eax), %eax; /* copy user_data */ \
237
+ movl %edx, closure_CF+28(%esp); \
238
+ movl %ecx, closure_CF+32(%esp); \
239
+ movl %eax, closure_CF+36(%esp)
240
+
241
+ #if HAVE_FASTCALL
242
+ # define FFI_CLOSURE_PREP_CALL \
243
+ movl %esp, %ecx; /* load closure_data */ \
244
+ leal closure_FS+4(%esp), %edx; /* load incoming stack */
245
+ #else
246
+ # define FFI_CLOSURE_PREP_CALL \
247
+ leal closure_CF(%esp), %ecx; /* load closure_data */ \
248
+ leal closure_FS+4(%esp), %edx; /* load incoming stack */ \
249
+ movl %ecx, (%esp); \
250
+ movl %edx, 4(%esp)
329
251
  #endif
330
252
 
331
- #if defined __PIC__
332
- # if defined __sun__ && defined __svr4__
333
- /* 32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld before 2.22
334
- doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this. */
335
- # define FDE_ENCODING 0x30 /* datarel */
336
- # define FDE_ENCODE(X) X@GOTOFF
253
+ #define FFI_CLOSURE_CALL_INNER(UWN) \
254
+ call ffi_closure_inner
255
+
256
+ #define FFI_CLOSURE_MASK_AND_JUMP(N, UW) \
257
+ andl $X86_RET_TYPE_MASK, %eax; \
258
+ leal L(C1(load_table,N))(, %eax, 8), %edx; \
259
+ movl closure_CF(%esp), %eax; /* optimiztic load */ \
260
+ _CET_NOTRACK jmp *%edx
261
+
262
+ #ifdef __PIC__
263
+ # if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
264
+ # undef FFI_CLOSURE_MASK_AND_JUMP
265
+ # define FFI_CLOSURE_MASK_AND_JUMP(N, UW) \
266
+ andl $X86_RET_TYPE_MASK, %eax; \
267
+ call C(__x86.get_pc_thunk.dx); \
268
+ L(C1(pc,N)): \
269
+ leal L(C1(load_table,N))-L(C1(pc,N))(%edx, %eax, 8), %edx; \
270
+ movl closure_CF(%esp), %eax; /* optimiztic load */ \
271
+ _CET_NOTRACK jmp *%edx
337
272
  # else
338
- # define FDE_ENCODING 0x1b /* pcrel sdata4 */
339
- # if defined HAVE_AS_X86_PCREL
340
- # define FDE_ENCODE(X) X-.
341
- # else
342
- # define FDE_ENCODE(X) X@rel
343
- # endif
344
- # endif
273
+ # define FFI_CLOSURE_CALL_INNER_SAVE_EBX
274
+ # undef FFI_CLOSURE_CALL_INNER
275
+ # define FFI_CLOSURE_CALL_INNER(UWN) \
276
+ movl %ebx, 40(%esp); /* save ebx */ \
277
+ L(C1(UW,UWN)): \
278
+ /* cfi_rel_offset(%ebx, 40); */ \
279
+ call C(__x86.get_pc_thunk.bx); /* load got register */ \
280
+ addl $C(_GLOBAL_OFFSET_TABLE_), %ebx; \
281
+ call ffi_closure_inner@PLT
282
+ # undef FFI_CLOSURE_MASK_AND_JUMP
283
+ # define FFI_CLOSURE_MASK_AND_JUMP(N, UWN) \
284
+ andl $X86_RET_TYPE_MASK, %eax; \
285
+ leal L(C1(load_table,N))@GOTOFF(%ebx, %eax, 8), %edx; \
286
+ movl 40(%esp), %ebx; /* restore ebx */ \
287
+ L(C1(UW,UWN)): \
288
+ /* cfi_restore(%ebx); */ \
289
+ movl closure_CF(%esp), %eax; /* optimiztic load */ \
290
+ _CET_NOTRACK jmp *%edx
291
+ # endif /* DARWIN || HIDDEN */
292
+ #endif /* __PIC__ */
293
+
294
+ .balign 16
295
+ .globl C(ffi_go_closure_EAX)
296
+ FFI_HIDDEN(C(ffi_go_closure_EAX))
297
+ C(ffi_go_closure_EAX):
298
+ L(UW6):
299
+ # cfi_startproc
300
+ _CET_ENDBR
301
+ subl $closure_FS, %esp
302
+ L(UW7):
303
+ # cfi_def_cfa_offset(closure_FS + 4)
304
+ FFI_CLOSURE_SAVE_REGS
305
+ movl 4(%eax), %edx /* copy cif */
306
+ movl 8(%eax), %ecx /* copy fun */
307
+ movl %edx, closure_CF+28(%esp)
308
+ movl %ecx, closure_CF+32(%esp)
309
+ movl %eax, closure_CF+36(%esp) /* closure is user_data */
310
+ jmp L(do_closure_i386)
311
+ L(UW8):
312
+ # cfi_endproc
313
+ ENDF(C(ffi_go_closure_EAX))
314
+
315
+ .balign 16
316
+ .globl C(ffi_go_closure_ECX)
317
+ FFI_HIDDEN(C(ffi_go_closure_ECX))
318
+ C(ffi_go_closure_ECX):
319
+ L(UW9):
320
+ # cfi_startproc
321
+ _CET_ENDBR
322
+ subl $closure_FS, %esp
323
+ L(UW10):
324
+ # cfi_def_cfa_offset(closure_FS + 4)
325
+ FFI_CLOSURE_SAVE_REGS
326
+ movl 4(%ecx), %edx /* copy cif */
327
+ movl 8(%ecx), %eax /* copy fun */
328
+ movl %edx, closure_CF+28(%esp)
329
+ movl %eax, closure_CF+32(%esp)
330
+ movl %ecx, closure_CF+36(%esp) /* closure is user_data */
331
+ jmp L(do_closure_i386)
332
+ L(UW11):
333
+ # cfi_endproc
334
+ ENDF(C(ffi_go_closure_ECX))
335
+
336
+ /* The closure entry points are reached from the ffi_closure trampoline.
337
+ On entry, %eax contains the address of the ffi_closure. */
338
+
339
+ .balign 16
340
+ .globl C(ffi_closure_i386)
341
+ FFI_HIDDEN(C(ffi_closure_i386))
342
+
343
+ C(ffi_closure_i386):
344
+ L(UW12):
345
+ # cfi_startproc
346
+ _CET_ENDBR
347
+ subl $closure_FS, %esp
348
+ L(UW13):
349
+ # cfi_def_cfa_offset(closure_FS + 4)
350
+
351
+ FFI_CLOSURE_SAVE_REGS
352
+ FFI_CLOSURE_COPY_TRAMP_DATA
353
+
354
+ /* Entry point from preceeding Go closures. */
355
+ L(do_closure_i386):
356
+
357
+ FFI_CLOSURE_PREP_CALL
358
+ FFI_CLOSURE_CALL_INNER(14)
359
+ FFI_CLOSURE_MASK_AND_JUMP(2, 15)
360
+
361
+ .balign 8
362
+ L(load_table2):
363
+ E(L(load_table2), X86_RET_FLOAT)
364
+ flds closure_CF(%esp)
365
+ jmp L(e2)
366
+ E(L(load_table2), X86_RET_DOUBLE)
367
+ fldl closure_CF(%esp)
368
+ jmp L(e2)
369
+ E(L(load_table2), X86_RET_LDOUBLE)
370
+ fldt closure_CF(%esp)
371
+ jmp L(e2)
372
+ E(L(load_table2), X86_RET_SINT8)
373
+ movsbl %al, %eax
374
+ jmp L(e2)
375
+ E(L(load_table2), X86_RET_SINT16)
376
+ movswl %ax, %eax
377
+ jmp L(e2)
378
+ E(L(load_table2), X86_RET_UINT8)
379
+ movzbl %al, %eax
380
+ jmp L(e2)
381
+ E(L(load_table2), X86_RET_UINT16)
382
+ movzwl %ax, %eax
383
+ jmp L(e2)
384
+ E(L(load_table2), X86_RET_INT64)
385
+ movl closure_CF+4(%esp), %edx
386
+ jmp L(e2)
387
+ E(L(load_table2), X86_RET_INT32)
388
+ nop
389
+ /* fallthru */
390
+ E(L(load_table2), X86_RET_VOID)
391
+ L(e2):
392
+ addl $closure_FS, %esp
393
+ L(UW16):
394
+ # cfi_adjust_cfa_offset(-closure_FS)
395
+ ret
396
+ L(UW17):
397
+ # cfi_adjust_cfa_offset(closure_FS)
398
+ E(L(load_table2), X86_RET_STRUCTPOP)
399
+ addl $closure_FS, %esp
400
+ L(UW18):
401
+ # cfi_adjust_cfa_offset(-closure_FS)
402
+ ret $4
403
+ L(UW19):
404
+ # cfi_adjust_cfa_offset(closure_FS)
405
+ E(L(load_table2), X86_RET_STRUCTARG)
406
+ jmp L(e2)
407
+ E(L(load_table2), X86_RET_STRUCT_1B)
408
+ movzbl %al, %eax
409
+ jmp L(e2)
410
+ E(L(load_table2), X86_RET_STRUCT_2B)
411
+ movzwl %ax, %eax
412
+ jmp L(e2)
413
+
414
+ /* Fill out the table so that bad values are predictable. */
415
+ E(L(load_table2), X86_RET_UNUSED14)
416
+ ud2
417
+ E(L(load_table2), X86_RET_UNUSED15)
418
+ ud2
419
+
420
+ L(UW20):
421
+ # cfi_endproc
422
+ ENDF(C(ffi_closure_i386))
423
+
424
+ .balign 16
425
+ .globl C(ffi_go_closure_STDCALL)
426
+ FFI_HIDDEN(C(ffi_go_closure_STDCALL))
427
+ C(ffi_go_closure_STDCALL):
428
+ L(UW21):
429
+ # cfi_startproc
430
+ _CET_ENDBR
431
+ subl $closure_FS, %esp
432
+ L(UW22):
433
+ # cfi_def_cfa_offset(closure_FS + 4)
434
+ FFI_CLOSURE_SAVE_REGS
435
+ movl 4(%ecx), %edx /* copy cif */
436
+ movl 8(%ecx), %eax /* copy fun */
437
+ movl %edx, closure_CF+28(%esp)
438
+ movl %eax, closure_CF+32(%esp)
439
+ movl %ecx, closure_CF+36(%esp) /* closure is user_data */
440
+ jmp L(do_closure_STDCALL)
441
+ L(UW23):
442
+ # cfi_endproc
443
+ ENDF(C(ffi_go_closure_STDCALL))
444
+
445
+ /* For REGISTER, we have no available parameter registers, and so we
446
+ enter here having pushed the closure onto the stack. */
447
+
448
+ .balign 16
449
+ .globl C(ffi_closure_REGISTER)
450
+ FFI_HIDDEN(C(ffi_closure_REGISTER))
451
+ C(ffi_closure_REGISTER):
452
+ L(UW24):
453
+ # cfi_startproc
454
+ # cfi_def_cfa(%esp, 8)
455
+ # cfi_offset(%eip, -8)
456
+ _CET_ENDBR
457
+ subl $closure_FS-4, %esp
458
+ L(UW25):
459
+ # cfi_def_cfa_offset(closure_FS + 4)
460
+ FFI_CLOSURE_SAVE_REGS
461
+ movl closure_FS-4(%esp), %ecx /* load retaddr */
462
+ movl closure_FS(%esp), %eax /* load closure */
463
+ movl %ecx, closure_FS(%esp) /* move retaddr */
464
+ jmp L(do_closure_REGISTER)
465
+ L(UW26):
466
+ # cfi_endproc
467
+ ENDF(C(ffi_closure_REGISTER))
468
+
469
+ /* For STDCALL (and others), we need to pop N bytes of arguments off
470
+ the stack following the closure. The amount needing to be popped
471
+ is returned to us from ffi_closure_inner. */
472
+
473
+ .balign 16
474
+ .globl C(ffi_closure_STDCALL)
475
+ FFI_HIDDEN(C(ffi_closure_STDCALL))
476
+ C(ffi_closure_STDCALL):
477
+ L(UW27):
478
+ # cfi_startproc
479
+ _CET_ENDBR
480
+ subl $closure_FS, %esp
481
+ L(UW28):
482
+ # cfi_def_cfa_offset(closure_FS + 4)
483
+
484
+ FFI_CLOSURE_SAVE_REGS
485
+
486
+ /* Entry point from ffi_closure_REGISTER. */
487
+ L(do_closure_REGISTER):
488
+
489
+ FFI_CLOSURE_COPY_TRAMP_DATA
490
+
491
+ /* Entry point from preceeding Go closure. */
492
+ L(do_closure_STDCALL):
493
+
494
+ FFI_CLOSURE_PREP_CALL
495
+ FFI_CLOSURE_CALL_INNER(29)
496
+
497
+ movl %eax, %ecx
498
+ shrl $X86_RET_POP_SHIFT, %ecx /* isolate pop count */
499
+ leal closure_FS(%esp, %ecx), %ecx /* compute popped esp */
500
+ movl closure_FS(%esp), %edx /* move return address */
501
+ movl %edx, (%ecx)
502
+
503
+ /* From this point on, the value of %esp upon return is %ecx+4,
504
+ and we've copied the return address to %ecx to make return easy.
505
+ There's no point in representing this in the unwind info, as
506
+ there is always a window between the mov and the ret which
507
+ will be wrong from one point of view or another. */
508
+
509
+ FFI_CLOSURE_MASK_AND_JUMP(3, 30)
510
+
511
+ .balign 8
512
+ L(load_table3):
513
+ E(L(load_table3), X86_RET_FLOAT)
514
+ flds closure_CF(%esp)
515
+ movl %ecx, %esp
516
+ ret
517
+ E(L(load_table3), X86_RET_DOUBLE)
518
+ fldl closure_CF(%esp)
519
+ movl %ecx, %esp
520
+ ret
521
+ E(L(load_table3), X86_RET_LDOUBLE)
522
+ fldt closure_CF(%esp)
523
+ movl %ecx, %esp
524
+ ret
525
+ E(L(load_table3), X86_RET_SINT8)
526
+ movsbl %al, %eax
527
+ movl %ecx, %esp
528
+ ret
529
+ E(L(load_table3), X86_RET_SINT16)
530
+ movswl %ax, %eax
531
+ movl %ecx, %esp
532
+ ret
533
+ E(L(load_table3), X86_RET_UINT8)
534
+ movzbl %al, %eax
535
+ movl %ecx, %esp
536
+ ret
537
+ E(L(load_table3), X86_RET_UINT16)
538
+ movzwl %ax, %eax
539
+ movl %ecx, %esp
540
+ ret
541
+ E(L(load_table3), X86_RET_INT64)
542
+ movl closure_CF+4(%esp), %edx
543
+ movl %ecx, %esp
544
+ ret
545
+ E(L(load_table3), X86_RET_INT32)
546
+ movl %ecx, %esp
547
+ ret
548
+ E(L(load_table3), X86_RET_VOID)
549
+ movl %ecx, %esp
550
+ ret
551
+ E(L(load_table3), X86_RET_STRUCTPOP)
552
+ movl %ecx, %esp
553
+ ret
554
+ E(L(load_table3), X86_RET_STRUCTARG)
555
+ movl %ecx, %esp
556
+ ret
557
+ E(L(load_table3), X86_RET_STRUCT_1B)
558
+ movzbl %al, %eax
559
+ movl %ecx, %esp
560
+ ret
561
+ E(L(load_table3), X86_RET_STRUCT_2B)
562
+ movzwl %ax, %eax
563
+ movl %ecx, %esp
564
+ ret
565
+
566
+ /* Fill out the table so that bad values are predictable. */
567
+ E(L(load_table3), X86_RET_UNUSED14)
568
+ ud2
569
+ E(L(load_table3), X86_RET_UNUSED15)
570
+ ud2
571
+
572
+ L(UW31):
573
+ # cfi_endproc
574
+ ENDF(C(ffi_closure_STDCALL))
575
+
576
+ #if defined(FFI_EXEC_STATIC_TRAMP)
577
+ .balign 16
578
+ .globl C(ffi_closure_i386_alt)
579
+ FFI_HIDDEN(C(ffi_closure_i386_alt))
580
+ C(ffi_closure_i386_alt):
581
+ /* See the comments above trampoline_code_table. */
582
+ _CET_ENDBR
583
+ movl 4(%esp), %eax /* Load closure in eax */
584
+ add $8, %esp /* Restore the stack */
585
+ jmp C(ffi_closure_i386)
586
+ ENDF(C(ffi_closure_i386_alt))
587
+
588
+ .balign 16
589
+ .globl C(ffi_closure_REGISTER_alt)
590
+ FFI_HIDDEN(C(ffi_closure_REGISTER_alt))
591
+ C(ffi_closure_REGISTER_alt):
592
+ /* See the comments above trampoline_code_table. */
593
+ _CET_ENDBR
594
+ movl (%esp), %eax /* Restore eax */
595
+ add $4, %esp /* Leave closure on stack */
596
+ jmp C(ffi_closure_REGISTER)
597
+ ENDF(C(ffi_closure_REGISTER_alt))
598
+
599
+ .balign 16
600
+ .globl C(ffi_closure_STDCALL_alt)
601
+ FFI_HIDDEN(C(ffi_closure_STDCALL_alt))
602
+ C(ffi_closure_STDCALL_alt):
603
+ /* See the comments above trampoline_code_table. */
604
+ _CET_ENDBR
605
+ movl 4(%esp), %eax /* Load closure in eax */
606
+ add $8, %esp /* Restore the stack */
607
+ jmp C(ffi_closure_STDCALL)
608
+ ENDF(C(ffi_closure_STDCALL_alt))
609
+
610
+ /*
611
+ * Below is the definition of the trampoline code table. Each element in
612
+ * the code table is a trampoline.
613
+ *
614
+ * Because we jump to the trampoline, we place a _CET_ENDBR at the
615
+ * beginning of the trampoline to mark it as a valid branch target. This is
616
+ * part of the the Intel CET (Control Flow Enforcement Technology).
617
+ */
618
+ /*
619
+ * The trampoline uses register eax. It saves the original value of eax on
620
+ * the stack.
621
+ *
622
+ * The trampoline has two parameters - target code to jump to and data for
623
+ * the target code. The trampoline extracts the parameters from its parameter
624
+ * block (see tramp_table_map()). The trampoline saves the data address on
625
+ * the stack. Finally, it jumps to the target code.
626
+ *
627
+ * The target code can choose to:
628
+ *
629
+ * - restore the value of eax
630
+ * - load the data address in a register
631
+ * - restore the stack pointer to what it was when the trampoline was invoked.
632
+ */
633
+ #ifdef ENDBR_PRESENT
634
+ #define X86_DATA_OFFSET 4081
635
+ #define X86_CODE_OFFSET 4070
345
636
  #else
346
- # define FDE_ENCODING 0 /* absolute */
347
- # define FDE_ENCODE(X) X
637
+ #define X86_DATA_OFFSET 4085
638
+ #define X86_CODE_OFFSET 4074
348
639
  #endif
349
640
 
350
- .section .eh_frame,EH_FRAME_FLAGS,@progbits
351
- .Lframe1:
352
- .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */
353
- .LSCIE1:
354
- .long 0x0 /* CIE Identifier Tag */
355
- .byte 0x1 /* CIE Version */
356
- #ifdef HAVE_AS_ASCII_PSEUDO_OP
641
+ .align X86_TRAMP_MAP_SIZE
642
+ .globl C(trampoline_code_table)
643
+ FFI_HIDDEN(C(trampoline_code_table))
644
+ C(trampoline_code_table):
645
+ .rept X86_TRAMP_MAP_SIZE / X86_TRAMP_SIZE
646
+ _CET_ENDBR
647
+ sub $8, %esp
648
+ movl %eax, (%esp) /* Save %eax on stack */
649
+ call 1f /* Get next PC into %eax */
650
+ movl X86_DATA_OFFSET(%eax), %eax /* Copy data into %eax */
651
+ movl %eax, 4(%esp) /* Save data on stack */
652
+ call 1f /* Get next PC into %eax */
653
+ movl X86_CODE_OFFSET(%eax), %eax /* Copy code into %eax */
654
+ jmp *%eax /* Jump to code */
655
+ 1:
656
+ mov (%esp), %eax
657
+ ret
658
+ .align 4
659
+ .endr
660
+ ENDF(C(trampoline_code_table))
661
+ .align X86_TRAMP_MAP_SIZE
662
+ #endif /* FFI_EXEC_STATIC_TRAMP */
663
+
664
+ #if !FFI_NO_RAW_API
665
+
666
+ #define raw_closure_S_FS (16+16+12)
667
+
668
+ .balign 16
669
+ .globl C(ffi_closure_raw_SYSV)
670
+ FFI_HIDDEN(C(ffi_closure_raw_SYSV))
671
+ C(ffi_closure_raw_SYSV):
672
+ L(UW32):
673
+ # cfi_startproc
674
+ _CET_ENDBR
675
+ subl $raw_closure_S_FS, %esp
676
+ L(UW33):
677
+ # cfi_def_cfa_offset(raw_closure_S_FS + 4)
678
+ movl %ebx, raw_closure_S_FS-4(%esp)
679
+ L(UW34):
680
+ # cfi_rel_offset(%ebx, raw_closure_S_FS-4)
681
+
682
+ movl FFI_TRAMPOLINE_SIZE+8(%eax), %edx /* load cl->user_data */
683
+ movl %edx, 12(%esp)
684
+ leal raw_closure_S_FS+4(%esp), %edx /* load raw_args */
685
+ movl %edx, 8(%esp)
686
+ leal 16(%esp), %edx /* load &res */
687
+ movl %edx, 4(%esp)
688
+ movl FFI_TRAMPOLINE_SIZE(%eax), %ebx /* load cl->cif */
689
+ movl %ebx, (%esp)
690
+ call *FFI_TRAMPOLINE_SIZE+4(%eax) /* call cl->fun */
691
+
692
+ movl 20(%ebx), %eax /* load cif->flags */
693
+ andl $X86_RET_TYPE_MASK, %eax
357
694
  #ifdef __PIC__
358
- .ascii "zR\0" /* CIE Augmentation */
695
+ call C(__x86.get_pc_thunk.bx)
696
+ L(pc4):
697
+ leal L(load_table4)-L(pc4)(%ebx, %eax, 8), %ecx
359
698
  #else
360
- .ascii "\0" /* CIE Augmentation */
699
+ leal L(load_table4)(,%eax, 8), %ecx
361
700
  #endif
362
- #elif defined HAVE_AS_STRING_PSEUDO_OP
701
+ movl raw_closure_S_FS-4(%esp), %ebx
702
+ L(UW35):
703
+ # cfi_restore(%ebx)
704
+ movl 16(%esp), %eax /* Optimistic load */
705
+ jmp *%ecx
706
+
707
+ .balign 8
708
+ L(load_table4):
709
+ E(L(load_table4), X86_RET_FLOAT)
710
+ flds 16(%esp)
711
+ jmp L(e4)
712
+ E(L(load_table4), X86_RET_DOUBLE)
713
+ fldl 16(%esp)
714
+ jmp L(e4)
715
+ E(L(load_table4), X86_RET_LDOUBLE)
716
+ fldt 16(%esp)
717
+ jmp L(e4)
718
+ E(L(load_table4), X86_RET_SINT8)
719
+ movsbl %al, %eax
720
+ jmp L(e4)
721
+ E(L(load_table4), X86_RET_SINT16)
722
+ movswl %ax, %eax
723
+ jmp L(e4)
724
+ E(L(load_table4), X86_RET_UINT8)
725
+ movzbl %al, %eax
726
+ jmp L(e4)
727
+ E(L(load_table4), X86_RET_UINT16)
728
+ movzwl %ax, %eax
729
+ jmp L(e4)
730
+ E(L(load_table4), X86_RET_INT64)
731
+ movl 16+4(%esp), %edx
732
+ jmp L(e4)
733
+ E(L(load_table4), X86_RET_INT32)
734
+ nop
735
+ /* fallthru */
736
+ E(L(load_table4), X86_RET_VOID)
737
+ L(e4):
738
+ addl $raw_closure_S_FS, %esp
739
+ L(UW36):
740
+ # cfi_adjust_cfa_offset(-raw_closure_S_FS)
741
+ ret
742
+ L(UW37):
743
+ # cfi_adjust_cfa_offset(raw_closure_S_FS)
744
+ E(L(load_table4), X86_RET_STRUCTPOP)
745
+ addl $raw_closure_S_FS, %esp
746
+ L(UW38):
747
+ # cfi_adjust_cfa_offset(-raw_closure_S_FS)
748
+ ret $4
749
+ L(UW39):
750
+ # cfi_adjust_cfa_offset(raw_closure_S_FS)
751
+ E(L(load_table4), X86_RET_STRUCTARG)
752
+ jmp L(e4)
753
+ E(L(load_table4), X86_RET_STRUCT_1B)
754
+ movzbl %al, %eax
755
+ jmp L(e4)
756
+ E(L(load_table4), X86_RET_STRUCT_2B)
757
+ movzwl %ax, %eax
758
+ jmp L(e4)
759
+
760
+ /* Fill out the table so that bad values are predictable. */
761
+ E(L(load_table4), X86_RET_UNUSED14)
762
+ ud2
763
+ E(L(load_table4), X86_RET_UNUSED15)
764
+ ud2
765
+
766
+ L(UW40):
767
+ # cfi_endproc
768
+ ENDF(C(ffi_closure_raw_SYSV))
769
+
770
+ #define raw_closure_T_FS (16+16+8)
771
+
772
+ .balign 16
773
+ .globl C(ffi_closure_raw_THISCALL)
774
+ FFI_HIDDEN(C(ffi_closure_raw_THISCALL))
775
+ C(ffi_closure_raw_THISCALL):
776
+ L(UW41):
777
+ # cfi_startproc
778
+ _CET_ENDBR
779
+ /* Rearrange the stack such that %ecx is the first argument.
780
+ This means moving the return address. */
781
+ popl %edx
782
+ L(UW42):
783
+ # cfi_def_cfa_offset(0)
784
+ # cfi_register(%eip, %edx)
785
+ pushl %ecx
786
+ L(UW43):
787
+ # cfi_adjust_cfa_offset(4)
788
+ pushl %edx
789
+ L(UW44):
790
+ # cfi_adjust_cfa_offset(4)
791
+ # cfi_rel_offset(%eip, 0)
792
+ subl $raw_closure_T_FS, %esp
793
+ L(UW45):
794
+ # cfi_adjust_cfa_offset(raw_closure_T_FS)
795
+ movl %ebx, raw_closure_T_FS-4(%esp)
796
+ L(UW46):
797
+ # cfi_rel_offset(%ebx, raw_closure_T_FS-4)
798
+
799
+ movl FFI_TRAMPOLINE_SIZE+8(%eax), %edx /* load cl->user_data */
800
+ movl %edx, 12(%esp)
801
+ leal raw_closure_T_FS+4(%esp), %edx /* load raw_args */
802
+ movl %edx, 8(%esp)
803
+ leal 16(%esp), %edx /* load &res */
804
+ movl %edx, 4(%esp)
805
+ movl FFI_TRAMPOLINE_SIZE(%eax), %ebx /* load cl->cif */
806
+ movl %ebx, (%esp)
807
+ call *FFI_TRAMPOLINE_SIZE+4(%eax) /* call cl->fun */
808
+
809
+ movl 20(%ebx), %eax /* load cif->flags */
810
+ andl $X86_RET_TYPE_MASK, %eax
363
811
  #ifdef __PIC__
364
- .string "zR" /* CIE Augmentation */
812
+ call C(__x86.get_pc_thunk.bx)
813
+ L(pc5):
814
+ leal L(load_table5)-L(pc5)(%ebx, %eax, 8), %ecx
365
815
  #else
366
- .string "" /* CIE Augmentation */
816
+ leal L(load_table5)(,%eax, 8), %ecx
367
817
  #endif
818
+ movl raw_closure_T_FS-4(%esp), %ebx
819
+ L(UW47):
820
+ # cfi_restore(%ebx)
821
+ movl 16(%esp), %eax /* Optimistic load */
822
+ jmp *%ecx
823
+
824
+ .balign 8
825
+ L(load_table5):
826
+ E(L(load_table5), X86_RET_FLOAT)
827
+ flds 16(%esp)
828
+ jmp L(e5)
829
+ E(L(load_table5), X86_RET_DOUBLE)
830
+ fldl 16(%esp)
831
+ jmp L(e5)
832
+ E(L(load_table5), X86_RET_LDOUBLE)
833
+ fldt 16(%esp)
834
+ jmp L(e5)
835
+ E(L(load_table5), X86_RET_SINT8)
836
+ movsbl %al, %eax
837
+ jmp L(e5)
838
+ E(L(load_table5), X86_RET_SINT16)
839
+ movswl %ax, %eax
840
+ jmp L(e5)
841
+ E(L(load_table5), X86_RET_UINT8)
842
+ movzbl %al, %eax
843
+ jmp L(e5)
844
+ E(L(load_table5), X86_RET_UINT16)
845
+ movzwl %ax, %eax
846
+ jmp L(e5)
847
+ E(L(load_table5), X86_RET_INT64)
848
+ movl 16+4(%esp), %edx
849
+ jmp L(e5)
850
+ E(L(load_table5), X86_RET_INT32)
851
+ nop
852
+ /* fallthru */
853
+ E(L(load_table5), X86_RET_VOID)
854
+ L(e5):
855
+ addl $raw_closure_T_FS, %esp
856
+ L(UW48):
857
+ # cfi_adjust_cfa_offset(-raw_closure_T_FS)
858
+ /* Remove the extra %ecx argument we pushed. */
859
+ ret $4
860
+ L(UW49):
861
+ # cfi_adjust_cfa_offset(raw_closure_T_FS)
862
+ E(L(load_table5), X86_RET_STRUCTPOP)
863
+ addl $raw_closure_T_FS, %esp
864
+ L(UW50):
865
+ # cfi_adjust_cfa_offset(-raw_closure_T_FS)
866
+ ret $8
867
+ L(UW51):
868
+ # cfi_adjust_cfa_offset(raw_closure_T_FS)
869
+ E(L(load_table5), X86_RET_STRUCTARG)
870
+ jmp L(e5)
871
+ E(L(load_table5), X86_RET_STRUCT_1B)
872
+ movzbl %al, %eax
873
+ jmp L(e5)
874
+ E(L(load_table5), X86_RET_STRUCT_2B)
875
+ movzwl %ax, %eax
876
+ jmp L(e5)
877
+
878
+ /* Fill out the table so that bad values are predictable. */
879
+ E(L(load_table5), X86_RET_UNUSED14)
880
+ ud2
881
+ E(L(load_table5), X86_RET_UNUSED15)
882
+ ud2
883
+
884
+ L(UW52):
885
+ # cfi_endproc
886
+ ENDF(C(ffi_closure_raw_THISCALL))
887
+
888
+ #endif /* !FFI_NO_RAW_API */
889
+
890
+ #ifdef X86_DARWIN
891
+ /* The linker in use on earlier Darwin needs weak definitions to be
892
+ placed in a coalesced section. That section should not be called
893
+ __TEXT,__text since that would be re-defining the attributes of the
894
+ .text section (which is an error for earlier tools). Here we use
895
+ '__textcoal_nt' which is what GCC emits for this.
896
+ Later linker versions are happy to use a normal section and, after
897
+ Darwin12 / OSX 10.8, the tools warn that using coalesced sections
898
+ for this is deprecated so we must switch to avoid build fails and/or
899
+ deprecation warnings. */
900
+ # if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
901
+ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1080
902
+ # define COMDAT(X) \
903
+ .section __TEXT,__textcoal_nt,coalesced,pure_instructions; \
904
+ .weak_definition X; \
905
+ FFI_HIDDEN(X)
906
+ # else
907
+ # define COMDAT(X) \
908
+ .text; \
909
+ .weak_definition X; \
910
+ FFI_HIDDEN(X)
911
+ # endif
912
+ #elif defined __ELF__ && !(defined(__sun__) && defined(__svr4__))
913
+ # define COMDAT(X) \
914
+ .section .text.X,"axG",@progbits,X,comdat; \
915
+ .globl X; \
916
+ FFI_HIDDEN(X)
368
917
  #else
369
- #error missing .ascii/.string
918
+ # define COMDAT(X)
370
919
  #endif
371
- .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
372
- .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
373
- .byte 0x8 /* CIE RA Column */
374
- #ifdef __PIC__
375
- .byte 0x1 /* .uleb128 0x1; Augmentation size */
376
- .byte FDE_ENCODING
920
+
921
+ #if defined(__PIC__)
922
+ COMDAT(C(__x86.get_pc_thunk.bx))
923
+ C(__x86.get_pc_thunk.bx):
924
+ movl (%esp), %ebx
925
+ ret
926
+ ENDF(C(__x86.get_pc_thunk.bx))
927
+ # if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
928
+ COMDAT(C(__x86.get_pc_thunk.dx))
929
+ C(__x86.get_pc_thunk.dx):
930
+ movl (%esp), %edx
931
+ ret
932
+ ENDF(C(__x86.get_pc_thunk.dx))
933
+ #endif /* DARWIN || HIDDEN */
934
+ #endif /* __PIC__ */
935
+
936
+ /* Sadly, OSX cctools-as does not understand .cfi directives at all so
937
+ we build an eh frame by hand. */
938
+
939
+ #ifdef __APPLE__
940
+ /* The cctools assembler will try to make a difference between two local
941
+ symbols into a relocation against, which will not work in the eh (produces
942
+ link-time fails).
943
+ To avoid this, we compute the symbol difference with a .set directive and
944
+ then substitute this value. */
945
+ # define LEN(N, P) .set Llen$N$P,L(N)-L(P); .long Llen$N$P
946
+ /* Note, this assume DW_CFA_advance_loc1 fits into 7 bits. */
947
+ # define ADV(N, P) .set Ladv$N$P,L(N)-L(P); .byte 2, Ladv$N$P
948
+ /* For historical reasons, the EH reg numbers for SP and FP are swapped from
949
+ the DWARF ones for 32b Darwin. */
950
+ # define SP 5
951
+ # define FP 4
952
+ # define ENC 0x10
953
+ #else
954
+ # define LEN(N, P) .long L(N)-L(P)
955
+ /* Assume DW_CFA_advance_loc1 fits. */
956
+ # define ADV(N, P) .byte 2, L(N)-L(P)
957
+ # define SP 4
958
+ # define FP 5
959
+ # define ENC 0x1b
377
960
  #endif
378
- .byte 0xc /* DW_CFA_def_cfa */
379
- .byte 0x4 /* .uleb128 0x4 */
380
- .byte 0x4 /* .uleb128 0x4 */
381
- .byte 0x88 /* DW_CFA_offset, column 0x8 */
382
- .byte 0x1 /* .uleb128 0x1 */
383
- .align 4
384
- .LECIE1:
385
- .LSFDE1:
386
- .long .LEFDE1-.LASFDE1 /* FDE Length */
387
- .LASFDE1:
388
- .long .LASFDE1-.Lframe1 /* FDE CIE offset */
389
- .long FDE_ENCODE(.LFB1) /* FDE initial location */
390
- .long .LFE1-.LFB1 /* FDE address range */
391
- #ifdef __PIC__
392
- .byte 0x0 /* .uleb128 0x0; Augmentation size */
961
+
962
+ #ifdef HAVE_AS_X86_PCREL
963
+ # define PCREL(X) X-.
964
+ #else
965
+ # define PCREL(X) X@rel
393
966
  #endif
394
- .byte 0x4 /* DW_CFA_advance_loc4 */
395
- .long .LCFI0-.LFB1
396
- .byte 0xe /* DW_CFA_def_cfa_offset */
397
- .byte 0x8 /* .uleb128 0x8 */
398
- .byte 0x85 /* DW_CFA_offset, column 0x5 */
399
- .byte 0x2 /* .uleb128 0x2 */
400
- .byte 0x4 /* DW_CFA_advance_loc4 */
401
- .long .LCFI1-.LCFI0
402
- .byte 0xd /* DW_CFA_def_cfa_register */
403
- .byte 0x5 /* .uleb128 0x5 */
404
- .align 4
405
- .LEFDE1:
406
- .LSFDE2:
407
- .long .LEFDE2-.LASFDE2 /* FDE Length */
408
- .LASFDE2:
409
- .long .LASFDE2-.Lframe1 /* FDE CIE offset */
410
- .long FDE_ENCODE(.LFB2) /* FDE initial location */
411
- .long .LFE2-.LFB2 /* FDE address range */
412
- #ifdef __PIC__
413
- .byte 0x0 /* .uleb128 0x0; Augmentation size */
967
+
968
+ #ifdef __APPLE__
969
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
970
+ EHFrame0:
971
+ #elif defined(X86_WIN32)
972
+ .section .eh_frame,"r"
973
+ #elif defined(HAVE_AS_X86_64_UNWIND_SECTION_TYPE)
974
+ .section .eh_frame,EH_FRAME_FLAGS,@unwind
975
+ #else
976
+ .section .eh_frame,EH_FRAME_FLAGS,@progbits
414
977
  #endif
415
- .byte 0x4 /* DW_CFA_advance_loc4 */
416
- .long .LCFI2-.LFB2
417
- .byte 0xe /* DW_CFA_def_cfa_offset */
418
- .byte 0x8 /* .uleb128 0x8 */
419
- .byte 0x85 /* DW_CFA_offset, column 0x5 */
420
- .byte 0x2 /* .uleb128 0x2 */
421
- .byte 0x4 /* DW_CFA_advance_loc4 */
422
- .long .LCFI3-.LCFI2
423
- .byte 0xd /* DW_CFA_def_cfa_register */
424
- .byte 0x5 /* .uleb128 0x5 */
425
- #if !defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE && defined __PIC__
426
- .byte 0x4 /* DW_CFA_advance_loc4 */
427
- .long .LCFI7-.LCFI3
428
- .byte 0x83 /* DW_CFA_offset, column 0x3 */
429
- .byte 0xa /* .uleb128 0xa */
978
+ #ifndef __APPLE__
979
+ /* EH sections are already suitably aligned on Darwin. */
980
+ .balign 4
430
981
  #endif
431
- .align 4
432
- .LEFDE2:
433
982
 
434
- #if !FFI_NO_RAW_API
983
+ L(CIE):
984
+ .set L(set0),L(ECIE)-L(SCIE)
985
+ .long L(set0) /* CIE Length */
986
+ L(SCIE):
987
+ .long 0 /* CIE Identifier Tag */
988
+ .byte 1 /* CIE Version */
989
+ .ascii "zR\0" /* CIE Augmentation */
990
+ .byte 1 /* CIE Code Alignment Factor */
991
+ .byte 0x7c /* CIE Data Alignment Factor */
992
+ .byte 0x8 /* CIE RA Column */
993
+ .byte 1 /* Augmentation size */
994
+ .byte ENC /* FDE Encoding (pcrel abs/4byte) */
995
+ .byte 0xc, SP, 4 /* DW_CFA_def_cfa, %esp offset 4 */
996
+ .byte 0x80+8, 1 /* DW_CFA_offset, %eip offset 1*-4 */
997
+ .balign 4
998
+ L(ECIE):
435
999
 
436
- .LSFDE3:
437
- .long .LEFDE3-.LASFDE3 /* FDE Length */
438
- .LASFDE3:
439
- .long .LASFDE3-.Lframe1 /* FDE CIE offset */
440
- .long FDE_ENCODE(.LFB3) /* FDE initial location */
441
- .long .LFE3-.LFB3 /* FDE address range */
442
- #ifdef __PIC__
443
- .byte 0x0 /* .uleb128 0x0; Augmentation size */
1000
+ .set L(set1),L(EFDE1)-L(SFDE1)
1001
+ .long L(set1) /* FDE Length */
1002
+ L(SFDE1):
1003
+ LEN(SFDE1, CIE) /* FDE CIE offset */
1004
+ .long PCREL(L(UW0)) /* Initial location */
1005
+ LEN(UW5, UW0) /* Address range */
1006
+ .byte 0 /* Augmentation size */
1007
+ ADV(UW1, UW0)
1008
+ .byte 0xc, FP, 8 /* DW_CFA_def_cfa, %ebp 8 */
1009
+ .byte 0x80+FP, 2 /* DW_CFA_offset, %ebp 2*-4 */
1010
+ ADV(UW2, UW1)
1011
+ .byte 0x80+3, 0 /* DW_CFA_offset, %ebx 0*-4 */
1012
+ ADV(UW3, UW2)
1013
+ .byte 0xa /* DW_CFA_remember_state */
1014
+ .byte 0xc, SP, 4 /* DW_CFA_def_cfa, %esp 4 */
1015
+ .byte 0xc0+3 /* DW_CFA_restore, %ebx */
1016
+ .byte 0xc0+FP /* DW_CFA_restore, %ebp */
1017
+ ADV(UW4, UW3)
1018
+ .byte 0xb /* DW_CFA_restore_state */
1019
+ .balign 4
1020
+ L(EFDE1):
1021
+
1022
+ .set L(set2),L(EFDE2)-L(SFDE2)
1023
+ .long L(set2) /* FDE Length */
1024
+ L(SFDE2):
1025
+ LEN(SFDE2, CIE) /* FDE CIE offset */
1026
+ .long PCREL(L(UW6)) /* Initial location */
1027
+ LEN(UW8,UW6) /* Address range */
1028
+ .byte 0 /* Augmentation size */
1029
+ ADV(UW7, UW6)
1030
+ .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */
1031
+ .balign 4
1032
+ L(EFDE2):
1033
+
1034
+ .set L(set3),L(EFDE3)-L(SFDE3)
1035
+ .long L(set3) /* FDE Length */
1036
+ L(SFDE3):
1037
+ LEN(SFDE3, CIE) /* FDE CIE offset */
1038
+ .long PCREL(L(UW9)) /* Initial location */
1039
+ LEN(UW11, UW9) /* Address range */
1040
+ .byte 0 /* Augmentation size */
1041
+ ADV(UW10, UW9)
1042
+ .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */
1043
+ .balign 4
1044
+ L(EFDE3):
1045
+
1046
+ .set L(set4),L(EFDE4)-L(SFDE4)
1047
+ .long L(set4) /* FDE Length */
1048
+ L(SFDE4):
1049
+ LEN(SFDE4, CIE) /* FDE CIE offset */
1050
+ .long PCREL(L(UW12)) /* Initial location */
1051
+ LEN(UW20, UW12) /* Address range */
1052
+ .byte 0 /* Augmentation size */
1053
+ ADV(UW13, UW12)
1054
+ .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */
1055
+ #ifdef FFI_CLOSURE_CALL_INNER_SAVE_EBX
1056
+ ADV(UW14, UW13)
1057
+ .byte 0x80+3, (40-(closure_FS+4))/-4 /* DW_CFA_offset %ebx */
1058
+ ADV(UW15, UW14)
1059
+ .byte 0xc0+3 /* DW_CFA_restore %ebx */
1060
+ ADV(UW16, UW15)
1061
+ #else
1062
+ ADV(UW16, UW13)
1063
+ #endif
1064
+ .byte 0xe, 4 /* DW_CFA_def_cfa_offset */
1065
+ ADV(UW17, UW16)
1066
+ .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */
1067
+ ADV(UW18, UW17)
1068
+ .byte 0xe, 4 /* DW_CFA_def_cfa_offset */
1069
+ ADV(UW19, UW18)
1070
+ .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */
1071
+ .balign 4
1072
+ L(EFDE4):
1073
+
1074
+ .set L(set5),L(EFDE5)-L(SFDE5)
1075
+ .long L(set5) /* FDE Length */
1076
+ L(SFDE5):
1077
+ LEN(SFDE5, CIE) /* FDE CIE offset */
1078
+ .long PCREL(L(UW21)) /* Initial location */
1079
+ LEN(UW23, UW21) /* Address range */
1080
+ .byte 0 /* Augmentation size */
1081
+ ADV(UW22, UW21)
1082
+ .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */
1083
+ .balign 4
1084
+ L(EFDE5):
1085
+
1086
+ .set L(set6),L(EFDE6)-L(SFDE6)
1087
+ .long L(set6) /* FDE Length */
1088
+ L(SFDE6):
1089
+ LEN(SFDE6, CIE) /* FDE CIE offset */
1090
+ .long PCREL(L(UW24)) /* Initial location */
1091
+ LEN(UW26, UW24) /* Address range */
1092
+ .byte 0 /* Augmentation size */
1093
+ .byte 0xe, 8 /* DW_CFA_def_cfa_offset */
1094
+ .byte 0x80+8, 2 /* DW_CFA_offset %eip, 2*-4 */
1095
+ ADV(UW25, UW24)
1096
+ .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */
1097
+ .balign 4
1098
+ L(EFDE6):
1099
+
1100
+ .set L(set7),L(EFDE7)-L(SFDE7)
1101
+ .long L(set7) /* FDE Length */
1102
+ L(SFDE7):
1103
+ LEN(SFDE7, CIE) /* FDE CIE offset */
1104
+ .long PCREL(L(UW27)) /* Initial location */
1105
+ LEN(UW31, UW27) /* Address range */
1106
+ .byte 0 /* Augmentation size */
1107
+ ADV(UW28, UW27)
1108
+ .byte 0xe, closure_FS+4 /* DW_CFA_def_cfa_offset */
1109
+ #ifdef FFI_CLOSURE_CALL_INNER_SAVE_EBX
1110
+ ADV(UW29, UW28)
1111
+ .byte 0x80+3, (40-(closure_FS+4))/-4 /* DW_CFA_offset %ebx */
1112
+ ADV(UW30, UW29)
1113
+ .byte 0xc0+3 /* DW_CFA_restore %ebx */
444
1114
  #endif
445
- .byte 0x4 /* DW_CFA_advance_loc4 */
446
- .long .LCFI4-.LFB3
447
- .byte 0xe /* DW_CFA_def_cfa_offset */
448
- .byte 0x8 /* .uleb128 0x8 */
449
- .byte 0x85 /* DW_CFA_offset, column 0x5 */
450
- .byte 0x2 /* .uleb128 0x2 */
451
- .byte 0x4 /* DW_CFA_advance_loc4 */
452
- .long .LCFI5-.LCFI4
453
- .byte 0xd /* DW_CFA_def_cfa_register */
454
- .byte 0x5 /* .uleb128 0x5 */
455
- .byte 0x4 /* DW_CFA_advance_loc4 */
456
- .long .LCFI6-.LCFI5
457
- .byte 0x86 /* DW_CFA_offset, column 0x6 */
458
- .byte 0x3 /* .uleb128 0x3 */
459
- .align 4
460
- .LEFDE3:
1115
+ .balign 4
1116
+ L(EFDE7):
1117
+ #if !FFI_NO_RAW_API
1118
+ .set L(set8),L(EFDE8)-L(SFDE8)
1119
+ .long L(set8) /* FDE Length */
1120
+ L(SFDE8):
1121
+ LEN(SFDE8, CIE) /* FDE CIE offset */
1122
+ .long PCREL(L(UW32)) /* Initial location */
1123
+ LEN(UW40, UW32) /* Address range */
1124
+ .byte 0 /* Augmentation size */
1125
+ ADV(UW33, UW32)
1126
+ .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */
1127
+ ADV(UW34, UW33)
1128
+ .byte 0x80+3, 2 /* DW_CFA_offset %ebx 2*-4 */
1129
+ ADV(UW35, UW34)
1130
+ .byte 0xc0+3 /* DW_CFA_restore %ebx */
1131
+ ADV(UW36, UW35)
1132
+ .byte 0xe, 4 /* DW_CFA_def_cfa_offset */
1133
+ ADV(UW37, UW36)
1134
+ .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */
1135
+ ADV(UW38, UW37)
1136
+ .byte 0xe, 4 /* DW_CFA_def_cfa_offset */
1137
+ ADV(UW39, UW38)
1138
+ .byte 0xe, raw_closure_S_FS+4 /* DW_CFA_def_cfa_offset */
1139
+ .balign 4
1140
+ L(EFDE8):
461
1141
 
1142
+ .set L(set9),L(EFDE9)-L(SFDE9)
1143
+ .long L(set9) /* FDE Length */
1144
+ L(SFDE9):
1145
+ LEN(SFDE9, CIE) /* FDE CIE offset */
1146
+ .long PCREL(L(UW41)) /* Initial location */
1147
+ LEN(UW52, UW41) /* Address range */
1148
+ .byte 0 /* Augmentation size */
1149
+ ADV(UW42, UW41)
1150
+ .byte 0xe, 0 /* DW_CFA_def_cfa_offset */
1151
+ .byte 0x9, 8, 2 /* DW_CFA_register %eip, %edx */
1152
+ ADV(UW43, UW42)
1153
+ .byte 0xe, 4 /* DW_CFA_def_cfa_offset */
1154
+ ADV(UW44, UW43)
1155
+ .byte 0xe, 8 /* DW_CFA_def_cfa_offset */
1156
+ .byte 0x80+8, 2 /* DW_CFA_offset %eip 2*-4 */
1157
+ ADV(UW45, UW44)
1158
+ .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */
1159
+ ADV(UW46, UW45)
1160
+ .byte 0x80+3, 3 /* DW_CFA_offset %ebx 3*-4 */
1161
+ ADV(UW47, UW46)
1162
+ .byte 0xc0+3 /* DW_CFA_restore %ebx */
1163
+ ADV(UW48, UW47)
1164
+ .byte 0xe, 8 /* DW_CFA_def_cfa_offset */
1165
+ ADV(UW49, UW48)
1166
+ .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */
1167
+ ADV(UW50, UW49)
1168
+ .byte 0xe, 8 /* DW_CFA_def_cfa_offset */
1169
+ ADV(UW51, UW50)
1170
+ .byte 0xe, raw_closure_T_FS+8 /* DW_CFA_def_cfa_offset */
1171
+ .balign 4
1172
+ L(EFDE9):
1173
+ #endif /* !FFI_NO_RAW_API */
1174
+
1175
+ #ifdef _WIN32
1176
+ .def @feat.00;
1177
+ .scl 3;
1178
+ .type 0;
1179
+ .endef
1180
+ .globl @feat.00
1181
+ @feat.00 = 1
462
1182
  #endif
463
1183
 
464
- #endif /* ifndef __x86_64__ */
1184
+ #if defined(__APPLE__)
1185
+ .subsections_via_symbols
1186
+ # if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
1187
+ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070 && __clang__
1188
+ /* compact unwind is not used with GCC at present, was not present before 10.6
1189
+ but has some bugs there, so do not emit until 10.7. */
1190
+ .section __LD,__compact_unwind,regular,debug
1191
+
1192
+ /* compact unwind for ffi_call_i386 */
1193
+ .long C(ffi_call_i386)
1194
+ .set L1,L(UW5)-L(UW0)
1195
+ .long L1
1196
+ .long 0x04000000 /* use dwarf unwind info */
1197
+ .long 0
1198
+ .long 0
1199
+
1200
+ /* compact unwind for ffi_go_closure_EAX */
1201
+ .long C(ffi_go_closure_EAX)
1202
+ .set L2,L(UW8)-L(UW6)
1203
+ .long L2
1204
+ .long 0x04000000 /* use dwarf unwind info */
1205
+ .long 0
1206
+ .long 0
1207
+
1208
+ /* compact unwind for ffi_go_closure_ECX */
1209
+ .long C(ffi_go_closure_ECX)
1210
+ .set L3,L(UW11)-L(UW9)
1211
+ .long L3
1212
+ .long 0x04000000 /* use dwarf unwind info */
1213
+ .long 0
1214
+ .long 0
1215
+
1216
+ /* compact unwind for ffi_closure_i386 */
1217
+ .long C(ffi_closure_i386)
1218
+ .set L4,L(UW20)-L(UW12)
1219
+ .long L4
1220
+ .long 0x04000000 /* use dwarf unwind info */
1221
+ .long 0
1222
+ .long 0
1223
+
1224
+ /* compact unwind for ffi_go_closure_STDCALL */
1225
+ .long C(ffi_go_closure_STDCALL)
1226
+ .set L5,L(UW23)-L(UW21)
1227
+ .long L5
1228
+ .long 0x04000000 /* use dwarf unwind info */
1229
+ .long 0
1230
+ .long 0
1231
+
1232
+ /* compact unwind for ffi_closure_REGISTER */
1233
+ .long C(ffi_closure_REGISTER)
1234
+ .set L6,L(UW26)-L(UW24)
1235
+ .long L6
1236
+ .long 0x04000000 /* use dwarf unwind info */
1237
+ .long 0
1238
+ .long 0
1239
+
1240
+ /* compact unwind for ffi_closure_STDCALL */
1241
+ .long C(ffi_closure_STDCALL)
1242
+ .set L7,L(UW31)-L(UW27)
1243
+ .long L7
1244
+ .long 0x04000000 /* use dwarf unwind info */
1245
+ .long 0
1246
+ .long 0
1247
+
1248
+ /* compact unwind for ffi_closure_raw_SYSV */
1249
+ .long C(ffi_closure_raw_SYSV)
1250
+ .set L8,L(UW40)-L(UW32)
1251
+ .long L8
1252
+ .long 0x04000000 /* use dwarf unwind info */
1253
+ .long 0
1254
+ .long 0
1255
+
1256
+ /* compact unwind for ffi_closure_raw_THISCALL */
1257
+ .long C(ffi_closure_raw_THISCALL)
1258
+ .set L9,L(UW52)-L(UW41)
1259
+ .long L9
1260
+ .long 0x04000000 /* use dwarf unwind info */
1261
+ .long 0
1262
+ .long 0
1263
+ #endif /* use compact unwind */
1264
+ #endif /* __APPLE__ */
1265
+
1266
+ #endif /* ifndef _MSC_VER */
1267
+
1268
+ #endif /* ifdef __i386__ */
465
1269
 
466
1270
  #if defined __ELF__ && defined __linux__
467
1271
  .section .note.GNU-stack,"",@progbits