ffi 1.10.0 → 1.15.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (349) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +240 -0
  3. data/Gemfile +3 -4
  4. data/README.md +42 -18
  5. data/Rakefile +68 -145
  6. data/ext/ffi_c/AbstractMemory.c +29 -34
  7. data/ext/ffi_c/Buffer.c +4 -9
  8. data/ext/ffi_c/Call.c +17 -50
  9. data/ext/ffi_c/Call.h +4 -7
  10. data/ext/ffi_c/ClosurePool.c +75 -25
  11. data/ext/ffi_c/ClosurePool.h +3 -1
  12. data/ext/ffi_c/DynamicLibrary.c +2 -7
  13. data/ext/ffi_c/Function.c +47 -131
  14. data/ext/ffi_c/Function.h +0 -4
  15. data/ext/ffi_c/FunctionInfo.c +3 -8
  16. data/ext/ffi_c/LastError.c +2 -6
  17. data/ext/ffi_c/LongDouble.c +12 -10
  18. data/ext/ffi_c/LongDouble.h +0 -4
  19. data/ext/ffi_c/MemoryPointer.c +3 -8
  20. data/ext/ffi_c/MemoryPointer.h +0 -4
  21. data/ext/ffi_c/MethodHandle.c +21 -31
  22. data/ext/ffi_c/MethodHandle.h +3 -2
  23. data/ext/ffi_c/Platform.c +5 -56
  24. data/ext/ffi_c/Pointer.c +25 -26
  25. data/ext/ffi_c/Pointer.h +0 -4
  26. data/ext/ffi_c/Struct.c +49 -56
  27. data/ext/ffi_c/Struct.h +12 -6
  28. data/ext/ffi_c/StructByValue.c +2 -7
  29. data/ext/ffi_c/StructLayout.c +22 -20
  30. data/ext/ffi_c/Thread.c +4 -228
  31. data/ext/ffi_c/Thread.h +1 -20
  32. data/ext/ffi_c/Type.c +1 -19
  33. data/ext/ffi_c/Type.h +0 -1
  34. data/ext/ffi_c/Types.c +7 -8
  35. data/ext/ffi_c/Types.h +3 -4
  36. data/ext/ffi_c/Variadic.c +23 -24
  37. data/ext/ffi_c/compat.h +4 -0
  38. data/ext/ffi_c/extconf.rb +56 -30
  39. data/ext/ffi_c/ffi.c +3 -8
  40. data/ext/ffi_c/libffi/.appveyor.yml +29 -13
  41. data/ext/ffi_c/libffi/.gitattributes +4 -0
  42. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  43. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  44. data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
  45. data/ext/ffi_c/libffi/.travis/build.sh +116 -8
  46. data/ext/ffi_c/libffi/.travis/install.sh +65 -16
  47. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  48. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  49. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  50. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  51. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  52. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  53. data/ext/ffi_c/libffi/.travis.yml +51 -2
  54. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  55. data/ext/ffi_c/libffi/LICENSE +1 -1
  56. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  57. data/ext/ffi_c/libffi/Makefile.am +56 -72
  58. data/ext/ffi_c/libffi/Makefile.in +458 -207
  59. data/ext/ffi_c/libffi/README.md +33 -8
  60. data/ext/ffi_c/libffi/config.guess +552 -331
  61. data/ext/ffi_c/libffi/config.sub +1321 -1306
  62. data/ext/ffi_c/libffi/configure +414 -342
  63. data/ext/ffi_c/libffi/configure.ac +37 -12
  64. data/ext/ffi_c/libffi/configure.host +56 -27
  65. data/ext/ffi_c/libffi/doc/Makefile.in +9 -5
  66. data/ext/ffi_c/libffi/doc/libffi.texi +26 -14
  67. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  68. data/ext/ffi_c/libffi/fficonfig.h.in +13 -0
  69. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
  70. data/ext/ffi_c/libffi/include/Makefile.in +10 -6
  71. data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
  72. data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
  73. data/ext/ffi_c/libffi/install-sh +23 -13
  74. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  75. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  76. data/ext/ffi_c/libffi/libtool-version +1 -1
  77. data/ext/ffi_c/libffi/ltmain.sh +156 -61
  78. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  79. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  80. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  81. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  82. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  83. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  84. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  85. data/ext/ffi_c/libffi/man/Makefile.in +9 -5
  86. data/ext/ffi_c/libffi/missing +8 -8
  87. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  88. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  89. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  90. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  91. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  92. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/fficonfig.h +219 -0
  93. data/ext/ffi_c/libffi/msvcc.sh +38 -13
  94. data/ext/ffi_c/libffi/src/aarch64/ffi.c +153 -69
  95. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
  96. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  97. data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
  98. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  99. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
  100. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  101. data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
  102. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  103. data/ext/ffi_c/libffi/src/closures.c +69 -14
  104. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  105. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  106. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  107. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  108. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  109. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  110. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  111. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  112. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  113. data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
  114. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  115. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  116. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  117. data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
  118. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  119. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  120. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  121. data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
  122. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  123. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  124. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  125. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  126. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  127. data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
  128. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
  129. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  130. data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
  131. data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
  132. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
  133. data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
  134. data/ext/ffi_c/libffi/src/x86/ffi.c +29 -12
  135. data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
  136. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  137. data/ext/ffi_c/libffi/src/x86/ffiw64.c +20 -10
  138. data/ext/ffi_c/libffi/src/x86/sysv.S +105 -10
  139. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
  140. data/ext/ffi_c/libffi/src/x86/unix64.S +100 -4
  141. data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
  142. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  143. data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
  144. data/ext/ffi_c/libffi/testsuite/Makefile.in +124 -84
  145. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
  146. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  147. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  148. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
  152. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  153. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  154. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
  155. data/ext/ffi_c/libffi.darwin.mk +1 -1
  156. data/ext/ffi_c/rbffi.h +0 -2
  157. data/ffi.gemspec +13 -7
  158. data/lib/ffi/abstract_memory.rb +44 -0
  159. data/lib/ffi/autopointer.rb +1 -1
  160. data/lib/ffi/data_converter.rb +67 -0
  161. data/lib/ffi/ffi.rb +3 -0
  162. data/lib/ffi/io.rb +3 -3
  163. data/lib/ffi/library.rb +13 -9
  164. data/lib/ffi/managedstruct.rb +2 -2
  165. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  166. data/lib/ffi/platform/aarch64-freebsd/types.conf +89 -89
  167. data/lib/ffi/platform/aarch64-freebsd12/types.conf +162 -109
  168. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  169. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  170. data/lib/ffi/platform/arm-freebsd/types.conf +87 -87
  171. data/lib/ffi/platform/arm-freebsd12/types.conf +87 -87
  172. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  173. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  174. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  175. data/lib/ffi/platform/i386-freebsd/types.conf +87 -87
  176. data/lib/ffi/platform/i386-freebsd12/types.conf +87 -87
  177. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  178. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  179. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  180. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  181. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  182. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  183. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  184. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  185. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  186. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  187. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  188. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  189. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  190. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  191. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  192. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  193. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  194. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  195. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  196. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  197. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  198. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  199. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  200. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  201. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  202. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  203. data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
  204. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  205. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  206. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  207. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  208. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  209. data/lib/ffi/platform/x86_64-freebsd/types.conf +89 -89
  210. data/lib/ffi/platform/x86_64-freebsd12/types.conf +139 -109
  211. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  212. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  213. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  214. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  215. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  216. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  217. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  218. data/lib/ffi/platform.rb +24 -9
  219. data/lib/ffi/pointer.rb +22 -15
  220. data/lib/ffi/struct.rb +13 -68
  221. data/lib/ffi/struct_by_reference.rb +72 -0
  222. data/lib/ffi/struct_layout.rb +96 -0
  223. data/lib/ffi/tools/const_generator.rb +11 -8
  224. data/lib/ffi/tools/generator.rb +47 -2
  225. data/lib/ffi/tools/generator_task.rb +13 -17
  226. data/lib/ffi/tools/struct_generator.rb +6 -5
  227. data/lib/ffi/tools/types_generator.rb +7 -4
  228. data/lib/ffi/types.rb +1 -1
  229. data/lib/ffi/variadic.rb +1 -10
  230. data/lib/ffi/version.rb +1 -1
  231. data/lib/ffi.rb +10 -3
  232. data/rakelib/ffi_gem_helper.rb +65 -0
  233. data/samples/getlogin.rb +1 -1
  234. data/samples/getpid.rb +1 -1
  235. data/samples/gettimeofday.rb +8 -8
  236. data/samples/hello.rb +2 -1
  237. data/samples/inotify.rb +1 -1
  238. data/samples/pty.rb +1 -2
  239. data/samples/qsort.rb +0 -1
  240. metadata +157 -139
  241. data/.gitignore +0 -22
  242. data/.gitmodules +0 -3
  243. data/.travis.yml +0 -43
  244. data/.yardopts +0 -5
  245. data/appveyor.yml +0 -22
  246. data/ext/ffi_c/DataConverter.c +0 -91
  247. data/ext/ffi_c/StructByReference.c +0 -190
  248. data/ext/ffi_c/StructByReference.h +0 -50
  249. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  250. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  251. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  252. data/ext/ffi_c/win32/stdbool.h +0 -8
  253. data/ext/ffi_c/win32/stdint.h +0 -201
  254. data/samples/sample_helper.rb +0 -6
  255. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  256. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  257. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  258. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  259. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  260. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  261. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  262. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  263. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  264. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  265. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  266. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  267. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  268. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  269. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  270. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  271. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  272. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  273. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  274. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  275. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  276. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  277. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  278. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  279. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  280. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  281. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  282. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  283. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  284. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  285. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  286. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  287. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  288. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  289. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  290. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  291. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  292. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  293. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  294. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  295. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  296. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  297. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  298. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  299. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  300. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  301. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  302. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  303. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  304. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  305. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  306. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  307. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  308. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  309. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  310. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  311. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  312. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  313. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  314. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  315. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  316. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  317. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  318. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  319. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  320. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  321. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  322. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  323. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  324. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  325. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  326. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  327. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  328. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  329. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  330. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  331. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  332. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  333. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  334. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  335. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  336. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  337. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  338. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  339. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  340. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  341. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  342. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  343. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  344. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  345. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  346. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  347. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  348. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  349. /data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
