ffi 1.9.25 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (339) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +212 -0
  3. data/Gemfile +3 -4
  4. data/README.md +38 -18
  5. data/Rakefile +55 -146
  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 +16 -49
  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 +49 -8
  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 +3 -54
  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 +53 -30
  39. data/ext/ffi_c/ffi.c +3 -8
  40. data/ext/ffi_c/libffi.darwin.mk +1 -1
  41. data/ext/ffi_c/libffi/.appveyor.yml +29 -13
  42. data/ext/ffi_c/libffi/.gitattributes +4 -0
  43. data/ext/ffi_c/libffi/.travis.yml +51 -2
  44. data/ext/ffi_c/libffi/.travis/bfin-sim.exp +58 -0
  45. data/ext/ffi_c/libffi/.travis/build-cross-in-container.sh +14 -0
  46. data/ext/ffi_c/libffi/.travis/build-in-container.sh +12 -0
  47. data/ext/ffi_c/libffi/.travis/build.sh +116 -8
  48. data/ext/ffi_c/libffi/.travis/install.sh +65 -16
  49. data/ext/ffi_c/libffi/.travis/m32r-sim.exp +58 -0
  50. data/ext/ffi_c/libffi/.travis/moxie-sim.exp +1 -1
  51. data/ext/ffi_c/libffi/.travis/or1k-sim.exp +58 -0
  52. data/ext/ffi_c/libffi/.travis/powerpc-eabisim.exp +58 -0
  53. data/ext/ffi_c/libffi/.travis/site.exp +10 -1
  54. data/ext/ffi_c/libffi/.travis/wine-sim.exp +55 -0
  55. data/ext/ffi_c/libffi/{ChangeLog.libffi-3.1 → ChangeLog.old} +1407 -0
  56. data/ext/ffi_c/libffi/LICENSE +1 -1
  57. data/ext/ffi_c/libffi/LICENSE-BUILDTOOLS +5 -4
  58. data/ext/ffi_c/libffi/Makefile.am +56 -72
  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.ac +37 -12
  63. data/ext/ffi_c/libffi/configure.host +56 -27
  64. data/ext/ffi_c/libffi/doc/Makefile.am +3 -0
  65. data/ext/ffi_c/libffi/doc/libffi.texi +997 -0
  66. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  67. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +2 -4
  68. data/ext/ffi_c/libffi/include/ffi.h.in +19 -7
  69. data/ext/ffi_c/libffi/include/ffi_common.h +5 -1
  70. data/ext/ffi_c/libffi/libffi.map.in +8 -12
  71. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +2 -48
  72. data/ext/ffi_c/libffi/libtool-version +1 -1
  73. data/ext/ffi_c/libffi/m4/asmcfi.m4 +1 -1
  74. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +5 -26
  75. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +5 -26
  76. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +2 -1
  77. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +5 -26
  78. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +7 -3
  79. data/ext/ffi_c/libffi/make_sunver.pl +333 -0
  80. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.sln +33 -0
  81. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj +130 -0
  82. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.filters +57 -0
  83. data/ext/ffi_c/libffi/msvc_build/aarch64/Ffi_staticLib.vcxproj.user +4 -0
  84. data/ext/ffi_c/libffi/msvc_build/aarch64/aarch64_include/ffi.h +511 -0
  85. data/ext/ffi_c/libffi/msvcc.sh +38 -13
  86. data/ext/ffi_c/libffi/src/aarch64/ffi.c +153 -69
  87. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +19 -3
  88. data/ext/ffi_c/libffi/src/aarch64/internal.h +1 -0
  89. data/ext/ffi_c/libffi/src/aarch64/sysv.S +22 -9
  90. data/ext/ffi_c/libffi/src/aarch64/win64_armasm.S +506 -0
  91. data/ext/ffi_c/libffi/src/arm/ffi.c +62 -5
  92. data/ext/ffi_c/libffi/src/arm/ffitarget.h +8 -1
  93. data/ext/ffi_c/libffi/src/arm/sysv.S +6 -4
  94. data/ext/ffi_c/libffi/src/arm/sysv_msvc_arm32.S +311 -0
  95. data/ext/ffi_c/libffi/src/closures.c +69 -14
  96. data/ext/ffi_c/libffi/src/csky/ffi.c +395 -0
  97. data/ext/ffi_c/libffi/src/csky/ffitarget.h +63 -0
  98. data/ext/ffi_c/libffi/src/csky/sysv.S +371 -0
  99. data/ext/ffi_c/libffi/src/dlmalloc.c +1 -1
  100. data/ext/ffi_c/libffi/src/frv/ffi.c +1 -1
  101. data/ext/ffi_c/libffi/src/kvx/asm.h +5 -0
  102. data/ext/ffi_c/libffi/src/kvx/ffi.c +273 -0
  103. data/ext/ffi_c/libffi/src/kvx/ffitarget.h +75 -0
  104. data/ext/ffi_c/libffi/src/kvx/sysv.S +127 -0
  105. data/ext/ffi_c/libffi/src/metag/ffi.c +1 -1
  106. data/ext/ffi_c/libffi/src/mips/ffi.c +5 -1
  107. data/ext/ffi_c/libffi/src/mips/ffitarget.h +1 -1
  108. data/ext/ffi_c/libffi/src/mips/o32.S +2 -0
  109. data/ext/ffi_c/libffi/src/moxie/ffi.c +1 -1
  110. data/ext/ffi_c/libffi/src/pa/ffi.c +46 -91
  111. data/ext/ffi_c/libffi/src/pa/ffitarget.h +1 -6
  112. data/ext/ffi_c/libffi/src/pa/hpux32.S +4 -2
  113. data/ext/ffi_c/libffi/src/pa/linux.S +27 -4
  114. data/ext/ffi_c/libffi/src/powerpc/ffi.c +6 -4
  115. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +13 -1
  116. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +211 -32
  117. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +18 -7
  118. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +10 -4
  119. data/ext/ffi_c/libffi/src/powerpc/linux64.S +91 -28
  120. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +81 -5
  121. data/ext/ffi_c/libffi/src/powerpc/sysv.S +5 -7
  122. data/ext/ffi_c/libffi/src/prep_cif.c +4 -2
  123. data/ext/ffi_c/libffi/src/riscv/ffi.c +42 -6
  124. data/ext/ffi_c/libffi/src/riscv/ffitarget.h +1 -0
  125. data/ext/ffi_c/libffi/src/riscv/sysv.S +86 -7
  126. data/ext/ffi_c/libffi/src/x86/ffi.c +29 -12
  127. data/ext/ffi_c/libffi/src/x86/ffi64.c +22 -11
  128. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -2
  129. data/ext/ffi_c/libffi/src/x86/ffiw64.c +20 -10
  130. data/ext/ffi_c/libffi/src/x86/sysv.S +105 -10
  131. data/ext/ffi_c/libffi/src/x86/sysv_intel.S +995 -0
  132. data/ext/ffi_c/libffi/src/x86/unix64.S +100 -4
  133. data/ext/ffi_c/libffi/src/x86/win64.S +12 -3
  134. data/ext/ffi_c/libffi/src/x86/win64_intel.S +3 -2
  135. data/ext/ffi_c/libffi/testsuite/Makefile.am +114 -109
  136. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +32 -8
  137. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/bhaible.exp +7 -2
  138. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-call.c +4 -4
  139. data/ext/ffi_c/libffi/testsuite/libffi.bhaible/test-callback.c +2 -2
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +12 -1
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +9 -8
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +1 -1
  143. data/ext/ffi_c/libffi/testsuite/libffi.closures/closure.exp +67 -0
  144. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn0.c +0 -0
  145. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn1.c +0 -0
  146. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn2.c +0 -0
  147. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn3.c +0 -0
  148. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn4.c +0 -0
  149. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn5.c +0 -0
  150. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_fn6.c +0 -0
  151. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_loc_fn0.c +0 -0
  152. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/closure_simple.c +0 -0
  153. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_12byte.c +0 -0
  154. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_16byte.c +0 -0
  155. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_18byte.c +0 -0
  156. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_19byte.c +0 -0
  157. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_1_1byte.c +0 -0
  158. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte.c +0 -0
  159. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_20byte1.c +0 -0
  160. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_24byte.c +0 -0
  161. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_2byte.c +0 -0
  162. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3_1byte.c +0 -0
  163. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte1.c +0 -0
  164. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3byte2.c +0 -0
  165. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_3float.c +0 -0
  166. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4_1byte.c +0 -0
  167. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_4byte.c +0 -0
  168. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5_1_byte.c +0 -0
  169. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_5byte.c +0 -0
  170. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_64byte.c +0 -0
  171. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6_1_byte.c +0 -0
  172. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_6byte.c +0 -0
  173. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7_1_byte.c +0 -0
  174. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_7byte.c +0 -0
  175. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_8byte.c +0 -0
  176. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte1.c +0 -0
  177. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_9byte2.c +0 -0
  178. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_double.c +0 -0
  179. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_float.c +0 -0
  180. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble.c +0 -0
  181. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split.c +0 -0
  182. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_longdouble_split2.c +0 -0
  183. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_pointer.c +0 -0
  184. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint16.c +0 -0
  185. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint32.c +0 -0
  186. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_sint64.c +0 -0
  187. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint16.c +0 -0
  188. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint32.c +0 -0
  189. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_align_uint64.c +0 -0
  190. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_dbls_struct.c +0 -0
  191. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double.c +0 -0
  192. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_double_va.c +0 -0
  193. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_float.c +0 -0
  194. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble.c +0 -0
  195. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_longdouble_va.c +0 -0
  196. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_args.c +0 -0
  197. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_many_mixed_float_double.c +0 -0
  198. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_schar.c +0 -0
  199. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshort.c +0 -0
  200. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_sshortchar.c +0 -0
  201. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_uchar.c +0 -0
  202. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushort.c +0 -0
  203. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_multi_ushortchar.c +0 -0
  204. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer.c +0 -0
  205. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_pointer_stack.c +0 -0
  206. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_schar.c +0 -0
  207. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sint.c +0 -0
  208. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_sshort.c +0 -0
  209. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_struct_va1.c +0 -0
  210. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar.c +0 -0
  211. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uchar_va.c +0 -0
  212. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint.c +0 -0
  213. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_uint_va.c +0 -0
  214. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulong_va.c +0 -0
  215. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ulonglong.c +0 -0
  216. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort.c +0 -0
  217. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/cls_ushort_va.c +0 -0
  218. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/err_bad_abi.c +0 -0
  219. data/ext/ffi_c/libffi/testsuite/libffi.closures/ffitest.h +138 -0
  220. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/huge_struct.c +3 -1
  221. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct.c +0 -0
  222. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct1.c +0 -0
  223. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct10.c +0 -0
  224. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct11.c +0 -0
  225. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct2.c +0 -0
  226. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct3.c +0 -0
  227. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct4.c +0 -0
  228. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct5.c +0 -0
  229. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct6.c +0 -0
  230. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct7.c +0 -0
  231. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct8.c +0 -0
  232. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/nested_struct9.c +0 -0
  233. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/problem1.c +0 -0
  234. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large.c +0 -0
  235. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_large2.c +0 -0
  236. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium.c +0 -0
  237. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/stret_medium2.c +0 -0
  238. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/testclosure.c +0 -0
  239. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest.cc +0 -0
  240. data/ext/ffi_c/libffi/testsuite/{libffi.call → libffi.closures}/unwindtest_ffi_call.cc +0 -0
  241. data/ext/ffi_c/rbffi.h +0 -2
  242. data/ffi.gemspec +13 -6
  243. data/lib/ffi.rb +10 -2
  244. data/lib/ffi/abstract_memory.rb +44 -0
  245. data/lib/ffi/autopointer.rb +1 -1
  246. data/lib/ffi/data_converter.rb +67 -0
  247. data/lib/ffi/ffi.rb +3 -0
  248. data/lib/ffi/io.rb +3 -3
  249. data/lib/ffi/library.rb +12 -8
  250. data/lib/ffi/managedstruct.rb +2 -2
  251. data/lib/ffi/platform.rb +34 -10
  252. data/lib/ffi/platform/aarch64-darwin/types.conf +130 -0
  253. data/lib/ffi/platform/aarch64-freebsd/types.conf +128 -0
  254. data/lib/ffi/platform/aarch64-freebsd12/types.conf +128 -0
  255. data/lib/ffi/platform/aarch64-linux/types.conf +81 -81
  256. data/lib/ffi/platform/aarch64-openbsd/types.conf +134 -0
  257. data/lib/ffi/platform/arm-freebsd/types.conf +152 -0
  258. data/lib/ffi/platform/arm-freebsd12/types.conf +152 -0
  259. data/lib/ffi/platform/arm-linux/types.conf +110 -82
  260. data/lib/ffi/platform/i386-cygwin/types.conf +1 -1
  261. data/lib/ffi/platform/i386-darwin/types.conf +63 -63
  262. data/lib/ffi/platform/i386-freebsd/types.conf +89 -89
  263. data/lib/ffi/platform/i386-freebsd12/types.conf +152 -0
  264. data/lib/ffi/platform/i386-gnu/types.conf +84 -84
  265. data/lib/ffi/platform/i386-linux/types.conf +77 -77
  266. data/lib/ffi/platform/i386-netbsd/types.conf +87 -87
  267. data/lib/ffi/platform/i386-openbsd/types.conf +89 -89
  268. data/lib/ffi/platform/i386-solaris/types.conf +96 -96
  269. data/lib/ffi/platform/i386-windows/types.conf +43 -96
  270. data/lib/ffi/platform/ia64-linux/types.conf +79 -79
  271. data/lib/ffi/platform/mips-linux/types.conf +79 -79
  272. data/lib/ffi/platform/mips64-linux/types.conf +81 -81
  273. data/lib/ffi/platform/mips64el-linux/types.conf +81 -81
  274. data/lib/ffi/platform/mipsel-linux/types.conf +79 -79
  275. data/lib/ffi/platform/mipsisa32r6-linux/types.conf +79 -79
  276. data/lib/ffi/platform/mipsisa32r6el-linux/types.conf +79 -79
  277. data/lib/ffi/platform/mipsisa64r6-linux/types.conf +81 -81
  278. data/lib/ffi/platform/mipsisa64r6el-linux/types.conf +81 -81
  279. data/lib/ffi/platform/powerpc-aix/types.conf +155 -155
  280. data/lib/ffi/platform/powerpc-darwin/types.conf +63 -63
  281. data/lib/ffi/platform/powerpc-linux/types.conf +108 -78
  282. data/lib/ffi/platform/powerpc-openbsd/types.conf +156 -0
  283. data/lib/ffi/platform/powerpc64-linux/types.conf +81 -81
  284. data/lib/ffi/platform/powerpc64le-linux/types.conf +100 -0
  285. data/lib/ffi/platform/riscv64-linux/types.conf +104 -0
  286. data/lib/ffi/platform/s390-linux/types.conf +79 -79
  287. data/lib/ffi/platform/s390x-linux/types.conf +79 -79
  288. data/lib/ffi/platform/sparc-linux/types.conf +79 -79
  289. data/lib/ffi/platform/sparc-solaris/types.conf +103 -103
  290. data/lib/ffi/platform/sparc64-linux/types.conf +79 -79
  291. data/lib/ffi/platform/sparcv9-openbsd/types.conf +156 -0
  292. data/lib/ffi/platform/sparcv9-solaris/types.conf +103 -103
  293. data/lib/ffi/platform/x86_64-cygwin/types.conf +1 -1
  294. data/lib/ffi/platform/x86_64-darwin/types.conf +88 -84
  295. data/lib/ffi/platform/x86_64-dragonflybsd/types.conf +130 -0
  296. data/lib/ffi/platform/x86_64-freebsd/types.conf +90 -90
  297. data/lib/ffi/platform/x86_64-freebsd12/types.conf +158 -0
  298. data/lib/ffi/platform/x86_64-haiku/types.conf +117 -0
  299. data/lib/ffi/platform/x86_64-linux/types.conf +107 -77
  300. data/lib/ffi/platform/x86_64-msys/types.conf +119 -0
  301. data/lib/ffi/platform/x86_64-netbsd/types.conf +89 -89
  302. data/lib/ffi/platform/x86_64-openbsd/types.conf +86 -86
  303. data/lib/ffi/platform/x86_64-solaris/types.conf +96 -96
  304. data/lib/ffi/platform/x86_64-windows/types.conf +42 -110
  305. data/lib/ffi/pointer.rb +26 -20
  306. data/lib/ffi/struct.rb +13 -68
  307. data/lib/ffi/struct_by_reference.rb +72 -0
  308. data/lib/ffi/struct_layout.rb +96 -0
  309. data/lib/ffi/tools/const_generator.rb +5 -4
  310. data/lib/ffi/tools/generator.rb +47 -2
  311. data/lib/ffi/tools/generator_task.rb +13 -17
  312. data/lib/ffi/tools/struct_generator.rb +4 -4
  313. data/lib/ffi/tools/types_generator.rb +7 -4
  314. data/lib/ffi/types.rb +1 -1
  315. data/lib/ffi/variadic.rb +1 -10
  316. data/lib/ffi/version.rb +1 -1
  317. data/rakelib/ffi_gem_helper.rb +65 -0
  318. data/samples/getlogin.rb +1 -1
  319. data/samples/getpid.rb +1 -1
  320. data/samples/gettimeofday.rb +8 -8
  321. data/samples/hello.rb +2 -1
  322. data/samples/inotify.rb +1 -1
  323. data/samples/pty.rb +1 -2
  324. data/samples/qsort.rb +0 -1
  325. metadata +160 -122
  326. data/.gitignore +0 -22
  327. data/.gitmodules +0 -3
  328. data/.travis.yml +0 -52
  329. data/.yardopts +0 -5
  330. data/appveyor.yml +0 -22
  331. data/ext/ffi_c/DataConverter.c +0 -91
  332. data/ext/ffi_c/StructByReference.c +0 -190
  333. data/ext/ffi_c/StructByReference.h +0 -50
  334. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  335. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  336. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  337. data/ext/ffi_c/win32/stdbool.h +0 -8
  338. data/ext/ffi_c/win32/stdint.h +0 -201
  339. data/samples/sample_helper.rb +0 -6
