ffi 1.0.0 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (694) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +4 -0
  3. data/CHANGELOG.md +465 -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 +165 -148
  10. data/ext/ffi_c/AbstractMemory.c +716 -97
  11. data/ext/ffi_c/AbstractMemory.h +38 -17
  12. data/ext/ffi_c/ArrayType.c +102 -33
  13. data/ext/ffi_c/ArrayType.h +20 -18
  14. data/ext/ffi_c/Buffer.c +229 -54
  15. data/ext/ffi_c/Call.c +211 -100
  16. data/ext/ffi_c/Call.h +46 -28
  17. data/ext/ffi_c/ClosurePool.c +110 -81
  18. data/ext/ffi_c/ClosurePool.h +31 -1
  19. data/ext/ffi_c/DynamicLibrary.c +216 -54
  20. data/ext/ffi_c/DynamicLibrary.h +76 -0
  21. data/ext/ffi_c/Function.c +527 -164
  22. data/ext/ffi_c/Function.h +24 -20
  23. data/ext/ffi_c/FunctionInfo.c +151 -50
  24. data/ext/ffi_c/LastError.c +112 -28
  25. data/ext/ffi_c/LastError.h +29 -0
  26. data/ext/ffi_c/LongDouble.c +65 -0
  27. data/ext/ffi_c/LongDouble.h +47 -0
  28. data/ext/ffi_c/MappedType.c +107 -42
  29. data/ext/ffi_c/MappedType.h +20 -20
  30. data/ext/ffi_c/MemoryPointer.c +108 -46
  31. data/ext/ffi_c/MemoryPointer.h +33 -4
  32. data/ext/ffi_c/MethodHandle.c +71 -67
  33. data/ext/ffi_c/MethodHandle.h +26 -23
  34. data/ext/ffi_c/Platform.c +42 -25
  35. data/ext/ffi_c/Platform.h +32 -3
  36. data/ext/ffi_c/Pointer.c +324 -51
  37. data/ext/ffi_c/Pointer.h +29 -18
  38. data/ext/ffi_c/Struct.c +434 -161
  39. data/ext/ffi_c/Struct.h +47 -27
  40. data/ext/ffi_c/StructByValue.c +74 -37
  41. data/ext/ffi_c/StructByValue.h +20 -18
  42. data/ext/ffi_c/StructLayout.c +358 -87
  43. data/ext/ffi_c/Thread.c +129 -0
  44. data/ext/ffi_c/Thread.h +76 -0
  45. data/ext/ffi_c/Type.c +241 -76
  46. data/ext/ffi_c/Type.h +27 -11
  47. data/ext/ffi_c/Types.c +54 -34
  48. data/ext/ffi_c/Types.h +24 -24
  49. data/ext/ffi_c/Variadic.c +151 -55
  50. data/ext/ffi_c/compat.h +48 -38
  51. data/ext/ffi_c/extconf.rb +106 -34
  52. data/ext/ffi_c/ffi.c +35 -26
  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} +6528 -3180
  78. data/ext/ffi_c/libffi/LICENSE +3 -3
  79. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +353 -0
  80. data/ext/ffi_c/libffi/Makefile.am +132 -162
  81. data/ext/ffi_c/libffi/Makefile.in +1339 -1003
  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 +227 -21
  86. data/ext/ffi_c/libffi/config.guess +1034 -778
  87. data/ext/ffi_c/libffi/config.sub +1394 -1204
  88. data/ext/ffi_c/libffi/configure +14327 -8503
  89. data/ext/ffi_c/libffi/configure.ac +294 -247
  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 +572 -67
  94. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  95. data/ext/ffi_c/libffi/fficonfig.h.in +53 -46
  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 +219 -79
  99. data/ext/ffi_c/libffi/include/ffi.h.in +230 -111
  100. data/ext/ffi_c/libffi/include/ffi_cfi.h +76 -0
  101. data/ext/ffi_c/libffi/include/ffi_common.h +78 -16
  102. data/ext/ffi_c/libffi/include/tramp.h +45 -0
  103. data/ext/ffi_c/libffi/install-sh +402 -184
  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 +5752 -2722
  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 +198 -0
  113. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +158 -0
  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 +119 -0
  116. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +49 -0
  117. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +302 -0
  118. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +267 -0
  119. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +89 -0
  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 +174 -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 +155 -300
  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/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  134. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
  135. data/ext/ffi_c/libffi/msvcc.sh +353 -0
  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 +162 -246
  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 +806 -194
  149. data/ext/ffi_c/libffi/src/arm/ffitarget.h +43 -3
  150. data/ext/ffi_c/libffi/src/arm/internal.h +17 -0
  151. data/ext/ffi_c/libffi/src/arm/sysv.S +381 -231
  152. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  153. data/ext/ffi_c/libffi/src/avr32/ffi.c +4 -2
  154. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +8 -3
  155. data/ext/ffi_c/libffi/src/bfin/ffi.c +196 -0
  156. data/ext/ffi_c/libffi/src/bfin/ffitarget.h +43 -0
  157. data/ext/ffi_c/libffi/src/bfin/sysv.S +179 -0
  158. data/ext/ffi_c/libffi/src/closures.c +574 -100
  159. data/ext/ffi_c/libffi/src/cris/ffi.c +11 -8
  160. data/ext/ffi_c/libffi/src/cris/ffitarget.h +8 -3
  161. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  162. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  163. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  164. data/ext/ffi_c/libffi/src/debug.c +8 -3
  165. data/ext/ffi_c/libffi/src/dlmalloc.c +89 -17
  166. data/ext/ffi_c/libffi/src/frv/ffi.c +2 -2
  167. data/ext/ffi_c/libffi/src/frv/ffitarget.h +8 -7
  168. data/ext/ffi_c/libffi/src/ia64/ffi.c +48 -12
  169. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +10 -4
  170. data/ext/ffi_c/libffi/src/ia64/unix.S +28 -3
  171. data/ext/ffi_c/libffi/src/java_raw_api.c +24 -6
  172. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  173. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  174. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  175. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  176. data/ext/ffi_c/libffi/src/loongarch64/ffi.c +624 -0
  177. data/ext/ffi_c/libffi/src/loongarch64/ffitarget.h +82 -0
  178. data/ext/ffi_c/libffi/src/loongarch64/sysv.S +327 -0
  179. data/ext/ffi_c/libffi/src/m32r/ffi.c +32 -15
  180. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +8 -3
  181. data/ext/ffi_c/libffi/src/m68k/ffi.c +97 -13
  182. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +8 -3
  183. data/ext/ffi_c/libffi/src/m68k/sysv.S +148 -25
  184. data/ext/ffi_c/libffi/src/m88k/ffi.c +400 -0
  185. data/ext/ffi_c/libffi/src/m88k/ffitarget.h +49 -0
  186. data/ext/ffi_c/libffi/src/m88k/obsd.S +209 -0
  187. data/ext/ffi_c/libffi/src/metag/ffi.c +330 -0
  188. data/ext/ffi_c/libffi/src/metag/ffitarget.h +53 -0
  189. data/ext/ffi_c/libffi/src/metag/sysv.S +311 -0
  190. data/ext/ffi_c/libffi/src/microblaze/ffi.c +321 -0
  191. data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +53 -0
  192. data/ext/ffi_c/libffi/src/microblaze/sysv.S +302 -0
  193. data/ext/ffi_c/libffi/src/mips/ffi.c +392 -104
  194. data/ext/ffi_c/libffi/src/mips/ffitarget.h +40 -24
  195. data/ext/ffi_c/libffi/src/mips/n32.S +325 -93
  196. data/ext/ffi_c/libffi/src/mips/o32.S +211 -31
  197. data/ext/ffi_c/libffi/src/moxie/eabi.S +101 -0
  198. data/ext/ffi_c/libffi/src/moxie/ffi.c +310 -0
  199. data/ext/ffi_c/libffi/src/moxie/ffitarget.h +52 -0
  200. data/ext/ffi_c/libffi/src/nios2/ffi.c +304 -0
  201. data/ext/ffi_c/libffi/src/nios2/ffitarget.h +52 -0
  202. data/ext/ffi_c/libffi/src/nios2/sysv.S +136 -0
  203. data/ext/ffi_c/libffi/src/or1k/ffi.c +341 -0
  204. data/ext/ffi_c/libffi/src/or1k/ffitarget.h +58 -0
  205. data/ext/ffi_c/libffi/src/or1k/sysv.S +107 -0
  206. data/ext/ffi_c/libffi/src/pa/ffi.c +68 -111
  207. data/ext/ffi_c/libffi/src/pa/ffi64.c +614 -0
  208. data/ext/ffi_c/libffi/src/pa/ffitarget.h +34 -17
  209. data/ext/ffi_c/libffi/src/pa/hpux32.S +87 -38
  210. data/ext/ffi_c/libffi/src/pa/hpux64.S +681 -0
  211. data/ext/ffi_c/libffi/src/pa/linux.S +109 -39
  212. data/ext/ffi_c/libffi/src/powerpc/aix.S +250 -8
  213. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +255 -4
  214. data/ext/ffi_c/libffi/src/powerpc/asm.h +3 -3
  215. data/ext/ffi_c/libffi/src/powerpc/darwin.S +211 -78
  216. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +356 -102
  217. data/ext/ffi_c/libffi/src/powerpc/ffi.c +108 -1375
  218. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +746 -210
  219. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +1153 -0
  220. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +105 -0
  221. data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +923 -0
  222. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +126 -48
  223. data/ext/ffi_c/libffi/src/powerpc/linux64.S +191 -85
  224. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +438 -108
  225. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +138 -68
  226. data/ext/ffi_c/libffi/src/powerpc/sysv.S +73 -119
  227. data/ext/ffi_c/libffi/src/powerpc/t-aix +5 -0
  228. data/ext/ffi_c/libffi/src/prep_cif.c +141 -32
  229. data/ext/ffi_c/libffi/src/raw_api.c +18 -5
  230. data/ext/ffi_c/libffi/src/riscv/ffi.c +514 -0
  231. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +69 -0
  232. data/ext/ffi_c/libffi/src/riscv/sysv.S +293 -0
  233. data/ext/ffi_c/libffi/src/s390/ffi.c +294 -318
  234. data/ext/ffi_c/libffi/src/s390/ffitarget.h +13 -3
  235. data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
  236. data/ext/ffi_c/libffi/src/s390/sysv.S +257 -366
  237. data/ext/ffi_c/libffi/src/sh/ffi.c +4 -3
  238. data/ext/ffi_c/libffi/src/sh/ffitarget.h +8 -3
  239. data/ext/ffi_c/libffi/src/sh64/ffi.c +3 -2
  240. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +8 -3
  241. data/ext/ffi_c/libffi/src/sparc/ffi.c +334 -491
  242. data/ext/ffi_c/libffi/src/sparc/ffi64.c +630 -0
  243. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +20 -5
  244. data/ext/ffi_c/libffi/src/sparc/internal.h +26 -0
  245. data/ext/ffi_c/libffi/src/sparc/v8.S +364 -234
  246. data/ext/ffi_c/libffi/src/sparc/v9.S +340 -207
  247. data/ext/ffi_c/libffi/src/tile/ffi.c +355 -0
  248. data/ext/ffi_c/libffi/src/tile/ffitarget.h +65 -0
  249. data/ext/ffi_c/libffi/src/tile/tile.S +360 -0
  250. data/ext/ffi_c/libffi/src/tramp.c +716 -0
  251. data/ext/ffi_c/libffi/src/types.c +48 -19
  252. data/ext/ffi_c/libffi/src/vax/elfbsd.S +195 -0
  253. data/ext/ffi_c/libffi/src/vax/ffi.c +276 -0
  254. data/ext/ffi_c/libffi/src/vax/ffitarget.h +49 -0
  255. data/ext/ffi_c/libffi/src/wasm32/ffi.c +947 -0
  256. data/ext/ffi_c/libffi/src/wasm32/ffitarget.h +62 -0
  257. data/ext/ffi_c/libffi/src/x86/asmnames.h +30 -0
  258. data/ext/ffi_c/libffi/src/x86/ffi.c +690 -540
  259. data/ext/ffi_c/libffi/src/x86/ffi64.c +450 -126
  260. data/ext/ffi_c/libffi/src/x86/ffitarget.h +86 -42
  261. data/ext/ffi_c/libffi/src/x86/ffiw64.c +361 -0
  262. data/ext/ffi_c/libffi/src/x86/internal.h +43 -0
  263. data/ext/ffi_c/libffi/src/x86/internal64.h +36 -0
  264. data/ext/ffi_c/libffi/src/x86/sysv.S +1199 -381
  265. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +998 -0
  266. data/ext/ffi_c/libffi/src/x86/unix64.S +587 -298
  267. data/ext/ffi_c/libffi/src/x86/win64.S +251 -457
  268. data/ext/ffi_c/libffi/src/x86/win64_intel.S +238 -0
  269. data/ext/ffi_c/libffi/src/xtensa/ffi.c +306 -0
  270. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +57 -0
  271. data/ext/ffi_c/libffi/src/xtensa/sysv.S +268 -0
  272. data/ext/ffi_c/libffi/stamp-h.in +1 -0
  273. data/ext/ffi_c/libffi/testsuite/Makefile.am +80 -73
  274. data/ext/ffi_c/libffi/testsuite/Makefile.in +251 -117
  275. data/ext/ffi_c/libffi/testsuite/emscripten/build-tests.sh +54 -0
  276. data/ext/ffi_c/libffi/testsuite/emscripten/build.sh +63 -0
  277. data/ext/ffi_c/libffi/testsuite/emscripten/conftest.py +86 -0
  278. data/ext/ffi_c/libffi/testsuite/emscripten/node-tests.sh +48 -0
  279. data/ext/ffi_c/libffi/testsuite/emscripten/test.html +7 -0
  280. data/ext/ffi_c/libffi/testsuite/emscripten/test_libffi.py +51 -0
  281. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +682 -0
  282. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +22 -2
  283. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
  284. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/README +78 -0
  285. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h +50 -0
  286. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +63 -0
  287. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1746 -0
  288. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2885 -0
  289. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +747 -0
  290. data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +46 -0
  291. data/ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c +46 -0
  292. data/ext/ffi_c/libffi/testsuite/libffi.call/bpo_38748.c +41 -0
  293. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +28 -10
  294. data/ext/ffi_c/libffi/testsuite/libffi.call/callback.c +99 -0
  295. data/ext/ffi_c/libffi/testsuite/libffi.call/callback2.c +108 -0
  296. data/ext/ffi_c/libffi/testsuite/libffi.call/callback3.c +114 -0
  297. data/ext/ffi_c/libffi/testsuite/libffi.call/callback4.c +119 -0
  298. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +4 -3
  299. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +88 -42
  300. data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +3 -1
  301. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +15 -12
  302. data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +4 -2
  303. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +110 -0
  304. data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +6 -16
  305. data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +57 -0
  306. data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +70 -0
  307. data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +78 -0
  308. data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +0 -1
  309. data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +46 -0
  310. data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +127 -0
  311. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +1 -0
  312. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +1 -1
  313. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +6 -0
  314. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +1 -1
  315. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +4 -0
  316. data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +1 -1
  317. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +4 -0
  318. data/ext/ffi_c/libffi/testsuite/libffi.call/s55.c +60 -0
  319. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +9 -10
  320. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +49 -0
  321. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +49 -0
  322. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +55 -0
  323. data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +9 -7
  324. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +57 -0
  325. data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +7 -7
  326. data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +7 -6
  327. data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +9 -8
  328. data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +9 -8
  329. data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +9 -9
  330. data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +9 -9
  331. data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +9 -8
  332. data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +9 -8
  333. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_2.c +63 -0
  334. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3.c +65 -0
  335. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_3f.c +65 -0
  336. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4.c +67 -0
  337. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_4f.c +67 -0
  338. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_big.c +93 -0
  339. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_by_value_small.c +61 -0
  340. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_2H.c +63 -0
  341. data/ext/ffi_c/libffi/testsuite/libffi.call/struct_return_8H.c +90 -0
  342. data/ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c +61 -0
  343. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +78 -0
  344. data/ext/ffi_c/libffi/testsuite/libffi.call/va_2.c +220 -0
  345. data/ext/ffi_c/libffi/testsuite/libffi.call/va_3.c +154 -0
  346. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +134 -0
  347. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +134 -0
  348. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +140 -0
  349. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  350. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +3 -2
  351. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +2 -0
  352. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +2 -0
  353. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +21 -1
  354. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +2 -0
  355. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +2 -0
  356. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +2 -0
  357. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +7 -6
  358. data/ext/ffi_c/libffi/testsuite/{libffi.call/closure_stdcall.c → libffi.closures/closure_simple.c} +13 -16
  359. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +22 -4
  360. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +26 -4
  361. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +28 -4
  362. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +33 -4
  363. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +8 -4
  364. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +23 -5
  365. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +25 -5
  366. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +40 -8
  367. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +17 -4
  368. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +23 -4
  369. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +17 -4
  370. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +17 -4
  371. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_3float.c +113 -0
  372. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +26 -4
  373. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +17 -4
  374. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +33 -5
  375. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +23 -5
  376. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +29 -5
  377. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +32 -5
  378. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +28 -6
  379. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +43 -5
  380. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +29 -5
  381. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +18 -4
  382. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +18 -5
  383. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +18 -6
  384. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +23 -5
  385. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +23 -5
  386. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +24 -5
  387. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +44 -31
  388. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +44 -9
  389. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +23 -5
  390. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +22 -5
  391. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +22 -7
  392. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +23 -5
  393. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +22 -5
  394. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +23 -5
  395. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +24 -5
  396. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +7 -5
  397. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +21 -9
  398. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +4 -0
  399. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +13 -3
  400. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +34 -11
  401. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_args.c +70 -0
  402. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_many_mixed_float_double.c +55 -0
  403. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +5 -1
  404. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +6 -1
  405. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +9 -1
  406. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +9 -1
  407. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +6 -2
  408. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +9 -1
  409. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +7 -2
  410. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +22 -10
  411. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +3 -0
  412. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +2 -0
  413. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +3 -0
  414. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_struct_va1.c +125 -0
  415. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +3 -0
  416. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +4 -0
  417. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_uint_va.c +49 -0
  418. data/ext/ffi_c/libffi/testsuite/libffi.closures/cls_ulong_va.c +49 -0
  419. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +8 -5
  420. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +3 -0
  421. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +2 -3
  422. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +1 -0
  423. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +57 -56
  424. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +38 -15
  425. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +9 -9
  426. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +19 -6
  427. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct11.c +137 -0
  428. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct12.c +86 -0
  429. data/ext/ffi_c/libffi/testsuite/libffi.closures/nested_struct13.c +115 -0
  430. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +15 -6
  431. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +15 -6
  432. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +14 -5
  433. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +14 -5
  434. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +17 -6
  435. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +14 -5
  436. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +17 -6
  437. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +17 -6
  438. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs1.c +86 -0
  439. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs2.c +102 -0
  440. data/ext/ffi_c/libffi/testsuite/libffi.closures/single_entry_structs3.c +101 -0
  441. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +7 -7
  442. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +7 -7
  443. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +6 -6
  444. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +7 -6
  445. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +8 -3
  446. data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest.cc +4 -10
  447. data/ext/ffi_c/libffi/testsuite/{libffi.special → libffi.closures}/unwindtest_ffi_call.cc +4 -2
  448. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc +91 -0
  449. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c +10 -0
  450. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c +10 -0
  451. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +10 -0
  452. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc +42 -0
  453. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c +10 -0
  454. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c +10 -0
  455. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +10 -0
  456. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc +71 -0
  457. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +10 -0
  458. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +10 -0
  459. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +10 -0
  460. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc +80 -0
  461. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c +10 -0
  462. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c +16 -0
  463. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +10 -0
  464. data/ext/ffi_c/libffi/testsuite/{libffi.special/special.exp → libffi.complex/complex.exp} +9 -10
  465. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +51 -0
  466. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +7 -0
  467. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +7 -0
  468. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +7 -0
  469. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +10 -0
  470. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +10 -0
  471. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +86 -0
  472. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +10 -0
  473. data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +1 -0
  474. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +78 -0
  475. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +10 -0
  476. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +10 -0
  477. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +10 -0
  478. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +37 -0
  479. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +41 -0
  480. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +10 -0
  481. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +10 -0
  482. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +10 -0
  483. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +44 -0
  484. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +10 -0
  485. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +10 -0
  486. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +10 -0
  487. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +10 -0
  488. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +10 -0
  489. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +10 -0
  490. data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +34 -0
  491. data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +28 -0
  492. data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +1 -0
  493. data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +36 -0
  494. data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +19 -0
  495. data/ext/ffi_c/libffi.bsd.mk +14 -8
  496. data/ext/ffi_c/libffi.darwin.mk +56 -26
  497. data/ext/ffi_c/libffi.gnu.mk +9 -6
  498. data/ext/ffi_c/libffi.mk +13 -8
  499. data/ext/ffi_c/libffi.vc.mk +26 -0
  500. data/ext/ffi_c/libffi.vc64.mk +26 -0
  501. data/ext/ffi_c/rbffi.h +34 -6
  502. data/ext/ffi_c/{endian.h → rbffi_endian.h} +21 -2
  503. data/ffi.gemspec +42 -0
  504. data/lib/ffi/abstract_memory.rb +44 -0
  505. data/lib/ffi/autopointer.rb +111 -52
  506. data/lib/ffi/compat.rb +43 -0
  507. data/lib/ffi/data_converter.rb +67 -0
  508. data/lib/ffi/dynamic_library.rb +118 -0
  509. data/lib/ffi/enum.rb +203 -22
  510. data/lib/ffi/errno.rb +27 -12
  511. data/lib/ffi/ffi.rb +88 -11
  512. data/lib/ffi/function.rb +71 -0
  513. data/lib/ffi/io.rb +35 -14
  514. data/lib/ffi/library.rb +382 -96
  515. data/lib/ffi/library_path.rb +109 -0
  516. data/lib/ffi/managedstruct.rb +64 -35
  517. data/lib/ffi/memorypointer.rb +1 -33
  518. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  519. data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
  520. data/lib/ffi/platform/aarch64-freebsd12/types.conf +181 -0
  521. data/lib/ffi/platform/aarch64-linux/types.conf +175 -0
  522. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  523. data/lib/ffi/platform/aarch64-windows/types.conf +52 -0
  524. data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
  525. data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
  526. data/lib/ffi/platform/arm-linux/types.conf +132 -0
  527. data/lib/ffi/platform/hppa1.1-linux/types.conf +178 -0
  528. data/lib/ffi/platform/hppa2.0-linux/types.conf +178 -0
  529. data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
  530. data/lib/ffi/platform/i386-darwin/types.conf +100 -0
  531. data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
  532. data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
  533. data/lib/ffi/platform/i386-gnu/types.conf +107 -0
  534. data/lib/ffi/platform/i386-linux/types.conf +103 -0
  535. data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
  536. data/lib/ffi/platform/i386-openbsd/types.conf +128 -0
  537. data/lib/ffi/platform/i386-solaris/types.conf +122 -0
  538. data/lib/ffi/platform/i386-windows/types.conf +52 -0
  539. data/lib/ffi/platform/ia64-linux/types.conf +104 -0
  540. data/lib/ffi/platform/loongarch64-linux/types.conf +141 -0
  541. data/lib/ffi/platform/mips-linux/types.conf +102 -0
  542. data/lib/ffi/platform/mips64-linux/types.conf +104 -0
  543. data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
  544. data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
  545. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +102 -0
  546. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +102 -0
  547. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +104 -0
  548. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +104 -0
  549. data/lib/ffi/platform/powerpc-aix/types.conf +180 -0
  550. data/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
  551. data/lib/ffi/platform/powerpc-linux/types.conf +130 -0
  552. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  553. data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
  554. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  555. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  556. data/lib/ffi/platform/s390-linux/types.conf +102 -0
  557. data/lib/ffi/platform/s390x-linux/types.conf +102 -0
  558. data/lib/ffi/platform/sparc-linux/types.conf +102 -0
  559. data/lib/ffi/platform/sparc-solaris/types.conf +128 -0
  560. data/lib/ffi/platform/sparcv9-linux/types.conf +102 -0
  561. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  562. data/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
  563. data/lib/ffi/platform/sw_64-linux/types.conf +141 -0
  564. data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
  565. data/lib/ffi/platform/x86_64-darwin/types.conf +130 -0
  566. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  567. data/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
  568. data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
  569. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  570. data/lib/ffi/platform/x86_64-linux/types.conf +132 -0
  571. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  572. data/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
  573. data/lib/ffi/platform/x86_64-openbsd/types.conf +134 -0
  574. data/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
  575. data/lib/ffi/platform/x86_64-windows/types.conf +52 -0
  576. data/lib/ffi/platform.rb +110 -34
  577. data/lib/ffi/pointer.rb +117 -90
  578. data/lib/ffi/struct.rb +101 -70
  579. data/lib/ffi/struct_by_reference.rb +72 -0
  580. data/lib/ffi/struct_layout.rb +96 -0
  581. data/lib/ffi/struct_layout_builder.rb +90 -21
  582. data/lib/ffi/tools/const_generator.rb +86 -31
  583. data/lib/ffi/tools/generator.rb +49 -2
  584. data/lib/ffi/tools/generator_task.rb +13 -16
  585. data/lib/ffi/tools/struct_generator.rb +6 -5
  586. data/lib/ffi/tools/types_generator.rb +25 -11
  587. data/lib/ffi/types.rb +105 -36
  588. data/lib/ffi/union.rb +23 -12
  589. data/lib/ffi/variadic.rb +44 -29
  590. data/lib/ffi/version.rb +3 -0
  591. data/lib/ffi.rb +25 -9
  592. data/rakelib/ffi_gem_helper.rb +65 -0
  593. data/samples/getlogin.rb +8 -0
  594. data/samples/getpid.rb +8 -0
  595. data/samples/gettimeofday.rb +18 -0
  596. data/samples/hello.rb +8 -0
  597. data/samples/hello_ractor.rb +11 -0
  598. data/samples/inotify.rb +60 -0
  599. data/samples/pty.rb +75 -0
  600. data/samples/qsort.rb +20 -0
  601. data/samples/qsort_ractor.rb +28 -0
  602. data/sig/ffi/abstract_memory.rbs +165 -0
  603. data/sig/ffi/auto_pointer.rbs +26 -0
  604. data/sig/ffi/buffer.rbs +18 -0
  605. data/sig/ffi/data_converter.rbs +10 -0
  606. data/sig/ffi/dynamic_library.rbs +9 -0
  607. data/sig/ffi/enum.rbs +38 -0
  608. data/sig/ffi/function.rbs +39 -0
  609. data/sig/ffi/library.rbs +42 -0
  610. data/sig/ffi/native_type.rbs +86 -0
  611. data/sig/ffi/pointer.rbs +42 -0
  612. data/sig/ffi/struct.rbs +76 -0
  613. data/sig/ffi/struct_by_reference.rbs +11 -0
  614. data/sig/ffi/struct_by_value.rbs +7 -0
  615. data/sig/ffi/struct_layout.rbs +9 -0
  616. data/sig/ffi/struct_layout_builder.rbs +5 -0
  617. data/sig/ffi/type.rbs +39 -0
  618. data/sig/ffi.rbs +26 -0
  619. data.tar.gz.sig +0 -0
  620. metadata +547 -248
  621. metadata.gz.sig +0 -0
  622. data/History.txt +0 -109
  623. data/README.rdoc +0 -70
  624. data/ext/ffi_c/DataConverter.c +0 -62
  625. data/ext/ffi_c/StructByReference.c +0 -150
  626. data/ext/ffi_c/StructByReference.h +0 -50
  627. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -658
  628. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  629. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  630. data/ext/ffi_c/libffi/README +0 -306
  631. data/ext/ffi_c/libffi/aclocal.m4 +0 -8998
  632. data/ext/ffi_c/libffi/depcomp +0 -584
  633. data/ext/ffi_c/libffi/doc/libffi.info +0 -533
  634. data/ext/ffi_c/libffi/doc/stamp-vti +0 -4
  635. data/ext/ffi_c/libffi/m4/libtool.m4 +0 -7360
  636. data/ext/ffi_c/libffi/m4/ltoptions.m4 +0 -368
  637. data/ext/ffi_c/libffi/m4/ltsugar.m4 +0 -123
  638. data/ext/ffi_c/libffi/m4/ltversion.m4 +0 -23
  639. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +0 -92
  640. data/ext/ffi_c/libffi/mdate-sh +0 -201
  641. data/ext/ffi_c/libffi/src/x86/darwin.S +0 -444
  642. data/ext/ffi_c/libffi/src/x86/darwin64.S +0 -416
  643. data/ext/ffi_c/libffi/src/x86/freebsd.S +0 -458
  644. data/ext/ffi_c/libffi/src/x86/win32.S +0 -877
  645. data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +0 -300
  646. data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +0 -63
  647. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +0 -44
  648. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +0 -96
  649. data/ext/ffi_c/libffi/texinfo.tex +0 -7210
  650. data/gen/Rakefile +0 -14
  651. data/spec/ffi/async_callback_spec.rb +0 -23
  652. data/spec/ffi/bool_spec.rb +0 -24
  653. data/spec/ffi/buffer_spec.rb +0 -202
  654. data/spec/ffi/callback_spec.rb +0 -653
  655. data/spec/ffi/custom_param_type.rb +0 -31
  656. data/spec/ffi/custom_type_spec.rb +0 -73
  657. data/spec/ffi/enum_spec.rb +0 -183
  658. data/spec/ffi/errno_spec.rb +0 -13
  659. data/spec/ffi/ffi_spec.rb +0 -24
  660. data/spec/ffi/function_spec.rb +0 -73
  661. data/spec/ffi/library_spec.rb +0 -174
  662. data/spec/ffi/managed_struct_spec.rb +0 -56
  663. data/spec/ffi/number_spec.rb +0 -231
  664. data/spec/ffi/pointer_spec.rb +0 -210
  665. data/spec/ffi/rbx/attach_function_spec.rb +0 -28
  666. data/spec/ffi/rbx/memory_pointer_spec.rb +0 -109
  667. data/spec/ffi/rbx/spec_helper.rb +0 -1
  668. data/spec/ffi/rbx/struct_spec.rb +0 -13
  669. data/spec/ffi/spec_helper.rb +0 -21
  670. data/spec/ffi/string_spec.rb +0 -103
  671. data/spec/ffi/strptr_spec.rb +0 -36
  672. data/spec/ffi/struct_callback_spec.rb +0 -64
  673. data/spec/ffi/struct_initialize_spec.rb +0 -30
  674. data/spec/ffi/struct_packed_spec.rb +0 -46
  675. data/spec/ffi/struct_spec.rb +0 -638
  676. data/spec/ffi/typedef_spec.rb +0 -62
  677. data/spec/ffi/union_spec.rb +0 -60
  678. data/spec/ffi/variadic_spec.rb +0 -84
  679. data/spec/spec.opts +0 -4
  680. data/tasks/ann.rake +0 -80
  681. data/tasks/extension.rake +0 -25
  682. data/tasks/gem.rake +0 -200
  683. data/tasks/git.rake +0 -41
  684. data/tasks/notes.rake +0 -27
  685. data/tasks/post_load.rake +0 -34
  686. data/tasks/rdoc.rake +0 -50
  687. data/tasks/rubyforge.rake +0 -55
  688. data/tasks/setup.rb +0 -301
  689. data/tasks/spec.rake +0 -54
  690. data/tasks/svn.rake +0 -47
  691. data/tasks/test.rake +0 -40
  692. /data/ext/ffi_c/libffi/testsuite/libffi.call/{pyobjc-tc.c → pyobjc_tc.c} +0 -0
  693. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  694. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