@@ -0,0 +1,219 @@
1
+ /* fficonfig.h. Generated from fficonfig.h.in by configure. */
2
+ /* fficonfig.h.in. Generated from configure.ac by autoheader. */
3
+
4
+ /* Define if building universal (internal helper macro) */
5
+ /* #undef AC_APPLE_UNIVERSAL_BUILD */
6
+
7
+ /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
8
+ systems. This function is required for `alloca.c' support on those systems.
9
+ */
10
+ /* #undef CRAY_STACKSEG_END */
11
+
12
+ /* Define to 1 if using `alloca.c'. */
13
+ /* #undef C_ALLOCA */
14
+
15
+ /* Define to the flags needed for the .section .eh_frame directive. */
16
+ #define EH_FRAME_FLAGS "a"
17
+
18
+ /* Define this if you want extra debugging. */
19
+ /* #undef FFI_DEBUG */
20
+
21
+ /* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
22
+ /* #undef FFI_EXEC_TRAMPOLINE_TABLE */
23
+
24
+ /* Define this if you want to enable pax emulated trampolines */
25
+ /* #undef FFI_MMAP_EXEC_EMUTRAMP_PAX */
26
+
27
+ /* Cannot use malloc on this target, so, we revert to alternative means */
28
+ /* #undef FFI_MMAP_EXEC_WRIT */
29
+
30
+ /* Define this if you do not want support for the raw API. */
31
+ /* #undef FFI_NO_RAW_API */
32
+
33
+ /* Define this if you do not want support for aggregate types. */
34
+ /* #undef FFI_NO_STRUCTS */
35
+
36
+ /* Define to 1 if you have `alloca', as a function or macro. */
37
+ #define HAVE_ALLOCA 1
38
+
39
+ /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
40
+ */
41
+ /*#define HAVE_ALLOCA_H 1 */
42
+
43
+ /* Define if your assembler supports .cfi_* directives. */
44
+ #define HAVE_AS_CFI_PSEUDO_OP 1
45
+
46
+ /* Define if your assembler supports .register. */
47
+ /* #undef HAVE_AS_REGISTER_PSEUDO_OP */
48
+
49
+ /* Define if the compiler uses zarch features. */
50
+ /* #undef HAVE_AS_S390_ZARCH */
51
+
52
+ /* Define if your assembler and linker support unaligned PC relative relocs.
53
+ */
54
+ /* #undef HAVE_AS_SPARC_UA_PCREL */
55
+
56
+ /* Define if your assembler supports unwind section type. */
57
+ /* #undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE */
58
+
59
+ /* Define if your assembler supports PC relative relocs. */
60
+ /* #undef HAVE_AS_X86_PCREL */
61
+
62
+ /* Define to 1 if you have the <dlfcn.h> header file. */
63
+ #define HAVE_DLFCN_H 1
64
+
65
+ /* Define if __attribute__((visibility("hidden"))) is supported. */
66
+ #define HAVE_HIDDEN_VISIBILITY_ATTRIBUTE 1
67
+
68
+ /* Define to 1 if you have the <inttypes.h> header file. */
69
+ #define HAVE_INTTYPES_H 1
70
+
71
+ /* Define if you have the long double type and it is bigger than a double */
72
+ #define HAVE_LONG_DOUBLE 1
73
+
74
+ /* Define if you support more than one size of the long double type */
75
+ /* #undef HAVE_LONG_DOUBLE_VARIANT */
76
+
77
+ /* Define to 1 if you have the `memcpy' function. */
78
+ #define HAVE_MEMCPY 1
79
+
80
+ /* Define to 1 if you have the <memory.h> header file. */
81
+ #define HAVE_MEMORY_H 1
82
+
83
+ /* Define to 1 if you have the `mkostemp' function. */
84
+ #define HAVE_MKOSTEMP 1
85
+
86
+ /* Define to 1 if you have the `mmap' function. */
87
+ #define HAVE_MMAP 1
88
+
89
+ /* Define if mmap with MAP_ANON(YMOUS) works. */
90
+ #define HAVE_MMAP_ANON 1
91
+
92
+ /* Define if mmap of /dev/zero works. */
93
+ #define HAVE_MMAP_DEV_ZERO 1
94
+
95
+ /* Define if read-only mmap of a plain file works. */
96
+ #define HAVE_MMAP_FILE 1
97
+
98
+ /* Define if .eh_frame sections should be read-only. */
99
+ #define HAVE_RO_EH_FRAME 1
100
+
101
+ /* Define to 1 if you have the <stdint.h> header file. */
102
+ #define HAVE_STDINT_H 1
103
+
104
+ /* Define to 1 if you have the <stdlib.h> header file. */
105
+ //#define HAVE_STDLIB_H 0
106
+ #define LACKS_STDLIB_H 1
107
+ /* Define to 1 if you have the <strings.h> header file. */
108
+ #define HAVE_STRINGS_H 1
109
+
110
+ /* Define to 1 if you have the <string.h> header file. */
111
+ #define HAVE_STRING_H 1
112
+
113
+ /* Define to 1 if you have the <sys/mman.h> header file. */
114
+ #define HAVE_SYS_MMAN_H 1
115
+
116
+ /* Define to 1 if you have the <sys/stat.h> header file. */
117
+ #define HAVE_SYS_STAT_H 1
118
+
119
+ /* Define to 1 if you have the <sys/types.h> header file. */
120
+ #define HAVE_SYS_TYPES_H 1
121
+
122
+ /* Define to 1 if you have the <unistd.h> header file. */
123
+ #define HAVE_UNISTD_H 1
124
+
125
+ /* Define to 1 if GNU symbol versioning is used for libatomic. */
126
+ #define LIBFFI_GNU_SYMBOL_VERSIONING 1
127
+
128
+ /* Define to the sub-directory in which libtool stores uninstalled libraries.
129
+ */
130
+ #define LT_OBJDIR ".libs/"
131
+
132
+ /* Define to 1 if your C compiler doesn't accept -c and -o together. */
133
+ /* #undef NO_MINUS_C_MINUS_O */
134
+
135
+ /* Name of package */
136
+ #define PACKAGE "libffi"
137
+
138
+ /* Define to the address where bug reports for this package should be sent. */
139
+ #define PACKAGE_BUGREPORT "http://github.com/libffi/libffi/issues"
140
+
141
+ /* Define to the full name of this package. */
142
+ #define PACKAGE_NAME "libffi"
143
+
144
+ /* Define to the full name and version of this package. */
145
+ #define PACKAGE_STRING "libffi 3.3-rc0"
146
+
147
+ /* Define to the one symbol short name of this package. */
148
+ #define PACKAGE_TARNAME "libffi"
149
+
150
+ /* Define to the home page for this package. */
151
+ #define PACKAGE_URL ""
152
+
153
+ /* Define to the version of this package. */
154
+ #define PACKAGE_VERSION "3.3-rc0"
155
+
156
+ /* The size of `double', as computed by sizeof. */
157
+ #define SIZEOF_DOUBLE 8
158
+
159
+ /* The size of `long double', as computed by sizeof. */
160
+ #define SIZEOF_LONG_DOUBLE 8
161
+
162
+ /* The size of `size_t', as computed by sizeof. */
163
+ #define SIZEOF_SIZE_T 8
164
+
165
+ /* If using the C implementation of alloca, define if you know the
166
+ direction of stack growth for your system; otherwise it will be
167
+ automatically deduced at runtime.
168
+ STACK_DIRECTION > 0 => grows toward higher addresses
169
+ STACK_DIRECTION < 0 => grows toward lower addresses
170
+ STACK_DIRECTION = 0 => direction of growth unknown */
171
+ /* #undef STACK_DIRECTION */
172
+
173
+ /* Define to 1 if you have the ANSI C header files. */
174
+ #define STDC_HEADERS 1
175
+
176
+ /* Define if symbols are underscored. */
177
+ /* #undef SYMBOL_UNDERSCORE */
178
+
179
+ /* Define this if you are using Purify and want to suppress spurious messages.
180
+ */
181
+ /* #undef USING_PURIFY */
182
+
183
+ /* Version number of package */
184
+ #define VERSION "3.3-rc0"
185
+
186
+ /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
187
+ significant byte first (like Motorola and SPARC, unlike Intel). */
188
+ #if defined AC_APPLE_UNIVERSAL_BUILD
189
+ # if defined __BIG_ENDIAN__
190
+ # define WORDS_BIGENDIAN 1
191
+ # endif
192
+ #else
193
+ # ifndef WORDS_BIGENDIAN
194
+ /* # undef WORDS_BIGENDIAN */
195
+ # endif
196
+ #endif
197
+
198
+ /* Define to `unsigned int' if <sys/types.h> does not define. */
199
+ /* #undef size_t */
200
+
201
+
202
+ #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
203
+ #ifdef LIBFFI_ASM
204
+ #ifdef __APPLE__
205
+ #define FFI_HIDDEN(name) .private_extern name
206
+ #else
207
+ #define FFI_HIDDEN(name) .hidden name
208
+ #endif
209
+ #else
210
+ #define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
211
+ #endif
212
+ #else
213
+ #ifdef LIBFFI_ASM
214
+ #define FFI_HIDDEN(name)
215
+ #else
216
+ #define FFI_HIDDEN
217
+ #endif
218
+ #endif
219
+
@@ -60,7 +60,7 @@ do
60
60
  case $1