@@ -129,7 +129,9 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
129
129
  cif->rtype = rtype;
130
130
 
131
131
  cif->flags = 0;
132
-
132
+ #if (defined(_M_ARM64) || defined(__aarch64__)) && defined(_WIN32)
133
+ cif->is_variadic = isvariadic;
134
+ #endif
133
135
  #if HAVE_LONG_DOUBLE_VARIANT
134
136
  ffi_prep_types (abi);
135
137
  #endif
@@ -199,7 +201,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
199
201
  bytes = 6*4;
200
202
  #endif
201
203
 
202
- bytes += STACK_ARG_SIZE((*ptr)->size);
204
+ bytes += (unsigned int)STACK_ARG_SIZE((*ptr)->size);
203
205
  }
204
206
  #endif
205
207
  }
@@ -324,9 +324,12 @@ ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, unsig
324
324
  }
325
325
 
326
326
  /* Low level routine for calling functions */
327
- extern void ffi_call_asm(void *stack, struct call_context *regs, void (*fn)(void)) FFI_HIDDEN;
327
+ extern void ffi_call_asm (void *stack, struct call_context *regs,
328
+ void (*fn) (void), void *closure) FFI_HIDDEN;
328
329
 
329
- void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
330
+ static void
331
+ ffi_call_int (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue,
332
+ void *closure)
330
333
  {
331
334
  /* this is a conservative estimate, assuming a complex return value and
332
335
  that all remaining arguments are long long / __int128 */
@@ -366,13 +369,26 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
366
369
  for (i = 0; i < cif->nargs; i++)
367
370
  marshal(&cb, cif->arg_types[i], i >= cif->riscv_nfixedargs, avalue[i]);
368
371
 
369
- ffi_call_asm((void*)alloc_base, cb.aregs, fn);
372
+ ffi_call_asm ((void *) alloc_base, cb.aregs, fn, closure);
370
373
 
371
374
  cb.used_float = cb.used_integer = 0;
372
375
  if (!return_by_ref && rvalue)
373
376
  unmarshal(&cb, cif->rtype, 0, rvalue);
374
377
  }