@@ -1,5 +1,7 @@
1
1
  /* -----------------------------------------------------------------------
2
- sysv.S - Copyright (c) 1996, 1998, 2001-2003, 2005, 2008 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,430 +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
- movl %esp,%eax
52
-
53
- /* Place all of the ffi_prep_args in position */
54
- pushl 12(%ebp)
55
- pushl %eax
56
- call *8(%ebp)
57
-
58
- /* Return stack to previous state and call the function */
59
- addl $8,%esp
60
-
61
- call *28(%ebp)
62
-
63
- /* Load %ecx with the return type code */
64
- movl 20(%ebp),%ecx
65
-
66
- /* Protect %esi. We're going to pop it in the epilogue. */
67
- pushl %esi
68
-
69
- /* If the return value pointer is NULL, assume no return value. */
70
- cmpl $0,24(%ebp)
71
- jne 0f
72
-
73
- /* Even if there is no space for the return value, we are
74
- obliged to handle floating-point values. */
75
- cmpl $FFI_TYPE_FLOAT,%ecx
76
- jne noretval
77
- fstp %st(0)
78
-
79
- jmp epilogue
80
-
81
- 0:
82
- call 1f
83
-
84
- .Lstore_table:
85
- .long noretval-.Lstore_table /* FFI_TYPE_VOID */
86
- .long retint-.Lstore_table /* FFI_TYPE_INT */
87
- .long retfloat-.Lstore_table /* FFI_TYPE_FLOAT */
88
- .long retdouble-.Lstore_table /* FFI_TYPE_DOUBLE */
89
- .long retlongdouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
90
- .long retuint8-.Lstore_table /* FFI_TYPE_UINT8 */
91
- .long retsint8-.Lstore_table /* FFI_TYPE_SINT8 */
92
- .long retuint16-.Lstore_table /* FFI_TYPE_UINT16 */
93
- .long retsint16-.Lstore_table /* FFI_TYPE_SINT16 */
94
- .long retint-.Lstore_table /* FFI_TYPE_UINT32 */
95
- .long retint-.Lstore_table /* FFI_TYPE_SINT32 */
96
- .long retint64-.Lstore_table /* FFI_TYPE_UINT64 */
97
- .long retint64-.Lstore_table /* FFI_TYPE_SINT64 */
98
- .long retstruct-.Lstore_table /* FFI_TYPE_STRUCT */
99
- .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
100
44
 
