ffi 0.4.0-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ffi might be problematic. Click here for more details.

Files changed (316) hide show
  1. data/LICENSE +51 -0
  2. data/README.rdoc +69 -0
  3. data/Rakefile +142 -0
  4. data/ext/ffi_c/AbstractMemory.c +412 -0
  5. data/ext/ffi_c/AbstractMemory.h +68 -0
  6. data/ext/ffi_c/AutoPointer.c +60 -0
  7. data/ext/ffi_c/AutoPointer.h +18 -0
  8. data/ext/ffi_c/Buffer.c +171 -0
  9. data/ext/ffi_c/Callback.c +374 -0
  10. data/ext/ffi_c/Callback.h +47 -0
  11. data/ext/ffi_c/DynamicLibrary.c +213 -0
  12. data/ext/ffi_c/DynamicLibrary.h +22 -0
  13. data/ext/ffi_c/Invoker.c +962 -0
  14. data/ext/ffi_c/LastError.c +135 -0
  15. data/ext/ffi_c/LastError.h +18 -0
  16. data/ext/ffi_c/MemoryPointer.c +156 -0
  17. data/ext/ffi_c/MemoryPointer.h +20 -0
  18. data/ext/ffi_c/NullPointer.c +143 -0
  19. data/ext/ffi_c/Platform.c +59 -0
  20. data/ext/ffi_c/Platform.h +16 -0
  21. data/ext/ffi_c/Pointer.c +164 -0
  22. data/ext/ffi_c/Pointer.h +25 -0
  23. data/ext/ffi_c/Struct.c +477 -0
  24. data/ext/ffi_c/Struct.h +26 -0
  25. data/ext/ffi_c/Type.c +230 -0
  26. data/ext/ffi_c/Type.h +28 -0
  27. data/ext/ffi_c/Types.c +118 -0
  28. data/ext/ffi_c/Types.h +54 -0
  29. data/ext/ffi_c/compat.h +22 -0
  30. data/ext/ffi_c/endian.h +40 -0
  31. data/ext/ffi_c/extconf.rb +31 -0
  32. data/ext/ffi_c/ffi.c +76 -0
  33. data/ext/ffi_c/libffi.bsd.mk +34 -0
  34. data/ext/ffi_c/libffi.darwin.mk +75 -0
  35. data/ext/ffi_c/libffi.gnu.mk +29 -0
  36. data/ext/ffi_c/libffi.mk +13 -0
  37. data/ext/ffi_c/libffi/ChangeLog +3243 -0
  38. data/ext/ffi_c/libffi/ChangeLog.libffi +347 -0
  39. data/ext/ffi_c/libffi/ChangeLog.libgcj +40 -0
  40. data/ext/ffi_c/libffi/ChangeLog.v1 +764 -0
  41. data/ext/ffi_c/libffi/LICENSE +21 -0
  42. data/ext/ffi_c/libffi/Makefile.am +177 -0
  43. data/ext/ffi_c/libffi/Makefile.in +1640 -0
  44. data/ext/ffi_c/libffi/README +328 -0
  45. data/ext/ffi_c/libffi/TODO +1 -0
  46. data/ext/ffi_c/libffi/acinclude.m4 +92 -0
  47. data/ext/ffi_c/libffi/aclocal.m4 +7516 -0
  48. data/ext/ffi_c/libffi/compile +142 -0
  49. data/ext/ffi_c/libffi/config.guess +1516 -0
  50. data/ext/ffi_c/libffi/config.sub +1626 -0
  51. data/ext/ffi_c/libffi/configure +24414 -0
  52. data/ext/ffi_c/libffi/configure.ac +365 -0
  53. data/ext/ffi_c/libffi/configure.host +11 -0
  54. data/ext/ffi_c/libffi/depcomp +584 -0
  55. data/ext/ffi_c/libffi/doc/libffi.info +533 -0
  56. data/ext/ffi_c/libffi/doc/libffi.texi +541 -0
  57. data/ext/ffi_c/libffi/doc/stamp-vti +4 -0
  58. data/ext/ffi_c/libffi/doc/version.texi +4 -0
  59. data/ext/ffi_c/libffi/fficonfig.h.in +160 -0
  60. data/ext/ffi_c/libffi/include/Makefile.am +9 -0
  61. data/ext/ffi_c/libffi/include/Makefile.in +422 -0
  62. data/ext/ffi_c/libffi/include/ffi.h.in +393 -0
  63. data/ext/ffi_c/libffi/include/ffi_common.h +98 -0
  64. data/ext/ffi_c/libffi/install-sh +323 -0
  65. data/ext/ffi_c/libffi/libffi.pc.in +10 -0
  66. data/ext/ffi_c/libffi/libtool-version +29 -0
  67. data/ext/ffi_c/libffi/ltcf-c.sh +861 -0
  68. data/ext/ffi_c/libffi/ltcf-cxx.sh +1069 -0
  69. data/ext/ffi_c/libffi/ltcf-gcj.sh +700 -0
  70. data/ext/ffi_c/libffi/ltconfig +2862 -0
  71. data/ext/ffi_c/libffi/ltmain.sh +6930 -0
  72. data/ext/ffi_c/libffi/man/Makefile.am +8 -0
  73. data/ext/ffi_c/libffi/man/Makefile.in +395 -0
  74. data/ext/ffi_c/libffi/man/ffi.3 +31 -0
  75. data/ext/ffi_c/libffi/man/ffi_call.3 +103 -0
  76. data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +66 -0
  77. data/ext/ffi_c/libffi/mdate-sh +201 -0
  78. data/ext/ffi_c/libffi/missing +353 -0
  79. data/ext/ffi_c/libffi/mkinstalldirs +158 -0
  80. data/ext/ffi_c/libffi/src/alpha/ffi.c +284 -0
  81. data/ext/ffi_c/libffi/src/alpha/ffitarget.h +48 -0
  82. data/ext/ffi_c/libffi/src/alpha/osf.S +366 -0
  83. data/ext/ffi_c/libffi/src/arm/ffi.c +309 -0
  84. data/ext/ffi_c/libffi/src/arm/ffitarget.h +49 -0
  85. data/ext/ffi_c/libffi/src/arm/sysv.S +299 -0
  86. data/ext/ffi_c/libffi/src/closures.c +596 -0
  87. data/ext/ffi_c/libffi/src/cris/ffi.c +383 -0
  88. data/ext/ffi_c/libffi/src/cris/ffitarget.h +51 -0
  89. data/ext/ffi_c/libffi/src/cris/sysv.S +215 -0
  90. data/ext/ffi_c/libffi/src/debug.c +59 -0
  91. data/ext/ffi_c/libffi/src/dlmalloc.c +5099 -0
  92. data/ext/ffi_c/libffi/src/frv/eabi.S +128 -0
  93. data/ext/ffi_c/libffi/src/frv/ffi.c +292 -0
  94. data/ext/ffi_c/libffi/src/frv/ffitarget.h +61 -0
  95. data/ext/ffi_c/libffi/src/ia64/ffi.c +580 -0
  96. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +50 -0
  97. data/ext/ffi_c/libffi/src/ia64/ia64_flags.h +40 -0
  98. data/ext/ffi_c/libffi/src/ia64/unix.S +560 -0
  99. data/ext/ffi_c/libffi/src/java_raw_api.c +359 -0
  100. data/ext/ffi_c/libffi/src/m32r/ffi.c +232 -0
  101. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +48 -0
  102. data/ext/ffi_c/libffi/src/m32r/sysv.S +121 -0
  103. data/ext/ffi_c/libffi/src/m68k/ffi.c +278 -0
  104. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +49 -0
  105. data/ext/ffi_c/libffi/src/m68k/sysv.S +234 -0
  106. data/ext/ffi_c/libffi/src/mips/ffi.c +926 -0
  107. data/ext/ffi_c/libffi/src/mips/ffitarget.h +202 -0
  108. data/ext/ffi_c/libffi/src/mips/n32.S +534 -0
  109. data/ext/ffi_c/libffi/src/mips/o32.S +381 -0
  110. data/ext/ffi_c/libffi/src/pa/ffi.c +709 -0
  111. data/ext/ffi_c/libffi/src/pa/ffitarget.h +77 -0
  112. data/ext/ffi_c/libffi/src/pa/hpux32.S +368 -0
  113. data/ext/ffi_c/libffi/src/pa/linux.S +357 -0
  114. data/ext/ffi_c/libffi/src/powerpc/aix.S +225 -0
  115. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +247 -0
  116. data/ext/ffi_c/libffi/src/powerpc/asm.h +125 -0
  117. data/ext/ffi_c/libffi/src/powerpc/darwin.S +245 -0
  118. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +317 -0
  119. data/ext/ffi_c/libffi/src/powerpc/ffi.c +1429 -0
  120. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +800 -0
  121. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +118 -0
  122. data/ext/ffi_c/libffi/src/powerpc/linux64.S +187 -0
  123. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +236 -0
  124. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +327 -0
  125. data/ext/ffi_c/libffi/src/powerpc/sysv.S +230 -0
  126. data/ext/ffi_c/libffi/src/prep_cif.c +174 -0
  127. data/ext/ffi_c/libffi/src/raw_api.c +254 -0
  128. data/ext/ffi_c/libffi/src/s390/ffi.c +780 -0
  129. data/ext/ffi_c/libffi/src/s390/ffitarget.h +60 -0
  130. data/ext/ffi_c/libffi/src/s390/sysv.S +434 -0
  131. data/ext/ffi_c/libffi/src/sh/ffi.c +716 -0
  132. data/ext/ffi_c/libffi/src/sh/ffitarget.h +49 -0
  133. data/ext/ffi_c/libffi/src/sh/sysv.S +850 -0
  134. data/ext/ffi_c/libffi/src/sh64/ffi.c +453 -0
  135. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +53 -0
  136. data/ext/ffi_c/libffi/src/sh64/sysv.S +530 -0
  137. data/ext/ffi_c/libffi/src/sparc/ffi.c +610 -0
  138. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +66 -0
  139. data/ext/ffi_c/libffi/src/sparc/v8.S +272 -0
  140. data/ext/ffi_c/libffi/src/sparc/v9.S +307 -0
  141. data/ext/ffi_c/libffi/src/types.c +77 -0
  142. data/ext/ffi_c/libffi/src/x86/darwin.S +443 -0
  143. data/ext/ffi_c/libffi/src/x86/darwin64.S +416 -0
  144. data/ext/ffi_c/libffi/src/x86/ffi.c +475 -0
  145. data/ext/ffi_c/libffi/src/x86/ffi64.c +572 -0
  146. data/ext/ffi_c/libffi/src/x86/ffitarget.h +90 -0
  147. data/ext/ffi_c/libffi/src/x86/freebsd.S +458 -0
  148. data/ext/ffi_c/libffi/src/x86/sysv.S +437 -0
  149. data/ext/ffi_c/libffi/src/x86/unix64.S +418 -0
  150. data/ext/ffi_c/libffi/src/x86/win32.S +391 -0
  151. data/ext/ffi_c/libffi/testsuite/Makefile.am +71 -0
  152. data/ext/ffi_c/libffi/testsuite/Makefile.in +447 -0
  153. data/ext/ffi_c/libffi/testsuite/config/default.exp +1 -0
  154. data/ext/ffi_c/libffi/testsuite/lib/libffi-dg.exp +289 -0
  155. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +263 -0
  156. data/ext/ffi_c/libffi/testsuite/lib/wrapper.exp +45 -0
  157. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +36 -0
  158. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +97 -0
  159. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +89 -0
  160. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +89 -0
  161. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +90 -0
  162. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +97 -0
  163. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +99 -0
  164. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +98 -0
  165. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_stdcall.c +72 -0
  166. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +102 -0
  167. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +103 -0
  168. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +104 -0
  169. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +110 -0
  170. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +97 -0
  171. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +99 -0
  172. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +101 -0
  173. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +121 -0
  174. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +98 -0
  175. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +103 -0
  176. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +98 -0
  177. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +98 -0
  178. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +106 -0
  179. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +98 -0
  180. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +117 -0
  181. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +106 -0
  182. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +132 -0
  183. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +121 -0
  184. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +107 -0
  185. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +125 -0
  186. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +105 -0
  187. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +96 -0
  188. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +98 -0
  189. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +99 -0
  190. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +101 -0
  191. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +99 -0
  192. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +100 -0
  193. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +101 -0
  194. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +99 -0
  195. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +99 -0
  196. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +99 -0
  197. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +99 -0
  198. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +99 -0
  199. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +100 -0
  200. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +51 -0
  201. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +51 -0
  202. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +82 -0
  203. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +82 -0
  204. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +94 -0
  205. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +99 -0
  206. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +82 -0
  207. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +94 -0
  208. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +52 -0
  209. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +50 -0
  210. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +50 -0
  211. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +50 -0
  212. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +51 -0
  213. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +54 -0
  214. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +51 -0
  215. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +86 -0
  216. data/ext/ffi_c/libffi/testsuite/libffi.call/float.c +59 -0
  217. data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +58 -0
  218. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +57 -0
  219. data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +72 -0
  220. data/ext/ffi_c/libffi/testsuite/libffi.call/float4.c +62 -0
  221. data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +69 -0
  222. data/ext/ffi_c/libffi/testsuite/libffi.call/many_win32.c +63 -0
  223. data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +53 -0
  224. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +160 -0
  225. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +169 -0
  226. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +141 -0
  227. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +118 -0
  228. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +119 -0
  229. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +119 -0
  230. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +120 -0
  231. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +139 -0
  232. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +119 -0
  233. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +139 -0
  234. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +139 -0
  235. data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +98 -0
  236. data/ext/ffi_c/libffi/testsuite/libffi.call/promotion.c +59 -0
  237. data/ext/ffi_c/libffi/testsuite/libffi.call/pyobjc-tc.c +114 -0
  238. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +35 -0
  239. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl1.c +43 -0
  240. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl2.c +42 -0
  241. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl.c +35 -0
  242. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl1.c +36 -0
  243. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl2.c +49 -0
  244. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl3.c +42 -0
  245. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +34 -0
  246. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll.c +41 -0
  247. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +42 -0
  248. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +36 -0
  249. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +38 -0
  250. data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +38 -0
  251. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +38 -0
  252. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +44 -0
  253. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen_win32.c +44 -0
  254. data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +65 -0
  255. data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +67 -0
  256. data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +59 -0
  257. data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +63 -0
  258. data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +65 -0
  259. data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +64 -0
  260. data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +74 -0
  261. data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +80 -0
  262. data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +67 -0
  263. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +86 -0
  264. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +38 -0
  265. data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest.cc +123 -0
  266. data/ext/ffi_c/libffi/testsuite/libffi.special/unwindtest_ffi_call.cc +53 -0
  267. data/ext/ffi_c/libffi/texinfo.tex +7482 -0
  268. data/ext/ffi_c/rbffi.h +23 -0
  269. data/gen/Rakefile +12 -0
  270. data/lib/1.8/ffi_c.so +0 -0
  271. data/lib/1.9/ffi_c.so +0 -0
  272. data/lib/ffi.rb +11 -0
  273. data/lib/ffi/autopointer.rb +61 -0
  274. data/lib/ffi/buffer.rb +0 -0
  275. data/lib/ffi/callback.rb +10 -0
  276. data/lib/ffi/enum.rb +78 -0
  277. data/lib/ffi/errno.rb +8 -0
  278. data/lib/ffi/ffi.rb +96 -0
  279. data/lib/ffi/io.rb +21 -0
  280. data/lib/ffi/library.rb +243 -0
  281. data/lib/ffi/managedstruct.rb +55 -0
  282. data/lib/ffi/memorypointer.rb +73 -0
  283. data/lib/ffi/platform.rb +78 -0
  284. data/lib/ffi/pointer.rb +119 -0
  285. data/lib/ffi/struct.rb +354 -0
  286. data/lib/ffi/tools/const_generator.rb +177 -0
  287. data/lib/ffi/tools/generator.rb +58 -0
  288. data/lib/ffi/tools/generator_task.rb +35 -0
  289. data/lib/ffi/tools/struct_generator.rb +194 -0
  290. data/lib/ffi/tools/types_generator.rb +123 -0
  291. data/lib/ffi/types.rb +153 -0
  292. data/lib/ffi/union.rb +17 -0
  293. data/lib/ffi/variadic.rb +30 -0
  294. data/spec/ffi/bool_spec.rb +24 -0
  295. data/spec/ffi/buffer_spec.rb +196 -0
  296. data/spec/ffi/callback_spec.rb +560 -0
  297. data/spec/ffi/enum_spec.rb +164 -0
  298. data/spec/ffi/errno_spec.rb +13 -0
  299. data/spec/ffi/library_spec.rb +144 -0
  300. data/spec/ffi/managed_struct_spec.rb +56 -0
  301. data/spec/ffi/number_spec.rb +231 -0
  302. data/spec/ffi/pointer_spec.rb +195 -0
  303. data/spec/ffi/rbx/attach_function_spec.rb +27 -0
  304. data/spec/ffi/rbx/memory_pointer_spec.rb +102 -0
  305. data/spec/ffi/rbx/spec_helper.rb +1 -0
  306. data/spec/ffi/rbx/struct_spec.rb +13 -0
  307. data/spec/ffi/spec_helper.rb +17 -0
  308. data/spec/ffi/string_spec.rb +103 -0
  309. data/spec/ffi/struct_callback_spec.rb +41 -0
  310. data/spec/ffi/struct_initialize_spec.rb +30 -0
  311. data/spec/ffi/struct_spec.rb +476 -0
  312. data/spec/ffi/typedef_spec.rb +48 -0
  313. data/spec/ffi/union_spec.rb +60 -0
  314. data/spec/ffi/variadic_spec.rb +84 -0
  315. data/spec/spec.opts +4 -0
  316. metadata +375 -0