375
378
 
379
+ void
380
+ ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
381
+ {
382
+ ffi_call_int(cif, fn, rvalue, avalue, NULL);
383
+ }
384
+
385
+ void
386
+ ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
387
+ void **avalue, void *closure)
388
+ {
389
+ ffi_call_int(cif, fn, rvalue, avalue, closure);
390
+ }
391
+
376
392
  extern void ffi_closure_asm(void) FFI_HIDDEN;
377
393
 
378
394
  ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void (*fun)(ffi_cif*,void*,void**,void*), void *user_data, void *codeloc)
@@ -406,11 +422,31 @@ ffi_status ffi_prep_closure_loc(ffi_closure *closure, ffi_cif *cif, void (*fun)(
406
422
  return FFI_OK;
407
423
  }
408
424
 
425
+ extern void ffi_go_closure_asm (void) FFI_HIDDEN;
426
+
427
+ ffi_status
428
+ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif,
429
+ void (*fun) (ffi_cif *, void *, void **, void *))
430
+ {
431
+ if (cif->abi <= FFI_FIRST_ABI || cif->abi >= FFI_LAST_ABI)
432
+ return FFI_BAD_ABI;
433
+
434
+ closure->tramp = (void *) ffi_go_closure_asm;
435
+ closure->cif = cif;
436
+ closure->fun = fun;
437
+
438
+ return FFI_OK;
439
+ }
440
+
409
441
  /* Called by the assembly code with aregs pointing to saved argument registers
410
442
  and stack pointing to the stacked arguments. Return values passed in
411
443
  registers will be reloaded from aregs. */