101
- 1:
102
- pop %esi
103
- add (%esi, %ecx, 4), %esi
104
- jmp *%esi
45
+ #ifdef X86_DARWIN
46
+ # define L(X) C1(L, X)
47
+ #else
48
+ # define L(X) C1(.L, X)
49
+ #endif
105
50
 
106
- /* Sign/zero extend as appropriate. */
107
- retsint8:
108
- movsbl %al, %eax
109
- jmp retint
51
+ #ifdef __ELF__
52
+ # define ENDF(X) .type X,@function; .size X, . - X
53
+ #else
54
+ # define ENDF(X)
55
+ #endif
110
56
 
111
- retsint16:
112
- movswl %ax, %eax
113
- 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
114
65
 
115
- retuint8:
116
- movzbl %al, %eax
117
- 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
118
75
 
119
- retuint16:
120
- movzwl %ax, %eax
121
- jmp retint
122
-
123
- retfloat:
124
- /* Load %ecx with the pointer to storage for the return value */
125
- movl 24(%ebp),%ecx
126
- fstps (%ecx)
127
- jmp epilogue
128
-
129
- retdouble:
130
- /* Load %ecx with the pointer to storage for the return value */
131
- movl 24(%ebp),%ecx
132
- fstpl (%ecx)
133
- jmp epilogue
134
-
135
- retlongdouble:
136
- /* Load %ecx with the pointer to storage for the return value */
137
- movl 24(%ebp),%ecx
138
- fstpt (%ecx)
139
- jmp epilogue
140
-
141
- retint64:
142
- /* Load %ecx with the pointer to storage for the return value */
143
- movl 24(%ebp),%ecx
144
- movl %eax,0(%ecx)
145
- movl %edx,4(%ecx)
146
- jmp epilogue
147
-
148
- retint:
149
- /* Load %ecx with the pointer to storage for the return value */
150
- movl 24(%ebp),%ecx
151
- movl %eax,0(%ecx)
152
-
153
- retstruct:
154
- /* Nothing to do! */
155
-
156
- noretval:
157
- epilogue:
158
- popl %esi
159
- movl %ebp,%esp
160
- popl %ebp
161
- ret
162
- .LFE1:
163
- .ffi_call_SYSV_end:
164
- .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)
165
80
 
