remogatto-ffi 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. data/LICENSE +51 -0
  2. data/README.rdoc +69 -0
  3. data/Rakefile +144 -0
  4. data/ext/ffi_c/AbstractMemory.c +489 -0
  5. data/ext/ffi_c/AbstractMemory.h +160 -0
  6. data/ext/ffi_c/ArrayType.c +129 -0
  7. data/ext/ffi_c/ArrayType.h +58 -0
  8. data/ext/ffi_c/AutoPointer.c +61 -0
  9. data/ext/ffi_c/AutoPointer.h +18 -0
  10. data/ext/ffi_c/Buffer.c +187 -0
  11. data/ext/ffi_c/Call.c +431 -0
  12. data/ext/ffi_c/Call.h +77 -0
  13. data/ext/ffi_c/DynamicLibrary.c +216 -0
  14. data/ext/ffi_c/DynamicLibrary.h +22 -0
  15. data/ext/ffi_c/Function.c +498 -0
  16. data/ext/ffi_c/Function.h +73 -0
  17. data/ext/ffi_c/FunctionInfo.c +213 -0
  18. data/ext/ffi_c/LastError.c +159 -0
  19. data/ext/ffi_c/LastError.h +18 -0
  20. data/ext/ffi_c/MemoryPointer.c +178 -0
  21. data/ext/ffi_c/MemoryPointer.h +20 -0
  22. data/ext/ffi_c/MethodHandle.c +356 -0
  23. data/ext/ffi_c/MethodHandle.h +53 -0
  24. data/ext/ffi_c/Platform.c +59 -0
  25. data/ext/ffi_c/Platform.h +16 -0
  26. data/ext/ffi_c/Pointer.c +217 -0
  27. data/ext/ffi_c/Pointer.h +49 -0
  28. data/ext/ffi_c/Struct.c +770 -0
  29. data/ext/ffi_c/Struct.h +80 -0
  30. data/ext/ffi_c/StructByValue.c +140 -0
  31. data/ext/ffi_c/StructByValue.h +53 -0
  32. data/ext/ffi_c/StructLayout.c +450 -0
  33. data/ext/ffi_c/Type.c +329 -0
  34. data/ext/ffi_c/Type.h +57 -0
  35. data/ext/ffi_c/Types.c +103 -0
  36. data/ext/ffi_c/Types.h +85 -0
  37. data/ext/ffi_c/Variadic.c +260 -0
  38. data/ext/ffi_c/compat.h +72 -0
  39. data/ext/ffi_c/endian.h +40 -0
  40. data/ext/ffi_c/extconf.rb +34 -0
  41. data/ext/ffi_c/ffi.c +80 -0
  42. data/ext/ffi_c/libffi.bsd.mk +34 -0
  43. data/ext/ffi_c/libffi.darwin.mk +75 -0
  44. data/ext/ffi_c/libffi.gnu.mk +29 -0
  45. data/ext/ffi_c/libffi.mk +13 -0
  46. data/ext/ffi_c/libffi/ChangeLog +3243 -0
  47. data/ext/ffi_c/libffi/ChangeLog.libffi +347 -0
  48. data/ext/ffi_c/libffi/ChangeLog.libgcj +40 -0
  49. data/ext/ffi_c/libffi/ChangeLog.v1 +764 -0
  50. data/ext/ffi_c/libffi/LICENSE +21 -0
  51. data/ext/ffi_c/libffi/Makefile.am +177 -0
  52. data/ext/ffi_c/libffi/Makefile.in +1640 -0
  53. data/ext/ffi_c/libffi/README +328 -0
  54. data/ext/ffi_c/libffi/TODO +1 -0
  55. data/ext/ffi_c/libffi/acinclude.m4 +92 -0
  56. data/ext/ffi_c/libffi/aclocal.m4 +7516 -0
  57. data/ext/ffi_c/libffi/compile +142 -0
  58. data/ext/ffi_c/libffi/config.guess +1516 -0
  59. data/ext/ffi_c/libffi/config.sub +1626 -0
  60. data/ext/ffi_c/libffi/configure +24414 -0
  61. data/ext/ffi_c/libffi/configure.ac +365 -0
  62. data/ext/ffi_c/libffi/configure.host +11 -0
  63. data/ext/ffi_c/libffi/depcomp +584 -0
  64. data/ext/ffi_c/libffi/doc/libffi.info +533 -0
  65. data/ext/ffi_c/libffi/doc/libffi.texi +541 -0
  66. data/ext/ffi_c/libffi/doc/stamp-vti +4 -0
  67. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  68. data/ext/ffi_c/libffi/fficonfig.h.in +160 -0
  69. data/ext/ffi_c/libffi/include/Makefile.am +9 -0
  70. data/ext/ffi_c/libffi/include/Makefile.in +422 -0
  71. data/ext/ffi_c/libffi/include/ffi.h.in +393 -0
  72. data/ext/ffi_c/libffi/include/ffi_common.h +98 -0
  73. data/ext/ffi_c/libffi/install-sh +323 -0
  74. data/ext/ffi_c/libffi/libffi.pc.in +10 -0
  75. data/ext/ffi_c/libffi/libtool-version +29 -0
  76. data/ext/ffi_c/libffi/ltcf-c.sh +861 -0
  77. data/ext/ffi_c/libffi/ltcf-cxx.sh +1069 -0
  78. data/ext/ffi_c/libffi/ltcf-gcj.sh +700 -0
  79. data/ext/ffi_c/libffi/ltconfig +2862 -0
  80. data/ext/ffi_c/libffi/ltmain.sh +6930 -0
  81. data/ext/ffi_c/libffi/man/Makefile.am +8 -0
  82. data/ext/ffi_c/libffi/man/Makefile.in +395 -0
  83. data/ext/ffi_c/libffi/man/ffi.3 +31 -0
  84. data/ext/ffi_c/libffi/man/ffi_call.3 +103 -0
  85. data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +66 -0
  86. data/ext/ffi_c/libffi/mdate-sh +201 -0
  87. data/ext/ffi_c/libffi/missing +353 -0
  88. data/ext/ffi_c/libffi/mkinstalldirs +158 -0
  89. data/ext/ffi_c/libffi/src/alpha/ffi.c +284 -0
  90. data/ext/ffi_c/libffi/src/alpha/ffitarget.h +48 -0
  91. data/ext/ffi_c/libffi/src/alpha/osf.S +366 -0
  92. data/ext/ffi_c/libffi/src/arm/ffi.c +309 -0
  93. data/ext/ffi_c/libffi/src/arm/ffitarget.h +49 -0
  94. data/ext/ffi_c/libffi/src/arm/sysv.S +299 -0
  95. data/ext/ffi_c/libffi/src/closures.c +596 -0
  96. data/ext/ffi_c/libffi/src/cris/ffi.c +383 -0
  97. data/ext/ffi_c/libffi/src/cris/ffitarget.h +51 -0
  98. data/ext/ffi_c/libffi/src/cris/sysv.S +215 -0
  99. data/ext/ffi_c/libffi/src/debug.c +59 -0
  100. data/ext/ffi_c/libffi/src/dlmalloc.c +5099 -0
  101. data/ext/ffi_c/libffi/src/frv/eabi.S +128 -0
  102. data/ext/ffi_c/libffi/src/frv/ffi.c +292 -0
  103. data/ext/ffi_c/libffi/src/frv/ffitarget.h +61 -0
  104. data/ext/ffi_c/libffi/src/ia64/ffi.c +580 -0
  105. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +50 -0
  106. data/ext/ffi_c/libffi/src/ia64/ia64_flags.h +40 -0
  107. data/ext/ffi_c/libffi/src/ia64/unix.S +560 -0
  108. data/ext/ffi_c/libffi/src/java_raw_api.c +359 -0
  109. data/ext/ffi_c/libffi/src/m32r/ffi.c +232 -0
  110. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +48 -0
  111. data/ext/ffi_c/libffi/src/m32r/sysv.S +121 -0
  112. data/ext/ffi_c/libffi/src/m68k/ffi.c +278 -0
  113. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +49 -0
  114. data/ext/ffi_c/libffi/src/m68k/sysv.S +234 -0
  115. data/ext/ffi_c/libffi/src/mips/ffi.c +926 -0
  116. data/ext/ffi_c/libffi/src/mips/ffitarget.h +202 -0
  117. data/ext/ffi_c/libffi/src/mips/n32.S +534 -0
  118. data/ext/ffi_c/libffi/src/mips/o32.S +381 -0
  119. data/ext/ffi_c/libffi/src/pa/ffi.c +709 -0
  120. data/ext/ffi_c/libffi/src/pa/ffitarget.h +77 -0
  121. data/ext/ffi_c/libffi/src/pa/hpux32.S +368 -0
  122. data/ext/ffi_c/libffi/src/pa/linux.S +357 -0
  123. data/ext/ffi_c/libffi/src/powerpc/aix.S +225 -0
  124. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +247 -0
  125. data/ext/ffi_c/libffi/src/powerpc/asm.h +125 -0
  126. data/ext/ffi_c/libffi/src/powerpc/darwin.S +245 -0
  127. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +317 -0
  128. data/ext/ffi_c/libffi/src/powerpc/ffi.c +1429 -0
  129. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +800 -0
  130. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +118 -0
  131. data/ext/ffi_c/libffi/src/powerpc/linux64.S +187 -0
  132. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +236 -0
  133. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +327 -0
  134. data/ext/ffi_c/libffi/src/powerpc/sysv.S +230 -0
  135. data/ext/ffi_c/libffi/src/prep_cif.c +174 -0
  136. data/ext/ffi_c/libffi/src/raw_api.c +254 -0
  137. data/ext/ffi_c/libffi/src/s390/ffi.c +780 -0
  138. data/ext/ffi_c/libffi/src/s390/ffitarget.h +60 -0
  139. data/ext/ffi_c/libffi/src/s390/sysv.S +434 -0
  140. data/ext/ffi_c/libffi/src/sh/ffi.c +716 -0
  141. data/ext/ffi_c/libffi/src/sh/ffitarget.h +49 -0
  142. data/ext/ffi_c/libffi/src/sh/sysv.S +850 -0
  143. data/ext/ffi_c/libffi/src/sh64/ffi.c +453 -0
  144. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +53 -0
  145. data/ext/ffi_c/libffi/src/sh64/sysv.S +530 -0
  146. data/ext/ffi_c/libffi/src/sparc/ffi.c +610 -0
  147. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +66 -0
  148. data/ext/ffi_c/libffi/src/sparc/v8.S +272 -0
  149. data/ext/ffi_c/libffi/src/sparc/v9.S +307 -0
  150. data/ext/ffi_c/libffi/src/types.c +77 -0
  151. data/ext/ffi_c/libffi/src/x86/darwin.S +443 -0
  152. data/ext/ffi_c/libffi/src/x86/darwin64.S +416 -0
  153. data/ext/ffi_c/libffi/src/x86/ffi.c +475 -0
  154. data/ext/ffi_c/libffi/src/x86/ffi64.c +572 -0
  155. data/ext/ffi_c/libffi/src/x86/ffitarget.h +90 -0
  156. data/ext/ffi_c/libffi/src/x86/freebsd.S +458 -0
  157. data/ext/ffi_c/libffi/src/x86/sysv.S +437 -0
  158. data/ext/ffi_c/libffi/src/x86/unix64.S +418 -0
  159. data/ext/ffi_c/libffi/src/x86/win32.S +391 -0
  160. data/ext/ffi_c/libffi/testsuite/Makefile.am +71 -0
  161. data/ext/ffi_c/libffi/testsuite/Makefile.in +447 -0
  162. data/ext/ffi_c/libffi/testsuite/config/default.exp +1 -0
  163. data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +289 -0
  164. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +263 -0
  165. data/ext/ffi_c/libffi/testsuite/lib/wrapper.exp +45 -0
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +36 -0
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +97 -0
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +89 -0
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +89 -0
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +90 -0
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +97 -0
  172. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +99 -0
  173. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +98 -0
  174. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_stdcall.c +72 -0
  175. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +102 -0
  176. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +103 -0
  177. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +104 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +110 -0
  179. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +97 -0
  180. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +99 -0
  181. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +101 -0
  182. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +121 -0
  183. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +98 -0
  184. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +103 -0
  185. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +98 -0
  186. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +98 -0
  187. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +106 -0
  188. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +98 -0
  189. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +117 -0
  190. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +106 -0
  191. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +132 -0
  192. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +121 -0
  193. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +107 -0
  194. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +125 -0
  195. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +105 -0
  196. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +96 -0
  197. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +98 -0
  198. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +99 -0
  199. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +101 -0
  200. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +99 -0
  201. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +100 -0
  202. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +101 -0
  203. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +99 -0
  204. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +99 -0
  205. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +99 -0
  206. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +99 -0
  207. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +99 -0
  208. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +100 -0
  209. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +51 -0
  210. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +51 -0
  211. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +82 -0
  212. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +82 -0
  213. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +94 -0
  214. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +99 -0
  215. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +82 -0
  216. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +94 -0
  217. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +52 -0
  218. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +50 -0
  219. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +50 -0
  220. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +50 -0
  221. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +51 -0
  222. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +54 -0
  223. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +51 -0
  224. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +86 -0
  225. data/ext/ffi_c/libffi/testsuite/libffi.call/float.c +59 -0
  226. data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +58 -0
  227. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +57 -0
  228. data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +72 -0
  229. data/ext/ffi_c/libffi/testsuite/libffi.call/float4.c +62 -0
  230. data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +69 -0
  231. data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +63 -0
  232. data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +53 -0
  233. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +160 -0
  234. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +169 -0
  235. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +141 -0
  236. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +118 -0
  237. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +119 -0
  238. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +119 -0
  239. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +120 -0
  240. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +139 -0
  241. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +119 -0
  242. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +139 -0
  243. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +139 -0
  244. data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +98 -0
  245. data/ext/ffi_c/libffi/testsuite/libffi.call/promotion.c +59 -0
  246. data/ext/ffi_c/libffi/testsuite/libffi.call/pyobjc-tc.c +114 -0
  247. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +35 -0
  248. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl1.c +43 -0
  249. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl2.c +42 -0
  250. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl.c +35 -0
  251. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl1.c +36 -0
  252. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl2.c +49 -0
  253. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl3.c +42 -0
  254. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +34 -0
  255. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll.c +41 -0
  256. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +42 -0
  257. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +36 -0
  258. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +38 -0
  259. data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +38 -0
  260. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +38 -0
  261. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +44 -0
  262. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +44 -0
  263. data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +65 -0
  264. data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +67 -0
  265. data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +59 -0
  266. data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +63 -0
  267. data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +65 -0
  268. data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +64 -0
  269. data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +74 -0
  270. data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +80 -0
  271. data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +67 -0
  272. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +86 -0
  273. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +38 -0
  274. data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest.cc +123 -0
  275. data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest_ffi_call.cc +53 -0
  276. data/ext/ffi_c/libffi/texinfo.tex +7482 -0
  277. data/ext/ffi_c/rbffi.h +26 -0
  278. data/gen/Rakefile +12 -0
  279. data/lib/ffi.rb +11 -0
  280. data/lib/ffi/autopointer.rb +61 -0
  281. data/lib/ffi/buffer.rb +0 -0
  282. data/lib/ffi/callback.rb +10 -0
  283. data/lib/ffi/enum.rb +78 -0
  284. data/lib/ffi/errno.rb +8 -0
  285. data/lib/ffi/ffi.rb +99 -0
  286. data/lib/ffi/io.rb +21 -0
  287. data/lib/ffi/library.rb +218 -0
  288. data/lib/ffi/managedstruct.rb +55 -0
  289. data/lib/ffi/memorypointer.rb +73 -0
  290. data/lib/ffi/platform.rb +78 -0
  291. data/lib/ffi/pointer.rb +119 -0
  292. data/lib/ffi/struct.rb +164 -0
  293. data/lib/ffi/tools/const_generator.rb +177 -0
  294. data/lib/ffi/tools/generator.rb +58 -0
  295. data/lib/ffi/tools/generator_task.rb +35 -0
  296. data/lib/ffi/tools/struct_generator.rb +194 -0
  297. data/lib/ffi/tools/types_generator.rb +123 -0
  298. data/lib/ffi/types.rb +153 -0
  299. data/lib/ffi/union.rb +12 -0
  300. data/lib/ffi/variadic.rb +25 -0
  301. data/spec/ffi/bool_spec.rb +24 -0
  302. data/spec/ffi/buffer_spec.rb +202 -0
  303. data/spec/ffi/callback_spec.rb +591 -0
  304. data/spec/ffi/enum_spec.rb +164 -0
  305. data/spec/ffi/errno_spec.rb +13 -0
  306. data/spec/ffi/function_spec.rb +47 -0
  307. data/spec/ffi/library_spec.rb +144 -0
  308. data/spec/ffi/managed_struct_spec.rb +56 -0
  309. data/spec/ffi/number_spec.rb +231 -0
  310. data/spec/ffi/pointer_spec.rb +195 -0
  311. data/spec/ffi/rbx/attach_function_spec.rb +27 -0
  312. data/spec/ffi/rbx/memory_pointer_spec.rb +102 -0
  313. data/spec/ffi/rbx/spec_helper.rb +1 -0
  314. data/spec/ffi/rbx/struct_spec.rb +13 -0
  315. data/spec/ffi/spec_helper.rb +17 -0
  316. data/spec/ffi/string_spec.rb +103 -0
  317. data/spec/ffi/struct_callback_spec.rb +62 -0
  318. data/spec/ffi/struct_initialize_spec.rb +30 -0
  319. data/spec/ffi/struct_spec.rb +529 -0
  320. data/spec/ffi/typedef_spec.rb +48 -0
  321. data/spec/ffi/union_spec.rb +60 -0
  322. data/spec/ffi/variadic_spec.rb +84 -0
  323. data/spec/spec.opts +4 -0
  324. metadata +432 -0