412
- void FFI_HIDDEN ffi_closure_inner(size_t *stack, call_context *aregs, ffi_closure *closure) {
413
- ffi_cif *cif = closure->cif;
444
+ void FFI_HIDDEN
445
+ ffi_closure_inner (ffi_cif *cif,
446
+ void (*fun) (ffi_cif *, void *, void **, void *),
447
+ void *user_data,
448
+ size_t *stack, call_context *aregs)
449
+ {
414
450
  void **avalue = alloca(cif->nargs * sizeof(void*));
415
451
  /* storage for arguments which will be copied by unmarshal(). We could
416
452
  theoretically avoid the copies in many cases and use at most 128 bytes
@@ -436,7 +472,7 @@ void FFI_HIDDEN ffi_closure_inner(size_t *stack, call_context *aregs, ffi_closur
436
472
  avalue[i] = unmarshal(&cb, cif->arg_types[i],
437
473
  i >= cif->riscv_nfixedargs, astorage + i*MAXCOPYARG);
438
474
 
439
- (closure->fun)(cif, rvalue, avalue, closure->user_data);
475
+ fun (cif, rvalue, avalue, user_data);
440
476
 
441
477
  if (!return_by_ref && cif->rtype->type != FFI_TYPE_VOID) {
442
478
  cb.used_integer = cb.used_float = 0;
@@ -59,6 +59,7 @@ typedef enum ffi_abi {
59
59
  /* ---- Definitions for closures ----------------------------------------- */
60
60
 
61
61
  #define FFI_CLOSURES 1
62
+ #define FFI_GO_CLOSURES 1
62
63
  #define FFI_TRAMPOLINE_SIZE 24
63
64
  #define FFI_NATIVE_RAW_API 0
64
65
  #define FFI_EXTRA_CIF_FIELDS unsigned riscv_nfixedargs; unsigned riscv_unused;
@@ -67,8 +67,8 @@
67
67
  intreg pad[rv32 ? 2 : 0];
68
68
  intreg save_fp, save_ra;
69
69
  }
70
- void ffi_call_asm(size_t *stackargs, struct call_context *regargs,
71
- void (*fn)(void));
70
+ void ffi_call_asm (size_t *stackargs, struct call_context *regargs,
71
+ void (*fn) (void), void *closure);
72
72
  */
73
73
 
74
74
  #define FRAME_LEN (8 * FLTS + 8 * PTRS + 16)
@@ -98,6 +98,7 @@ ffi_call_asm:
98
98
 
99
99
  # Load arguments
100
100
  mv t1, a2
101
+ mv t2, a3
101
102
 
102
103
  #if FLTS
103
104
  FLARG fa0, -FRAME_LEN+0*FLTS(fp)
@@ -145,8 +146,10 @@ ffi_call_asm:
145
146
 
146
147
  /*
147
148
  ffi_closure_asm. Expects address of the passed-in ffi_closure in t1.
148
- void ffi_closure_inner(size_t *stackargs, struct call_context *regargs,
149
- ffi_closure *closure);
149
+ void ffi_closure_inner (ffi_cif *cif,
150
+ void (*fun) (ffi_cif *, void *, void **, void *),
151
+ void *user_data,
152
+ size_t *stackargs, struct call_context *regargs)
150
153
  */
151
154
 
152
155
  .globl ffi_closure_asm
@@ -187,9 +190,11 @@ ffi_closure_asm:
187
190
  SARG a7, 8*FLTS+7*PTRS(sp)
188
191
 
189
192
  /* enter C */
190
- addi a0, sp, FRAME_LEN
191
- mv a1, sp
192
- mv a2, t1
193
+ LARG a0, FFI_TRAMPOLINE_SIZE+0*PTRS(t1)
194
+ LARG a1, FFI_TRAMPOLINE_SIZE+1*PTRS(t1)
195
+ LARG a2, FFI_TRAMPOLINE_SIZE+2*PTRS(t1)
196
+ addi a3, sp, FRAME_LEN
197
+ mv a4, sp
193
198
 
194
199
  call ffi_closure_inner
195
200
 
@@ -212,3 +217,77 @@ ffi_closure_asm:
212
217
  ret
213
218
  .cfi_endproc
214
219
  .size ffi_closure_asm, .-ffi_closure_asm
220
+
221
+ /*
222
+ ffi_go_closure_asm. Expects address of the passed-in ffi_go_closure in t2.
223
+ void ffi_closure_inner (ffi_cif *cif,
224
+ void (*fun) (ffi_cif *, void *, void **, void *),
225
+ void *user_data,
226
+ size_t *stackargs, struct call_context *regargs)
227
+ */
228
+
229
+ .globl ffi_go_closure_asm
230
+ .hidden ffi_go_closure_asm
231
+ .type ffi_go_closure_asm, @function
232
+ ffi_go_closure_asm:
233
+ .cfi_startproc
234
+
235
+ addi sp, sp, -FRAME_LEN
236
+ .cfi_def_cfa_offset FRAME_LEN
237
+
238
+ /* make a frame */
239
+ SARG fp, FRAME_LEN - 2*PTRS(sp)
240
+ .cfi_offset 8, -2*PTRS
241
+ SARG ra, FRAME_LEN - 1*PTRS(sp)
242
+ .cfi_offset 1, -1*PTRS
243
+ addi fp, sp, FRAME_LEN
244
+
245
+ /* save arguments */
246
+ #if FLTS
247
+ FSARG fa0, 0*FLTS(sp)
248
+ FSARG fa1, 1*FLTS(sp)
249
+ FSARG fa2, 2*FLTS(sp)
250
+ FSARG fa3, 3*FLTS(sp)
251
+ FSARG fa4, 4*FLTS(sp)
252
+ FSARG fa5, 5*FLTS(sp)
253
+ FSARG fa6, 6*FLTS(sp)
254
+ FSARG fa7, 7*FLTS(sp)
255
+ #endif
256
+
257
+ SARG a0, 8*FLTS+0*PTRS(sp)
258
+ SARG a1, 8*FLTS+1*PTRS(sp)
259
+ SARG a2, 8*FLTS+2*PTRS(sp)
260
+ SARG a3, 8*FLTS+3*PTRS(sp)
261
+ SARG a4, 8*FLTS+4*PTRS(sp)
262
+ SARG a5, 8*FLTS+5*PTRS(sp)
263
+ SARG a6, 8*FLTS+6*PTRS(sp)
264
+ SARG a7, 8*FLTS+7*PTRS(sp)
265
+
266
+ /* enter C */
267
+ LARG a0, 1*PTRS(t2)
268
+ LARG a1, 2*PTRS(t2)
269
+ mv a2, t2
270
+ addi a3, sp, FRAME_LEN
271
+ mv a4, sp
272
+
273
+ call ffi_closure_inner
274
+
275
+ /* return values */
276
+ #if FLTS
277
+ FLARG fa0, 0*FLTS(sp)
278
+ FLARG fa1, 1*FLTS(sp)
279
+ #endif
280
+
281
+ LARG a0, 8*FLTS+0*PTRS(sp)
282
+ LARG a1, 8*FLTS+1*PTRS(sp)
283
+
284
+ /* restore and return */
285
+ LARG ra, FRAME_LEN-1*PTRS(sp)
286
+ .cfi_restore 1
287
+ LARG fp, FRAME_LEN-2*PTRS(sp)
288
+ .cfi_restore 8
289
+ addi sp, sp, FRAME_LEN
290
+ .cfi_def_cfa_offset 0
291
+ ret
292
+ .cfi_endproc
293
+ .size ffi_go_closure_asm, .-ffi_go_closure_asm
@@ -29,7 +29,7 @@
29
29
  DEALINGS IN THE SOFTWARE.
30
30
  ----------------------------------------------------------------------- */
31
31
 
32
- #ifndef __x86_64__
32
+ #if defined(__i386__) || defined(_M_IX86)
33
33
  #include <ffi.h>
34
34
  #include <ffi_common.h>
35
35
  #include <stdint.h>
@@ -51,6 +51,13 @@
51
51
  # define __declspec(x) __attribute__((x))
52
52
  #endif
53
53
 
54
+ #if defined(_MSC_VER) && defined(_M_IX86)
55
+ /* Stack is not 16-byte aligned on Windows. */
56
+ #define STACK_ALIGN(bytes) (bytes)
57
+ #else
58
+ #define STACK_ALIGN(bytes) FFI_ALIGN (bytes, 16)
59
+ #endif
60
+
54
61
  /* Perform machine dependent cif processing. */
55
62
  ffi_status FFI_HIDDEN
56
63
  ffi_prep_cif_machdep(ffi_cif *cif)
@@ -177,7 +184,7 @@ ffi_prep_cif_machdep(ffi_cif *cif)
177
184
  bytes = FFI_ALIGN (bytes, t->alignment);
178
185
  bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG);