166
- .align 4
167
- FFI_HIDDEN (ffi_closure_SYSV)
168
- .globl ffi_closure_SYSV
169
- .type ffi_closure_SYSV, @function
170
-
171
- ffi_closure_SYSV:
172
- .LFB2:
173
- pushl %ebp
174
- .LCFI2:
175
- movl %esp, %ebp
176
- .LCFI3:
177
- subl $40, %esp
178
- leal -24(%ebp), %edx
179
- movl %edx, -12(%ebp) /* resp */
180
- leal 8(%ebp), %edx
181
- movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
182
- leal -12(%ebp), %edx
183
- movl %edx, (%esp) /* &resp */
184
- #if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__
185
- 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
186
133
  #else
187
- movl %ebx, 8(%esp)
188
- .LCFI7:
189
- call 1f
190
- 1: popl %ebx
191
- addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
192
- call ffi_closure_SYSV_inner@PLT
193
- movl 8(%esp), %ebx
134
+ leal L(store_table)(,%ecx, 8), %ebx
194
135
  #endif
195
- movl -12(%ebp), %ecx
196
- cmpl $FFI_TYPE_INT, %eax
197
- je .Lcls_retint
198
-
199
- /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
200
- FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
201
- cmpl $FFI_TYPE_UINT64, %eax
202
- jge 0f
203
- cmpl $FFI_TYPE_UINT8, %eax
204
- jge .Lcls_retint
205
-
206
- 0: cmpl $FFI_TYPE_FLOAT, %eax
207
- je .Lcls_retfloat
208
- cmpl $FFI_TYPE_DOUBLE, %eax
209
- je .Lcls_retdouble
210
- cmpl $FFI_TYPE_LONGDOUBLE, %eax
211
- je .Lcls_retldouble
212
- cmpl $FFI_TYPE_SINT64, %eax
213
- je .Lcls_retllong
214
- cmpl $FFI_TYPE_STRUCT, %eax
215
- je .Lcls_retstruct
216
- .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
217
175
  movl %ebp, %esp
