ffi 1.9.21-x86-mingw32 → 1.9.22-x86-mingw32

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 (551) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +22 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +52 -0
  5. data/.yardopts +5 -0
  6. data/Gemfile +15 -0
  7. data/{spec/ffi/LICENSE.SPECS → LICENSE.SPECS} +1 -1
  8. data/README.md +1 -1
  9. data/Rakefile +28 -3
  10. data/appveyor.yml +22 -0
  11. data/ffi.gemspec +14 -1
  12. data/lib/2.0/ffi_c.so +0 -0
  13. data/lib/2.1/ffi_c.so +0 -0
  14. data/lib/2.2/ffi_c.so +0 -0
  15. data/lib/2.3/ffi_c.so +0 -0
  16. data/lib/2.4/ffi_c.so +0 -0
  17. data/lib/2.5/ffi_c.so +0 -0
  18. data/lib/ffi/library.rb +1 -1
  19. data/lib/ffi/version.rb +1 -1
  20. data/samples/getlogin.rb +8 -0
  21. data/samples/getpid.rb +8 -0
  22. data/samples/gettimeofday.rb +18 -0
  23. data/samples/hello.rb +7 -0
  24. data/samples/inotify.rb +60 -0
  25. data/samples/pty.rb +76 -0
  26. data/samples/qsort.rb +21 -0
  27. data/samples/sample_helper.rb +6 -0
  28. metadata +17 -526
  29. data/ext/ffi_c/AbstractMemory.c +0 -1109
  30. data/ext/ffi_c/AbstractMemory.h +0 -175
  31. data/ext/ffi_c/ArrayType.c +0 -162
  32. data/ext/ffi_c/ArrayType.h +0 -59
  33. data/ext/ffi_c/Buffer.c +0 -365
  34. data/ext/ffi_c/Call.c +0 -517
  35. data/ext/ffi_c/Call.h +0 -110
  36. data/ext/ffi_c/ClosurePool.c +0 -283
  37. data/ext/ffi_c/ClosurePool.h +0 -57
  38. data/ext/ffi_c/DataConverter.c +0 -91
  39. data/ext/ffi_c/DynamicLibrary.c +0 -339
  40. data/ext/ffi_c/DynamicLibrary.h +0 -98
  41. data/ext/ffi_c/Function.c +0 -998
  42. data/ext/ffi_c/Function.h +0 -87
  43. data/ext/ffi_c/FunctionInfo.c +0 -271
  44. data/ext/ffi_c/LastError.c +0 -184
  45. data/ext/ffi_c/LastError.h +0 -47
  46. data/ext/ffi_c/LongDouble.c +0 -63
  47. data/ext/ffi_c/LongDouble.h +0 -51
  48. data/ext/ffi_c/MappedType.c +0 -168
  49. data/ext/ffi_c/MappedType.h +0 -59
  50. data/ext/ffi_c/MemoryPointer.c +0 -197
  51. data/ext/ffi_c/MemoryPointer.h +0 -53
  52. data/ext/ffi_c/MethodHandle.c +0 -358
  53. data/ext/ffi_c/MethodHandle.h +0 -55
  54. data/ext/ffi_c/Platform.c +0 -129
  55. data/ext/ffi_c/Platform.h +0 -45
  56. data/ext/ffi_c/Pointer.c +0 -508
  57. data/ext/ffi_c/Pointer.h +0 -63
  58. data/ext/ffi_c/Struct.c +0 -829
  59. data/ext/ffi_c/Struct.h +0 -106
  60. data/ext/ffi_c/StructByReference.c +0 -190
  61. data/ext/ffi_c/StructByReference.h +0 -50
  62. data/ext/ffi_c/StructByValue.c +0 -150
  63. data/ext/ffi_c/StructByValue.h +0 -55
  64. data/ext/ffi_c/StructLayout.c +0 -698
  65. data/ext/ffi_c/Thread.c +0 -352
  66. data/ext/ffi_c/Thread.h +0 -95
  67. data/ext/ffi_c/Type.c +0 -397
  68. data/ext/ffi_c/Type.h +0 -62
  69. data/ext/ffi_c/Types.c +0 -139
  70. data/ext/ffi_c/Types.h +0 -89
  71. data/ext/ffi_c/Variadic.c +0 -304
  72. data/ext/ffi_c/compat.h +0 -78
  73. data/ext/ffi_c/extconf.rb +0 -71
  74. data/ext/ffi_c/ffi.c +0 -98
  75. data/ext/ffi_c/libffi.bsd.mk +0 -40
  76. data/ext/ffi_c/libffi.darwin.mk +0 -105
  77. data/ext/ffi_c/libffi.gnu.mk +0 -32
  78. data/ext/ffi_c/libffi.mk +0 -18
  79. data/ext/ffi_c/libffi.vc.mk +0 -26
  80. data/ext/ffi_c/libffi.vc64.mk +0 -26
  81. data/ext/ffi_c/libffi/ChangeLog.libffi +0 -584
  82. data/ext/ffi_c/libffi/ChangeLog.libffi-3.1 +0 -6000
  83. data/ext/ffi_c/libffi/ChangeLog.libgcj +0 -40
  84. data/ext/ffi_c/libffi/ChangeLog.v1 +0 -764
  85. data/ext/ffi_c/libffi/LICENSE +0 -21
  86. data/ext/ffi_c/libffi/Makefile.am +0 -205
  87. data/ext/ffi_c/libffi/Makefile.in +0 -1805
  88. data/ext/ffi_c/libffi/README +0 -454
  89. data/ext/ffi_c/libffi/acinclude.m4 +0 -473
  90. data/ext/ffi_c/libffi/aclocal.m4 +0 -2134
  91. data/ext/ffi_c/libffi/autogen.sh +0 -2
  92. data/ext/ffi_c/libffi/autom4te.cache/output.0 +0 -21972
  93. data/ext/ffi_c/libffi/autom4te.cache/output.1 +0 -21972
  94. data/ext/ffi_c/libffi/autom4te.cache/output.2 +0 -21972
  95. data/ext/ffi_c/libffi/autom4te.cache/output.3 +0 -21972
  96. data/ext/ffi_c/libffi/autom4te.cache/requests +0 -331
  97. data/ext/ffi_c/libffi/autom4te.cache/traces.0 +0 -4010
  98. data/ext/ffi_c/libffi/autom4te.cache/traces.1 +0 -1005
  99. data/ext/ffi_c/libffi/autom4te.cache/traces.2 +0 -4010
  100. data/ext/ffi_c/libffi/autom4te.cache/traces.3 +0 -4010
  101. data/ext/ffi_c/libffi/compile +0 -347
  102. data/ext/ffi_c/libffi/config.guess +0 -1462
  103. data/ext/ffi_c/libffi/config.sub +0 -1825
  104. data/ext/ffi_c/libffi/configure +0 -21972
  105. data/ext/ffi_c/libffi/configure.ac +0 -388
  106. data/ext/ffi_c/libffi/configure.host +0 -272
  107. data/ext/ffi_c/libffi/depcomp +0 -791
  108. data/ext/ffi_c/libffi/doc/Makefile.am +0 -3
  109. data/ext/ffi_c/libffi/doc/Makefile.in +0 -811
  110. data/ext/ffi_c/libffi/doc/libffi.texi +0 -985
  111. data/ext/ffi_c/libffi/doc/mdate-sh +0 -228
  112. data/ext/ffi_c/libffi/doc/texinfo.tex +0 -10079
  113. data/ext/ffi_c/libffi/doc/version.texi +0 -4
  114. data/ext/ffi_c/libffi/fficonfig.h.in +0 -210
  115. data/ext/ffi_c/libffi/fficonfig.h.in~ +0 -210
  116. data/ext/ffi_c/libffi/generate-darwin-source-and-headers.py +0 -207
  117. data/ext/ffi_c/libffi/include/Makefile.am +0 -9
  118. data/ext/ffi_c/libffi/include/Makefile.in +0 -604
  119. data/ext/ffi_c/libffi/include/ffi.h.in +0 -484
  120. data/ext/ffi_c/libffi/include/ffi_cfi.h +0 -55
  121. data/ext/ffi_c/libffi/include/ffi_common.h +0 -147
  122. data/ext/ffi_c/libffi/install-sh +0 -508
  123. data/ext/ffi_c/libffi/libffi.map.in +0 -80
  124. data/ext/ffi_c/libffi/libffi.pc.in +0 -11
  125. data/ext/ffi_c/libffi/libffi.xcodeproj/project.pbxproj +0 -637
  126. data/ext/ffi_c/libffi/libtool-ldflags +0 -106
  127. data/ext/ffi_c/libffi/libtool-version +0 -29
  128. data/ext/ffi_c/libffi/ltmain.sh +0 -11156
  129. data/ext/ffi_c/libffi/m4/asmcfi.m4 +0 -13
  130. data/ext/ffi_c/libffi/m4/ax_append_flag.m4 +0 -69
  131. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +0 -181
  132. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +0 -122
  133. data/ext/ffi_c/libffi/m4/ax_check_compile_flag.m4 +0 -72
  134. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +0 -84
  135. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +0 -70
  136. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +0 -301
  137. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +0 -225
  138. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +0 -79
  139. data/ext/ffi_c/libffi/m4/libtool.m4 +0 -8387
  140. data/ext/ffi_c/libffi/m4/ltoptions.m4 +0 -437
  141. data/ext/ffi_c/libffi/m4/ltsugar.m4 +0 -124
  142. data/ext/ffi_c/libffi/m4/ltversion.m4 +0 -23
  143. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +0 -99
  144. data/ext/ffi_c/libffi/man/Makefile.am +0 -8
  145. data/ext/ffi_c/libffi/man/Makefile.in +0 -558
  146. data/ext/ffi_c/libffi/man/ffi.3 +0 -41
  147. data/ext/ffi_c/libffi/man/ffi_call.3 +0 -103
  148. data/ext/ffi_c/libffi/man/ffi_prep_cif.3 +0 -68
  149. data/ext/ffi_c/libffi/man/ffi_prep_cif_var.3 +0 -73
  150. data/ext/ffi_c/libffi/missing +0 -215
  151. data/ext/ffi_c/libffi/msvcc.sh +0 -260
  152. data/ext/ffi_c/libffi/src/aarch64/ffi.c +0 -941
  153. data/ext/ffi_c/libffi/src/aarch64/ffitarget.h +0 -81
  154. data/ext/ffi_c/libffi/src/aarch64/internal.h +0 -67
  155. data/ext/ffi_c/libffi/src/aarch64/sysv.S +0 -438
  156. data/ext/ffi_c/libffi/src/alpha/ffi.c +0 -521
  157. data/ext/ffi_c/libffi/src/alpha/ffitarget.h +0 -57
  158. data/ext/ffi_c/libffi/src/alpha/internal.h +0 -23
  159. data/ext/ffi_c/libffi/src/alpha/osf.S +0 -282
  160. data/ext/ffi_c/libffi/src/arc/arcompact.S +0 -135
  161. data/ext/ffi_c/libffi/src/arc/ffi.c +0 -266
  162. data/ext/ffi_c/libffi/src/arc/ffitarget.h +0 -53
  163. data/ext/ffi_c/libffi/src/arm/ffi.c +0 -808
  164. data/ext/ffi_c/libffi/src/arm/ffitarget.h +0 -82
  165. data/ext/ffi_c/libffi/src/arm/internal.h +0 -7
  166. data/ext/ffi_c/libffi/src/arm/sysv.S +0 -383
  167. data/ext/ffi_c/libffi/src/avr32/ffi.c +0 -423
  168. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +0 -55
  169. data/ext/ffi_c/libffi/src/avr32/sysv.S +0 -208
  170. data/ext/ffi_c/libffi/src/bfin/ffi.c +0 -196
  171. data/ext/ffi_c/libffi/src/bfin/ffitarget.h +0 -43
  172. data/ext/ffi_c/libffi/src/bfin/sysv.S +0 -179
  173. data/ext/ffi_c/libffi/src/closures.c +0 -890
  174. data/ext/ffi_c/libffi/src/cris/ffi.c +0 -386
  175. data/ext/ffi_c/libffi/src/cris/ffitarget.h +0 -56
  176. data/ext/ffi_c/libffi/src/cris/sysv.S +0 -215
  177. data/ext/ffi_c/libffi/src/debug.c +0 -64
  178. data/ext/ffi_c/libffi/src/dlmalloc.c +0 -5166
  179. data/ext/ffi_c/libffi/src/frv/eabi.S +0 -128
  180. data/ext/ffi_c/libffi/src/frv/ffi.c +0 -292
  181. data/ext/ffi_c/libffi/src/frv/ffitarget.h +0 -62
  182. data/ext/ffi_c/libffi/src/ia64/ffi.c +0 -586
  183. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +0 -55
  184. data/ext/ffi_c/libffi/src/ia64/ia64_flags.h +0 -40
  185. data/ext/ffi_c/libffi/src/ia64/unix.S +0 -560
  186. data/ext/ffi_c/libffi/src/java_raw_api.c +0 -374
  187. data/ext/ffi_c/libffi/src/m32r/ffi.c +0 -232
  188. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +0 -53
  189. data/ext/ffi_c/libffi/src/m32r/sysv.S +0 -121
  190. data/ext/ffi_c/libffi/src/m68k/ffi.c +0 -362
  191. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +0 -54
  192. data/ext/ffi_c/libffi/src/m68k/sysv.S +0 -357
  193. data/ext/ffi_c/libffi/src/m88k/ffi.c +0 -400
  194. data/ext/ffi_c/libffi/src/m88k/ffitarget.h +0 -49
  195. data/ext/ffi_c/libffi/src/m88k/obsd.S +0 -209
  196. data/ext/ffi_c/libffi/src/metag/ffi.c +0 -330
  197. data/ext/ffi_c/libffi/src/metag/ffitarget.h +0 -53
  198. data/ext/ffi_c/libffi/src/metag/sysv.S +0 -311
  199. data/ext/ffi_c/libffi/src/microblaze/ffi.c +0 -321
  200. data/ext/ffi_c/libffi/src/microblaze/ffitarget.h +0 -53
  201. data/ext/ffi_c/libffi/src/microblaze/sysv.S +0 -302
  202. data/ext/ffi_c/libffi/src/mips/ffi.c +0 -1105
  203. data/ext/ffi_c/libffi/src/mips/ffitarget.h +0 -249
  204. data/ext/ffi_c/libffi/src/mips/n32.S +0 -661
  205. data/ext/ffi_c/libffi/src/mips/o32.S +0 -502
  206. data/ext/ffi_c/libffi/src/moxie/eabi.S +0 -101
  207. data/ext/ffi_c/libffi/src/moxie/ffi.c +0 -272
  208. data/ext/ffi_c/libffi/src/moxie/ffitarget.h +0 -52
  209. data/ext/ffi_c/libffi/src/nios2/ffi.c +0 -304
  210. data/ext/ffi_c/libffi/src/nios2/ffitarget.h +0 -52
  211. data/ext/ffi_c/libffi/src/nios2/sysv.S +0 -136
  212. data/ext/ffi_c/libffi/src/or1k/ffi.c +0 -328
  213. data/ext/ffi_c/libffi/src/or1k/ffitarget.h +0 -58
  214. data/ext/ffi_c/libffi/src/or1k/sysv.S +0 -107
  215. data/ext/ffi_c/libffi/src/pa/ffi.c +0 -719
  216. data/ext/ffi_c/libffi/src/pa/ffitarget.h +0 -85
  217. data/ext/ffi_c/libffi/src/pa/hpux32.S +0 -368
  218. data/ext/ffi_c/libffi/src/pa/linux.S +0 -357
  219. data/ext/ffi_c/libffi/src/powerpc/aix.S +0 -328
  220. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +0 -447
  221. data/ext/ffi_c/libffi/src/powerpc/asm.h +0 -125
  222. data/ext/ffi_c/libffi/src/powerpc/darwin.S +0 -378
  223. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +0 -571
  224. data/ext/ffi_c/libffi/src/powerpc/ffi.c +0 -173
  225. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +0 -1359
  226. data/ext/ffi_c/libffi/src/powerpc/ffi_linux64.c +0 -945
  227. data/ext/ffi_c/libffi/src/powerpc/ffi_powerpc.h +0 -94
  228. data/ext/ffi_c/libffi/src/powerpc/ffi_sysv.c +0 -923
  229. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +0 -195
  230. data/ext/ffi_c/libffi/src/powerpc/linux64.S +0 -228
  231. data/ext/ffi_c/libffi/src/powerpc/linux64_closure.S +0 -488
  232. data/ext/ffi_c/libffi/src/powerpc/ppc_closure.S +0 -397
  233. data/ext/ffi_c/libffi/src/powerpc/sysv.S +0 -175
  234. data/ext/ffi_c/libffi/src/prep_cif.c +0 -261
  235. data/ext/ffi_c/libffi/src/raw_api.c +0 -267
  236. data/ext/ffi_c/libffi/src/s390/ffi.c +0 -756
  237. data/ext/ffi_c/libffi/src/s390/ffitarget.h +0 -70
  238. data/ext/ffi_c/libffi/src/s390/internal.h +0 -11
  239. data/ext/ffi_c/libffi/src/s390/sysv.S +0 -325
  240. data/ext/ffi_c/libffi/src/sh/ffi.c +0 -717
  241. data/ext/ffi_c/libffi/src/sh/ffitarget.h +0 -54
  242. data/ext/ffi_c/libffi/src/sh/sysv.S +0 -850
  243. data/ext/ffi_c/libffi/src/sh64/ffi.c +0 -469
  244. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +0 -58
  245. data/ext/ffi_c/libffi/src/sh64/sysv.S +0 -539
  246. data/ext/ffi_c/libffi/src/sparc/ffi.c +0 -468
  247. data/ext/ffi_c/libffi/src/sparc/ffi64.c +0 -608
  248. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +0 -81
  249. data/ext/ffi_c/libffi/src/sparc/internal.h +0 -26
  250. data/ext/ffi_c/libffi/src/sparc/v8.S +0 -443
  251. data/ext/ffi_c/libffi/src/sparc/v9.S +0 -440
  252. data/ext/ffi_c/libffi/src/tile/ffi.c +0 -355
  253. data/ext/ffi_c/libffi/src/tile/ffitarget.h +0 -65
  254. data/ext/ffi_c/libffi/src/tile/tile.S +0 -360
  255. data/ext/ffi_c/libffi/src/types.c +0 -106
  256. data/ext/ffi_c/libffi/src/vax/elfbsd.S +0 -195
  257. data/ext/ffi_c/libffi/src/vax/ffi.c +0 -276
  258. data/ext/ffi_c/libffi/src/vax/ffitarget.h +0 -49
  259. data/ext/ffi_c/libffi/src/x86/asmnames.h +0 -30
  260. data/ext/ffi_c/libffi/src/x86/ffi.c +0 -733
  261. data/ext/ffi_c/libffi/src/x86/ffi64.c +0 -857
  262. data/ext/ffi_c/libffi/src/x86/ffitarget.h +0 -141
  263. data/ext/ffi_c/libffi/src/x86/ffiw64.c +0 -287
  264. data/ext/ffi_c/libffi/src/x86/internal.h +0 -29
  265. data/ext/ffi_c/libffi/src/x86/internal64.h +0 -22
  266. data/ext/ffi_c/libffi/src/x86/sysv.S +0 -1043
  267. data/ext/ffi_c/libffi/src/x86/unix64.S +0 -525
  268. data/ext/ffi_c/libffi/src/x86/win64.S +0 -232
  269. data/ext/ffi_c/libffi/src/x86/win64_intel.S +0 -237
  270. data/ext/ffi_c/libffi/src/xtensa/ffi.c +0 -298
  271. data/ext/ffi_c/libffi/src/xtensa/ffitarget.h +0 -53
  272. data/ext/ffi_c/libffi/src/xtensa/sysv.S +0 -253
  273. data/ext/ffi_c/libffi/stamp-h.in +0 -1
  274. data/ext/ffi_c/libffi/testsuite/Makefile.am +0 -85
  275. data/ext/ffi_c/libffi/testsuite/Makefile.in +0 -607
  276. data/ext/ffi_c/libffi/testsuite/config/default.exp +0 -1
  277. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +0 -445
  278. data/ext/ffi_c/libffi/testsuite/lib/target-libpath.exp +0 -283
  279. data/ext/ffi_c/libffi/testsuite/lib/wrapper.exp +0 -45
  280. data/ext/ffi_c/libffi/testsuite/libffi.call/align_mixed.c +0 -46
  281. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +0 -30
  282. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn0.c +0 -89
  283. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn1.c +0 -81
  284. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn2.c +0 -81
  285. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn3.c +0 -82
  286. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn4.c +0 -89
  287. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn5.c +0 -92
  288. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_fn6.c +0 -90
  289. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_loc_fn0.c +0 -95
  290. data/ext/ffi_c/libffi/testsuite/libffi.call/closure_simple.c +0 -55
  291. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_12byte.c +0 -94
  292. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_16byte.c +0 -95
  293. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_18byte.c +0 -96
  294. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_19byte.c +0 -102
  295. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_1_1byte.c +0 -89
  296. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte.c +0 -91
  297. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_20byte1.c +0 -93
  298. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_24byte.c +0 -113
  299. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_2byte.c +0 -90
  300. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3_1byte.c +0 -95
  301. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte1.c +0 -90
  302. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_3byte2.c +0 -90
  303. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4_1byte.c +0 -98
  304. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_4byte.c +0 -90
  305. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5_1_byte.c +0 -109
  306. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_5byte.c +0 -98
  307. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_64byte.c +0 -124
  308. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6_1_byte.c +0 -113
  309. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_6byte.c +0 -99
  310. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7_1_byte.c +0 -117
  311. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_7byte.c +0 -97
  312. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_8byte.c +0 -88
  313. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte1.c +0 -90
  314. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_9byte2.c +0 -91
  315. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_double.c +0 -93
  316. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_float.c +0 -91
  317. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble.c +0 -92
  318. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +0 -132
  319. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +0 -115
  320. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_pointer.c +0 -95
  321. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint16.c +0 -91
  322. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint32.c +0 -91
  323. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +0 -92
  324. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint16.c +0 -91
  325. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint32.c +0 -91
  326. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +0 -93
  327. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_dbls_struct.c +0 -66
  328. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double.c +0 -43
  329. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +0 -61
  330. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_float.c +0 -42
  331. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +0 -105
  332. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +0 -61
  333. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_many_mixed_args.c +0 -70
  334. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_many_mixed_float_double.c +0 -55
  335. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_schar.c +0 -74
  336. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshort.c +0 -74
  337. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_sshortchar.c +0 -86
  338. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_uchar.c +0 -91
  339. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushort.c +0 -74
  340. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_multi_ushortchar.c +0 -86
  341. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +0 -74
  342. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +0 -142
  343. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_schar.c +0 -44
  344. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sint.c +0 -42
  345. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_sshort.c +0 -42
  346. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_struct_va1.c +0 -114
  347. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar.c +0 -42
  348. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uchar_va.c +0 -44
  349. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint.c +0 -43
  350. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_uint_va.c +0 -45
  351. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulong_va.c +0 -45
  352. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +0 -47
  353. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort.c +0 -43
  354. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ushort_va.c +0 -44
  355. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +0 -36
  356. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +0 -26
  357. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +0 -136
  358. data/ext/ffi_c/libffi/testsuite/libffi.call/float.c +0 -59
  359. data/ext/ffi_c/libffi/testsuite/libffi.call/float1.c +0 -60
  360. data/ext/ffi_c/libffi/testsuite/libffi.call/float2.c +0 -60
  361. data/ext/ffi_c/libffi/testsuite/libffi.call/float3.c +0 -74
  362. data/ext/ffi_c/libffi/testsuite/libffi.call/float4.c +0 -62
  363. data/ext/ffi_c/libffi/testsuite/libffi.call/float_va.c +0 -107
  364. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +0 -341
  365. data/ext/ffi_c/libffi/testsuite/libffi.call/many.c +0 -59
  366. data/ext/ffi_c/libffi/testsuite/libffi.call/many2.c +0 -57
  367. data/ext/ffi_c/libffi/testsuite/libffi.call/many_double.c +0 -70
  368. data/ext/ffi_c/libffi/testsuite/libffi.call/many_mixed.c +0 -78
  369. data/ext/ffi_c/libffi/testsuite/libffi.call/negint.c +0 -52
  370. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct.c +0 -152
  371. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct1.c +0 -161
  372. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct10.c +0 -133
  373. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct11.c +0 -121
  374. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct2.c +0 -110
  375. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct3.c +0 -111
  376. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct4.c +0 -111
  377. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct5.c +0 -112
  378. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct6.c +0 -131
  379. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct7.c +0 -111
  380. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct8.c +0 -131
  381. data/ext/ffi_c/libffi/testsuite/libffi.call/nested_struct9.c +0 -131
  382. data/ext/ffi_c/libffi/testsuite/libffi.call/offsets.c +0 -46
  383. data/ext/ffi_c/libffi/testsuite/libffi.call/pr1172638.c +0 -127
  384. data/ext/ffi_c/libffi/testsuite/libffi.call/problem1.c +0 -90
  385. data/ext/ffi_c/libffi/testsuite/libffi.call/promotion.c +0 -59
  386. data/ext/ffi_c/libffi/testsuite/libffi.call/pyobjc-tc.c +0 -114
  387. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl.c +0 -36
  388. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl1.c +0 -43
  389. data/ext/ffi_c/libffi/testsuite/libffi.call/return_dbl2.c +0 -42
  390. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl.c +0 -35
  391. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl1.c +0 -36
  392. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl2.c +0 -49
  393. data/ext/ffi_c/libffi/testsuite/libffi.call/return_fl3.c +0 -42
  394. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ldl.c +0 -34
  395. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll.c +0 -41
  396. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +0 -43
  397. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sc.c +0 -36
  398. data/ext/ffi_c/libffi/testsuite/libffi.call/return_sl.c +0 -38
  399. data/ext/ffi_c/libffi/testsuite/libffi.call/return_uc.c +0 -38
  400. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ul.c +0 -38
  401. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large.c +0 -145
  402. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_large2.c +0 -148
  403. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium.c +0 -124
  404. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +0 -125
  405. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen.c +0 -44
  406. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen2.c +0 -49
  407. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen3.c +0 -49
  408. data/ext/ffi_c/libffi/testsuite/libffi.call/strlen4.c +0 -55
  409. data/ext/ffi_c/libffi/testsuite/libffi.call/struct1.c +0 -67
  410. data/ext/ffi_c/libffi/testsuite/libffi.call/struct2.c +0 -67
  411. data/ext/ffi_c/libffi/testsuite/libffi.call/struct3.c +0 -60
  412. data/ext/ffi_c/libffi/testsuite/libffi.call/struct4.c +0 -64
  413. data/ext/ffi_c/libffi/testsuite/libffi.call/struct5.c +0 -66
  414. data/ext/ffi_c/libffi/testsuite/libffi.call/struct6.c +0 -64
  415. data/ext/ffi_c/libffi/testsuite/libffi.call/struct7.c +0 -74
  416. data/ext/ffi_c/libffi/testsuite/libffi.call/struct8.c +0 -81
  417. data/ext/ffi_c/libffi/testsuite/libffi.call/struct9.c +0 -68
  418. data/ext/ffi_c/libffi/testsuite/libffi.call/testclosure.c +0 -70
  419. data/ext/ffi_c/libffi/testsuite/libffi.call/uninitialized.c +0 -61
  420. data/ext/ffi_c/libffi/testsuite/libffi.call/unwindtest.cc +0 -117
  421. data/ext/ffi_c/libffi/testsuite/libffi.call/unwindtest_ffi_call.cc +0 -54
  422. data/ext/ffi_c/libffi/testsuite/libffi.call/va_1.c +0 -196
  423. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct1.c +0 -121
  424. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct2.c +0 -123
  425. data/ext/ffi_c/libffi/testsuite/libffi.call/va_struct3.c +0 -125
  426. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex.inc +0 -91
  427. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_double.c +0 -10
  428. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_float.c +0 -10
  429. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_align_complex_longdouble.c +0 -10
  430. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex.inc +0 -42
  431. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_double.c +0 -10
  432. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_float.c +0 -10
  433. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_longdouble.c +0 -10
  434. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct.inc +0 -71
  435. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_double.c +0 -10
  436. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_float.c +0 -10
  437. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_struct_longdouble.c +0 -10
  438. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va.inc +0 -80
  439. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_double.c +0 -10
  440. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_float.c +0 -16
  441. data/ext/ffi_c/libffi/testsuite/libffi.complex/cls_complex_va_longdouble.c +0 -10
  442. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.exp +0 -36
  443. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex.inc +0 -51
  444. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_double.inc +0 -7
  445. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_float.inc +0 -7
  446. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_defs_longdouble.inc +0 -7
  447. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_double.c +0 -10
  448. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_float.c +0 -10
  449. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_int.c +0 -86
  450. data/ext/ffi_c/libffi/testsuite/libffi.complex/complex_longdouble.c +0 -10
  451. data/ext/ffi_c/libffi/testsuite/libffi.complex/ffitest.h +0 -1
  452. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex.inc +0 -78
  453. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_double.c +0 -10
  454. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_float.c +0 -10
  455. data/ext/ffi_c/libffi/testsuite/libffi.complex/many_complex_longdouble.c +0 -10
  456. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex.inc +0 -37
  457. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1.inc +0 -41
  458. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_double.c +0 -10
  459. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_float.c +0 -10
  460. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex1_longdouble.c +0 -10
  461. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2.inc +0 -44
  462. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_double.c +0 -10
  463. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_float.c +0 -10
  464. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex2_longdouble.c +0 -10
  465. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_double.c +0 -10
  466. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_float.c +0 -10
  467. data/ext/ffi_c/libffi/testsuite/libffi.complex/return_complex_longdouble.c +0 -10
  468. data/ext/ffi_c/libffi/testsuite/libffi.go/aa-direct.c +0 -34
  469. data/ext/ffi_c/libffi/testsuite/libffi.go/closure1.c +0 -28
  470. data/ext/ffi_c/libffi/testsuite/libffi.go/ffitest.h +0 -1
  471. data/ext/ffi_c/libffi/testsuite/libffi.go/go.exp +0 -36
  472. data/ext/ffi_c/libffi/testsuite/libffi.go/static-chain.h +0 -19
  473. data/ext/ffi_c/rbffi.h +0 -57
  474. data/ext/ffi_c/rbffi_endian.h +0 -59
  475. data/ext/ffi_c/win32/stdbool.h +0 -8
  476. data/ext/ffi_c/win32/stdint.h +0 -201
  477. data/gen/Rakefile +0 -30
  478. data/libtest/Benchmark.c +0 -52
  479. data/libtest/BoolTest.c +0 -34
  480. data/libtest/BufferTest.c +0 -31
  481. data/libtest/ClosureTest.c +0 -205
  482. data/libtest/EnumTest.c +0 -51
  483. data/libtest/FunctionTest.c +0 -70
  484. data/libtest/GNUmakefile +0 -149
  485. data/libtest/GlobalVariable.c +0 -62
  486. data/libtest/LastErrorTest.c +0 -21
  487. data/libtest/NumberTest.c +0 -132
  488. data/libtest/PointerTest.c +0 -63
  489. data/libtest/ReferenceTest.c +0 -23
  490. data/libtest/StringTest.c +0 -34
  491. data/libtest/StructTest.c +0 -243
  492. data/libtest/UnionTest.c +0 -43
  493. data/libtest/VariadicTest.c +0 -99
  494. data/spec/ffi/async_callback_spec.rb +0 -35
  495. data/spec/ffi/bitmask_spec.rb +0 -575
  496. data/spec/ffi/bool_spec.rb +0 -32
  497. data/spec/ffi/buffer_spec.rb +0 -279
  498. data/spec/ffi/callback_spec.rb +0 -773
  499. data/spec/ffi/custom_param_type.rb +0 -37
  500. data/spec/ffi/custom_type_spec.rb +0 -74
  501. data/spec/ffi/dup_spec.rb +0 -52
  502. data/spec/ffi/embed-test/ext/Makefile +0 -242
  503. data/spec/ffi/enum_spec.rb +0 -423
  504. data/spec/ffi/errno_spec.rb +0 -20
  505. data/spec/ffi/ffi_spec.rb +0 -28
  506. data/spec/ffi/fixtures/Benchmark.c +0 -52
  507. data/spec/ffi/fixtures/BitmaskTest.c +0 -51
  508. data/spec/ffi/fixtures/BoolTest.c +0 -34
  509. data/spec/ffi/fixtures/BufferTest.c +0 -31
  510. data/spec/ffi/fixtures/ClosureTest.c +0 -205
  511. data/spec/ffi/fixtures/EnumTest.c +0 -51
  512. data/spec/ffi/fixtures/FunctionTest.c +0 -142
  513. data/spec/ffi/fixtures/GNUmakefile +0 -149
  514. data/spec/ffi/fixtures/GlobalVariable.c +0 -62
  515. data/spec/ffi/fixtures/LastErrorTest.c +0 -21
  516. data/spec/ffi/fixtures/NumberTest.c +0 -132
  517. data/spec/ffi/fixtures/PipeHelper.h +0 -21
  518. data/spec/ffi/fixtures/PipeHelperPosix.c +0 -41
  519. data/spec/ffi/fixtures/PipeHelperWindows.c +0 -72
  520. data/spec/ffi/fixtures/PointerTest.c +0 -63
  521. data/spec/ffi/fixtures/ReferenceTest.c +0 -23
  522. data/spec/ffi/fixtures/StringTest.c +0 -34
  523. data/spec/ffi/fixtures/StructTest.c +0 -243
  524. data/spec/ffi/fixtures/UnionTest.c +0 -43
  525. data/spec/ffi/fixtures/VariadicTest.c +0 -99
  526. data/spec/ffi/fixtures/classes.rb +0 -438
  527. data/spec/ffi/function_spec.rb +0 -97
  528. data/spec/ffi/io_spec.rb +0 -16
  529. data/spec/ffi/library_spec.rb +0 -286
  530. data/spec/ffi/long_double.rb +0 -30
  531. data/spec/ffi/managed_struct_spec.rb +0 -68
  532. data/spec/ffi/memorypointer_spec.rb +0 -78
  533. data/spec/ffi/number_spec.rb +0 -247
  534. data/spec/ffi/platform_spec.rb +0 -114
  535. data/spec/ffi/pointer_spec.rb +0 -285
  536. data/spec/ffi/rbx/attach_function_spec.rb +0 -34
  537. data/spec/ffi/rbx/memory_pointer_spec.rb +0 -198
  538. data/spec/ffi/rbx/spec_helper.rb +0 -6
  539. data/spec/ffi/rbx/struct_spec.rb +0 -18
  540. data/spec/ffi/spec_helper.rb +0 -93
  541. data/spec/ffi/string_spec.rb +0 -118
  542. data/spec/ffi/strptr_spec.rb +0 -50
  543. data/spec/ffi/struct_by_ref_spec.rb +0 -43
  544. data/spec/ffi/struct_callback_spec.rb +0 -69
  545. data/spec/ffi/struct_initialize_spec.rb +0 -35
  546. data/spec/ffi/struct_packed_spec.rb +0 -50
  547. data/spec/ffi/struct_spec.rb +0 -882
  548. data/spec/ffi/typedef_spec.rb +0 -91
  549. data/spec/ffi/union_spec.rb +0 -67
  550. data/spec/ffi/variadic_spec.rb +0 -132
  551. data/spec/spec.opts +0 -4