179
186
  }
180
- cif->bytes = FFI_ALIGN (bytes, 16);
187
+ cif->bytes = bytes;
181
188
 
182
189
  return FFI_OK;
183
190
  }
@@ -285,7 +292,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
285
292
  }
286
293
  }
287
294
 
288
- bytes = cif->bytes;
295
+ bytes = STACK_ALIGN (cif->bytes);
289
296
  stack = alloca(bytes + sizeof(*frame) + rsize);
290
297
  argp = (dir < 0 ? stack + bytes : stack);
291
298
  frame = (struct call_frame *)(stack + bytes);
@@ -346,7 +353,7 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
346
353
  size_t align = FFI_SIZEOF_ARG;
347
354
 
348
355
  /* Issue 434: For thiscall and fastcall, if the paramter passed
349
- as 64-bit integer or struct, all following integer paramters
356
+ as 64-bit integer or struct, all following integer parameters
350
357
  will be passed on stack. */
351
358
  if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
352
359
  && (t == FFI_TYPE_SINT64
@@ -390,12 +397,14 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
390
397
  ffi_call_int (cif, fn, rvalue, avalue, NULL);
391
398
  }
392
399
 
400
+ #ifdef FFI_GO_CLOSURES
393
401
  void
394
402
  ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
395
403
  void **avalue, void *closure)