218
176
  popl %ebp
177
+ L(UW3):
178
+ # cfi_remember_state
179
+ # cfi_def_cfa(%esp, 4)
180
+ # cfi_restore(%ebx)
181
+ # cfi_restore(%ebp)
219
182
  ret
220
- .Lcls_retint:
221
- movl (%ecx), %eax
222
- jmp .Lcls_epilogue
223
- .Lcls_retfloat:
224
- flds (%ecx)
225
- jmp .Lcls_epilogue
226
- .Lcls_retdouble:
227
- fldl (%ecx)
228
- jmp .Lcls_epilogue
229
- .Lcls_retldouble:
230
- fldt (%ecx)
231
- jmp .Lcls_epilogue
232
- .Lcls_retllong:
233
- movl (%ecx), %eax
234
- movl 4(%ecx), %edx
235
- jmp .Lcls_epilogue
236
- .Lcls_retstruct:
237
- movl %ebp, %esp
238
- popl %ebp
239
- ret $4
240
- .LFE2:
241
- .size ffi_closure_SYSV, .-ffi_closure_SYSV
183
+ L(UW4):
184
+ # cfi_restore_state
242
185
 
243
- #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
244
208
 
245
- /* Precalculate for e.g. the Solaris 10/x86 assembler. */
246
- #if FFI_TRAMPOLINE_SIZE == 10
247
- #define RAW_CLOSURE_CIF_OFFSET 12
248
- #define RAW_CLOSURE_FUN_OFFSET 16
249
- #define RAW_CLOSURE_USER_DATA_OFFSET 20
250
- #elif FFI_TRAMPOLINE_SIZE == 24
251
- #define RAW_CLOSURE_CIF_OFFSET 24
252
- #define RAW_CLOSURE_FUN_OFFSET 28
253
- #define RAW_CLOSURE_USER_DATA_OFFSET 32
209
+ void ffi_closure_inner(struct closure_frame *frame, char *argp)
210
+ __attribute_((fastcall))
211
+
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
254
223
  #else
