ffi 1.10.0

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 (530) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +43 -0
  5. data/.yardopts +5 -0
  6. data/CHANGELOG.md +98 -0
  7. data/COPYING +49 -0
  8. data/Gemfile +15 -0
  9. data/LICENSE +24 -0
  10. data/LICENSE.SPECS +22 -0
  11. data/README.md +112 -0
  12. data/Rakefile +268 -0
  13. data/appveyor.yml +22 -0
  14. data/ext/ffi_c/AbstractMemory.c +1109 -0
  15. data/ext/ffi_c/AbstractMemory.h +175 -0
  16. data/ext/ffi_c/ArrayType.c +162 -0
  17. data/ext/ffi_c/ArrayType.h +59 -0
  18. data/ext/ffi_c/Buffer.c +365 -0
  19. data/ext/ffi_c/Call.c +520 -0
  20. data/ext/ffi_c/Call.h +110 -0
  21. data/ext/ffi_c/ClosurePool.c +283 -0
  22. data/ext/ffi_c/ClosurePool.h +57 -0
  23. data/ext/ffi_c/DataConverter.c +91 -0
  24. data/ext/ffi_c/DynamicLibrary.c +339 -0
  25. data/ext/ffi_c/DynamicLibrary.h +98 -0
  26. data/ext/ffi_c/Function.c +1001 -0
  27. data/ext/ffi_c/Function.h +87 -0
  28. data/ext/ffi_c/FunctionInfo.c +271 -0
  29. data/ext/ffi_c/LastError.c +229 -0
  30. data/ext/ffi_c/LastError.h +47 -0
  31. data/ext/ffi_c/LongDouble.c +63 -0
  32. data/ext/ffi_c/LongDouble.h +51 -0
  33. data/ext/ffi_c/MappedType.c +168 -0
  34. data/ext/ffi_c/MappedType.h +59 -0
  35. data/ext/ffi_c/MemoryPointer.c +197 -0
  36. data/ext/ffi_c/MemoryPointer.h +53 -0
  37. data/ext/ffi_c/MethodHandle.c +358 -0
  38. data/ext/ffi_c/MethodHandle.h +55 -0
  39. data/ext/ffi_c/Platform.c +129 -0
  40. data/ext/ffi_c/Platform.h +45 -0
  41. data/ext/ffi_c/Pointer.c +508 -0
  42. data/ext/ffi_c/Pointer.h +63 -0
  43. data/ext/ffi_c/Struct.c +829 -0
  44. data/ext/ffi_c/Struct.h +106 -0
  45. data/ext/ffi_c/StructByReference.c +190 -0
  46. data/ext/ffi_c/StructByReference.h +50 -0
  47. data/ext/ffi_c/StructByValue.c +150 -0
  48. data/ext/ffi_c/StructByValue.h +55 -0
  49. data/ext/ffi_c/StructLayout.c +698 -0
  50. data/ext/ffi_c/Thread.c +353 -0
  51. data/ext/ffi_c/Thread.h +95 -0
  52. data/ext/ffi_c/Type.c +397 -0
  53. data/ext/ffi_c/Type.h +62 -0
  54. data/ext/ffi_c/Types.c +139 -0
  55. data/ext/ffi_c/Types.h +89 -0
  56. data/ext/ffi_c/Variadic.c +304 -0
  57. data/ext/ffi_c/compat.h +78 -0
  58. data/ext/ffi_c/extconf.rb +72 -0
  59. data/ext/ffi_c/ffi.c +98 -0
  60. data/ext/ffi_c/libffi.bsd.mk +40 -0
  61. data/ext/ffi_c/libffi.darwin.mk +105 -0
  62. data/ext/ffi_c/libffi.gnu.mk +32 -0
  63. data/ext/ffi_c/libffi.mk +18 -0
  64. data/ext/ffi_c/libffi.vc.mk +26 -0
  65. data/ext/ffi_c/libffi.vc64.mk +26 -0
  66. data/ext/ffi_c/libffi/.appveyor.yml +50 -0
  67. data/ext/ffi_c/libffi/.github/issue_template.md +10 -0
  68. data/ext/ffi_c/libffi/.gitignore +38 -0
  69. data/ext/ffi_c/libffi/.travis.yml +34 -0
  70. data/ext/ffi_c/libffi/.travis/ar-lib +270 -0
  71. data/ext/ffi_c/libffi/.travis/build.sh +34 -0
  72. data/ext/ffi_c/libffi/.travis/compile +351 -0
  73. data/ext/ffi_c/libffi/.travis/install.sh +22 -0
  74. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +60 -0
  75. data/ext/ffi_c/libffi/.travis/site.exp +18 -0
  76. data/ext/ffi_c/libffi/ChangeLog.libffi +584 -0
  77. data/ext/ffi_c/libffi/ChangeLog.libffi-3.1 +6000 -0
  78. data/ext/ffi_c/libffi/ChangeLog.libgcj +40 -0
  79. data/ext/ffi_c/libffi/ChangeLog.v1 +764 -0
  80. data/ext/ffi_c/libffi/LICENSE +21 -0
  81. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +352 -0
  82. data/ext/ffi_c/libffi/Makefile.am +166 -0
  83. data/ext/ffi_c/libffi/README.md +461 -0
  84. data/ext/ffi_c/libffi/acinclude.m4 +479 -0
  85. data/ext/ffi_c/libffi/autogen.sh +2 -0
  86. data/ext/ffi_c/libffi/config.guess +1466 -0
  87. data/ext/ffi_c/libffi/config.sub +1836 -0
  88. data/ext/ffi_c/libffi/configure.ac +390 -0
  89. data/ext/ffi_c/libffi/configure.host +289 -0
  90. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +203 -0
  91. data/ext/ffi_c/libffi/include/Makefile.am +9 -0
  92. data/ext/ffi_c/libffi/include/ffi.h.in +511 -0
  93. data/ext/ffi_c/libffi/include/ffi_cfi.h +55 -0
  94. data/ext/ffi_c/libffi/include/ffi_common.h +149 -0
  95. data/ext/ffi_c/libffi/libffi.map.in +80 -0
  96. data/ext/ffi_c/libffi/libffi.pc.in +11 -0
  97. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +1043 -0
  98. data/ext/ffi_c/libffi/libtool-version +29 -0
  99. data/ext/ffi_c/libffi/m4/asmcfi.m4 +13 -0
  100. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +71 -0
  101. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +194 -0
  102. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +122 -0
  103. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +74 -0
  104. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +87 -0
  105. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +70 -0
  106. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +302 -0
  107. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +263 -0
  108. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +89 -0
  109. data/ext/ffi_c/libffi/m4/ax_require_defined.m4 +37 -0
  110. data/ext/ffi_c/libffi/man/Makefile.am +8 -0
  111. data/ext/ffi_c/libffi/man/ffi.3 +41 -0
  112. data/ext/ffi_c/libffi/man/ffi_call.3 +103 -0
  113. data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +68 -0
  114. data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +73 -0
  115. data/ext/ffi_c/libffi/msvcc.sh +328 -0
  116. data/ext/ffi_c/libffi/src/aarch64/ffi.c +941 -0
  117. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +81 -0
  118. data/ext/ffi_c/libffi/src/aarch64/internal.h +67 -0
  119. data/ext/ffi_c/libffi/src/aarch64/sysv.S +438 -0
  120. data/ext/ffi_c/libffi/src/alpha/ffi.c +521 -0
  121. data/ext/ffi_c/libffi/src/alpha/ffitarget.h +57 -0
  122. data/ext/ffi_c/libffi/src/alpha/internal.h +23 -0
  123. data/ext/ffi_c/libffi/src/alpha/osf.S +282 -0
  124. data/ext/ffi_c/libffi/src/arc/arcompact.S +135 -0
  125. data/ext/ffi_c/libffi/src/arc/ffi.c +266 -0
  126. data/ext/ffi_c/libffi/src/arc/ffitarget.h +53 -0
  127. data/ext/ffi_c/libffi/src/arm/ffi.c +819 -0
  128. data/ext/ffi_c/libffi/src/arm/ffitarget.h +82 -0
  129. data/ext/ffi_c/libffi/src/arm/internal.h +7 -0
  130. data/ext/ffi_c/libffi/src/arm/sysv.S +383 -0
  131. data/ext/ffi_c/libffi/src/avr32/ffi.c +423 -0
  132. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +55 -0
  133. data/ext/ffi_c/libffi/src/avr32/sysv.S +208 -0
  134. data/ext/ffi_c/libffi/src/bfin/ffi.c +196 -0
  135. data/ext/ffi_c/libffi/src/bfin/ffitarget.h +43 -0
  136. data/ext/ffi_c/libffi/src/bfin/sysv.S +179 -0
  137. data/ext/ffi_c/libffi/src/closures.c +966 -0
  138. data/ext/ffi_c/libffi/src/cris/ffi.c +386 -0
  139. data/ext/ffi_c/libffi/src/cris/ffitarget.h +56 -0
  140. data/ext/ffi_c/libffi/src/cris/sysv.S +215 -0
  141. data/ext/ffi_c/libffi/src/debug.c +64 -0
  142. data/ext/ffi_c/libffi/src/dlmalloc.c +5166 -0
  143. data/ext/ffi_c/libffi/src/frv/eabi.S +128 -0
  144. data/ext/ffi_c/libffi/src/frv/ffi.c +292 -0
  145. data/ext/ffi_c/libffi/src/frv/ffitarget.h +62 -0
  146. data/ext/ffi_c/libffi/src/ia64/ffi.c +604 -0
  147. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +56 -0
  148. data/ext/ffi_c/libffi/src/ia64/ia64_flags.h +40 -0
  149. data/ext/ffi_c/libffi/src/ia64/unix.S +567 -0
  150. data/ext/ffi_c/libffi/src/java_raw_api.c +374 -0
  151. data/ext/ffi_c/libffi/src/m32r/ffi.c +232 -0
  152. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +53 -0
  153. data/ext/ffi_c/libffi/src/m32r/sysv.S +121 -0
  154. data/ext/ffi_c/libffi/src/m68k/ffi.c +362 -0
  155. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +54 -0
  156. data/ext/ffi_c/libffi/src/m68k/sysv.S +357 -0
  157. data/ext/ffi_c/libffi/src/m88k/ffi.c +400 -0
  158. data/ext/ffi_c/libffi/src/m88k/ffitarget.h +49 -0
  159. data/ext/ffi_c/libffi/src/m88k/obsd.S +209 -0
  160. data/ext/ffi_c/libffi/src/metag/ffi.c +330 -0
  161. data/ext/ffi_c/libffi/src/metag/ffitarget.h +53 -0
  162. data/ext/ffi_c/libffi/src/metag/sysv.S +311 -0
  163. data/ext/ffi_c/libffi/src/microblaze/ffi.c +321 -0
  164. data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +53 -0
  165. data/ext/ffi_c/libffi/src/microblaze/sysv.S +302 -0
  166. data/ext/ffi_c/libffi/src/mips/ffi.c +1130 -0
  167. data/ext/ffi_c/libffi/src/mips/ffitarget.h +244 -0
  168. data/ext/ffi_c/libffi/src/mips/n32.S +663 -0
  169. data/ext/ffi_c/libffi/src/mips/o32.S +502 -0
  170. data/ext/ffi_c/libffi/src/moxie/eabi.S +101 -0
  171. data/ext/ffi_c/libffi/src/moxie/ffi.c +285 -0
  172. data/ext/ffi_c/libffi/src/moxie/ffitarget.h +52 -0
  173. data/ext/ffi_c/libffi/src/nios2/ffi.c +304 -0
  174. data/ext/ffi_c/libffi/src/nios2/ffitarget.h +52 -0
  175. data/ext/ffi_c/libffi/src/nios2/sysv.S +136 -0
  176. data/ext/ffi_c/libffi/src/or1k/ffi.c +328 -0
  177. data/ext/ffi_c/libffi/src/or1k/ffitarget.h +58 -0
  178. data/ext/ffi_c/libffi/src/or1k/sysv.S +107 -0
  179. data/ext/ffi_c/libffi/src/pa/ffi.c +719 -0
  180. data/ext/ffi_c/libffi/src/pa/ffitarget.h +85 -0
  181. data/ext/ffi_c/libffi/src/pa/hpux32.S +368 -0
  182. data/ext/ffi_c/libffi/src/pa/linux.S +357 -0
  183. data/ext/ffi_c/libffi/src/powerpc/aix.S +566 -0
  184. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +694 -0
  185. data/ext/ffi_c/libffi/src/powerpc/asm.h +125 -0
  186. data/ext/ffi_c/libffi/src/powerpc/darwin.S +378 -0
  187. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +571 -0
  188. data/ext/ffi_c/libffi/src/powerpc/ffi.c +173 -0
  189. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +1440 -0
  190. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +974 -0
  191. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +94 -0
  192. data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +923 -0
  193. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +198 -0
  194. data/ext/ffi_c/libffi/src/powerpc/linux64.S +228 -0
  195. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +488 -0
  196. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +397 -0
  197. data/ext/ffi_c/libffi/src/powerpc/sysv.S +175 -0
  198. data/ext/ffi_c/libffi/src/prep_cif.c +261 -0
  199. data/ext/ffi_c/libffi/src/raw_api.c +267 -0
  200. data/ext/ffi_c/libffi/src/riscv/ffi.c +445 -0
  201. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +68 -0
  202. data/ext/ffi_c/libffi/src/riscv/sysv.S +214 -0
  203. data/ext/ffi_c/libffi/src/s390/ffi.c +756 -0
  204. data/ext/ffi_c/libffi/src/s390/ffitarget.h +70 -0
  205. data/ext/ffi_c/libffi/src/s390/internal.h +11 -0
  206. data/ext/ffi_c/libffi/src/s390/sysv.S +325 -0
  207. data/ext/ffi_c/libffi/src/sh/ffi.c +717 -0
  208. data/ext/ffi_c/libffi/src/sh/ffitarget.h +54 -0
  209. data/ext/ffi_c/libffi/src/sh/sysv.S +850 -0
  210. data/ext/ffi_c/libffi/src/sh64/ffi.c +469 -0
  211. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +58 -0
  212. data/ext/ffi_c/libffi/src/sh64/sysv.S +539 -0
  213. data/ext/ffi_c/libffi/src/sparc/ffi.c +468 -0
  214. data/ext/ffi_c/libffi/src/sparc/ffi64.c +608 -0
  215. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +81 -0
  216. data/ext/ffi_c/libffi/src/sparc/internal.h +26 -0
  217. data/ext/ffi_c/libffi/src/sparc/v8.S +443 -0
  218. data/ext/ffi_c/libffi/src/sparc/v9.S +440 -0
  219. data/ext/ffi_c/libffi/src/tile/ffi.c +355 -0
  220. data/ext/ffi_c/libffi/src/tile/ffitarget.h +65 -0
  221. data/ext/ffi_c/libffi/src/tile/tile.S +360 -0
  222. data/ext/ffi_c/libffi/src/types.c +108 -0
  223. data/ext/ffi_c/libffi/src/vax/elfbsd.S +195 -0
  224. data/ext/ffi_c/libffi/src/vax/ffi.c +276 -0
  225. data/ext/ffi_c/libffi/src/vax/ffitarget.h +49 -0
  226. data/ext/ffi_c/libffi/src/x86/asmnames.h +30 -0
  227. data/ext/ffi_c/libffi/src/x86/ffi.c +753 -0
  228. data/ext/ffi_c/libffi/src/x86/ffi64.c +884 -0
  229. data/ext/ffi_c/libffi/src/x86/ffitarget.h +147 -0
  230. data/ext/ffi_c/libffi/src/x86/ffiw64.c +308 -0
  231. data/ext/ffi_c/libffi/src/x86/internal.h +29 -0
  232. data/ext/ffi_c/libffi/src/x86/internal64.h +22 -0
  233. data/ext/ffi_c/libffi/src/x86/sysv.S +1043 -0
  234. data/ext/ffi_c/libffi/src/x86/unix64.S +525 -0
  235. data/ext/ffi_c/libffi/src/x86/win64.S +232 -0
  236. data/ext/ffi_c/libffi/src/x86/win64_intel.S +237 -0
  237. data/ext/ffi_c/libffi/src/xtensa/ffi.c +298 -0
  238. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +53 -0
  239. data/ext/ffi_c/libffi/src/xtensa/sysv.S +258 -0
  240. data/ext/ffi_c/libffi/stamp-h.in +1 -0
  241. data/ext/ffi_c/libffi/testsuite/Makefile.am +117 -0
  242. data/ext/ffi_c/libffi/testsuite/config/default.exp +1 -0
  243. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +636 -0
  244. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +283 -0
  245. data/ext/ffi_c/libffi/testsuite/lib/wrapper.exp +45 -0
  246. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/Makefile +28 -0
  247. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/README +78 -0
  248. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/alignof.h +50 -0
  249. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +58 -0
  250. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +1745 -0
  251. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2885 -0
  252. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/testcases.c +743 -0
  253. data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +46 -0
  254. data/ext/ffi_c/libffi/testsuite/libffi.call/align_stdcall.c +46 -0
  255. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +43 -0
  256. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +89 -0
  257. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +81 -0
  258. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +81 -0
  259. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +82 -0
  260. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +89 -0
  261. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +92 -0
  262. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +90 -0
  263. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c +95 -0
  264. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_simple.c +55 -0
  265. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +94 -0
  266. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +95 -0
  267. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +96 -0
  268. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +102 -0
  269. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +89 -0
  270. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +91 -0
  271. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +93 -0
  272. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +113 -0
  273. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +90 -0
  274. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +95 -0
  275. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +90 -0
  276. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +90 -0
  277. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3float.c +95 -0
  278. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +98 -0
  279. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +90 -0
  280. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +109 -0
  281. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +98 -0
  282. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +124 -0
  283. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +113 -0
  284. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +99 -0
  285. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +117 -0
  286. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +97 -0
  287. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +88 -0
  288. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +90 -0
  289. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +91 -0
  290. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +93 -0
  291. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +91 -0
  292. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +92 -0
  293. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +132 -0
  294. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +115 -0
  295. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +95 -0
  296. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +91 -0
  297. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +91 -0
  298. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +92 -0
  299. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +91 -0
  300. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +91 -0
  301. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +93 -0
  302. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +66 -0
  303. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +43 -0
  304. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +61 -0
  305. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +42 -0
  306. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +105 -0
  307. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +61 -0
  308. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_many_mixed_args.c +70 -0
  309. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c +55 -0
  310. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +74 -0
  311. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +74 -0
  312. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +86 -0
  313. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +91 -0
  314. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +74 -0
  315. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +86 -0
  316. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +74 -0
  317. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +142 -0
  318. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +44 -0
  319. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +42 -0
  320. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +42 -0
  321. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_struct_va1.c +114 -0
  322. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +42 -0
  323. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar_va.c +44 -0
  324. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +43 -0
  325. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint_va.c +45 -0
  326. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulong_va.c +45 -0
  327. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +47 -0
  328. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +43 -0
  329. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort_va.c +44 -0
  330. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +36 -0
  331. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +26 -0
  332. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +138 -0
  333. data/ext/ffi_c/libffi/testsuite/libffi.call/float.c +59 -0
  334. data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +60 -0
  335. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +60 -0
  336. data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +74 -0
  337. data/ext/ffi_c/libffi/testsuite/libffi.call/float4.c +62 -0
  338. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +107 -0
  339. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +341 -0
  340. data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +59 -0
  341. data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +57 -0
  342. data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +70 -0
  343. data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +78 -0
  344. data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +52 -0
  345. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +152 -0
  346. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +161 -0
  347. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +134 -0
  348. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct11.c +121 -0
  349. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +110 -0
  350. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +111 -0
  351. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +111 -0
  352. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +112 -0
  353. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +131 -0
  354. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +111 -0
  355. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +131 -0
  356. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +131 -0
  357. data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +46 -0
  358. data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +127 -0
  359. data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +90 -0
  360. data/ext/ffi_c/libffi/testsuite/libffi.call/promotion.c +59 -0
  361. data/ext/ffi_c/libffi/testsuite/libffi.call/pyobjc-tc.c +114 -0
  362. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +36 -0
  363. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl1.c +43 -0
  364. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl2.c +42 -0
  365. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl.c +35 -0
  366. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl1.c +36 -0
  367. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl2.c +49 -0
  368. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl3.c +42 -0
  369. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +34 -0
  370. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll.c +41 -0
  371. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +43 -0
  372. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +36 -0
  373. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +38 -0
  374. data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +38 -0
  375. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +38 -0
  376. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +145 -0
  377. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +148 -0
  378. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +124 -0
  379. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +125 -0
  380. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +44 -0
  381. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +49 -0
  382. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +49 -0
  383. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +55 -0
  384. data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +67 -0
  385. data/ext/ffi_c/libffi/testsuite/libffi.call/struct10.c +57 -0
  386. data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +67 -0
  387. data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +60 -0
  388. data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +64 -0
  389. data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +66 -0
  390. data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +64 -0
  391. data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +74 -0
  392. data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +81 -0
  393. data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +68 -0
  394. data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +70 -0
  395. data/ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c +61 -0
  396. data/ext/ffi_c/libffi/testsuite/libffi.call/unwindtest.cc +117 -0
  397. data/ext/ffi_c/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc +54 -0
  398. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +196 -0
  399. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +121 -0
  400. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +123 -0
  401. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +125 -0
  402. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc +91 -0
  403. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c +10 -0
  404. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c +10 -0
  405. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +10 -0
  406. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc +42 -0
  407. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c +10 -0
  408. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c +10 -0
  409. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +10 -0
  410. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc +71 -0
  411. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +10 -0
  412. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +10 -0
  413. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +10 -0
  414. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc +80 -0
  415. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c +10 -0
  416. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c +16 -0
  417. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +10 -0
  418. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.exp +36 -0
  419. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +51 -0
  420. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +7 -0
  421. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +7 -0
  422. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +7 -0
  423. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +10 -0
  424. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +10 -0
  425. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +86 -0
  426. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +10 -0
  427. data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +1 -0
  428. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +78 -0
  429. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +10 -0
  430. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +10 -0
  431. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +10 -0
  432. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +37 -0
  433. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +41 -0
  434. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +10 -0
  435. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +10 -0
  436. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +10 -0
  437. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +44 -0
  438. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +10 -0
  439. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +10 -0
  440. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +10 -0
  441. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +10 -0
  442. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +10 -0
  443. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +10 -0
  444. data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +34 -0
  445. data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +28 -0
  446. data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +1 -0
  447. data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +36 -0
  448. data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +19 -0
  449. data/ext/ffi_c/rbffi.h +57 -0
  450. data/ext/ffi_c/rbffi_endian.h +59 -0
  451. data/ext/ffi_c/win32/stdbool.h +8 -0
  452. data/ext/ffi_c/win32/stdint.h +201 -0
  453. data/ffi.gemspec +36 -0
  454. data/lib/ffi.rb +20 -0
  455. data/lib/ffi/autopointer.rb +203 -0
  456. data/lib/ffi/buffer.rb +4 -0
  457. data/lib/ffi/callback.rb +4 -0
  458. data/lib/ffi/enum.rb +296 -0
  459. data/lib/ffi/errno.rb +43 -0
  460. data/lib/ffi/ffi.rb +44 -0
  461. data/lib/ffi/io.rb +62 -0
  462. data/lib/ffi/library.rb +588 -0
  463. data/lib/ffi/managedstruct.rb +84 -0
  464. data/lib/ffi/memorypointer.rb +1 -0
  465. data/lib/ffi/platform.rb +170 -0
  466. data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
  467. data/lib/ffi/platform/aarch64-freebsd12/types.conf +128 -0
  468. data/lib/ffi/platform/aarch64-linux/types.conf +104 -0
  469. data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
  470. data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
  471. data/lib/ffi/platform/arm-linux/types.conf +104 -0
  472. data/lib/ffi/platform/i386-cygwin/types.conf +3 -0
  473. data/lib/ffi/platform/i386-darwin/types.conf +100 -0
  474. data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
  475. data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
  476. data/lib/ffi/platform/i386-gnu/types.conf +107 -0
  477. data/lib/ffi/platform/i386-linux/types.conf +103 -0
  478. data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
  479. data/lib/ffi/platform/i386-openbsd/types.conf +128 -0
  480. data/lib/ffi/platform/i386-solaris/types.conf +122 -0
  481. data/lib/ffi/platform/i386-windows/types.conf +105 -0
  482. data/lib/ffi/platform/ia64-linux/types.conf +104 -0
  483. data/lib/ffi/platform/mips-linux/types.conf +102 -0
  484. data/lib/ffi/platform/mips64-linux/types.conf +104 -0
  485. data/lib/ffi/platform/mips64el-linux/types.conf +104 -0
  486. data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
  487. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +102 -0
  488. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +102 -0
  489. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +104 -0
  490. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +104 -0
  491. data/lib/ffi/platform/powerpc-aix/types.conf +180 -0
  492. data/lib/ffi/platform/powerpc-darwin/types.conf +100 -0
  493. data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
  494. data/lib/ffi/platform/powerpc64-linux/types.conf +104 -0
  495. data/lib/ffi/platform/s390-linux/types.conf +102 -0
  496. data/lib/ffi/platform/s390x-linux/types.conf +102 -0
  497. data/lib/ffi/platform/sparc-linux/types.conf +102 -0
  498. data/lib/ffi/platform/sparc-solaris/types.conf +128 -0
  499. data/lib/ffi/platform/sparc64-linux/types.conf +102 -0
  500. data/lib/ffi/platform/sparcv9-solaris/types.conf +128 -0
  501. data/lib/ffi/platform/x86_64-cygwin/types.conf +3 -0
  502. data/lib/ffi/platform/x86_64-darwin/types.conf +126 -0
  503. data/lib/ffi/platform/x86_64-freebsd/types.conf +128 -0
  504. data/lib/ffi/platform/x86_64-freebsd12/types.conf +128 -0
  505. data/lib/ffi/platform/x86_64-linux/types.conf +102 -0
  506. data/lib/ffi/platform/x86_64-netbsd/types.conf +128 -0
  507. data/lib/ffi/platform/x86_64-openbsd/types.conf +134 -0
  508. data/lib/ffi/platform/x86_64-solaris/types.conf +122 -0
  509. data/lib/ffi/platform/x86_64-windows/types.conf +120 -0
  510. data/lib/ffi/pointer.rb +160 -0
  511. data/lib/ffi/struct.rb +371 -0
  512. data/lib/ffi/struct_layout_builder.rb +227 -0
  513. data/lib/ffi/tools/const_generator.rb +229 -0
  514. data/lib/ffi/tools/generator.rb +60 -0
  515. data/lib/ffi/tools/generator_task.rb +36 -0
  516. data/lib/ffi/tools/struct_generator.rb +194 -0
  517. data/lib/ffi/tools/types_generator.rb +134 -0
  518. data/lib/ffi/types.rb +194 -0
  519. data/lib/ffi/union.rb +43 -0
  520. data/lib/ffi/variadic.rb +78 -0
  521. data/lib/ffi/version.rb +3 -0
  522. data/samples/getlogin.rb +8 -0
  523. data/samples/getpid.rb +8 -0
  524. data/samples/gettimeofday.rb +18 -0
  525. data/samples/hello.rb +7 -0
  526. data/samples/inotify.rb +60 -0
  527. data/samples/pty.rb +76 -0
  528. data/samples/qsort.rb +21 -0
  529. data/samples/sample_helper.rb +6 -0
  530. metadata +658 -0
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining
5
+ * a copy of this software and associated documentation files (the
6
+ * ``Software''), to deal in the Software without restriction, including
7
+ * without limitation the rights to use, copy, modify, merge, publish,
8
+ * distribute, sublicense, and/or sell copies of the Software, and to
9
+ * permit persons to whom the Software is furnished to do so, subject to
10
+ * the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included
13
+ * in all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
16
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ /*
25
+ * vax Foreign Function Interface
26
+ */
27
+
28
+ #ifndef LIBFFI_TARGET_H
29
+ #define LIBFFI_TARGET_H
30
+
31
+ #ifndef LIBFFI_ASM
32
+ typedef unsigned long ffi_arg;
33
+ typedef signed long ffi_sarg;
34
+
35
+ typedef enum ffi_abi {
36
+ FFI_FIRST_ABI = 0,
37
+ FFI_ELFBSD,
38
+ FFI_DEFAULT_ABI = FFI_ELFBSD,
39
+ FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
40
+ } ffi_abi;
41
+ #endif
42
+
43
+ /* ---- Definitions for closures ----------------------------------------- */
44
+
45
+ #define FFI_CLOSURES 1
46
+ #define FFI_TRAMPOLINE_SIZE 15
47
+ #define FFI_NATIVE_RAW_API 0
48
+
49
+ #endif
@@ -0,0 +1,30 @@
1
+ #ifndef ASMNAMES_H
2
+ #define ASMNAMES_H
3
+
4
+ #define C2(X, Y) X ## Y
5
+ #define C1(X, Y) C2(X, Y)
6
+ #ifdef __USER_LABEL_PREFIX__
7
+ # define C(X) C1(__USER_LABEL_PREFIX__, X)
8
+ #else
9
+ # define C(X) X
10
+ #endif
11
+
12
+ #ifdef __APPLE__
13
+ # define L(X) C1(L, X)
14
+ #else
15
+ # define L(X) C1(.L, X)
16
+ #endif
17
+
18
+ #if defined(__ELF__) && defined(__PIC__)
19
+ # define PLT(X) X@PLT
20
+ #else
21
+ # define PLT(X) X
22
+ #endif
23
+
24
+ #ifdef __ELF__
25
+ # define ENDF(X) .type X,@function; .size X, . - X
26
+ #else
27
+ # define ENDF(X)
28
+ #endif
29
+
30
+ #endif /* ASMNAMES_H */
@@ -0,0 +1,753 @@
1
+ /* -----------------------------------------------------------------------
2
+ ffi.c - Copyright (c) 2017 Anthony Green
3
+ Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc.
4
+ Copyright (c) 2002 Ranjit Mathew
5
+ Copyright (c) 2002 Bo Thorsen
6
+ Copyright (c) 2002 Roger Sayle
7
+ Copyright (C) 2008, 2010 Free Software Foundation, Inc.
8
+
9
+ x86 Foreign Function Interface
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining
12
+ a copy of this software and associated documentation files (the
13
+ ``Software''), to deal in the Software without restriction, including
14
+ without limitation the rights to use, copy, modify, merge, publish,
15
+ distribute, sublicense, and/or sell copies of the Software, and to
16
+ permit persons to whom the Software is furnished to do so, subject to
17
+ the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included
20
+ in all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
23
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29
+ DEALINGS IN THE SOFTWARE.
30
+ ----------------------------------------------------------------------- */
31
+
32
+ #ifndef __x86_64__
33
+ #include <ffi.h>
34
+ #include <ffi_common.h>
35
+ #include <stdint.h>
36
+ #include <stdlib.h>
37
+ #include "internal.h"
38
+
39
+ /* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
40
+ all further uses in this file will refer to the 80-bit type. */
41
+ #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
42
+ # if FFI_TYPE_LONGDOUBLE != 4
43
+ # error FFI_TYPE_LONGDOUBLE out of date
44
+ # endif
45
+ #else
46
+ # undef FFI_TYPE_LONGDOUBLE
47
+ # define FFI_TYPE_LONGDOUBLE 4
48
+ #endif
49
+
50
+ #if defined(__GNUC__) && !defined(__declspec)
51
+ # define __declspec(x) __attribute__((x))
52
+ #endif
53
+
54
+ /* Perform machine dependent cif processing. */
55
+ ffi_status FFI_HIDDEN
56
+ ffi_prep_cif_machdep(ffi_cif *cif)
57
+ {
58
+ size_t bytes = 0;
59
+ int i, n, flags, cabi = cif->abi;
60
+
61
+ switch (cabi)
62
+ {
63
+ case FFI_SYSV:
64
+ case FFI_STDCALL:
65
+ case FFI_THISCALL:
66
+ case FFI_FASTCALL:
67
+ case FFI_MS_CDECL:
68
+ case FFI_PASCAL:
69
+ case FFI_REGISTER:
70
+ break;
71
+ default:
72
+ return FFI_BAD_ABI;
73
+ }
74
+
75
+ switch (cif->rtype->type)
76
+ {
77
+ case FFI_TYPE_VOID:
78
+ flags = X86_RET_VOID;
79
+ break;
80
+ case FFI_TYPE_FLOAT:
81
+ flags = X86_RET_FLOAT;
82
+ break;
83
+ case FFI_TYPE_DOUBLE:
84
+ flags = X86_RET_DOUBLE;
85
+ break;
86
+ case FFI_TYPE_LONGDOUBLE:
87
+ flags = X86_RET_LDOUBLE;
88
+ break;
89
+ case FFI_TYPE_UINT8:
90
+ flags = X86_RET_UINT8;
91
+ break;
92
+ case FFI_TYPE_UINT16:
93
+ flags = X86_RET_UINT16;
94
+ break;
95
+ case FFI_TYPE_SINT8:
96
+ flags = X86_RET_SINT8;
97
+ break;
98
+ case FFI_TYPE_SINT16:
99
+ flags = X86_RET_SINT16;
100
+ break;
101
+ case FFI_TYPE_INT:
102
+ case FFI_TYPE_SINT32:
103
+ case FFI_TYPE_UINT32:
104
+ case FFI_TYPE_POINTER:
105
+ flags = X86_RET_INT32;
106
+ break;
107
+ case FFI_TYPE_SINT64:
108
+ case FFI_TYPE_UINT64:
109
+ flags = X86_RET_INT64;
110
+ break;
111
+ case FFI_TYPE_STRUCT:
112
+ #ifndef X86
113
+ /* ??? This should be a different ABI rather than an ifdef. */
114
+ if (cif->rtype->size == 1)
115
+ flags = X86_RET_STRUCT_1B;
116
+ else if (cif->rtype->size == 2)
117
+ flags = X86_RET_STRUCT_2B;
118
+ else if (cif->rtype->size == 4)
119
+ flags = X86_RET_INT32;
120
+ else if (cif->rtype->size == 8)
121
+ flags = X86_RET_INT64;
122
+ else
123
+ #endif
124
+ {
125
+ do_struct:
126
+ switch (cabi)
127
+ {
128
+ case FFI_THISCALL:
129
+ case FFI_FASTCALL:
130
+ case FFI_STDCALL:
131
+ case FFI_MS_CDECL:
132
+ flags = X86_RET_STRUCTARG;
133
+ break;
134
+ default:
135
+ flags = X86_RET_STRUCTPOP;
136
+ break;
137
+ }
138
+ /* Allocate space for return value pointer. */
139
+ bytes += FFI_ALIGN (sizeof(void*), FFI_SIZEOF_ARG);
140
+ }
141
+ break;
142
+ case FFI_TYPE_COMPLEX:
143
+ switch (cif->rtype->elements[0]->type)
144
+ {
145
+ case FFI_TYPE_DOUBLE:
146
+ case FFI_TYPE_LONGDOUBLE:
147
+ case FFI_TYPE_SINT64:
148
+ case FFI_TYPE_UINT64:
149
+ goto do_struct;
150
+ case FFI_TYPE_FLOAT:
151
+ case FFI_TYPE_INT:
152
+ case FFI_TYPE_SINT32:
153
+ case FFI_TYPE_UINT32:
154
+ flags = X86_RET_INT64;
155
+ break;
156
+ case FFI_TYPE_SINT16:
157
+ case FFI_TYPE_UINT16:
158
+ flags = X86_RET_INT32;
159
+ break;
160
+ case FFI_TYPE_SINT8:
161
+ case FFI_TYPE_UINT8:
162
+ flags = X86_RET_STRUCT_2B;
163
+ break;
164
+ default:
165
+ return FFI_BAD_TYPEDEF;
166
+ }
167
+ break;
168
+ default:
169
+ return FFI_BAD_TYPEDEF;
170
+ }
171
+ cif->flags = flags;
172
+
173
+ for (i = 0, n = cif->nargs; i < n; i++)
174
+ {
175
+ ffi_type *t = cif->arg_types[i];
176
+
177
+ bytes = FFI_ALIGN (bytes, t->alignment);
178
+ bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG);
179
+ }
180
+ cif->bytes = FFI_ALIGN (bytes, 16);
181
+
182
+ return FFI_OK;
183
+ }
184
+
185
+ static ffi_arg
186
+ extend_basic_type(void *arg, int type)
187
+ {
188
+ switch (type)
189
+ {
190
+ case FFI_TYPE_SINT8:
191
+ return *(SINT8 *)arg;
192
+ case FFI_TYPE_UINT8:
193
+ return *(UINT8 *)arg;
194
+ case FFI_TYPE_SINT16:
195
+ return *(SINT16 *)arg;
196
+ case FFI_TYPE_UINT16:
197
+ return *(UINT16 *)arg;
198
+
199
+ case FFI_TYPE_SINT32:
200
+ case FFI_TYPE_UINT32:
201
+ case FFI_TYPE_POINTER:
202
+ case FFI_TYPE_FLOAT:
203
+ return *(UINT32 *)arg;
204
+
205
+ default:
206
+ abort();
207
+ }
208
+ }
209
+
210
+ struct call_frame
211
+ {
212
+ void *ebp; /* 0 */
213
+ void *retaddr; /* 4 */
214
+ void (*fn)(void); /* 8 */
215
+ int flags; /* 12 */
216
+ void *rvalue; /* 16 */
217
+ unsigned regs[3]; /* 20-28 */
218
+ };
219
+
220
+ struct abi_params
221
+ {
222
+ int dir; /* parameter growth direction */
223
+ int static_chain; /* the static chain register used by gcc */
224
+ int nregs; /* number of register parameters */
225
+ int regs[3];
226
+ };
227
+
228
+ static const struct abi_params abi_params[FFI_LAST_ABI] = {
229
+ [FFI_SYSV] = { 1, R_ECX, 0 },
230
+ [FFI_THISCALL] = { 1, R_EAX, 1, { R_ECX } },
231
+ [FFI_FASTCALL] = { 1, R_EAX, 2, { R_ECX, R_EDX } },
232
+ [FFI_STDCALL] = { 1, R_ECX, 0 },
233
+ [FFI_PASCAL] = { -1, R_ECX, 0 },
234
+ /* ??? No defined static chain; gcc does not support REGISTER. */
235
+ [FFI_REGISTER] = { -1, R_ECX, 3, { R_EAX, R_EDX, R_ECX } },
236
+ [FFI_MS_CDECL] = { 1, R_ECX, 0 }
237
+ };
238
+
239
+ #ifdef HAVE_FASTCALL
240
+ #ifdef _MSC_VER
241
+ #define FFI_DECLARE_FASTCALL __fastcall
242
+ #else
243
+ #define FFI_DECLARE_FASTCALL __declspec(fastcall)
244
+ #endif
245
+ #else
246
+ #define FFI_DECLARE_FASTCALL
247
+ #endif
248
+
249
+ extern void FFI_DECLARE_FASTCALL ffi_call_i386(struct call_frame *, char *) FFI_HIDDEN;
250
+
251
+ static void
252
+ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
253
+ void **avalue, void *closure)
254
+ {
255
+ size_t rsize, bytes;
256
+ struct call_frame *frame;
257
+ char *stack, *argp;
258
+ ffi_type **arg_types;
259
+ int flags, cabi, i, n, dir, narg_reg;
260
+ const struct abi_params *pabi;
261
+
262
+ flags = cif->flags;
263
+ cabi = cif->abi;
264
+ pabi = &abi_params[cabi];
265
+ dir = pabi->dir;
266
+
267
+ rsize = 0;
268
+ if (rvalue == NULL)
269
+ {
270
+ switch (flags)
271
+ {
272
+ case X86_RET_FLOAT:
273
+ case X86_RET_DOUBLE:
274
+ case X86_RET_LDOUBLE:
275
+ case X86_RET_STRUCTPOP:
276
+ case X86_RET_STRUCTARG:
277
+ /* The float cases need to pop the 387 stack.
278
+ The struct cases need to pass a valid pointer to the callee. */
279
+ rsize = cif->rtype->size;
280
+ break;
281
+ default:
282
+ /* We can pretend that the callee returns nothing. */
283
+ flags = X86_RET_VOID;
284
+ break;
285
+ }
286
+ }
287
+
288
+ bytes = cif->bytes;
289
+ stack = alloca(bytes + sizeof(*frame) + rsize);
290
+ argp = (dir < 0 ? stack + bytes : stack);
291
+ frame = (struct call_frame *)(stack + bytes);
292
+ if (rsize)
293
+ rvalue = frame + 1;
294
+
295
+ frame->fn = fn;
296
+ frame->flags = flags;
297
+ frame->rvalue = rvalue;
298
+ frame->regs[pabi->static_chain] = (unsigned)closure;
299
+
300
+ narg_reg = 0;
301
+ switch (flags)
302
+ {
303
+ case X86_RET_STRUCTARG:
304
+ /* The pointer is passed as the first argument. */
305
+ if (pabi->nregs > 0)
306
+ {
307
+ frame->regs[pabi->regs[0]] = (unsigned)rvalue;
308
+ narg_reg = 1;
309
+ break;
310
+ }
311
+ /* fallthru */
312
+ case X86_RET_STRUCTPOP:
313
+ *(void **)argp = rvalue;
314
+ argp += sizeof(void *);
315
+ break;
316
+ }
317
+
318
+ arg_types = cif->arg_types;
319
+ for (i = 0, n = cif->nargs; i < n; i++)
320
+ {
321
+ ffi_type *ty = arg_types[i];
322
+ void *valp = avalue[i];
323
+ size_t z = ty->size;
324
+ int t = ty->type;
325
+
326
+ if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT)
327
+ {
328
+ ffi_arg val = extend_basic_type (valp, t);
329
+
330
+ if (t != FFI_TYPE_FLOAT && narg_reg < pabi->nregs)
331
+ frame->regs[pabi->regs[narg_reg++]] = val;
332
+ else if (dir < 0)
333
+ {
334
+ argp -= 4;
335
+ *(ffi_arg *)argp = val;
336
+ }
337
+ else
338
+ {
339
+ *(ffi_arg *)argp = val;
340
+ argp += 4;
341
+ }
342
+ }
343
+ else
344
+ {
345
+ size_t za = FFI_ALIGN (z, FFI_SIZEOF_ARG);
346
+ size_t align = FFI_SIZEOF_ARG;
347
+
348
+ /* Issue 434: For thiscall and fastcall, if the paramter passed
349
+ as 64-bit integer or struct, all following integer paramters
350
+ will be passed on stack. */
351
+ if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
352
+ && (t == FFI_TYPE_SINT64
353
+ || t == FFI_TYPE_UINT64
354
+ || t == FFI_TYPE_STRUCT))
355
+ narg_reg = 2;
356
+
357
+ /* Alignment rules for arguments are quite complex. Vectors and
358
+ structures with 16 byte alignment get it. Note that long double
359
+ on Darwin does have 16 byte alignment, and does not get this
360
+ alignment if passed directly; a structure with a long double
361
+ inside, however, would get 16 byte alignment. Since libffi does
362
+ not support vectors, we need non concern ourselves with other
363
+ cases. */
364
+ if (t == FFI_TYPE_STRUCT && ty->alignment >= 16)
365
+ align = 16;
366
+
367
+ if (dir < 0)
368
+ {
369
+ /* ??? These reverse argument ABIs are probably too old
370
+ to have cared about alignment. Someone should check. */
371
+ argp -= za;
372
+ memcpy (argp, valp, z);
373
+ }
374
+ else
375
+ {
376
+ argp = (char *)FFI_ALIGN (argp, align);
377
+ memcpy (argp, valp, z);
378
+ argp += za;
379
+ }
380
+ }
381
+ }
382
+ FFI_ASSERT (dir > 0 || argp == stack);
383
+
384
+ ffi_call_i386 (frame, stack);
385
+ }
386
+
387
+ void
388
+ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
389
+ {
390
+ ffi_call_int (cif, fn, rvalue, avalue, NULL);
391
+ }
392
+
393
+ void
394
+ ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
395
+ void **avalue, void *closure)
396
+ {
397
+ ffi_call_int (cif, fn, rvalue, avalue, closure);
398
+ }
399
+
400
+ /** private members **/
401
+
402
+ void FFI_HIDDEN ffi_closure_i386(void);
403
+ void FFI_HIDDEN ffi_closure_STDCALL(void);
404
+ void FFI_HIDDEN ffi_closure_REGISTER(void);
405
+
406
+ struct closure_frame
407
+ {
408
+ unsigned rettemp[4]; /* 0 */
409
+ unsigned regs[3]; /* 16-24 */
410
+ ffi_cif *cif; /* 28 */
411
+ void (*fun)(ffi_cif*,void*,void**,void*); /* 32 */
412
+ void *user_data; /* 36 */
413
+ };
414
+
415
+ int FFI_HIDDEN FFI_DECLARE_FASTCALL
416
+ ffi_closure_inner (struct closure_frame *frame, char *stack)
417
+ {
418
+ ffi_cif *cif = frame->cif;
419
+ int cabi, i, n, flags, dir, narg_reg;
420
+ const struct abi_params *pabi;
421
+ ffi_type **arg_types;
422
+ char *argp;
423
+ void *rvalue;
424
+ void **avalue;
425
+
426
+ cabi = cif->abi;
427
+ flags = cif->flags;
428
+ narg_reg = 0;
429
+ rvalue = frame->rettemp;
430
+ pabi = &abi_params[cabi];
431
+ dir = pabi->dir;
432
+ argp = (dir < 0 ? stack + cif->bytes : stack);
433
+
434
+ switch (flags)
435
+ {
436
+ case X86_RET_STRUCTARG:
437
+ if (pabi->nregs > 0)
438
+ {
439
+ rvalue = (void *)frame->regs[pabi->regs[0]];
440
+ narg_reg = 1;
441
+ frame->rettemp[0] = (unsigned)rvalue;
442
+ break;
443
+ }
444
+ /* fallthru */
445
+ case X86_RET_STRUCTPOP:
446
+ rvalue = *(void **)argp;
447
+ argp += sizeof(void *);
448
+ frame->rettemp[0] = (unsigned)rvalue;
449
+ break;
450
+ }
451
+
452
+ n = cif->nargs;
453
+ avalue = alloca(sizeof(void *) * n);
454
+
455
+ arg_types = cif->arg_types;
456
+ for (i = 0; i < n; ++i)
457
+ {
458
+ ffi_type *ty = arg_types[i];
459
+ size_t z = ty->size;
460
+ int t = ty->type;
461
+ void *valp;
462
+
463
+ if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT)
464
+ {
465
+ if (t != FFI_TYPE_FLOAT && narg_reg < pabi->nregs)
466
+ valp = &frame->regs[pabi->regs[narg_reg++]];
467
+ else if (dir < 0)
468
+ {
469
+ argp -= 4;
470
+ valp = argp;
471
+ }
472
+ else
473
+ {
474
+ valp = argp;
475
+ argp += 4;
476
+ }
477
+ }
478
+ else
479
+ {
480
+ size_t za = FFI_ALIGN (z, FFI_SIZEOF_ARG);
481
+ size_t align = FFI_SIZEOF_ARG;
482
+
483
+ /* See the comment in ffi_call_int. */
484
+ if (t == FFI_TYPE_STRUCT && ty->alignment >= 16)
485
+ align = 16;
486
+
487
+ /* Issue 434: For thiscall and fastcall, if the paramter passed
488
+ as 64-bit integer or struct, all following integer paramters
489
+ will be passed on stack. */
490
+ if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
491
+ && (t == FFI_TYPE_SINT64
492
+ || t == FFI_TYPE_UINT64
493
+ || t == FFI_TYPE_STRUCT))
494
+ narg_reg = 2;
495
+
496
+ if (dir < 0)
497
+ {
498
+ /* ??? These reverse argument ABIs are probably too old
499
+ to have cared about alignment. Someone should check. */
500
+ argp -= za;
501
+ valp = argp;
502
+ }
503
+ else
504
+ {
505
+ argp = (char *)FFI_ALIGN (argp, align);
506
+ valp = argp;
507
+ argp += za;
508
+ }
509
+ }
510
+
511
+ avalue[i] = valp;
512
+ }
513
+
514
+ frame->fun (cif, rvalue, avalue, frame->user_data);
515
+
516
+ if (cabi == FFI_STDCALL)
517
+ return flags + (cif->bytes << X86_RET_POP_SHIFT);
518
+ else
519
+ return flags;
520
+ }
521
+
522
+ ffi_status
523
+ ffi_prep_closure_loc (ffi_closure* closure,
524
+ ffi_cif* cif,
525
+ void (*fun)(ffi_cif*,void*,void**,void*),
526
+ void *user_data,
527
+ void *codeloc)
528
+ {
529
+ char *tramp = closure->tramp;
530
+ void (*dest)(void);
531
+ int op = 0xb8; /* movl imm, %eax */
532
+
533
+ switch (cif->abi)
534
+ {
535
+ case FFI_SYSV:
536
+ case FFI_THISCALL:
537
+ case FFI_FASTCALL:
538
+ case FFI_MS_CDECL:
539
+ dest = ffi_closure_i386;
540
+ break;
541
+ case FFI_STDCALL:
542
+ case FFI_PASCAL:
543
+ dest = ffi_closure_STDCALL;
544
+ break;
545
+ case FFI_REGISTER:
546
+ dest = ffi_closure_REGISTER;
547
+ op = 0x68; /* pushl imm */
548
+ default:
549
+ return FFI_BAD_ABI;
550
+ }
551
+
552
+ /* movl or pushl immediate. */
553
+ tramp[0] = op;
554
+ *(void **)(tramp + 1) = codeloc;
555
+
556
+ /* jmp dest */
557
+ tramp[5] = 0xe9;
558
+ *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10);
559
+
560
+ closure->cif = cif;
561
+ closure->fun = fun;
562
+ closure->user_data = user_data;
563
+
564
+ return FFI_OK;
565
+ }
566
+
567
+ void FFI_HIDDEN ffi_go_closure_EAX(void);
568
+ void FFI_HIDDEN ffi_go_closure_ECX(void);
569
+ void FFI_HIDDEN ffi_go_closure_STDCALL(void);
570
+
571
+ ffi_status
572
+ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
573
+ void (*fun)(ffi_cif*,void*,void**,void*))
574
+ {
575
+ void (*dest)(void);
576
+
577
+ switch (cif->abi)
578
+ {
579
+ case FFI_SYSV:
580
+ case FFI_MS_CDECL:
581
+ dest = ffi_go_closure_ECX;
582
+ break;
583
+ case FFI_THISCALL:
584
+ case FFI_FASTCALL:
585
+ dest = ffi_go_closure_EAX;
586
+ break;
587
+ case FFI_STDCALL:
588
+ case FFI_PASCAL:
589
+ dest = ffi_go_closure_STDCALL;
590
+ break;
591
+ case FFI_REGISTER:
592
+ default:
593
+ return FFI_BAD_ABI;
594
+ }
595
+
596
+ closure->tramp = dest;
597
+ closure->cif = cif;
598
+ closure->fun = fun;
599
+
600
+ return FFI_OK;
601
+ }
602
+
603
+ /* ------- Native raw API support -------------------------------- */
604
+
605
+ #if !FFI_NO_RAW_API
606
+
607
+ void FFI_HIDDEN ffi_closure_raw_SYSV(void);
608
+ void FFI_HIDDEN ffi_closure_raw_THISCALL(void);
609
+
610
+ ffi_status
611
+ ffi_prep_raw_closure_loc (ffi_raw_closure *closure,
612
+ ffi_cif *cif,
613
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
614
+ void *user_data,
615
+ void *codeloc)
616
+ {
617
+ char *tramp = closure->tramp;
618
+ void (*dest)(void);
619
+ int i;
620
+
621
+ /* We currently don't support certain kinds of arguments for raw
622
+ closures. This should be implemented by a separate assembly
623
+ language routine, since it would require argument processing,
624
+ something we don't do now for performance. */
625
+ for (i = cif->nargs-1; i >= 0; i--)
626
+ switch (cif->arg_types[i]->type)
627
+ {
628
+ case FFI_TYPE_STRUCT:
629
+ case FFI_TYPE_LONGDOUBLE:
630
+ return FFI_BAD_TYPEDEF;
631
+ }
632
+
633
+ switch (cif->abi)
634
+ {
635
+ case FFI_THISCALL:
636
+ dest = ffi_closure_raw_THISCALL;
637
+ break;
638
+ case FFI_SYSV:
639
+ dest = ffi_closure_raw_SYSV;
640
+ break;
641
+ default:
642
+ return FFI_BAD_ABI;
643
+ }
644
+
645
+ /* movl imm, %eax. */
646
+ tramp[0] = 0xb8;
647
+ *(void **)(tramp + 1) = codeloc;
648
+
649
+ /* jmp dest */
650
+ tramp[5] = 0xe9;
651
+ *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10);
652
+
653
+ closure->cif = cif;
654
+ closure->fun = fun;
655
+ closure->user_data = user_data;
656
+
657
+ return FFI_OK;
658
+ }
659
+
660
+ void
661
+ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
662
+ {
663
+ size_t rsize, bytes;
664
+ struct call_frame *frame;
665
+ char *stack, *argp;
666
+ ffi_type **arg_types;
667
+ int flags, cabi, i, n, narg_reg;
668
+ const struct abi_params *pabi;
669
+
670
+ flags = cif->flags;
671
+ cabi = cif->abi;
672
+ pabi = &abi_params[cabi];
673
+
674
+ rsize = 0;
675
+ if (rvalue == NULL)
676
+ {
677
+ switch (flags)
678
+ {
679
+ case X86_RET_FLOAT:
680
+ case X86_RET_DOUBLE:
681
+ case X86_RET_LDOUBLE:
682
+ case X86_RET_STRUCTPOP:
683
+ case X86_RET_STRUCTARG:
684
+ /* The float cases need to pop the 387 stack.
685
+ The struct cases need to pass a valid pointer to the callee. */
686
+ rsize = cif->rtype->size;
687
+ break;
688
+ default:
689
+ /* We can pretend that the callee returns nothing. */
690
+ flags = X86_RET_VOID;
691
+ break;
692
+ }
693
+ }
694
+
695
+ bytes = cif->bytes;
696
+ argp = stack =
697
+ (void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16);
698
+ frame = (struct call_frame *)(stack + bytes);
699
+ if (rsize)
700
+ rvalue = frame + 1;
701
+
702
+ frame->fn = fn;
703
+ frame->flags = flags;
704
+ frame->rvalue = rvalue;
705
+
706
+ narg_reg = 0;
707
+ switch (flags)
708
+ {
709
+ case X86_RET_STRUCTARG:
710
+ /* The pointer is passed as the first argument. */
711
+ if (pabi->nregs > 0)
712
+ {
713
+ frame->regs[pabi->regs[0]] = (unsigned)rvalue;
714
+ narg_reg = 1;
715
+ break;
716
+ }
717
+ /* fallthru */
718
+ case X86_RET_STRUCTPOP:
719
+ *(void **)argp = rvalue;
720
+ argp += sizeof(void *);
721
+ bytes -= sizeof(void *);
722
+ break;
723
+ }
724
+
725
+ arg_types = cif->arg_types;
726
+ for (i = 0, n = cif->nargs; narg_reg < pabi->nregs && i < n; i++)
727
+ {
728
+ ffi_type *ty = arg_types[i];
729
+ size_t z = ty->size;
730
+ int t = ty->type;
731
+
732
+ if (z <= FFI_SIZEOF_ARG && t != FFI_TYPE_STRUCT && t != FFI_TYPE_FLOAT)
733
+ {
734
+ ffi_arg val = extend_basic_type (avalue, t);
735
+ frame->regs[pabi->regs[narg_reg++]] = val;
736
+ z = FFI_SIZEOF_ARG;
737
+ }
738
+ else
739
+ {
740
+ memcpy (argp, avalue, z);
741
+ z = FFI_ALIGN (z, FFI_SIZEOF_ARG);
742
+ argp += z;
743
+ }
744
+ avalue += z;
745
+ bytes -= z;
746
+ }
747
+ if (i < n)
748
+ memcpy (argp, avalue, bytes);
749
+
750
+ ffi_call_i386 (frame, stack);
751
+ }
752
+ #endif /* !FFI_NO_RAW_API */
753
+ #endif /* !__x86_64__ */