61
61
  in
62
62
  --verbose)
63
- $verbose=1
63
+ verbose=1
64
64
  shift 1
65
65
  ;;
66
66
  --version)
@@ -80,6 +80,16 @@ do
80
80
  safeseh=
81
81
  shift 1
82
82
  ;;
83
+ -marm)
84
+ ml='armasm'
85
+ safeseh=
86
+ shift 1
87
+ ;;
88
+ -marm64)
89
+ ml='armasm64'
90
+ safeseh=
91
+ shift 1
92
+ ;;
83
93
  -clang-cl)
84
94
  cl="clang-cl"
85
95
  shift 1
@@ -155,24 +165,24 @@ do
155
165
  shift 1
156
166
  ;;
157
167
  -I)
158
- p=$(cygpath -m $2)
159
- args="$args -I$p"
160
- includes="$includes -I$p"
168
+ p=$(cygpath -ma "$2")
169
+ args="$args -I\"$p\""
170
+ includes="$includes -I\"$p\""
161
171
  shift 2
162
172
  ;;
163
173
  -I*)
164
- p=$(cygpath -m ${1#-I})
165
- args="$args -I$p"
166
- includes="$includes -I$p"
174
+ p=$(cygpath -ma "${1#-I}")
175
+ args="$args -I\"$p\""
176
+ includes="$includes -I\"$p\""
167
177
  shift 1
168
178
  ;;
169
179
  -L)
170
- p=$(cygpath -m $2)
180
+ p=$(cygpath -ma $2)
171
181
  linkargs="$linkargs -LIBPATH:$p"
172
182
  shift 2
173
183
  ;;
174
184
  -L*)