396
404
  {
397
405
  ffi_call_int (cif, fn, rvalue, avalue, closure);
398
406
  }
407
+ #endif
399
408
 
400
409
  /** private members **/
401
410
 
@@ -429,7 +438,7 @@ ffi_closure_inner (struct closure_frame *frame, char *stack)
429
438
  rvalue = frame->rettemp;
430
439
  pabi = &abi_params[cabi];
431
440
  dir = pabi->dir;
432
- argp = (dir < 0 ? stack + cif->bytes : stack);
441
+ argp = (dir < 0 ? stack + STACK_ALIGN (cif->bytes) : stack);
433
442
 
434
443
  switch (flags)
435
444
  {
@@ -485,7 +494,7 @@ ffi_closure_inner (struct closure_frame *frame, char *stack)
485
494
  align = 16;
486
495
 
487
496
  /* Issue 434: For thiscall and fastcall, if the paramter passed
488
- as 64-bit integer or struct, all following integer paramters
497
+ as 64-bit integer or struct, all following integer parameters
489
498
  will be passed on stack. */
490
499
  if ((cabi == FFI_THISCALL || cabi == FFI_FASTCALL)
491
500
  && (t == FFI_TYPE_SINT64
@@ -545,17 +554,21 @@ ffi_prep_closure_loc (ffi_closure* closure,
545
554
  case FFI_REGISTER:
546
555
  dest = ffi_closure_REGISTER;
547
556
  op = 0x68; /* pushl imm */
557
+ break;
548
558
  default:
549
559
  return FFI_BAD_ABI;
550
560
  }
551
561
 
562
+ /* endbr32. */
563
+ *(UINT32 *) tramp = 0xfb1e0ff3;
564
+
552
565
  /* movl or pushl immediate. */
553
- tramp[0] = op;
554
- *(void **)(tramp + 1) = codeloc;
566
+ tramp[4] = op;
567
+ *(void **)(tramp + 5) = codeloc;
555
568
 
556
569
  /* jmp dest */
557
- tramp[5] = 0xe9;
558
- *(unsigned *)(tramp + 6) = (unsigned)dest - ((unsigned)codeloc + 10);
570
+ tramp[9] = 0xe9;
571
+ *(unsigned *)(tramp + 10) = (unsigned)dest - ((unsigned)codeloc + 14);
559
572
 
560
573
  closure->cif = cif;
561
574
  closure->fun = fun;
@@ -564,6 +577,8 @@ ffi_prep_closure_loc (ffi_closure* closure,
564
577
  return FFI_OK;
565
578
  }
566
579
 
580
+ #ifdef FFI_GO_CLOSURES
581
+
567
582
  void FFI_HIDDEN ffi_go_closure_EAX(void);
568
583
  void FFI_HIDDEN ffi_go_closure_ECX(void);
569
584
  void FFI_HIDDEN ffi_go_closure_STDCALL(void);
@@ -600,6 +615,8 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
600
615
  return FFI_OK;
601
616
  }
602
617
 
618
+ #endif /* FFI_GO_CLOSURES */
619
+
603
620
  /* ------- Native raw API support -------------------------------- */
604
621
 
605
622
  #if !FFI_NO_RAW_API
@@ -692,7 +709,7 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
692
709
  }
693
710
  }