@@ -1,985 +0,0 @@
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, 2010, 2011 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 Development
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
- * Closure Example:: A closure example.
110
- * Thread Safety:: Thread safety.
111
- @end menu
112
-
113
-
114
- @node The Basics
115
- @section The Basics
116
-
117
- @samp{Libffi} assumes that you have a pointer to the function you wish
118
- to call and that you know the number and types of arguments to pass
119
- it, as well as the return type of the function.
120
-
121
- The first thing you must do is create an @code{ffi_cif} object that
122
- matches the signature of the function you wish to call. This is a
123
- separate step because it is common to make multiple calls using a
124
- single @code{ffi_cif}. The @dfn{cif} in @code{ffi_cif} stands for
125
- Call InterFace. To prepare a call interface object, use the function
126
- @code{ffi_prep_cif}.
127
- @cindex cif
128
-
129
- @findex ffi_prep_cif
130
- @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})
131
- This initializes @var{cif} according to the given parameters.
132
-
133
- @var{abi} is the ABI to use; normally @code{FFI_DEFAULT_ABI} is what
134
- you want. @ref{Multiple ABIs} for more information.
135
-
136
- @var{nargs} is the number of arguments that this function accepts.
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
- If the function being called is variadic (varargs) then
153
- @code{ffi_prep_cif_var} must be used instead of @code{ffi_prep_cif}.
154
-
155
- @findex ffi_prep_cif_var
156
- @defun ffi_status ffi_prep_cif_var (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nfixedargs}, unsigned int @var{ntotalargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes})
157
- This initializes @var{cif} according to the given parameters for
158
- a call to a variadic function. In general its operation is the
159
- same as for @code{ffi_prep_cif} except that:
160
-
161
- @var{nfixedargs} is the number of fixed arguments, prior to any
162
- variadic arguments. It must be greater than zero.
163
-
164
- @var{ntotalargs} the total number of arguments, including variadic
165
- and fixed arguments. @var{argtypes} must have this many elements.
166
-
167
- Note that, different cif's must be prepped for calls to the same
168
- function when different numbers of arguments are passed.
169
-
170
- Also note that a call to @code{ffi_prep_cif_var} with
171
- @var{nfixedargs}=@var{nototalargs} is NOT equivalent to a call to
172
- @code{ffi_prep_cif}.
173
-
174
- @end defun
175
-
176
- Note that the resulting @code{ffi_cif} holds pointers to all the
177
- @code{ffi_type} objects that were used during initialization. You
178
- must ensure that these type objects have a lifetime at least as long
179
- as that of the @code{ffi_cif}.
180
-
181
- To call a function using an initialized @code{ffi_cif}, use the
182
- @code{ffi_call} function:
183
-
184
- @findex ffi_call
185
- @defun void ffi_call (ffi_cif *@var{cif}, void *@var{fn}, void *@var{rvalue}, void **@var{avalues})
186
- This calls the function @var{fn} according to the description given in
187
- @var{cif}. @var{cif} must have already been prepared using
188
- @code{ffi_prep_cif}.
189
-
190
- @var{rvalue} is a pointer to a chunk of memory that will hold the
191
- result of the function call. This must be large enough to hold the
192
- result, no smaller than the system register size (generally 32 or 64
193
- bits), and must be suitably aligned; it is the caller's responsibility
194
- to ensure this. If @var{cif} declares that the function returns
195
- @code{void} (using @code{ffi_type_void}), then @var{rvalue} is
196
- ignored.
197
-
198
- In most situations, @samp{libffi} will handle promotion according to
199
- the ABI. However, for historical reasons, there is a special case
200
- with return values that must be handled by your code. In particular,
201
- for integral (not @code{struct}) types that are narrower than the
202
- system register size, the return value will be widened by
203
- @samp{libffi}. @samp{libffi} provides a type, @code{ffi_arg}, that
204
- can be used as the return type. For example, if the CIF was defined
205
- with a return type of @code{char}, @samp{libffi} will try to store a
206
- full @code{ffi_arg} into the return value.
207
-
208
- @var{avalues} is a vector of @code{void *} pointers that point to the
209
- memory locations holding the argument values for a call. If @var{cif}
210
- declares that the function has no arguments (i.e., @var{nargs} was 0),
211
- then @var{avalues} is ignored. Note that argument values may be
212
- modified by the callee (for instance, structs passed by value); the
213
- burden of copying pass-by-value arguments is placed on the caller.
214
-
215
- Note that while the return value must be register-sized, arguments
216
- should exactly match their declared type. For example, if an argument
217
- is a @code{short}, then the entry in @var{avalues} should point to an
218
- object declared as @code{short}; but if the return type is
219
- @code{short}, then @var{rvalue} should point to an object declared as
220
- a larger type -- usually @code{ffi_arg}.
221
- @end defun
222
-
223
-
224
- @node Simple Example
225
- @section Simple Example
226
-
227
- Here is a trivial example that calls @code{puts} a few times.
228
-
229
- @example
230
- #include <stdio.h>
231
- #include <ffi.h>
232
-
233
- int main()
234
- @{
235
- ffi_cif cif;
236
- ffi_type *args[1];
237
- void *values[1];
238
- char *s;
239
- ffi_arg rc;
240
-
241
- /* Initialize the argument info vectors */
242
- args[0] = &ffi_type_pointer;
243
- values[0] = &s;
244
-
245
- /* Initialize the cif */
246
- if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
247
- &ffi_type_sint, args) == FFI_OK)
248
- @{
249
- s = "Hello World!";
250
- ffi_call(&cif, puts, &rc, values);
251
- /* rc now holds the result of the call to puts */
252
-
253
- /* values holds a pointer to the function's arg, so to
254
- call puts() again all we need to do is change the
255
- value of s */
256
- s = "This is cool!";
257
- ffi_call(&cif, puts, &rc, values);
258
- @}
259
-
260
- return 0;
261
- @}
262
- @end example
263
-
264
-
265
- @node Types
266
- @section Types
267
-
268
- @menu
269
- * Primitive Types:: Built-in types.
270
- * Structures:: Structure types.
271
- * Size and Alignment:: Size and alignment of types.
272
- * Arrays Unions Enums:: Arrays, unions, and enumerations.
273
- * Type Example:: Structure type example.
274
- * Complex:: Complex types.
275
- * Complex Type Example:: Complex type example.
276
- @end menu
277
-
278
- @node Primitive Types
279
- @subsection Primitive Types
280
-
281
- @code{Libffi} provides a number of built-in type descriptors that can
282
- be used to describe argument and return types:
283
-
284
- @table @code
285
- @item ffi_type_void
286
- @tindex ffi_type_void
287
- The type @code{void}. This cannot be used for argument types, only
288
- for return values.
289
-
290
- @item ffi_type_uint8
291
- @tindex ffi_type_uint8
292
- An unsigned, 8-bit integer type.
293
-
294
- @item ffi_type_sint8
295
- @tindex ffi_type_sint8
296
- A signed, 8-bit integer type.
297
-
298
- @item ffi_type_uint16
299
- @tindex ffi_type_uint16
300
- An unsigned, 16-bit integer type.
301
-
302
- @item ffi_type_sint16
303
- @tindex ffi_type_sint16
304
- A signed, 16-bit integer type.
305
-
306
- @item ffi_type_uint32
307
- @tindex ffi_type_uint32
308
- An unsigned, 32-bit integer type.
309
-
310
- @item ffi_type_sint32
311
- @tindex ffi_type_sint32
312
- A signed, 32-bit integer type.
313
-
314
- @item ffi_type_uint64
315
- @tindex ffi_type_uint64
316
- An unsigned, 64-bit integer type.
317
-
318
- @item ffi_type_sint64
319
- @tindex ffi_type_sint64
320
- A signed, 64-bit integer type.
321
-
322
- @item ffi_type_float
323
- @tindex ffi_type_float
324
- The C @code{float} type.
325
-
326
- @item ffi_type_double
327
- @tindex ffi_type_double
328
- The C @code{double} type.
329
-
330
- @item ffi_type_uchar
331
- @tindex ffi_type_uchar
332
- The C @code{unsigned char} type.
333
-
334
- @item ffi_type_schar
335
- @tindex ffi_type_schar
336
- The C @code{signed char} type. (Note that there is not an exact
337
- equivalent to the C @code{char} type in @code{libffi}; ordinarily you
338
- should either use @code{ffi_type_schar} or @code{ffi_type_uchar}
339
- depending on whether @code{char} is signed.)
340
-
341
- @item ffi_type_ushort
342
- @tindex ffi_type_ushort
343
- The C @code{unsigned short} type.
344
-
345
- @item ffi_type_sshort
346
- @tindex ffi_type_sshort
347
- The C @code{short} type.
348
-
349
- @item ffi_type_uint
350
- @tindex ffi_type_uint
351
- The C @code{unsigned int} type.
352
-
353
- @item ffi_type_sint
354
- @tindex ffi_type_sint
355
- The C @code{int} type.
356
-
357
- @item ffi_type_ulong
358
- @tindex ffi_type_ulong
359
- The C @code{unsigned long} type.
360
-
361
- @item ffi_type_slong
362
- @tindex ffi_type_slong
363
- The C @code{long} type.
364
-
365
- @item ffi_type_longdouble
366
- @tindex ffi_type_longdouble
367
- On platforms that have a C @code{long double} type, this is defined.
368
- On other platforms, it is not.
369
-
370
- @item ffi_type_pointer
371
- @tindex ffi_type_pointer
372
- A generic @code{void *} pointer. You should use this for all
373
- pointers, regardless of their real type.
374
-
375
- @item ffi_type_complex_float
376
- @tindex ffi_type_complex_float
377
- The C @code{_Complex float} type.
378
-
379
- @item ffi_type_complex_double
380
- @tindex ffi_type_complex_double
381
- The C @code{_Complex double} type.
382
-
383
- @item ffi_type_complex_longdouble
384
- @tindex ffi_type_complex_longdouble
385
- The C @code{_Complex long double} type.
386
- On platforms that have a C @code{long double} type, this is defined.
387
- On other platforms, it is not.
388
- @end table
389
-
390
- Each of these is of type @code{ffi_type}, so you must take the address
391
- when passing to @code{ffi_prep_cif}.
392
-
393
-
394
- @node Structures
395
- @subsection Structures
396
-
397
- @samp{libffi} is perfectly happy passing structures back and forth.
398
- You must first describe the structure to @samp{libffi} by creating a
399
- new @code{ffi_type} object for it.
400
-
401
- @tindex ffi_type
402
- @deftp {Data type} ffi_type
403
- The @code{ffi_type} has the following members:
404
- @table @code
405
- @item size_t size
406
- This is set by @code{libffi}; you should initialize it to zero.
407
-
408
- @item unsigned short alignment
409
- This is set by @code{libffi}; you should initialize it to zero.
410
-
411
- @item unsigned short type
412
- For a structure, this should be set to @code{FFI_TYPE_STRUCT}.
413
-
414
- @item ffi_type **elements
415
- This is a @samp{NULL}-terminated array of pointers to @code{ffi_type}
416
- objects. There is one element per field of the struct.
417
-
418
- Note that @samp{libffi} has no special support for bit-fields. You
419
- must manage these manually.
420
- @end table
421
- @end deftp
422
-
423
- The @code{size} and @code{alignment} fields will be filled in by
424
- @code{ffi_prep_cif} or @code{ffi_prep_cif_var}, as needed.
425
-
426
- @node Size and Alignment
427
- @subsection Size and Alignment
428
-
429
- @code{libffi} will set the @code{size} and @code{alignment} fields of
430
- an @code{ffi_type} object for you. It does so using its knowledge of
431
- the ABI.
432
-
433
- You might expect that you can simply read these fields for a type that
434
- has been laid out by @code{libffi}. However, there are some caveats.
435
-
436
- @itemize @bullet
437
- @item
438
- The size or alignment of some of the built-in types may vary depending
439
- on the chosen ABI.
440
-
441
- @item
442
- The size and alignment of a new structure type will not be set by
443
- @code{libffi} until it has been passed to @code{ffi_prep_cif} or
444
- @code{ffi_get_struct_offsets}.
445
-
446
- @item
447
- A structure type cannot be shared across ABIs. Instead each ABI needs
448
- its own copy of the structure type.
449
- @end itemize
450
-
451
- So, before examining these fields, it is safest to pass the
452
- @code{ffi_type} object to @code{ffi_prep_cif} or
453
- @code{ffi_get_struct_offsets} first. This function will do all the
454
- needed setup.
455
-
456
- @example
457
- ffi_type *desired_type;
458
- ffi_abi desired_abi;
459
- @dots{}
460
- ffi_cif cif;
461
- if (ffi_prep_cif (&cif, desired_abi, 0, desired_type, NULL) == FFI_OK)
462
- @{
463
- size_t size = desired_type->size;
464
- unsigned short alignment = desired_type->alignment;
465
- @}
466
- @end example
467
-
468
- @code{libffi} also provides a way to get the offsets of the members of
469
- a structure.
470
-
471
- @findex ffi_get_struct_offsets
472
- @defun ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, size_t *offsets)
473
- Compute the offset of each element of the given structure type.
474
- @var{abi} is the ABI to use; this is needed because in some cases the
475
- layout depends on the ABI.
476
-
477
- @var{offsets} is an out parameter. The caller is responsible for
478
- providing enough space for all the results to be written -- one
479
- element per element type in @var{struct_type}. If @var{offsets} is
480
- @code{NULL}, then the type will be laid out but not otherwise
481
- modified. This can be useful for accessing the type's size or layout,
482
- as mentioned above.
483
-
484
- This function returns @code{FFI_OK} on success; @code{FFI_BAD_ABI} if
485
- @var{abi} is invalid; or @code{FFI_BAD_TYPEDEF} if @var{struct_type}
486
- is invalid in some way. Note that only @code{FFI_STRUCT} types are
487
- valid here.
488
- @end defun
489
-
490
- @node Arrays Unions Enums
491
- @subsection Arrays, Unions, and Enumerations
492
-
493
- @subsubsection Arrays
494
-
495
- @samp{libffi} does not have direct support for arrays or unions.
496
- However, they can be emulated using structures.
497
-
498
- To emulate an array, simply create an @code{ffi_type} using
499
- @code{FFI_TYPE_STRUCT} with as many members as there are elements in
500
- the array.
501
-
502
- @example
503
- ffi_type array_type;
504
- ffi_type **elements
505
- int i;
506
-
507
- elements = malloc ((n + 1) * sizeof (ffi_type *));
508
- for (i = 0; i < n; ++i)
509
- elements[i] = array_element_type;
510
- elements[n] = NULL;
511
-
512
- array_type.size = array_type.alignment = 0;
513
- array_type.type = FFI_TYPE_STRUCT;
514
- array_type.elements = elements;
515
- @end example
516
-
517
- Note that arrays cannot be passed or returned by value in C --
518
- structure types created like this should only be used to refer to
519
- members of real @code{FFI_TYPE_STRUCT} objects.
520
-
521
- However, a phony array type like this will not cause any errors from
522
- @samp{libffi} if you use it as an argument or return type. This may
523
- be confusing.
524
-
525
- @subsubsection Unions
526
-
527
- A union can also be emulated using @code{FFI_TYPE_STRUCT}. In this
528
- case, however, you must make sure that the size and alignment match
529
- the real requirements of the union.
530
-
531
- One simple way to do this is to ensue that each element type is laid
532
- out. Then, give the new structure type a single element; the size of
533
- the largest element; and the largest alignment seen as well.
534
-
535
- This example uses the @code{ffi_prep_cif} trick to ensure that each
536
- element type is laid out.
537
-
538
- @example
539
- ffi_abi desired_abi;
540
- ffi_type union_type;
541
- ffi_type **union_elements;
542
-
543
- int i;
544
- ffi_type element_types[2];
545
-
546
- element_types[1] = NULL;
547
-
548
- union_type.size = union_type.alignment = 0;
549
- union_type.type = FFI_TYPE_STRUCT;
550
- union_type.elements = element_types;
551
-
552
- for (i = 0; union_elements[i]; ++i)
553
- @{
554
- ffi_cif cif;
555
- if (ffi_prep_cif (&cif, desired_abi, 0, union_elements[i], NULL) == FFI_OK)
556
- @{
557
- if (union_elements[i]->size > union_type.size)
558
- @{
559
- union_type.size = union_elements[i];
560
- size = union_elements[i]->size;
561
- @}
562
- if (union_elements[i]->alignment > union_type.alignment)
563
- union_type.alignment = union_elements[i]->alignment;
564
- @}
565
- @}
566
- @end example
567
-
568
- @subsubsection Enumerations
569
-
570
- @code{libffi} does not have any special support for C @code{enum}s.
571
- Although any given @code{enum} is implemented using a specific
572
- underlying integral type, exactly which type will be used cannot be
573
- determined by @code{libffi} -- it may depend on the values in the
574
- enumeration or on compiler flags such as @option{-fshort-enums}.
575
- @xref{Structures unions enumerations and bit-fields implementation, , , gcc},
576
- for more information about how GCC handles enumerations.
577
-
578
- @node Type Example
579
- @subsection Type Example
580
-
581
- The following example initializes a @code{ffi_type} object
582
- representing the @code{tm} struct from Linux's @file{time.h}.
583
-
584
- Here is how the struct is defined:
585
-
586
- @example
587
- struct tm @{
588
- int tm_sec;
589
- int tm_min;
590
- int tm_hour;
591
- int tm_mday;
592
- int tm_mon;
593
- int tm_year;
594
- int tm_wday;
595
- int tm_yday;
596
- int tm_isdst;
597
- /* Those are for future use. */
598
- long int __tm_gmtoff__;
599
- __const char *__tm_zone__;
600
- @};
601
- @end example
602
-
603
- Here is the corresponding code to describe this struct to
604
- @code{libffi}:
605
-
606
- @example
607
- @{
608
- ffi_type tm_type;
609
- ffi_type *tm_type_elements[12];
610
- int i;
611
-
612
- tm_type.size = tm_type.alignment = 0;
613
- tm_type.type = FFI_TYPE_STRUCT;
614
- tm_type.elements = &tm_type_elements;
615
-
616
- for (i = 0; i < 9; i++)
617
- tm_type_elements[i] = &ffi_type_sint;
618
-
619
- tm_type_elements[9] = &ffi_type_slong;
620
- tm_type_elements[10] = &ffi_type_pointer;
621
- tm_type_elements[11] = NULL;
622
-
623
- /* tm_type can now be used to represent tm argument types and
624
- return types for ffi_prep_cif() */
625
- @}
626
- @end example
627
-
628
- @node Complex
629
- @subsection Complex Types
630
-
631
- @samp{libffi} supports the complex types defined by the C99
632
- standard (@code{_Complex float}, @code{_Complex double} and
633
- @code{_Complex long double} with the built-in type descriptors
634
- @code{ffi_type_complex_float}, @code{ffi_type_complex_double} and
635
- @code{ffi_type_complex_longdouble}.
636
-
637
- Custom complex types like @code{_Complex int} can also be used.
638
- An @code{ffi_type} object has to be defined to describe the
639
- complex type to @samp{libffi}.
640
-
641
- @tindex ffi_type
642
- @deftp {Data type} ffi_type
643
- @table @code
644
- @item size_t size
645
- This must be manually set to the size of the complex type.
646
-
647
- @item unsigned short alignment
648
- This must be manually set to the alignment of the complex type.
649
-
650
- @item unsigned short type
651
- For a complex type, this must be set to @code{FFI_TYPE_COMPLEX}.
652
-
653
- @item ffi_type **elements
654
-
655
- This is a @samp{NULL}-terminated array of pointers to
656
- @code{ffi_type} objects. The first element is set to the
657
- @code{ffi_type} of the complex's base type. The second element
658
- must be set to @code{NULL}.
659
- @end table
660
- @end deftp
661
-
662
- The section @ref{Complex Type Example} shows a way to determine
663
- the @code{size} and @code{alignment} members in a platform
664
- independent way.
665
-
666
- For platforms that have no complex support in @code{libffi} yet,
667
- the functions @code{ffi_prep_cif} and @code{ffi_prep_args} abort
668
- the program if they encounter a complex type.
669
-
670
- @node Complex Type Example
671
- @subsection Complex Type Example
672
-
673
- This example demonstrates how to use complex types:
674
-
675
- @example
676
- #include <stdio.h>
677
- #include <ffi.h>
678
- #include <complex.h>
679
-
680
- void complex_fn(_Complex float cf,
681
- _Complex double cd,
682
- _Complex long double cld)
683
- @{
684
- printf("cf=%f+%fi\ncd=%f+%fi\ncld=%f+%fi\n",
685
- (float)creal (cf), (float)cimag (cf),
686
- (float)creal (cd), (float)cimag (cd),
687
- (float)creal (cld), (float)cimag (cld));
688
- @}
689
-
690
- int main()
691
- @{
692
- ffi_cif cif;
693
- ffi_type *args[3];
694
- void *values[3];
695
- _Complex float cf;
696
- _Complex double cd;
697
- _Complex long double cld;
698
-
699
- /* Initialize the argument info vectors */
700
- args[0] = &ffi_type_complex_float;
701
- args[1] = &ffi_type_complex_double;
702
- args[2] = &ffi_type_complex_longdouble;
703
- values[0] = &cf;
704
- values[1] = &cd;
705
- values[2] = &cld;
706
-
707
- /* Initialize the cif */
708
- if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
709
- &ffi_type_void, args) == FFI_OK)
710
- @{
711
- cf = 1.0 + 20.0 * I;
712
- cd = 300.0 + 4000.0 * I;
713
- cld = 50000.0 + 600000.0 * I;
714
- /* Call the function */
715
- ffi_call(&cif, (void (*)(void))complex_fn, 0, values);
716
- @}
717
-
718
- return 0;
719
- @}
720
- @end example
721
-
722
- This is an example for defining a custom complex type descriptor
723
- for compilers that support them:
724
-
725
- @example
726
- /*
727
- * This macro can be used to define new complex type descriptors
728
- * in a platform independent way.
729
- *
730
- * name: Name of the new descriptor is ffi_type_complex_<name>.
731
- * type: The C base type of the complex type.
732
- */
733
- #define FFI_COMPLEX_TYPEDEF(name, type, ffitype) \
734
- static ffi_type *ffi_elements_complex_##name [2] = @{ \
735
- (ffi_type *)(&ffitype), NULL \
736
- @}; \
737
- struct struct_align_complex_##name @{ \
738
- char c; \
739
- _Complex type x; \
740
- @}; \
741
- ffi_type ffi_type_complex_##name = @{ \
742
- sizeof(_Complex type), \
743
- offsetof(struct struct_align_complex_##name, x), \
744
- FFI_TYPE_COMPLEX, \
745
- (ffi_type **)ffi_elements_complex_##name \
746
- @}
747
-
748
- /* Define new complex type descriptors using the macro: */
749
- /* ffi_type_complex_sint */
750
- FFI_COMPLEX_TYPEDEF(sint, int, ffi_type_sint);
751
- /* ffi_type_complex_uchar */
752
- FFI_COMPLEX_TYPEDEF(uchar, unsigned char, ffi_type_uint8);
753
- @end example
754
-
755
- The new type descriptors can then be used like one of the built-in
756
- type descriptors in the previous example.
757
-
758
- @node Multiple ABIs
759
- @section Multiple ABIs
760
-
761
- A given platform may provide multiple different ABIs at once. For
762
- instance, the x86 platform has both @samp{stdcall} and @samp{fastcall}
763
- functions.
764
-
765
- @code{libffi} provides some support for this. However, this is
766
- necessarily platform-specific.
767
-
768
- @c FIXME: document the platforms
769
-
770
- @node The Closure API
771
- @section The Closure API
772
-
773
- @code{libffi} also provides a way to write a generic function -- a
774
- function that can accept and decode any combination of arguments.
775
- This can be useful when writing an interpreter, or to provide wrappers
776
- for arbitrary functions.
777
-
778
- This facility is called the @dfn{closure API}. Closures are not
779
- supported on all platforms; you can check the @code{FFI_CLOSURES}
780
- define to determine whether they are supported on the current
781
- platform.
782
- @cindex closures
783
- @cindex closure API
784
- @findex FFI_CLOSURES
785
-
786
- Because closures work by assembling a tiny function at runtime, they
787
- require special allocation on platforms that have a non-executable
788
- heap. Memory management for closures is handled by a pair of
789
- functions:
790
-
791
- @findex ffi_closure_alloc
792
- @defun void *ffi_closure_alloc (size_t @var{size}, void **@var{code})
793
- Allocate a chunk of memory holding @var{size} bytes. This returns a
794
- pointer to the writable address, and sets *@var{code} to the
795
- corresponding executable address.
796
-
797
- @var{size} should be sufficient to hold a @code{ffi_closure} object.
798
- @end defun
799
-
800
- @findex ffi_closure_free
801
- @defun void ffi_closure_free (void *@var{writable})
802
- Free memory allocated using @code{ffi_closure_alloc}. The argument is
803
- the writable address that was returned.
804
- @end defun
805
-
806
-
807
- Once you have allocated the memory for a closure, you must construct a
808
- @code{ffi_cif} describing the function call. Finally you can prepare
809
- the closure function:
810
-
811
- @findex ffi_prep_closure_loc
812
- @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})
813
- Prepare a closure function. The arguments to
814
- @code{ffi_prep_closure_loc} are:
815
-
816
- @table @var
817
- @item closure
818
- The address of a @code{ffi_closure} object; this is the writable
819
- address returned by @code{ffi_closure_alloc}.
820
-
821
- @item cif
822
- The @code{ffi_cif} describing the function parameters. Note that this
823
- object, and the types to which it refers, must be kept alive until the
824
- closure itself is freed.
825
-
826
- @item user_data
827
- An arbitrary datum that is passed, uninterpreted, to your closure
828
- function.
829
-
830
- @item codeloc
831
- The executable address returned by @code{ffi_closure_alloc}.
832
-
833
- @item fun
834
- The function which will be called when the closure is invoked. It is
835
- called with the arguments:
836
-
837
- @table @var
838
- @item cif
839
- The @code{ffi_cif} passed to @code{ffi_prep_closure_loc}.
840
-
841
- @item ret
842
- A pointer to the memory used for the function's return value.
843
-
844
- If the function is declared as returning @code{void}, then this value
845
- is garbage and should not be used.
846
-
847
- Otherwise, @var{fun} must fill the object to which this points,
848
- following the same special promotion behavior as @code{ffi_call}.
849
- That is, in most cases, @var{ret} points to an object of exactly the
850
- size of the type specified when @var{cif} was constructed. However,
851
- integral types narrower than the system register size are widened. In
852
- these cases your program may assume that @var{ret} points to an
853
- @code{ffi_arg} object.
854
-
855
- @item args
856
- A vector of pointers to memory holding the arguments to the function.
857
-
858
- @item user_data
859
- The same @var{user_data} that was passed to
860
- @code{ffi_prep_closure_loc}.
861
- @end table
862
- @end table
863
-
864
- @code{ffi_prep_closure_loc} will return @code{FFI_OK} if everything
865
- went ok, and one of the other @code{ffi_status} values on error.
866
-
867
- After calling @code{ffi_prep_closure_loc}, you can cast @var{codeloc}
868
- to the appropriate pointer-to-function type.
869
- @end defun
870
-
871
- You may see old code referring to @code{ffi_prep_closure}. This
872
- function is deprecated, as it cannot handle the need for separate
873
- writable and executable addresses.
874
-
875
- @node Closure Example
876
- @section Closure Example
877
-
878
- A trivial example that creates a new @code{puts} by binding
879
- @code{fputs} with @code{stdout}.
880
-
881
- @example
882
- #include <stdio.h>
883
- #include <ffi.h>
884
-
885
- /* Acts like puts with the file given at time of enclosure. */
886
- void puts_binding(ffi_cif *cif, void *ret, void* args[],
887
- void *stream)
888
- @{
889
- *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
890
- @}
891
-
892
- typedef int (*puts_t)(char *);
893
-
894
- int main()
895
- @{
896
- ffi_cif cif;
897
- ffi_type *args[1];
898
- ffi_closure *closure;
899
-
900
- void *bound_puts;
901
- int rc;
902
-
903
- /* Allocate closure and bound_puts */
904
- closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
905
-
906
- if (closure)
907
- @{
908
- /* Initialize the argument info vectors */
909
- args[0] = &ffi_type_pointer;
910
-
911
- /* Initialize the cif */
912
- if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
913
- &ffi_type_sint, args) == FFI_OK)
914
- @{
915
- /* Initialize the closure, setting stream to stdout */
916
- if (ffi_prep_closure_loc(closure, &cif, puts_binding,
917
- stdout, bound_puts) == FFI_OK)
918
- @{
919
- rc = ((puts_t)bound_puts)("Hello World!");
920
- /* rc now holds the result of the call to fputs */
921
- @}
922
- @}
923
- @}
924
-
925
- /* Deallocate both closure, and bound_puts */
926
- ffi_closure_free(closure);
927
-
928
- return 0;
929
- @}
930
-
931
- @end example
932
-
933
- @node Thread Safety
934
- @section Thread Safety
935
-
936
- @code{libffi} is not completely thread-safe. However, many parts are,
937
- and if you follow some simple rules, you can use it safely in a
938
- multi-threaded program.
939
-
940
- @itemize @bullet
941
- @item
942
- @code{ffi_prep_cif} may modify the @code{ffi_type} objects passed to
943
- it. It is best to ensure that only a single thread prepares a given
944
- @code{ffi_cif} at a time.
945
-
946
- @item
947
- On some platforms, @code{ffi_prep_cif} may modify the size and
948
- alignment of some types, depending on the chosen ABI. On these
949
- platforms, if you switch between ABIs, you must ensure that there is
950
- only one call to @code{ffi_prep_cif} at a time.
951
-
952
- Currently the only affected platform is PowerPC and the only affected
953
- type is @code{long double}.
954
- @end itemize
955
-
956
- @node Missing Features
957
- @chapter Missing Features
958
-
959
- @code{libffi} is missing a few features. We welcome patches to add
960
- support for these.
961
-
962
- @itemize @bullet
963
- @item
964
- Variadic closures.
965
-
966
- @item
967
- There is no support for bit fields in structures.
968
-
969
- @item
970
- The ``raw'' API is undocumented.
971
- @c anything else?
972
-
973
- @item
974
- The Go API is undocumented.
975
- @end itemize
976
-
977
- Note that variadic support is very new and tested on a relatively
978
- small number of platforms.
979
-
980
- @node Index
981
- @unnumbered Index
982
-
983
- @printindex cp
984
-
985
- @bye