175
- p=$(cygpath -m ${1#-L})
185
+ p=$(cygpath -ma ${1#-L})
176
186
  linkargs="$linkargs -LIBPATH:$p"
177
187
  shift 1
178
188
  ;;
@@ -237,6 +247,7 @@ do
237
247
  else
238
248
  output="-Fe$2"
239
249
  fi
250
+ armasm_output="-o $2"
240
251
  if [ -n "$assembly" ]; then
241
252
  args="$args $output"
242
253
  else
@@ -245,12 +256,12 @@ do
245
256
  shift 2
246
257
  ;;
247
258
  *.S)
248
- src=$1
259
+ src="$(cygpath -ma $1)"
249
260
  assembly="true"
250
261
  shift 1
251
262
  ;;
252
263
  *.c)
253
- args="$args $1"
264
+ args="$args $(cygpath -ma $1)"
254
265
  shift 1
255
266
  ;;
256
267
  *)
@@ -289,13 +300,27 @@ if [ -n "$assembly" ]; then
289
300
  fi
290
301
  ppsrc="$outdir/$(basename $src|sed 's/.S$/.asm/g')"
291
302
 
303
+ if [ $ml = "armasm" ]; then
304
+ defines="$defines -D_M_ARM"
305
+ fi
306
+
307
+ if [ $ml = "armasm64" ]; then
308
+ defines="$defines -D_M_ARM64"
309
+ fi
310
+
292
311
  if test -n "$verbose"; then
293
312
  echo "$cl -nologo -EP $includes $defines $src > $ppsrc"
294
313
  fi
295
314
 
296
- "$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $?
315
+ eval "\"$cl\" -nologo -EP $includes $defines $src" > $ppsrc || exit $?
297
316
  output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')"
298
- args="-nologo $safeseh $single $output $ppsrc"
317
+ if [ $ml = "armasm" ]; then
318
+ args="-nologo -g -oldit $armasm_output $ppsrc -errorReport:prompt"
319
+ elif [ $ml = "armasm64" ]; then
320
+ args="-nologo -g $armasm_output $ppsrc -errorReport:prompt"
321
+ else
322
+ args="-nologo $safeseh $single $output $ppsrc"
323
+ fi
299
324
 
300
325
  if test -n "$verbose"; then
301
326
  echo "$ml $args"
@@ -19,6 +19,7 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
19
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
20
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
21
21
 
22
+ #if defined(__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)
22
23
  #include <stdio.h>
23
24
  #include <stdlib.h>
24
25
  #include <stdint.h>
@@ -26,6 +27,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
26
27
  #include <ffi.h>
27
28
  #include <ffi_common.h>
28
29
  #include "internal.h"
30
+ #ifdef _WIN32
31
+ #include <windows.h> /* FlushInstructionCache */
32
+ #endif
29
33
 
30
34
  /* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
31
35
  all further uses in this file will refer to the 128-bit type. */
@@ -58,6 +62,9 @@ struct call_context
58
62
  #if FFI_EXEC_TRAMPOLINE_TABLE
59
63
 
60
64
  #ifdef __MACH__
65
+ #ifdef HAVE_PTRAUTH
66
+ #include <ptrauth.h>
67
+ #endif
61
68
  #include <mach/vm_param.h>
62
69
  #endif
63
70
 
@@ -74,6 +81,8 @@ ffi_clear_cache (void *start, void *end)
74
81
  sys_icache_invalidate (start, (char *)end - (char *)start);
75
82
  #elif defined (__GNUC__)
76
83
  __builtin___clear_cache (start, end);
84
+ #elif defined (_WIN32)
85
+ FlushInstructionCache(GetCurrentProcess(), start, (char*)end - (char*)start);
77
86
  #else
78
87
  #error "Missing builtin to flush instruction cache"
79
88
  #endif
@@ -315,6 +324,9 @@ extend_integer_type (void *source, int type)
315
324
  }