@@ -0,0 +1,572 @@
1
+ /* -----------------------------------------------------------------------
2
+ ffi.c - Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
3
+ Copyright (c) 2008 Red Hat, Inc.
4
+
5
+ x86-64 Foreign Function Interface
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ ``Software''), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included
16
+ in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
+ DEALINGS IN THE SOFTWARE.
26
+ ----------------------------------------------------------------------- */
27
+
28
+ #include <ffi.h>
29
+ #include <ffi_common.h>
30
+
31
+ #include <stdlib.h>
32
+ #include <stdarg.h>
33
+
34
+ #ifdef __x86_64__
35
+
36
+ #define MAX_GPR_REGS 6
37
+ #define MAX_SSE_REGS 8
38
+
39
+ struct register_args
40
+ {
41
+ /* Registers for argument passing. */
42
+ UINT64 gpr[MAX_GPR_REGS];
43
+ __int128_t sse[MAX_SSE_REGS];
44
+ };
45
+
46
+ extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
47
+ void *raddr, void (*fnaddr)(void), unsigned ssecount);
48
+
49
+ /* All reference to register classes here is identical to the code in
50
+ gcc/config/i386/i386.c. Do *not* change one without the other. */
51
+
52
+ /* Register class used for passing given 64bit part of the argument.
53
+ These represent classes as documented by the PS ABI, with the exception
54
+ of SSESF, SSEDF classes, that are basically SSE class, just gcc will
55
+ use SF or DFmode move instead of DImode to avoid reformating penalties.
56
+
57
+ Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
58
+ whenever possible (upper half does contain padding). */
59
+ enum x86_64_reg_class
60
+ {
61
+ X86_64_NO_CLASS,
62
+ X86_64_INTEGER_CLASS,
63
+ X86_64_INTEGERSI_CLASS,
64
+ X86_64_SSE_CLASS,
65
+ X86_64_SSESF_CLASS,
66
+ X86_64_SSEDF_CLASS,
67
+ X86_64_SSEUP_CLASS,
68
+ X86_64_X87_CLASS,
69
+ X86_64_X87UP_CLASS,
70
+ X86_64_COMPLEX_X87_CLASS,
71
+ X86_64_MEMORY_CLASS
72
+ };
73
+
74
+ #define MAX_CLASSES 4
75
+
76
+ #define SSE_CLASS_P(X) ((X) >= X86_64_SSE_CLASS && X <= X86_64_SSEUP_CLASS)
77
+
78
+ /* x86-64 register passing implementation. See x86-64 ABI for details. Goal
79
+ of this code is to classify each 8bytes of incoming argument by the register
80
+ class and assign registers accordingly. */
81
+
82
+ /* Return the union class of CLASS1 and CLASS2.
83
+ See the x86-64 PS ABI for details. */
84
+
85
+ static enum x86_64_reg_class
86
+ merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
87
+ {
88
+ /* Rule #1: If both classes are equal, this is the resulting class. */
89
+ if (class1 == class2)
90
+ return class1;
91
+
92
+ /* Rule #2: If one of the classes is NO_CLASS, the resulting class is
93
+ the other class. */
94
+ if (class1 == X86_64_NO_CLASS)
95
+ return class2;
96
+ if (class2 == X86_64_NO_CLASS)
97
+ return class1;
98
+
99
+ /* Rule #3: If one of the classes is MEMORY, the result is MEMORY. */
100
+ if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS)
101
+ return X86_64_MEMORY_CLASS;
102
+
103
+ /* Rule #4: If one of the classes is INTEGER, the result is INTEGER. */
104
+ if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS)
105
+ || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS))
106
+ return X86_64_INTEGERSI_CLASS;
107
+ if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS
108
+ || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS)
109
+ return X86_64_INTEGER_CLASS;
110
+
111
+ /* Rule #5: If one of the classes is X87, X87UP, or COMPLEX_X87 class,
112
+ MEMORY is used. */
113
+ if (class1 == X86_64_X87_CLASS
114
+ || class1 == X86_64_X87UP_CLASS
115
+ || class1 == X86_64_COMPLEX_X87_CLASS
116
+ || class2 == X86_64_X87_CLASS
117
+ || class2 == X86_64_X87UP_CLASS
118
+ || class2 == X86_64_COMPLEX_X87_CLASS)
119
+ return X86_64_MEMORY_CLASS;
120
+
121
+ /* Rule #6: Otherwise class SSE is used. */
122
+ return X86_64_SSE_CLASS;
123
+ }
124
+
125
+ /* Classify the argument of type TYPE and mode MODE.
126
+ CLASSES will be filled by the register class used to pass each word
127
+ of the operand. The number of words is returned. In case the parameter
128
+ should be passed in memory, 0 is returned. As a special case for zero
129
+ sized containers, classes[0] will be NO_CLASS and 1 is returned.
130
+
131
+ See the x86-64 PS ABI for details.
132
+ */
133
+ static int
134
+ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
135
+ size_t byte_offset)
136
+ {
137
+ switch (type->type)
138
+ {
139
+ case FFI_TYPE_UINT8:
140
+ case FFI_TYPE_SINT8:
141
+ case FFI_TYPE_UINT16:
142
+ case FFI_TYPE_SINT16:
143
+ case FFI_TYPE_UINT32:
144
+ case FFI_TYPE_SINT32:
145
+ case FFI_TYPE_UINT64:
146
+ case FFI_TYPE_SINT64:
147
+ case FFI_TYPE_POINTER:
148
+ if (byte_offset + type->size <= 4)
149
+ classes[0] = X86_64_INTEGERSI_CLASS;
150
+ else
151
+ classes[0] = X86_64_INTEGER_CLASS;
152
+ return 1;
153
+ case FFI_TYPE_FLOAT:
154
+ if (byte_offset == 0)
155
+ classes[0] = X86_64_SSESF_CLASS;
156
+ else
157
+ classes[0] = X86_64_SSE_CLASS;
158
+ return 1;
159
+ case FFI_TYPE_DOUBLE:
160
+ classes[0] = X86_64_SSEDF_CLASS;
161
+ return 1;
162
+ case FFI_TYPE_LONGDOUBLE:
163
+ classes[0] = X86_64_X87_CLASS;
164
+ classes[1] = X86_64_X87UP_CLASS;
165
+ return 2;
166
+ case FFI_TYPE_STRUCT:
167
+ {
168
+ const int UNITS_PER_WORD = 8;
169
+ int words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
170
+ ffi_type **ptr;
171
+ int i;
172
+ enum x86_64_reg_class subclasses[MAX_CLASSES];
173
+
174
+ /* If the struct is larger than 16 bytes, pass it on the stack. */
175
+ if (type->size > 16)
176
+ return 0;
177
+
178
+ for (i = 0; i < words; i++)
179
+ classes[i] = X86_64_NO_CLASS;
180
+
181
+ /* Merge the fields of structure. */
182
+ for (ptr = type->elements; *ptr != NULL; ptr++)
183
+ {
184
+ int num;
185
+
186
+ byte_offset = ALIGN (byte_offset, (*ptr)->alignment);
187
+
188
+ num = classify_argument (*ptr, subclasses, byte_offset % 8);
189
+ if (num == 0)
190
+ return 0;
191
+ for (i = 0; i < num; i++)
192
+ {
193
+ int pos = byte_offset / 8;
194
+ classes[i + pos] =
195
+ merge_classes (subclasses[i], classes[i + pos]);
196
+ }
197
+
198
+ byte_offset += (*ptr)->size;
199
+ }
200
+
201
+ /* Final merger cleanup. */
202
+ for (i = 0; i < words; i++)
203
+ {
204
+ /* If one class is MEMORY, everything should be passed in
205
+ memory. */
206
+ if (classes[i] == X86_64_MEMORY_CLASS)
207
+ return 0;
208
+
209
+ /* The X86_64_SSEUP_CLASS should be always preceded by
210
+ X86_64_SSE_CLASS. */
211
+ if (classes[i] == X86_64_SSEUP_CLASS
212
+ && (i == 0 || classes[i - 1] != X86_64_SSE_CLASS))
213
+ classes[i] = X86_64_SSE_CLASS;
214
+
215
+ /* X86_64_X87UP_CLASS should be preceded by X86_64_X87_CLASS. */
216
+ if (classes[i] == X86_64_X87UP_CLASS
217
+ && (i == 0 || classes[i - 1] != X86_64_X87_CLASS))
218
+ classes[i] = X86_64_SSE_CLASS;
219
+ }
220
+ return words;
221
+ }
222
+
223
+ default:
224
+ FFI_ASSERT(0);
225
+ }
226
+ return 0; /* Never reached. */
227
+ }
228
+
229
+ /* Examine the argument and return set number of register required in each
230
+ class. Return zero iff parameter should be passed in memory, otherwise
231
+ the number of registers. */
232
+
233
+ static int
234
+ examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES],
235
+ _Bool in_return, int *pngpr, int *pnsse)
236
+ {
237
+ int i, n, ngpr, nsse;
238
+
239
+ n = classify_argument (type, classes, 0);
240
+ if (n == 0)
241
+ return 0;
242
+
243
+ ngpr = nsse = 0;
244
+ for (i = 0; i < n; ++i)
245
+ switch (classes[i])
246
+ {
247
+ case X86_64_INTEGER_CLASS:
248
+ case X86_64_INTEGERSI_CLASS:
249
+ ngpr++;
250
+ break;
251
+ case X86_64_SSE_CLASS:
252
+ case X86_64_SSESF_CLASS:
253
+ case X86_64_SSEDF_CLASS:
254
+ nsse++;
255
+ break;
256
+ case X86_64_NO_CLASS:
257
+ case X86_64_SSEUP_CLASS:
258
+ break;
259
+ case X86_64_X87_CLASS:
260
+ case X86_64_X87UP_CLASS:
261
+ case X86_64_COMPLEX_X87_CLASS:
262
+ return in_return != 0;
263
+ default:
264
+ abort ();
265
+ }
266
+
267
+ *pngpr = ngpr;
268
+ *pnsse = nsse;
269
+
270
+ return n;
271
+ }
272
+
273
+ /* Perform machine dependent cif processing. */
274
+
275
+ ffi_status
276
+ ffi_prep_cif_machdep (ffi_cif *cif)
277
+ {
278
+ int gprcount, ssecount, i, avn, n, ngpr, nsse, flags;
279
+ enum x86_64_reg_class classes[MAX_CLASSES];
280
+ size_t bytes;
281
+
282
+ gprcount = ssecount = 0;
283
+
284
+ flags = cif->rtype->type;
285
+ if (flags != FFI_TYPE_VOID)
286
+ {
287
+ n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
288
+ if (n == 0)
289
+ {
290
+ /* The return value is passed in memory. A pointer to that
291
+ memory is the first argument. Allocate a register for it. */
292
+ gprcount++;
293
+ /* We don't have to do anything in asm for the return. */
294
+ flags = FFI_TYPE_VOID;
295
+ }
296
+ else if (flags == FFI_TYPE_STRUCT)
297
+ {
298
+ /* Mark which registers the result appears in. */
299
+ _Bool sse0 = SSE_CLASS_P (classes[0]);
300
+ _Bool sse1 = n == 2 && SSE_CLASS_P (classes[1]);
301
+ if (sse0 && !sse1)
302
+ flags |= 1 << 8;
303
+ else if (!sse0 && sse1)
304
+ flags |= 1 << 9;
305
+ else if (sse0 && sse1)
306
+ flags |= 1 << 10;
307
+ /* Mark the true size of the structure. */
308
+ flags |= cif->rtype->size << 12;
309
+ }
310
+ }
311
+
312
+ /* Go over all arguments and determine the way they should be passed.
313
+ If it's in a register and there is space for it, let that be so. If
314
+ not, add it's size to the stack byte count. */
315
+ for (bytes = 0, i = 0, avn = cif->nargs; i < avn; i++)
316
+ {
317
+ if (examine_argument (cif->arg_types[i], classes, 0, &ngpr, &nsse) == 0
318
+ || gprcount + ngpr > MAX_GPR_REGS
319
+ || ssecount + nsse > MAX_SSE_REGS)
320
+ {
321
+ long align = cif->arg_types[i]->alignment;
322
+
323
+ if (align < 8)
324
+ align = 8;
325
+
326
+ bytes = ALIGN(bytes, align);
327
+ bytes += cif->arg_types[i]->size;
328
+ }
329
+ else
330
+ {
331
+ gprcount += ngpr;
332
+ ssecount += nsse;
333
+ }
334
+ }
335
+ if (ssecount)
336
+ flags |= 1 << 11;
337
+ cif->flags = flags;
338
+ cif->bytes = bytes;
339
+
340
+ return FFI_OK;
341
+ }
342
+
343
+ void
344
+ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
345
+ {
346
+ enum x86_64_reg_class classes[MAX_CLASSES];
347
+ char *stack, *argp;
348
+ ffi_type **arg_types;
349
+ int gprcount, ssecount, ngpr, nsse, i, avn;
350
+ _Bool ret_in_memory;
351
+ struct register_args *reg_args;
352
+
353
+ /* Can't call 32-bit mode from 64-bit mode. */
354
+ FFI_ASSERT (cif->abi == FFI_UNIX64);
355
+
356
+ /* If the return value is a struct and we don't have a return value
357
+ address then we need to make one. Note the setting of flags to
358
+ VOID above in ffi_prep_cif_machdep. */
359
+ ret_in_memory = (cif->rtype->type == FFI_TYPE_STRUCT
360
+ && (cif->flags & 0xff) == FFI_TYPE_VOID);
361
+ if (rvalue == NULL && ret_in_memory)
362
+ rvalue = alloca (cif->rtype->size);
363
+
364
+ /* Allocate the space for the arguments, plus 4 words of temp space. */
365
+ stack = alloca (sizeof (struct register_args) + cif->bytes + 4*8);
366
+ reg_args = (struct register_args *) stack;
367
+ argp = stack + sizeof (struct register_args);
368
+
369
+ gprcount = ssecount = 0;
370
+
371
+ /* If the return value is passed in memory, add the pointer as the
372
+ first integer argument. */
373
+ if (ret_in_memory)
374
+ reg_args->gpr[gprcount++] = (long) rvalue;
375
+
376
+ avn = cif->nargs;
377
+ arg_types = cif->arg_types;
378
+
379
+ for (i = 0; i < avn; ++i)
380
+ {
381
+ size_t size = arg_types[i]->size;
382
+ int n;
383
+
384
+ n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
385
+ if (n == 0
386
+ || gprcount + ngpr > MAX_GPR_REGS
387
+ || ssecount + nsse > MAX_SSE_REGS)
388
+ {
389
+ long align = arg_types[i]->alignment;
390
+
391
+ /* Stack arguments are *always* at least 8 byte aligned. */
392
+ if (align < 8)
393
+ align = 8;
394
+
395
+ /* Pass this argument in memory. */
396
+ argp = (void *) ALIGN (argp, align);
397
+ memcpy (argp, avalue[i], size);
398
+ argp += size;
399
+ }
400
+ else
401
+ {
402
+ /* The argument is passed entirely in registers. */
403
+ char *a = (char *) avalue[i];
404
+ int j;
405
+
406
+ for (j = 0; j < n; j++, a += 8, size -= 8)
407
+ {
408
+ switch (classes[j])
409
+ {
410
+ case X86_64_INTEGER_CLASS:
411
+ case X86_64_INTEGERSI_CLASS:
412
+ reg_args->gpr[gprcount] = 0;
413
+ memcpy (&reg_args->gpr[gprcount], a, size < 8 ? size : 8);
414
+ gprcount++;
415
+ break;
416
+ case X86_64_SSE_CLASS:
417
+ case X86_64_SSEDF_CLASS:
418
+ reg_args->sse[ssecount++] = *(UINT64 *) a;
419
+ break;
420
+ case X86_64_SSESF_CLASS:
421
+ reg_args->sse[ssecount++] = *(UINT32 *) a;
422
+ break;
423
+ default:
424
+ abort();
425
+ }
426
+ }
427
+ }
428
+ }
429
+
430
+ ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args),
431
+ cif->flags, rvalue, fn, ssecount);
432
+ }
433
+
434
+
435
+ extern void ffi_closure_unix64(void);
436
+
437
+ ffi_status
438
+ ffi_prep_closure_loc (ffi_closure* closure,
439
+ ffi_cif* cif,
440
+ void (*fun)(ffi_cif*, void*, void**, void*),
441
+ void *user_data,
442
+ void *codeloc)
443
+ {
444
+ volatile unsigned short *tramp;
445
+
446
+ tramp = (volatile unsigned short *) &closure->tramp[0];
447
+
448
+ tramp[0] = 0xbb49; /* mov <code>, %r11 */
449
+ *(void * volatile *) &tramp[1] = ffi_closure_unix64;
450
+ tramp[5] = 0xba49; /* mov <data>, %r10 */
451
+ *(void * volatile *) &tramp[6] = codeloc;
452
+
453
+ /* Set the carry bit iff the function uses any sse registers.
454
+ This is clc or stc, together with the first byte of the jmp. */
455
+ tramp[10] = cif->flags & (1 << 11) ? 0x49f9 : 0x49f8;
456
+
457
+ tramp[11] = 0xe3ff; /* jmp *%r11 */
458
+
459
+ closure->cif = cif;
460
+ closure->fun = fun;
461
+ closure->user_data = user_data;
462
+
463
+ return FFI_OK;
464
+ }
465
+
466
+ int
467
+ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
468
+ struct register_args *reg_args, char *argp)
469
+ {
470
+ ffi_cif *cif;
471
+ void **avalue;
472
+ ffi_type **arg_types;
473
+ long i, avn;
474
+ int gprcount, ssecount, ngpr, nsse;
475
+ int ret;
476
+
477
+ cif = closure->cif;
478
+ avalue = alloca(cif->nargs * sizeof(void *));
479
+ gprcount = ssecount = 0;
480
+
481
+ ret = cif->rtype->type;
482
+ if (ret != FFI_TYPE_VOID)
483
+ {
484
+ enum x86_64_reg_class classes[MAX_CLASSES];
485
+ int n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
486
+ if (n == 0)
487
+ {
488
+ /* The return value goes in memory. Arrange for the closure
489
+ return value to go directly back to the original caller. */
490
+ rvalue = (void *) reg_args->gpr[gprcount++];
491
+ /* We don't have to do anything in asm for the return. */
492
+ ret = FFI_TYPE_VOID;
493
+ }
494
+ else if (ret == FFI_TYPE_STRUCT && n == 2)
495
+ {
496
+ /* Mark which register the second word of the structure goes in. */
497
+ _Bool sse0 = SSE_CLASS_P (classes[0]);
498
+ _Bool sse1 = SSE_CLASS_P (classes[1]);
499
+ if (!sse0 && sse1)
500
+ ret |= 1 << 8;
501
+ else if (sse0 && !sse1)
502
+ ret |= 1 << 9;
503
+ }
504
+ }
505
+
506
+ avn = cif->nargs;
507
+ arg_types = cif->arg_types;
508
+
509
+ for (i = 0; i < avn; ++i)
510
+ {
511
+ enum x86_64_reg_class classes[MAX_CLASSES];
512
+ int n;
513
+
514
+ n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
515
+ if (n == 0
516
+ || gprcount + ngpr > MAX_GPR_REGS
517
+ || ssecount + nsse > MAX_SSE_REGS)
518
+ {
519
+ long align = arg_types[i]->alignment;
520
+
521
+ /* Stack arguments are *always* at least 8 byte aligned. */
522
+ if (align < 8)
523
+ align = 8;
524
+
525
+ /* Pass this argument in memory. */
526
+ argp = (void *) ALIGN (argp, align);
527
+ avalue[i] = argp;
528
+ argp += arg_types[i]->size;
529
+ }
530
+ /* If the argument is in a single register, or two consecutive
531
+ registers, then we can use that address directly. */
532
+ else if (n == 1
533
+ || (n == 2
534
+ && SSE_CLASS_P (classes[0]) == SSE_CLASS_P (classes[1])))
535
+ {
536
+ /* The argument is in a single register. */
537
+ if (SSE_CLASS_P (classes[0]))
538
+ {
539
+ avalue[i] = &reg_args->sse[ssecount];
540
+ ssecount += n;
541
+ }
542
+ else
543
+ {
544
+ avalue[i] = &reg_args->gpr[gprcount];
545
+ gprcount += n;
546
+ }
547
+ }
548
+ /* Otherwise, allocate space to make them consecutive. */
549
+ else
550
+ {
551
+ char *a = alloca (16);
552
+ int j;
553
+
554
+ avalue[i] = a;
555
+ for (j = 0; j < n; j++, a += 8)
556
+ {
557
+ if (SSE_CLASS_P (classes[j]))
558
+ memcpy (a, &reg_args->sse[ssecount++], 8);
559
+ else
560
+ memcpy (a, &reg_args->gpr[gprcount++], 8);
561
+ }
562
+ }
563
+ }
564
+
565
+ /* Invoke the closure. */
566
+ closure->fun (cif, rvalue, avalue, closure->user_data);
567
+
568
+ /* Tell assembly how to perform return type promotions. */
569
+ return ret;
570
+ }
571
+
572
+ #endif /* __x86_64__ */