255
- #define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
256
- #define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
257
- #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
224
+ # define closure_FS (8 + 40 + 12)
225
+ # define closure_CF 8
258
226
  #endif
259
- #define CIF_FLAGS_OFFSET 20
260
227
 
261
- .align 4
262
- FFI_HIDDEN (ffi_closure_raw_SYSV)
263
- .globl ffi_closure_raw_SYSV
264
- .type ffi_closure_raw_SYSV, @function
265
-
266
- ffi_closure_raw_SYSV:
267
- .LFB3:
268
- pushl %ebp
269
- .LCFI4:
270
- movl %esp, %ebp
271
- .LCFI5:
272
- pushl %esi
273
- .LCFI6:
274
- subl $36, %esp
275
- movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
276
- movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
277
- movl %edx, 12(%esp) /* user_data */
278
- leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
279
- movl %edx, 8(%esp) /* raw_args */
280
- leal -24(%ebp), %edx
281
- movl %edx, 4(%esp) /* &res */
282
- movl %esi, (%esp) /* cif */
283
- call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
284
- movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
285
- cmpl $FFI_TYPE_INT, %eax
286
- je .Lrcls_retint
287
-
288
- /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
289
- FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
290
- cmpl $FFI_TYPE_UINT64, %eax
291
- jge 0f
292
- cmpl $FFI_TYPE_UINT8, %eax
293
- jge .Lrcls_retint
294
- 0:
295
- cmpl $FFI_TYPE_FLOAT, %eax
296
- je .Lrcls_retfloat
297
- cmpl $FFI_TYPE_DOUBLE, %eax
298
- je .Lrcls_retdouble
299
- cmpl $FFI_TYPE_LONGDOUBLE, %eax
300
- je .Lrcls_retldouble
301
- cmpl $FFI_TYPE_SINT64, %eax
302
- je .Lrcls_retllong
303
- .Lrcls_epilogue:
304
- addl $36, %esp
305
- popl %esi
306
- popl %ebp
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)
251
+ #endif
252
+
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
272
+ # else
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)
307
395
  ret