316
325
  }
317
326
 
327
+ #if defined(_MSC_VER)
328
+ void extend_hfa_type (void *dest, void *src, int h);
329
+ #else
318
330
  static void
319
331
  extend_hfa_type (void *dest, void *src, int h)
320
332
  {
@@ -350,10 +362,10 @@ extend_hfa_type (void *dest, void *src, int h)
350
362
  " b 1f\n"
351
363
  " nop\n"
352
364
  " ldp q16, q17, [%3]\n" /* Q4 */
353
- " ldp q18, q19, [%3, #16]\n"
365
+ " ldp q18, q19, [%3, #32]\n"
354
366
  " b 4f\n"
355
367
  " ldp q16, q17, [%3]\n" /* Q3 */
356
- " ldr q18, [%3, #16]\n"
368
+ " ldr q18, [%3, #32]\n"
357
369
  " b 3f\n"
358
370
  " ldp q16, q17, [%3]\n" /* Q2 */
359
371
  " b 2f\n"
@@ -368,7 +380,11 @@ extend_hfa_type (void *dest, void *src, int h)
368
380
  : "r"(f * 12), "r"(dest), "r"(src)
369
381
  : "memory", "v16", "v17", "v18", "v19");
370
382
  }
383
+ #endif
371
384
 
385
+ #if defined(_MSC_VER)
386
+ void* compress_hfa_type (void *dest, void *src, int h);
387
+ #else
372
388
  static void *