@@ -0,0 +1,541 @@
1
+ \input texinfo @c -*-texinfo-*-
2
+ @c %**start of header
3
+ @setfilename libffi.info
4
+ @settitle libffi
5
+ @setchapternewpage off
6
+ @c %**end of header
7
+
8
+ @c Merge the standard indexes into a single one.
9
+ @syncodeindex fn cp
10
+ @syncodeindex vr cp
11
+ @syncodeindex ky cp
12
+ @syncodeindex pg cp
13
+ @syncodeindex tp cp
14
+
15
+ @include version.texi
16
+
17
+ @copying
18
+
19
+ This manual is for Libffi, a portable foreign-function interface
20
+ library.
21
+
22
+ Copyright @copyright{} 2008 Red Hat, Inc.
23
+
24
+ @quotation
25
+ Permission is granted to copy, distribute and/or modify this document
26
+ under the terms of the GNU General Public License as published by the
27
+ Free Software Foundation; either version 2, or (at your option) any
28
+ later version. A copy of the license is included in the
29
+ section entitled ``GNU General Public License''.
30
+
31
+ @end quotation
32
+ @end copying
33
+
34
+ @dircategory
35
+ @direntry
36
+ * libffi: (libffi). Portable foreign-function interface library.
37
+ @end direntry
38
+
39
+ @titlepage
40
+ @title Libffi
41
+ @page
42
+ @vskip 0pt plus 1filll
43
+ @insertcopying
44
+ @end titlepage
45
+
46
+
47
+ @ifnottex
48
+ @node Top
49
+ @top libffi
50
+
51
+ @insertcopying
52
+
53
+ @menu
54
+ * Introduction:: What is libffi?
55
+ * Using libffi:: How to use libffi.
56
+ * Missing Features:: Things libffi can't do.
57
+ * Index:: Index.
58
+ @end menu
59
+
60
+ @end ifnottex
61
+
62
+
63
+ @node Introduction
64
+ @chapter What is libffi?
65
+
66
+ Compilers for high level languages generate code that follow certain
67
+ conventions. These conventions are necessary, in part, for separate
68
+ compilation to work. One such convention is the @dfn{calling
69
+ convention}. The calling convention is a set of assumptions made by
70
+ the compiler about where function arguments will be found on entry to
71
+ a function. A calling convention also specifies where the return
72
+ value for a function is found. The calling convention is also
73
+ sometimes called the @dfn{ABI} or @dfn{Application Binary Interface}.
74
+ @cindex calling convention
75
+ @cindex ABI
76
+ @cindex Application Binary Interface
77
+
78
+ Some programs may not know at the time of compilation what arguments
79
+ are to be passed to a function. For instance, an interpreter may be
80
+ told at run-time about the number and types of arguments used to call
81
+ a given function. @samp{Libffi} can be used in such programs to
82
+ provide a bridge from the interpreter program to compiled code.
83
+
84
+ The @samp{libffi} library provides a portable, high level programming
85
+ interface to various calling conventions. This allows a programmer to
86
+ call any function specified by a call interface description at run
87
+ time.
88
+
89
+ @acronym{FFI} stands for Foreign Function Interface. A foreign
90
+ function interface is the popular name for the interface that allows
91
+ code written in one language to call code written in another language.
92
+ The @samp{libffi} library really only provides the lowest, machine
93
+ dependent layer of a fully featured foreign function interface. A
94
+ layer must exist above @samp{libffi} that handles type conversions for
95
+ values passed between the two languages.
96
+ @cindex FFI
97
+ @cindex Foreign Function Interface
98
+
99
+
100
+ @node Using libffi
101
+ @chapter Using libffi
102
+
103
+ @menu
104
+ * The Basics:: The basic libffi API.
105
+ * Simple Example:: A simple example.
106
+ * Types:: libffi type descriptions.
107
+ * Multiple ABIs:: Different passing styles on one platform.
108
+ * The Closure API:: Writing a generic function.
109
+ @end menu
110
+
111
+
112
+ @node The Basics
113
+ @section The Basics
114
+
115
+ @samp{Libffi} assumes that you have a pointer to the function you wish
116
+ to call and that you know the number and types of arguments to pass
117
+ it, as well as the return type of the function.
118
+
119
+ The first thing you must do is create an @code{ffi_cif} object that
120
+ matches the signature of the function you wish to call. This is a
121
+ separate step because it is common to make multiple calls using a
122
+ single @code{ffi_cif}. The @dfn{cif} in @code{ffi_cif} stands for
123
+ Call InterFace. To prepare a call interface object, use the function
124
+ @code{ffi_prep_cif}.
125
+ @cindex cif
126
+
127
+ @findex ffi_prep_cif
128
+ @defun ffi_status ffi_prep_cif (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes})
129
+ This initializes @var{cif} according to the given parameters.
130
+
131
+ @var{abi} is the ABI to use; normally @code{FFI_DEFAULT_ABI} is what
132
+ you want. @ref{Multiple ABIs} for more information.
133
+
134
+ @var{nargs} is the number of arguments that this function accepts.
135
+ @samp{libffi} does not yet handle varargs functions; see @ref{Missing
136
+ Features} for more information.
137
+
138
+ @var{rtype} is a pointer to an @code{ffi_type} structure that
139
+ describes the return type of the function. @xref{Types}.
140
+
141
+ @var{argtypes} is a vector of @code{ffi_type} pointers.
142
+ @var{argtypes} must have @var{nargs} elements. If @var{nargs} is 0,
143
+ this argument is ignored.
144
+
145
+ @code{ffi_prep_cif} returns a @code{libffi} status code, of type
146
+ @code{ffi_status}. This will be either @code{FFI_OK} if everything
147
+ worked properly; @code{FFI_BAD_TYPEDEF} if one of the @code{ffi_type}
148
+ objects is incorrect; or @code{FFI_BAD_ABI} if the @var{abi} parameter
149
+ is invalid.
150
+ @end defun
151
+
152
+
153
+ To call a function using an initialized @code{ffi_cif}, use the
154
+ @code{ffi_call} function:
155
+
156
+ @findex ffi_call
157
+ @defun void ffi_call (ffi_cif *@var{cif}, void *@var{fn}, void *@var{rvalue}, void **@var{avalues})
158
+ This calls the function @var{fn} according to the description given in
159
+ @var{cif}. @var{cif} must have already been prepared using
160
+ @code{ffi_prep_cif}.
161
+
162
+ @var{rvalue} is a pointer to a chunk of memory that will hold the
163
+ result of the function call. This must be large enough to hold the
164
+ result and must be suitably aligned; it is the caller's responsibility
165
+ to ensure this. If @var{cif} declares that the function returns
166
+ @code{void} (using @code{ffi_type_void}), then @var{rvalue} is
167
+ ignored. If @var{rvalue} is @samp{NULL}, then the return value is
168
+ discarded.
169
+
170
+ @var{avalues} is a vector of @code{void *} pointers that point to the
171
+ memory locations holding the argument values for a call. If @var{cif}
172
+ declares that the function has no arguments (i.e., @var{nargs} was 0),
173
+ then @var{avalues} is ignored.
174
+ @end defun
175
+
176
+
177
+ @node Simple Example
178
+ @section Simple Example
179
+
180
+ Here is a trivial example that calls @code{puts} a few times.
181
+
182
+ @example
183
+ #include <stdio.h>
184
+ #include <ffi.h>
185
+
186
+ int main()
187
+ @{
188
+ ffi_cif cif;
189
+ ffi_type *args[1];
190
+ void *values[1];
191
+ char *s;
192
+ int rc;
193
+
194
+ /* Initialize the argument info vectors */
195
+ args[0] = &ffi_type_pointer;
196
+ values[0] = &s;
197
+
198
+ /* Initialize the cif */
199
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
200
+ &ffi_type_uint, args) == FFI_OK)
201
+ @{
202
+ s = "Hello World!";
203
+ ffi_call(&cif, puts, &rc, values);
204
+ /* rc now holds the result of the call to puts */
205
+
206
+ /* values holds a pointer to the function's arg, so to
207
+ call puts() again all we need to do is change the
208
+ value of s */
209
+ s = "This is cool!";
210
+ ffi_call(&cif, puts, &rc, values);
211
+ @}
212
+
213
+ return 0;
214
+ @}
215
+ @end example
216
+
217
+
218
+ @node Types
219
+ @section Types
220
+
221
+ @menu
222
+ * Primitive Types:: Built-in types.
223
+ * Structures:: Structure types.
224
+ * Type Example:: Structure type example.
225
+ @end menu
226
+
227
+ @node Primitive Types
228
+ @subsection Primitive Types
229
+
230
+ @code{Libffi} provides a number of built-in type descriptors that can
231
+ be used to describe argument and return types:
232
+
233
+ @table @code
234
+ @item ffi_type_void
235
+ @tindex ffi_type_void
236
+ The type @code{void}. This cannot be used for argument types, only
237
+ for return values.
238
+
239
+ @item ffi_type_uint8
240
+ @tindex ffi_type_uint8
241
+ An unsigned, 8-bit integer type.
242
+
243
+ @item ffi_type_sint8
244
+ @tindex ffi_type_sint8
245
+ A signed, 8-bit integer type.
246
+
247
+ @item ffi_type_uint16
248
+ @tindex ffi_type_uint16
249
+ An unsigned, 16-bit integer type.
250
+
251
+ @item ffi_type_sint16
252
+ @tindex ffi_type_sint16
253
+ A signed, 16-bit integer type.
254
+
255
+ @item ffi_type_uint32
256
+ @tindex ffi_type_uint32
257
+ An unsigned, 32-bit integer type.
258
+
259
+ @item ffi_type_sint32
260
+ @tindex ffi_type_sint32
261
+ A signed, 32-bit integer type.
262
+
263
+ @item ffi_type_uint64
264
+ @tindex ffi_type_uint64
265
+ An unsigned, 64-bit integer type.
266
+
267
+ @item ffi_type_sint64
268
+ @tindex ffi_type_sint64
269
+ A signed, 64-bit integer type.
270
+
271
+ @item ffi_type_float
272
+ @tindex ffi_type_float
273
+ The C @code{float} type.
274
+
275
+ @item ffi_type_double
276
+ @tindex ffi_type_double
277
+ The C @code{double} type.
278
+
279
+ @item ffi_type_uchar
280
+ @tindex ffi_type_uchar
281
+ The C @code{unsigned char} type.
282
+
283
+ @item ffi_type_schar
284
+ @tindex ffi_type_schar
285
+ The C @code{signed char} type. (Note that there is not an exact
286
+ equivalent to the C @code{char} type in @code{libffi}; ordinarily you
287
+ should either use @code{ffi_type_schar} or @code{ffi_type_uchar}
288
+ depending on whether @code{char} is signed.)
289
+
290
+ @item ffi_type_ushort
291
+ @tindex ffi_type_ushort
292
+ The C @code{unsigned short} type.
293
+
294
+ @item ffi_type_sshort
295
+ @tindex ffi_type_sshort
296
+ The C @code{short} type.
297
+
298
+ @item ffi_type_uint
299
+ @tindex ffi_type_uint
300
+ The C @code{unsigned int} type.
301
+
302
+ @item ffi_type_sint
303
+ @tindex ffi_type_sint
304
+ The C @code{int} type.
305
+
306
+ @item ffi_type_ulong
307
+ @tindex ffi_type_ulong
308
+ The C @code{unsigned long} type.
309
+
310
+ @item ffi_type_slong
311
+ @tindex ffi_type_slong
312
+ The C @code{long} type.
313
+
314
+ @item ffi_type_longdouble
315
+ @tindex ffi_type_longdouble
316
+ On platforms that have a C @code{long double} type, this is defined.
317
+ On other platforms, it is not.
318
+
319
+ @item ffi_type_pointer
320
+ @tindex ffi_type_pointer
321
+ A generic @code{void *} pointer. You should use this for all
322
+ pointers, regardless of their real type.
323
+ @end table
324
+
325
+ Each of these is of type @code{ffi_type}, so you must take the address
326
+ when passing to @code{ffi_prep_cif}.
327
+
328
+
329
+ @node Structures
330
+ @subsection Structures
331
+
332
+ Although @samp{libffi} has no special support for unions or
333
+ bit-fields, it is perfectly happy passing structures back and forth.
334
+ You must first describe the structure to @samp{libffi} by creating a
335
+ new @code{ffi_type} object for it.
336
+
337
+ @tindex ffi_type
338
+ @deftp ffi_type
339
+ The @code{ffi_type} has the following members:
340
+ @table @code
341
+ @item size_t size
342
+ This is set by @code{libffi}; you should initialize it to zero.
343
+
344
+ @item unsigned short alignment
345
+ This is set by @code{libffi}; you should initialize it to zero.
346
+
347
+ @item unsigned short type
348
+ For a structure, this should be set to @code{FFI_TYPE_STRUCT}.
349
+
350
+ @item ffi_type **elements
351
+ This is a @samp{NULL}-terminated array of pointers to @code{ffi_type}
352
+ objects. There is one element per field of the struct.
353
+ @end table
354
+ @end deftp
355
+
356
+
357
+ @node Type Example
358
+ @subsection Type Example
359
+
360
+ The following example initializes a @code{ffi_type} object
361
+ representing the @code{tm} struct from Linux's @file{time.h}.
362
+
363
+ Here is how the struct is defined:
364
+
365
+ @example
366
+ struct tm @{
367
+ int tm_sec;
368
+ int tm_min;
369
+ int tm_hour;
370
+ int tm_mday;
371
+ int tm_mon;
372
+ int tm_year;
373
+ int tm_wday;
374
+ int tm_yday;
375
+ int tm_isdst;
376
+ /* Those are for future use. */
377
+ long int __tm_gmtoff__;
378
+ __const char *__tm_zone__;
379
+ @};
380
+ @end example
381
+
382
+ Here is the corresponding code to describe this struct to
383
+ @code{libffi}:
384
+
385
+ @example
386
+ @{
387
+ ffi_type tm_type;
388
+ ffi_type *tm_type_elements[12];
389
+ int i;
390
+
391
+ tm_type.size = tm_type.alignment = 0;
392
+ tm_type.elements = &tm_type_elements;
393
+
394
+ for (i = 0; i < 9; i++)
395
+ tm_type_elements[i] = &ffi_type_sint;
396
+
397
+ tm_type_elements[9] = &ffi_type_slong;
398
+ tm_type_elements[10] = &ffi_type_pointer;
399
+ tm_type_elements[11] = NULL;
400
+
401
+ /* tm_type can now be used to represent tm argument types and
402
+ return types for ffi_prep_cif() */
403
+ @}
404
+ @end example
405
+
406
+
407
+ @node Multiple ABIs
408
+ @section Multiple ABIs
409
+
410
+ A given platform may provide multiple different ABIs at once. For
411
+ instance, the x86 platform has both @samp{stdcall} and @samp{fastcall}
412
+ functions.
413
+
414
+ @code{libffi} provides some support for this. However, this is
415
+ necessarily platform-specific.
416
+
417
+ @c FIXME: document the platforms
418
+
419
+ @node The Closure API
420
+ @section The Closure API
421
+
422
+ @code{libffi} also provides a way to write a generic function -- a
423
+ function that can accept and decode any combination of arguments.
424
+ This can be useful when writing an interpreter, or to provide wrappers
425
+ for arbitrary functions.
426
+
427
+ This facility is called the @dfn{closure API}. Closures are not
428
+ supported on all platforms; you can check the @code{FFI_CLOSURES}
429
+ define to determine whether they are supported on the current
430
+ platform.
431
+ @cindex closures
432
+ @cindex closure API
433
+ @findex FFI_CLOSURES
434
+
435
+ Because closures work by assembling a tiny function at runtime, they
436
+ require special allocation on platforms that have a non-executable
437
+ heap. Memory management for closures is handled by a pair of
438
+ functions:
439
+
440
+ @findex ffi_closure_alloca
441
+ @defun void *ffi_closure_alloc (size_t @var{size}, void **@var{code})
442
+ Allocate a chunk of memory holding @var{size} bytes. This returns a
443
+ pointer to the writable address, and sets *@var{code} to the
444
+ corresponding executable address.
445
+
446
+ @var{size} should be sufficient to hold a @code{ffi_closure} object.
447
+ @end defun
448
+
449
+ @findex ffi_closure_free
450
+ @defun void ffi_closure_free (void *@var{writable})
451
+ Free memory allocated using @code{ffi_closure_alloc}. The argument is
452
+ the writable address that was returned.
453
+ @end defun
454
+
455
+
456
+ Once you have allocated the memory for a closure, you must construct a
457
+ @code{ffi_cif} describing the function call. Finally you can prepare
458
+ the closure function:
459
+
460
+ @findex ffi_prep_closure_loc
461
+ @defun ffi_status ffi_prep_closure_loc (ffi_closure *@var{closure}, ffi_cif *@var{cif}, void (*@var{fun}) (ffi_cif *@var{cif}, void *@var{ret}, void **@var{args}, void *@var{user_data}), void *@var{user_data}, void *@var{codeloc})
462
+ Prepare a closure function.
463
+
464
+ @var{closure} is the address of a @code{ffi_closure} object; this is
465
+ the writable address returned by @code{ffi_closure_alloc}.
466
+
467
+ @var{cif} is the @code{ffi_cif} describing the function parameters.
468
+
469
+ @var{user_data} is an arbitrary datum that is passed, uninterpreted,
470
+ to your closure function.
471
+
472
+ @var{codeloc} is the executable address returned by
473
+ @code{ffi_closure_alloc}.
474
+
475
+ @var{fun} is the function which will be called when the closure is
476
+ invoked. It is called with the arguments:
477
+ @table @var
478
+ @item cif
479
+ The @code{ffi_cif} passed to @code{ffi_prep_closure_loc}.
480
+
481
+ @item ret
482
+ A pointer to the memory used for the function's return value.
483
+ @var{fun} must fill this, unless the function is declared as returning
484
+ @code{void}.
485
+ @c FIXME: is this NULL for void-returning functions?
486
+
487
+ @item args
488
+ A vector of pointers to memory holding the arguments to the function.
489
+
490
+ @item user_data
491
+ The same @var{user_data} that was passed to
492
+ @code{ffi_prep_closure_loc}.
493
+ @end table
494
+
495
+ @code{ffi_prep_closure_loc} will return @code{FFI_OK} if everything
496
+ went ok, and something else on error.
497
+ @c FIXME: what?
498
+
499
+ After calling @code{ffi_prep_closure_loc}, you can cast @var{codeloc}
500
+ to the appropriate pointer-to-function type.
501
+ @end defun
502
+
503
+ @c FIXME: example
504
+
505
+ You may see old code referring to @code{ffi_prep_closure}. This
506
+ function is deprecated, as it cannot handle the need for separate
507
+ writable and executable addresses.
508
+
509
+
510
+ @node Missing Features
511
+ @chapter Missing Features
512
+
513
+ @code{libffi} is missing a few features. We welcome patches to add
514
+ support for these.
515
+
516
+ @itemize @bullet
517
+ @item
518
+ There is no support for calling varargs functions. This may work on
519
+ some platforms, depending on how the ABI is defined, but it is not
520
+ reliable.
521
+
522
+ @item
523
+ There is no support for bit fields in structures.
524
+
525
+ @item
526
+ The closure API is
527
+
528
+ @item
529
+ The ``raw'' API is undocumented.
530
+ @c argument promotion?
531
+ @c unions?
532
+ @c anything else?
533
+ @end itemize
534
+
535
+
536
+ @node Index
537
+ @unnumbered Index
538
+
539
+ @printindex cp
540
+
541
+ @bye