308
- .Lrcls_retint:
309
- movl -24(%ebp), %eax
310
- jmp .Lrcls_epilogue
311
- .Lrcls_retfloat:
312
- flds -24(%ebp)
313
- jmp .Lrcls_epilogue
314
- .Lrcls_retdouble:
315
- fldl -24(%ebp)
316
- jmp .Lrcls_epilogue
317
- .Lrcls_retldouble:
318
- fldt -24(%ebp)
319
- jmp .Lrcls_epilogue
320
- .Lrcls_retllong:
321
- movl -24(%ebp), %eax
322
- movl -20(%ebp), %edx
323
- jmp .Lrcls_epilogue
324
- .LFE3:
325
- .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
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
636
+ #else
637
+ #define X86_DATA_OFFSET 4085
638
+ #define X86_CODE_OFFSET 4074
326
639
  #endif
327
640
 
328
- .section .eh_frame,EH_FRAME_FLAGS,@progbits
329
- .Lframe1:
330
- .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */
331
- .LSCIE1:
332
- .long 0x0 /* CIE Identifier Tag */
333
- .byte 0x1 /* CIE Version */
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
334
694
  #ifdef __PIC__
335
- .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
336
698
  #else
337
- .ascii "\0" /* CIE Augmentation */
699
+ leal L(load_table4)(,%eax, 8), %ecx
338
700
  #endif
339
- .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
340
- .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
341
- .byte 0x8 /* CIE RA Column */
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
342
811
  #ifdef __PIC__