373
389
  compress_hfa_type (void *dest, void *reg, int h)
374
390
  {
@@ -437,6 +453,7 @@ compress_hfa_type (void *dest, void *reg, int h)
437
453
  }
438
454
  return dest;
439
455
  }
456
+ #endif
440
457
 
441
458
  /* Either allocate an appropriate register for the argument type, or if
442
459
  none are available, allocate a stack slot and return a pointer
@@ -454,7 +471,7 @@ allocate_int_to_reg_or_stack (struct call_context *context,
454
471
  return allocate_to_stack (state, stack, size, size);
455
472
  }
456
473
 
457
- ffi_status
474
+ ffi_status FFI_HIDDEN
458
475
  ffi_prep_cif_machdep (ffi_cif *cif)
459
476
  {
460
477
  ffi_type *rtype = cif->rtype;
@@ -539,14 +556,22 @@ ffi_prep_cif_machdep (ffi_cif *cif)
539
556
 
540
557
  #if defined (__APPLE__)
541
558
  /* Perform Apple-specific cif processing for variadic calls */
542
- ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
543
- unsigned int nfixedargs,
544
- unsigned int ntotalargs)
559
+ ffi_status FFI_HIDDEN
560
+ ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs,
561
+ unsigned int ntotalargs)
545
562
  {
546
563
  ffi_status status = ffi_prep_cif_machdep (cif);
547
564
  cif->aarch64_nfixedargs = nfixedargs;
548
565
  return status;
549
566
  }
567
+ #else
568
+ ffi_status FFI_HIDDEN
569
+ ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, unsigned int ntotalargs)
570
+ {
571
+ ffi_status status = ffi_prep_cif_machdep (cif);
572
+ cif->flags |= AARCH64_FLAG_VARARG;
573
+ return status;
574
+ }
550
575
  #endif /* __APPLE__ */
551
576
 