694
711
 
695
- bytes = cif->bytes;
712
+ bytes = STACK_ALIGN (cif->bytes);
696
713
  argp = stack =
697
714
  (void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16);
698
715
  frame = (struct call_frame *)(stack + bytes);
@@ -750,4 +767,4 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
750
767
  ffi_call_i386 (frame, stack);
751
768
  }
752
769
  #endif /* !FFI_NO_RAW_API */
753
- #endif /* !__x86_64__ */
770
+ #endif /* __i386__ */
@@ -282,7 +282,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
282
282
 
283
283
  /* The X86_64_SSEUP_CLASS should be always preceded by
284
284
  X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */
285
- if (classes[i] == X86_64_SSEUP_CLASS
285
+ if (i > 1 && classes[i] == X86_64_SSEUP_CLASS
286
286
  && classes[i - 1] != X86_64_SSE_CLASS
287
287
  && classes[i - 1] != X86_64_SSEUP_CLASS)
288
288
  {
@@ -293,7 +293,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
293
293
 
294
294
  /* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
295
295
  everything should be passed in memory. */
296
- if (classes[i] == X86_64_X87UP_CLASS
296
+ if (i > 1 && classes[i] == X86_64_X87UP_CLASS
297
297
  && (classes[i - 1] != X86_64_X87_CLASS))
298
298
  {
299
299
  /* The first one should never be X86_64_X87UP_CLASS. */
@@ -394,7 +394,7 @@ extern ffi_status
394
394
  ffi_prep_cif_machdep_efi64(ffi_cif *cif);
395
395
  #endif
396
396
 
397
- ffi_status
397
+ ffi_status FFI_HIDDEN
398
398
  ffi_prep_cif_machdep (ffi_cif *cif)
399
399
  {
400
400
  int gprcount, ssecount, i, avn, ngpr, nsse;
@@ -451,9 +451,11 @@ ffi_prep_cif_machdep (ffi_cif *cif)
451
451
  case FFI_TYPE_DOUBLE:
452
452
  flags = UNIX64_RET_XMM64;
453
453
  break;
454
+ #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
454
455
  case FFI_TYPE_LONGDOUBLE:
455
456
  flags = UNIX64_RET_X87;
456
457
  break;
458
+ #endif
457
459
  case FFI_TYPE_STRUCT:
458
460
  n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
459
461
  if (n == 0)
@@ -686,6 +688,8 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
686
688
  ffi_call_int (cif, fn, rvalue, avalue, NULL);
687
689
  }
688
690
 
691
+ #ifdef FFI_GO_CLOSURES
692
+
689
693
  #ifndef __ILP32__
690
694
  extern void
691
695
  ffi_call_go_efi64(ffi_cif *cif, void (*fn)(void), void *rvalue,
@@ -706,6 +710,7 @@ ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
706
710
  ffi_call_int (cif, fn, rvalue, avalue, closure);
707
711
  }
708
712
 
713
+ #endif /* FFI_GO_CLOSURES */
709
714
 
710
715
  extern void ffi_closure_unix64(void) FFI_HIDDEN;
711
716
  extern void ffi_closure_unix64_sse(void) FFI_HIDDEN;
@@ -726,13 +731,15 @@ ffi_prep_closure_loc (ffi_closure* closure,
726
731
  void *user_data,
727
732
  void *codeloc)
728
733
  {
729
- static const unsigned char trampoline[16] = {
730
- /* leaq -0x7(%rip),%r10 # 0x0 */
731
- 0x4c, 0x8d, 0x15, 0xf9, 0xff, 0xff, 0xff,
732
- /* jmpq *0x3(%rip) # 0x10 */
733
- 0xff, 0x25, 0x03, 0x00, 0x00, 0x00,
734
- /* nopl (%rax) */
735
- 0x0f, 0x1f, 0x00
734
+ static const unsigned char trampoline[24] = {
735
+ /* endbr64 */
736
+ 0xf3, 0x0f, 0x1e, 0xfa,
737
+ /* leaq -0xb(%rip),%r10 # 0x0 */
738
+ 0x4c, 0x8d, 0x15, 0xf5, 0xff, 0xff, 0xff,
739
+ /* jmpq *0x7(%rip) # 0x18 */
740
+ 0xff, 0x25, 0x07, 0x00, 0x00, 0x00,
741
+ /* nopl 0(%rax) */
742
+ 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00
736
743
  };
737
744
  void (*dest)(void);
738
745
  char *tramp = closure->tramp;
@@ -750,7 +757,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
750
757
  dest = ffi_closure_unix64;
751
758
 
752
759
  memcpy (tramp, trampoline, sizeof(trampoline));
753
- *(UINT64 *)(tramp + 16) = (uintptr_t)dest;
760
+ *(UINT64 *)(tramp + sizeof (trampoline)) = (uintptr_t)dest;
754
761
 
755
762
  closure->cif = cif;
756
763
  closure->fun = fun;
@@ -852,6 +859,8 @@ ffi_closure_unix64_inner(ffi_cif *cif,
852
859
  return flags;
853
860
  }
854
861
 
862
+ #ifdef FFI_GO_CLOSURES
863
+
855
864
  extern void ffi_go_closure_unix64(void) FFI_HIDDEN;
856
865
  extern void ffi_go_closure_unix64_sse(void) FFI_HIDDEN;
857
866
 
@@ -881,4 +890,6 @@ ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
881
890
  return FFI_OK;
882
891
  }
883
892
 
893
+ #endif /* FFI_GO_CLOSURES */
894
+
884
895
  #endif /* __x86_64__ */