343
- .byte 0x1 /* .uleb128 0x1; Augmentation size */
344
- .byte 0x1b /* FDE Encoding (pcrel sdata4) */
812
+ call C(__x86.get_pc_thunk.bx)
813
+ L(pc5):
814
+ leal L(load_table5)-L(pc5)(%ebx, %eax, 8), %ecx
815
+ #else
816
+ leal L(load_table5)(,%eax, 8), %ecx
345
817
  #endif
346
- .byte 0xc /* DW_CFA_def_cfa */
347
- .byte 0x4 /* .uleb128 0x4 */
348
- .byte 0x4 /* .uleb128 0x4 */
349
- .byte 0x88 /* DW_CFA_offset, column 0x8 */
350
- .byte 0x1 /* .uleb128 0x1 */
351
- .align 4
352
- .LECIE1:
353
- .LSFDE1:
354
- .long .LEFDE1-.LASFDE1 /* FDE Length */
355
- .LASFDE1:
356
- .long .LASFDE1-.Lframe1 /* FDE CIE offset */
357
- #if defined __PIC__ && defined HAVE_AS_X86_PCREL
358
- .long .LFB1-. /* FDE initial location */
359
- #elif defined __PIC__
360
- .long .LFB1@rel
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)
361
917
  #else
362
- .long .LFB1
918
+ # define COMDAT(X)
363
919
  #endif
364
- .long .LFE1-.LFB1 /* FDE address range */
365
- #ifdef __PIC__
366
- .byte 0x0 /* .uleb128 0x0; Augmentation size */
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
367
960
  #endif
368
- .byte 0x4 /* DW_CFA_advance_loc4 */
369
- .long .LCFI0-.LFB1
370
- .byte 0xe /* DW_CFA_def_cfa_offset */
371
- .byte 0x8 /* .uleb128 0x8 */
372
- .byte 0x85 /* DW_CFA_offset, column 0x5 */
373
- .byte 0x2 /* .uleb128 0x2 */
374
- .byte 0x4 /* DW_CFA_advance_loc4 */
375
- .long .LCFI1-.LCFI0
376
- .byte 0xd /* DW_CFA_def_cfa_register */
377
- .byte 0x5 /* .uleb128 0x5 */
378
- .align 4
379
- .LEFDE1:
380
- .LSFDE2:
381
- .long .LEFDE2-.LASFDE2 /* FDE Length */
382
- .LASFDE2:
383
- .long .LASFDE2-.Lframe1 /* FDE CIE offset */
384
- #if defined __PIC__ && defined HAVE_AS_X86_PCREL
385
- .long .LFB2-. /* FDE initial location */
386
- #elif defined __PIC__
387
- .long .LFB2@rel
961
+
962
+ #ifdef HAVE_AS_X86_PCREL
963
+ # define PCREL(X) X-.
388
964
  #else
389
- .long .LFB2
965
+ # define PCREL(X) X@rel
390
966
  #endif
391
- .long .LFE2-.LFB2 /* FDE address range */
392
- #ifdef __PIC__
393
- .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
394
977
  #endif
395
- .byte 0x4 /* DW_CFA_advance_loc4 */
396
- .long .LCFI2-.LFB2
397
- .byte 0xe /* DW_CFA_def_cfa_offset */
398
- .byte 0x8 /* .uleb128 0x8 */
399
- .byte 0x85 /* DW_CFA_offset, column 0x5 */
400
- .byte 0x2 /* .uleb128 0x2 */
401
- .byte 0x4 /* DW_CFA_advance_loc4 */
402
- .long .LCFI3-.LCFI2
403
- .byte 0xd /* DW_CFA_def_cfa_register */
404
- .byte 0x5 /* .uleb128 0x5 */
405
- #if !defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE && defined __PIC__
406
- .byte 0x4 /* DW_CFA_advance_loc4 */
407
- .long .LCFI7-.LCFI3
408
- .byte 0x83 /* DW_CFA_offset, column 0x3 */
409
- .byte 0xa /* .uleb128 0xa */
978
+ #ifndef __APPLE__
979
+ /* EH sections are already suitably aligned on Darwin. */
980
+ .balign 4
410
981
  #endif
411
- .align 4
412
- .LEFDE2:
413
982
 
414
- #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):
999
+
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):
415
1021
 
416
- .LSFDE3:
417
- .long .LEFDE3-.LASFDE3 /* FDE Length */
418
- .LASFDE3:
419
- .long .LASFDE3-.Lframe1 /* FDE CIE offset */
420
- #if defined __PIC__ && defined HAVE_AS_X86_PCREL
421
- .long .LFB3-. /* FDE initial location */
422
- #elif defined __PIC__
423
- .long .LFB3@rel
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)
424
1061
  #else
425
- .long .LFB3
1062
+ ADV(UW16, UW13)
426
1063
  #endif
427
- .long .LFE3-.LFB3 /* FDE address range */
428
- #ifdef __PIC__
429
- .byte 0x0 /* .uleb128 0x0; Augmentation size */
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 */
430
1114
  #endif
431
- .byte 0x4 /* DW_CFA_advance_loc4 */
432
- .long .LCFI4-.LFB3
433
- .byte 0xe /* DW_CFA_def_cfa_offset */
434
- .byte 0x8 /* .uleb128 0x8 */
435
- .byte 0x85 /* DW_CFA_offset, column 0x5 */
436
- .byte 0x2 /* .uleb128 0x2 */
437
- .byte 0x4 /* DW_CFA_advance_loc4 */
438
- .long .LCFI5-.LCFI4
439
- .byte 0xd /* DW_CFA_def_cfa_register */
440
- .byte 0x5 /* .uleb128 0x5 */
441
- .byte 0x4 /* DW_CFA_advance_loc4 */
442
- .long .LCFI6-.LCFI5
443
- .byte 0x86 /* DW_CFA_offset, column 0x6 */
444
- .byte 0x3 /* .uleb128 0x3 */
445
- .align 4
446
- .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):
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 */
447
1174
 
1175
+ #ifdef _WIN32
1176
+ .def @feat.00;
1177
+ .scl 3;
1178
+ .type 0;
1179
+ .endef
1180
+ .globl @feat.00
1181
+ @feat.00 = 1
448
1182
  #endif
449
1183
 
450
- #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__ */
451
1269
 
452
1270
  #if defined __ELF__ && defined __linux__
453
1271
  .section .note.GNU-stack,"",@progbits