552
577
  extern void ffi_call_SYSV (struct call_context *context, void *frame,
@@ -563,7 +588,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
563
588
  void *stack, *frame, *rvalue;
564
589
  struct arg_state state;
565
590
  size_t stack_bytes, rtype_size, rsize;
566
- int i, nargs, flags;
591
+ int i, nargs, flags, isvariadic = 0;
567
592
  ffi_type *rtype;
568
593
 
569
594
  flags = cif->flags;
@@ -571,6 +596,12 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
571
596
  rtype_size = rtype->size;
572
597
  stack_bytes = cif->bytes;
573
598
 
599
+ if (flags & AARCH64_FLAG_VARARG)
600
+ {
601
+ isvariadic = 1;
602
+ flags &= ~AARCH64_FLAG_VARARG;
603
+ }
604
+
574
605
  /* If the target function returns a structure via hidden pointer,
575
606
  then we cannot allow a null rvalue. Otherwise, mash a null
576
607
  rvalue to void return type. */
@@ -588,8 +619,8 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
588
619
  /* Allocate consectutive stack for everything we'll need. */
589
620
  context = alloca (sizeof(struct call_context) + stack_bytes + 32 + rsize);
590
621
  stack = context + 1;
591
- frame = stack + stack_bytes;
592
- rvalue = (rsize ? frame + 32 : orig_rvalue);
622
+ frame = (void*)((uintptr_t)stack + (uintptr_t)stack_bytes);
623
+ rvalue = (rsize ? (void*)((uintptr_t)frame + 32) : orig_rvalue);
593
624
 
594
625
  arg_init (&state);
595
626
  for (i = 0, nargs = cif->nargs; i < nargs; i++)
@@ -650,16 +681,31 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
650
681
  h = is_vfp_type (ty);
651
682
  if (h)
652
683
  {
653
- int elems = 4 - (h & 3);
654
- if (state.nsrn + elems <= N_V_ARG_REG)
655
- {
656
- dest = &context->v[state.nsrn];
657
- state.nsrn += elems;
658
- extend_hfa_type (dest, a, h);
659
- break;
660
- }
661
- state.nsrn = N_V_ARG_REG;
662
- dest = allocate_to_stack (&state, stack, ty->alignment, s);
684
+ int elems = 4 - (h & 3);
685
+ if (cif->abi == FFI_WIN64 && isvariadic)
686
+ {
687
+ if (state.ngrn + elems <= N_X_ARG_REG)
688
+ {
689
+ dest = &context->x[state.ngrn];
690
+ state.ngrn += elems;
691
+ extend_hfa_type(dest, a, h);
692
+ break;
693
+ }
694
+ state.nsrn = N_X_ARG_REG;
695
+ dest = allocate_to_stack(&state, stack, ty->alignment, s);
696
+ }
697
+ else
698
+ {
699
+ if (state.nsrn + elems <= N_V_ARG_REG)
700
+ {
701
+ dest = &context->v[state.nsrn];
702
+ state.nsrn += elems;
703
+ extend_hfa_type (dest, a, h);
704
+ break;
705
+ }
706
+ state.nsrn = N_V_ARG_REG;
707
+ dest = allocate_to_stack (&state, stack, ty->alignment, s);
708
+ }
663
709
  }
664
710
  else if (s > 16)
665
711
  {
@@ -681,7 +727,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
681
727
  X registers, then the argument is copied into
682
728
  consecutive X registers. */
683
729
  dest = &context->x[state.ngrn];
684
- state.ngrn += n;
730
+ state.ngrn += (unsigned int)n;
685
731
  }
686
732
  else
687
733
  {
@@ -756,6 +802,9 @@ ffi_prep_closure_loc (ffi_closure *closure,
756
802
 
757
803
  #if FFI_EXEC_TRAMPOLINE_TABLE
758
804
  #ifdef __MACH__
805
+ #ifdef HAVE_PTRAUTH
806
+ codeloc = ptrauth_strip (codeloc, ptrauth_key_asia);
807
+ #endif
759
808
  void **config = (void **)((uint8_t *)codeloc - PAGE_MAX_SIZE);
760
809
  config[0] = closure;
761
810
  config[1] = start;
@@ -773,6 +822,16 @@ ffi_prep_closure_loc (ffi_closure *closure,
773
822
  *(UINT64 *)(tramp + 16) = (uintptr_t)start;
774
823
 
775
824
  ffi_clear_cache(tramp, tramp + FFI_TRAMPOLINE_SIZE);
825
+
826
+ /* Also flush the cache for code mapping. */
827
+ #ifdef _WIN32
828
+ // Not using dlmalloc.c for Windows ARM64 builds
829
+ // so calling ffi_data_to_code_pointer() isn't necessary
830
+ unsigned char *tramp_code = tramp;
831
+ #else
832
+ unsigned char *tramp_code = ffi_data_to_code_pointer (tramp);
833
+ #endif
834
+ ffi_clear_cache (tramp_code, tramp_code + FFI_TRAMPOLINE_SIZE);
776
835
  #endif
777
836
 
778
837
  closure->cif = cif;
@@ -871,55 +930,78 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
871
930
  if (h)
872
931
  {
873
932
  n = 4 - (h & 3);
874
- if (state.nsrn + n <= N_V_ARG_REG)
875
- {
876
- void *reg = &context->v[state.nsrn];
877
- state.nsrn += n;
878
-
879
- /* Eeek! We need a pointer to the structure, however the
880
- homogeneous float elements are being passed in individual
881
- registers, therefore for float and double the structure
882
- is not represented as a contiguous sequence of bytes in
883
- our saved register context. We don't need the original
884
- contents of the register storage, so we reformat the
885
- structure into the same memory. */
886
- avalue[i] = compress_hfa_type (reg, reg, h);
887
- }
888
- else
889
- {
890
- state.nsrn = N_V_ARG_REG;
891
- avalue[i] = allocate_to_stack (&state, stack,
892
- ty->alignment, s);
893
- }
894
- }
895
- else if (s > 16)
896
- {
897
- /* Replace Composite type of size greater than 16 with a
898
- pointer. */
899
- avalue[i] = *(void **)
900
- allocate_int_to_reg_or_stack (context, &state, stack,
901
- sizeof (void *));
902
- }
903
- else
904
- {
905
- n = (s + 7) / 8;
906
- if (state.ngrn + n <= N_X_ARG_REG)
907
- {
908
- avalue[i] = &context->x[state.ngrn];
909
- state.ngrn += n;
910
- }
911
- else
912
- {
913
- state.ngrn = N_X_ARG_REG;
914
- avalue[i] = allocate_to_stack (&state, stack,
915
- ty->alignment, s);
916
- }
917
- }
918
- break;
919
-
920
- default:
921
- abort();
922
- }
933
+ #ifdef _WIN32 /* for handling armasm calling convention */
934
+ if (cif->is_variadic)
935
+ {
936
+ if (state.ngrn + n <= N_X_ARG_REG)
937
+ {
938
+ void *reg = &context->x[state.ngrn];
939
+ state.ngrn += (unsigned int)n;
940
+
941
+ /* Eeek! We need a pointer to the structure, however the
942
+ homogeneous float elements are being passed in individual
943
+ registers, therefore for float and double the structure
944
+ is not represented as a contiguous sequence of bytes in
945
+ our saved register context. We don't need the original
946
+ contents of the register storage, so we reformat the
947
+ structure into the same memory. */
948
+ avalue[i] = compress_hfa_type(reg, reg, h);
949
+ }
950
+ else
951
+ {
952
+ state.ngrn = N_X_ARG_REG;
953
+ state.nsrn = N_V_ARG_REG;
954
+ avalue[i] = allocate_to_stack(&state, stack,
955
+ ty->alignment, s);
956
+ }
957
+ }
958
+ else
959
+ {
960
+ #endif /* for handling armasm calling convention */
961
+ if (state.nsrn + n <= N_V_ARG_REG)
962
+ {
963
+ void *reg = &context->v[state.nsrn];
964
+ state.nsrn += (unsigned int)n;
965
+ avalue[i] = compress_hfa_type(reg, reg, h);
966
+ }
967
+ else
968
+ {
969
+ state.nsrn = N_V_ARG_REG;
970
+ avalue[i] = allocate_to_stack(&state, stack,
971
+ ty->alignment, s);
972
+ }
973
+ #ifdef _WIN32 /* for handling armasm calling convention */
974
+ }
975
+ #endif /* for handling armasm calling convention */
976
+ }
977
+ else if (s > 16)
978
+ {
979
+ /* Replace Composite type of size greater than 16 with a
980
+ pointer. */
981
+ avalue[i] = *(void **)
982
+ allocate_int_to_reg_or_stack (context, &state, stack,
983
+ sizeof (void *));
984
+ }
985
+ else
986
+ {
987
+ n = (s + 7) / 8;
988
+ if (state.ngrn + n <= N_X_ARG_REG)
989
+ {
990
+ avalue[i] = &context->x[state.ngrn];
991
+ state.ngrn += (unsigned int)n;
992
+ }
993
+ else
994
+ {
995
+ state.ngrn = N_X_ARG_REG;
996
+ avalue[i] = allocate_to_stack(&state, stack,
997
+ ty->alignment, s);
998
+ }
999
+ }
1000
+ break;
1001
+
1002
+ default:
1003
+ abort();
1004
+ }
923
1005
 
924
1006
  #if defined (__APPLE__)
925
1007
  if (i + 1 == cif->aarch64_nfixedargs)
@@ -939,3 +1021,5 @@ ffi_closure_SYSV_inner (ffi_cif *cif,
939
1021
 
940
1022
  return flags;
941
1023
  }
1024
+
1025
+ #endif /* (__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)*/