ffi 1.0.9-x86-mingw32 → 1.0.12.pre-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 (218) hide show
  1. data/Rakefile +16 -16
  2. data/ext/ffi_c/AbstractMemory.c +376 -14
  3. data/ext/ffi_c/AbstractMemory.h +8 -0
  4. data/ext/ffi_c/ArrayType.c +28 -0
  5. data/ext/ffi_c/Buffer.c +109 -25
  6. data/ext/ffi_c/Call.c +16 -5
  7. data/ext/ffi_c/ClosurePool.c +21 -8
  8. data/ext/ffi_c/DataConverter.c +29 -0
  9. data/ext/ffi_c/DynamicLibrary.c +71 -2
  10. data/ext/ffi_c/Function.c +122 -11
  11. data/ext/ffi_c/Function.h +6 -0
  12. data/ext/ffi_c/FunctionInfo.c +21 -1
  13. data/ext/ffi_c/LastError.c +24 -0
  14. data/ext/ffi_c/MappedType.c +22 -0
  15. data/ext/ffi_c/MemoryPointer.c +19 -1
  16. data/ext/ffi_c/MemoryPointer.h +6 -0
  17. data/ext/ffi_c/MethodHandle.c +26 -11
  18. data/ext/ffi_c/Platform.c +17 -3
  19. data/ext/ffi_c/Pointer.c +106 -0
  20. data/ext/ffi_c/Pointer.h +6 -0
  21. data/ext/ffi_c/Struct.c +10 -4
  22. data/ext/ffi_c/Struct.h +2 -1
  23. data/ext/ffi_c/StructByReference.c +8 -0
  24. data/ext/ffi_c/StructByValue.c +8 -0
  25. data/ext/ffi_c/StructLayout.c +8 -2
  26. data/ext/ffi_c/Thread.c +131 -1
  27. data/ext/ffi_c/Thread.h +6 -0
  28. data/ext/ffi_c/Type.c +111 -17
  29. data/ext/ffi_c/Types.c +9 -2
  30. data/ext/ffi_c/Types.h +4 -0
  31. data/ext/ffi_c/Variadic.c +13 -4
  32. data/ext/ffi_c/compat.h +8 -0
  33. data/ext/ffi_c/endian.h +10 -1
  34. data/ext/ffi_c/extconf.rb +51 -35
  35. data/ext/ffi_c/ffi.c +5 -0
  36. data/ext/ffi_c/libffi.darwin.mk +15 -15
  37. data/ext/ffi_c/libffi.gnu.mk +3 -3
  38. data/ext/ffi_c/libffi.mk +4 -4
  39. data/ext/ffi_c/libffi.vc.mk +26 -0
  40. data/ext/ffi_c/libffi.vc64.mk +26 -0
  41. data/ext/ffi_c/libffi/ChangeLog +541 -0
  42. data/ext/ffi_c/libffi/ChangeLog.libffi +13 -87
  43. data/ext/ffi_c/libffi/LICENSE +3 -3
  44. data/ext/ffi_c/libffi/Makefile.am +41 -32
  45. data/ext/ffi_c/libffi/Makefile.in +95 -66
  46. data/ext/ffi_c/libffi/Makefile.vc +141 -0
  47. data/ext/ffi_c/libffi/Makefile.vc64 +141 -0
  48. data/ext/ffi_c/libffi/README +40 -4
  49. data/ext/ffi_c/libffi/aclocal.m4 +729 -7854
  50. data/ext/ffi_c/libffi/build-ios.sh +67 -0
  51. data/ext/ffi_c/libffi/compile +11 -10
  52. data/ext/ffi_c/libffi/config.guess +4 -1
  53. data/ext/ffi_c/libffi/config.sub +6 -3
  54. data/ext/ffi_c/libffi/configure +6264 -6354
  55. data/ext/ffi_c/libffi/configure.ac +155 -63
  56. data/ext/ffi_c/libffi/depcomp +81 -35
  57. data/ext/ffi_c/libffi/doc/libffi.info +78 -18
  58. data/ext/ffi_c/libffi/doc/libffi.texi +64 -5
  59. data/ext/ffi_c/libffi/doc/stamp-vti +4 -4
  60. data/ext/ffi_c/libffi/doc/version.texi +4 -4
  61. data/ext/ffi_c/libffi/fficonfig.h.in +18 -0
  62. data/ext/ffi_c/libffi/fficonfig.hw +57 -0
  63. data/ext/ffi_c/libffi/include/Makefile.in +21 -3
  64. data/ext/ffi_c/libffi/include/ffi.h.in +42 -14
  65. data/ext/ffi_c/libffi/include/ffi.h.vc +427 -0
  66. data/ext/ffi_c/libffi/include/ffi.h.vc64 +427 -0
  67. data/ext/ffi_c/libffi/include/ffi_common.h +9 -5
  68. data/ext/ffi_c/libffi/install-sh +364 -167
  69. data/ext/ffi_c/libffi/ltmain.sh +2599 -1369
  70. data/ext/ffi_c/libffi/m4/ax_cc_maxopt.m4 +176 -0
  71. data/ext/ffi_c/libffi/m4/ax_cflags_warn_all.m4 +195 -0
  72. data/ext/ffi_c/libffi/m4/ax_check_compiler_flags.m4 +76 -0
  73. data/ext/ffi_c/libffi/m4/ax_compiler_vendor.m4 +63 -0
  74. data/ext/ffi_c/libffi/m4/ax_configure_args.m4 +70 -0
  75. data/ext/ffi_c/libffi/m4/ax_enable_builddir.m4 +300 -0
  76. data/ext/ffi_c/libffi/m4/ax_gcc_archflag.m4 +215 -0
  77. data/ext/ffi_c/libffi/m4/ax_gcc_x86_cpuid.m4 +79 -0
  78. data/ext/ffi_c/libffi/m4/libtool.m4 +1239 -768
  79. data/ext/ffi_c/libffi/m4/ltoptions.m4 +7 -6
  80. data/ext/ffi_c/libffi/m4/ltversion.m4 +6 -6
  81. data/ext/ffi_c/libffi/m4/lt~obsolete.m4 +9 -3
  82. data/ext/ffi_c/libffi/man/Makefile.in +21 -3
  83. data/ext/ffi_c/libffi/mdate-sh +0 -0
  84. data/ext/ffi_c/libffi/missing +60 -44
  85. data/ext/ffi_c/libffi/msvcc.sh +197 -0
  86. data/ext/ffi_c/libffi/src/alpha/osf.S +39 -18
  87. data/ext/ffi_c/libffi/src/arm/ffi.c +443 -24
  88. data/ext/ffi_c/libffi/src/arm/ffitarget.h +17 -1
  89. data/ext/ffi_c/libffi/src/arm/gentramp.sh +118 -0
  90. data/ext/ffi_c/libffi/src/arm/sysv.S +206 -15
  91. data/ext/ffi_c/libffi/src/arm/trampoline.S +4450 -0
  92. data/ext/ffi_c/libffi/src/avr32/ffi.c +4 -2
  93. data/ext/ffi_c/libffi/src/avr32/ffitarget.h +2 -2
  94. data/ext/ffi_c/libffi/src/closures.c +17 -35
  95. data/ext/ffi_c/libffi/src/cris/ffi.c +1 -1
  96. data/ext/ffi_c/libffi/src/cris/ffitarget.h +2 -2
  97. data/ext/ffi_c/libffi/src/dlmalloc.c +66 -4
  98. data/ext/ffi_c/libffi/src/frv/ffitarget.h +2 -6
  99. data/ext/ffi_c/libffi/src/ia64/ffi.c +7 -5
  100. data/ext/ffi_c/libffi/src/ia64/ffitarget.h +2 -2
  101. data/ext/ffi_c/libffi/src/java_raw_api.c +1 -1
  102. data/ext/ffi_c/libffi/src/m32r/ffitarget.h +2 -2
  103. data/ext/ffi_c/libffi/src/m68k/ffi.c +10 -0
  104. data/ext/ffi_c/libffi/src/m68k/ffitarget.h +2 -2
  105. data/ext/ffi_c/libffi/src/m68k/sysv.S +36 -0
  106. data/ext/ffi_c/libffi/src/mips/ffi.c +12 -5
  107. data/ext/ffi_c/libffi/src/mips/ffitarget.h +18 -11
  108. data/ext/ffi_c/libffi/src/mips/n32.S +4 -4
  109. data/ext/ffi_c/libffi/src/moxie/eabi.S +128 -0
  110. data/ext/ffi_c/libffi/src/moxie/ffi.c +276 -0
  111. data/ext/ffi_c/libffi/src/pa/ffi.c +7 -4
  112. data/ext/ffi_c/libffi/src/pa/ffitarget.h +6 -5
  113. data/ext/ffi_c/libffi/src/powerpc/aix.S +5 -1
  114. data/ext/ffi_c/libffi/src/powerpc/aix_closure.S +2 -0
  115. data/ext/ffi_c/libffi/src/powerpc/asm.h +1 -1
  116. data/ext/ffi_c/libffi/src/powerpc/darwin.S +215 -77
  117. data/ext/ffi_c/libffi/src/powerpc/darwin_closure.S +358 -100
  118. data/ext/ffi_c/libffi/src/powerpc/ffi.c +11 -5
  119. data/ext/ffi_c/libffi/src/powerpc/ffi_darwin.c +603 -172
  120. data/ext/ffi_c/libffi/src/powerpc/ffitarget.h +17 -4
  121. data/ext/ffi_c/libffi/src/prep_cif.c +16 -13
  122. data/ext/ffi_c/libffi/src/s390/ffitarget.h +4 -2
  123. data/ext/ffi_c/libffi/src/sh/ffitarget.h +2 -2
  124. data/ext/ffi_c/libffi/src/sh64/ffitarget.h +2 -2
  125. data/ext/ffi_c/libffi/src/sparc/ffi.c +55 -11
  126. data/ext/ffi_c/libffi/src/sparc/ffitarget.h +5 -3
  127. data/ext/ffi_c/libffi/src/x86/ffi.c +54 -92
  128. data/ext/ffi_c/libffi/src/x86/ffi64.c +17 -8
  129. data/ext/ffi_c/libffi/src/x86/ffitarget.h +15 -14
  130. data/ext/ffi_c/libffi/src/x86/sysv.S +40 -26
  131. data/ext/ffi_c/libffi/src/x86/unix64.S +4 -0
  132. data/ext/ffi_c/libffi/src/x86/win32.S +379 -191
  133. data/ext/ffi_c/libffi/src/x86/win64.S +15 -7
  134. data/ext/ffi_c/libffi/testsuite/Makefile.am +1 -1
  135. data/ext/ffi_c/libffi/testsuite/Makefile.in +22 -4
  136. data/ext/ffi_c/libffi/testsuite/lib/libffi.exp +350 -0
  137. data/ext/ffi_c/libffi/testsuite/libffi.call/call.exp +1 -5
  138. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split.c +1 -1
  139. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_longdouble_split2.c +1 -1
  140. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_sint64.c +1 -0
  141. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_align_uint64.c +1 -0
  142. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_double_va.c +3 -0
  143. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble.c +2 -2
  144. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_longdouble_va.c +3 -0
  145. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer.c +1 -1
  146. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_pointer_stack.c +1 -1
  147. data/ext/ffi_c/libffi/testsuite/libffi.call/cls_ulonglong.c +1 -0
  148. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_abi.c +2 -3
  149. data/ext/ffi_c/libffi/testsuite/libffi.call/err_bad_typedef.c +2 -1
  150. data/ext/ffi_c/libffi/testsuite/libffi.call/ffitest.h +36 -0
  151. data/ext/ffi_c/libffi/testsuite/libffi.call/huge_struct.c +17 -17
  152. data/ext/ffi_c/libffi/testsuite/libffi.call/return_ll1.c +1 -0
  153. data/ext/ffi_c/libffi/testsuite/libffi.call/stret_medium2.c +1 -0
  154. data/ext/ffi_c/libffi/testsuite/libffi.special/ffitestcxx.h +1 -1
  155. data/ext/ffi_c/libffi/testsuite/libffi.special/special.exp +1 -3
  156. data/ext/ffi_c/win32/stdint.h +199 -0
  157. data/gen/Rakefile +18 -2
  158. data/lib/1.8/ffi_c.so +0 -0
  159. data/lib/ffi.rb +13 -9
  160. data/lib/ffi/autopointer.rb +88 -26
  161. data/lib/ffi/enum.rb +42 -0
  162. data/lib/ffi/errno.rb +6 -1
  163. data/lib/ffi/ffi.rb +1 -0
  164. data/lib/ffi/io.rb +13 -2
  165. data/lib/ffi/library.rb +219 -24
  166. data/lib/ffi/memorypointer.rb +1 -33
  167. data/lib/ffi/platform.rb +21 -7
  168. data/lib/ffi/platform/arm-linux/types.conf +102 -0
  169. data/lib/ffi/platform/i386-freebsd/types.conf +152 -0
  170. data/lib/ffi/platform/i386-netbsd/types.conf +126 -0
  171. data/lib/ffi/platform/i486-gnu/types.conf +107 -0
  172. data/lib/ffi/platform/ia64-linux/types.conf +102 -0
  173. data/lib/ffi/platform/mips-linux/types.conf +102 -0
  174. data/lib/ffi/platform/mipsel-linux/types.conf +102 -0
  175. data/lib/ffi/platform/powerpc-linux/types.conf +100 -0
  176. data/lib/ffi/platform/s390-linux/types.conf +102 -0
  177. data/lib/ffi/platform/s390x-linux/types.conf +102 -0
  178. data/lib/ffi/platform/sparc-linux/types.conf +102 -0
  179. data/lib/ffi/platform/x86_64-freebsd/types.conf +126 -0
  180. data/lib/ffi/platform/x86_64-netbsd/types.conf +126 -0
  181. data/lib/ffi/pointer.rb +44 -0
  182. data/lib/ffi/struct.rb +2 -6
  183. data/lib/ffi/struct_layout_builder.rb +2 -1
  184. data/lib/ffi/tools/const_generator.rb +78 -26
  185. data/lib/ffi/tools/types_generator.rb +8 -1
  186. data/lib/ffi/types.rb +21 -1
  187. data/spec/ffi/async_callback_spec.rb +2 -2
  188. data/spec/ffi/bool_spec.rb +6 -6
  189. data/spec/ffi/buffer_spec.rb +23 -23
  190. data/spec/ffi/callback_spec.rb +101 -102
  191. data/spec/ffi/custom_type_spec.rb +20 -24
  192. data/spec/ffi/dup_spec.rb +7 -7
  193. data/spec/ffi/enum_spec.rb +127 -127
  194. data/spec/ffi/errno_spec.rb +2 -2
  195. data/spec/ffi/ffi_spec.rb +3 -3
  196. data/spec/ffi/function_spec.rb +10 -10
  197. data/spec/ffi/library_spec.rb +30 -12
  198. data/spec/ffi/managed_struct_spec.rb +4 -4
  199. data/spec/ffi/number_spec.rb +40 -40
  200. data/spec/ffi/pointer_spec.rb +21 -24
  201. data/spec/ffi/rbx/memory_pointer_spec.rb +17 -15
  202. data/spec/ffi/rbx/struct_spec.rb +2 -2
  203. data/spec/ffi/spec_helper.rb +1 -1
  204. data/spec/ffi/string_spec.rb +9 -9
  205. data/spec/ffi/strptr_spec.rb +3 -3
  206. data/spec/ffi/struct_callback_spec.rb +7 -7
  207. data/spec/ffi/struct_initialize_spec.rb +2 -2
  208. data/spec/ffi/struct_packed_spec.rb +6 -6
  209. data/spec/ffi/struct_spec.rb +94 -84
  210. data/spec/ffi/typedef_spec.rb +15 -4
  211. data/spec/ffi/union_spec.rb +3 -3
  212. data/spec/ffi/variadic_spec.rb +17 -14
  213. data/tasks/extension.rake +0 -1
  214. data/tasks/gem.rake +0 -1
  215. data/tasks/rdoc.rake +1 -1
  216. data/tasks/yard.rake +11 -0
  217. metadata +50 -11
  218. data/lib/1.9/ffi_c.so +0 -0
@@ -4,7 +4,7 @@ from ../libffi/doc/libffi.texi.
4
4
  This manual is for Libffi, a portable foreign-function interface
5
5
  library.
6
6
 
7
- Copyright (C) 2008 Red Hat, Inc.
7
+ Copyright (C) 2008, 2010 Red Hat, Inc.
8
8
 
9
9
  Permission is granted to copy, distribute and/or modify this
10
10
  document under the terms of the GNU General Public License as
@@ -27,7 +27,7 @@ libffi
27
27
  This manual is for Libffi, a portable foreign-function interface
28
28
  library.
29
29
 
30
- Copyright (C) 2008 Red Hat, Inc.
30
+ Copyright (C) 2008, 2010 Red Hat, Inc.
31
31
 
32
32
  Permission is granted to copy, distribute and/or modify this
33
33
  document under the terms of the GNU General Public License as
@@ -89,6 +89,7 @@ File: libffi.info, Node: Using libffi, Next: Missing Features, Prev: Introduc
89
89
  * Types:: libffi type descriptions.
90
90
  * Multiple ABIs:: Different passing styles on one platform.
91
91
  * The Closure API:: Writing a generic function.
92
+ * Closure Example:: A closure example.
92
93
 
93
94
  
94
95
  File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
@@ -146,7 +147,9 @@ To prepare a call interface object, use the function `ffi_prep_cif'.
146
147
  AVALUES is a vector of `void *' pointers that point to the memory
147
148
  locations holding the argument values for a call. If CIF declares
148
149
  that the function has no arguments (i.e., NARGS was 0), then
149
- AVALUES is ignored.
150
+ AVALUES is ignored. Note that argument values may be modified by
151
+ the callee (for instance, structs passed by value); the burden of
152
+ copying pass-by-value arguments is placed on the caller.
150
153
 
151
154
  
152
155
  File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
@@ -368,7 +371,7 @@ instance, the x86 platform has both `stdcall' and `fastcall' functions.
368
371
  necessarily platform-specific.
369
372
 
370
373
  
371
- File: libffi.info, Node: The Closure API, Prev: Multiple ABIs, Up: Using libffi
374
+ File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multiple ABIs, Up: Using libffi
372
375
 
373
376
  2.5 The Closure API
374
377
  ===================
@@ -443,6 +446,62 @@ closure function:
443
446
  is deprecated, as it cannot handle the need for separate writable and
444
447
  executable addresses.
445
448
 
449
+ 
450
+ File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using libffi
451
+
452
+ 2.6 Closure Example
453
+ ===================
454
+
455
+ A trivial example that creates a new `puts' by binding `fputs' with
456
+ `stdin'.
457
+
458
+ #include <stdio.h>
459
+ #include <ffi.h>
460
+
461
+ /* Acts like puts with the file given at time of enclosure. */
462
+ void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[],
463
+ FILE *stream)
464
+ {
465
+ *ret = fputs(*(char **)args[0], stream);
466
+ }
467
+
468
+ int main()
469
+ {
470
+ ffi_cif cif;
471
+ ffi_type *args[1];
472
+ ffi_closure *closure;
473
+
474
+ int (*bound_puts)(char *);
475
+ int rc;
476
+
477
+ /* Allocate closure and bound_puts */
478
+ closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
479
+
480
+ if (closure)
481
+ {
482
+ /* Initialize the argument info vectors */
483
+ args[0] = &ffi_type_pointer;
484
+
485
+ /* Initialize the cif */
486
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
487
+ &ffi_type_uint, args) == FFI_OK)
488
+ {
489
+ /* Initialize the closure, setting stream to stdout */
490
+ if (ffi_prep_closure_loc(closure, &cif, puts_binding,
491
+ stdout, bound_puts) == FFI_OK)
492
+ {
493
+ rc = bound_puts("Hello World!");
494
+ /* rc now holds the result of the call to fputs */
495
+ }
496
+ }
497
+ }
498
+
499
+ /* Deallocate both closure, and bound_puts */
500
+ ffi_closure_free(closure);
501
+
502
+ return 0;
503
+ }
504
+
446
505
  
447
506
  File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
448
507
 
@@ -480,7 +539,7 @@ Index
480
539
  * closures: The Closure API. (line 13)
481
540
  * FFI: Introduction. (line 31)
482
541
  * ffi_call: The Basics. (line 41)
483
- * ffi_closure_alloca: The Closure API. (line 19)
542
+ * ffi_closure_alloc: The Closure API. (line 19)
484
543
  * ffi_closure_free: The Closure API. (line 26)
485
544
  * FFI_CLOSURES: The Closure API. (line 13)
486
545
  * ffi_prep_cif: The Basics. (line 16)
@@ -516,18 +575,19 @@ Index
516
575
 
517
576
  
518
577
  Tag Table:
519
- Node: Top700
520
- Node: Introduction1436
521
- Node: Using libffi3072
522
- Node: The Basics3507
523
- Node: Simple Example6114
524
- Node: Types7141
525
- Node: Primitive Types7424
526
- Node: Structures9244
527
- Node: Type Example10104
528
- Node: Multiple ABIs11327
529
- Node: The Closure API11698
530
- Node: Missing Features14618
531
- Node: Index15111
578
+ Node: Top706
579
+ Node: Introduction1448
580
+ Node: Using libffi3084
581
+ Node: The Basics3570
582
+ Node: Simple Example6356
583
+ Node: Types7383
584
+ Node: Primitive Types7666
585
+ Node: Structures9486
586
+ Node: Type Example10346
587
+ Node: Multiple ABIs11569
588
+ Node: The Closure API11940
589
+ Node: Closure Example14884
590
+ Node: Missing Features16443
591
+ Node: Index16936
532
592
  
533
593
  End Tag Table
@@ -19,7 +19,7 @@
19
19
  This manual is for Libffi, a portable foreign-function interface
20
20
  library.
21
21
 
22
- Copyright @copyright{} 2008 Red Hat, Inc.
22
+ Copyright @copyright{} 2008, 2010 Red Hat, Inc.
23
23
 
24
24
  @quotation
25
25
  Permission is granted to copy, distribute and/or modify this document
@@ -106,6 +106,7 @@ values passed between the two languages.
106
106
  * Types:: libffi type descriptions.
107
107
  * Multiple ABIs:: Different passing styles on one platform.
108
108
  * The Closure API:: Writing a generic function.
109
+ * Closure Example:: A closure example.
109
110
  @end menu
110
111
 
111
112
 
@@ -170,7 +171,9 @@ discarded.
170
171
  @var{avalues} is a vector of @code{void *} pointers that point to the
171
172
  memory locations holding the argument values for a call. If @var{cif}
172
173
  declares that the function has no arguments (i.e., @var{nargs} was 0),
173
- then @var{avalues} is ignored.
174
+ then @var{avalues} is ignored. Note that argument values may be
175
+ modified by the callee (for instance, structs passed by value); the
176
+ burden of copying pass-by-value arguments is placed on the caller.
174
177
  @end defun
175
178
 
176
179
 
@@ -437,7 +440,7 @@ require special allocation on platforms that have a non-executable
437
440
  heap. Memory management for closures is handled by a pair of
438
441
  functions:
439
442
 
440
- @findex ffi_closure_alloca
443
+ @findex ffi_closure_alloc
441
444
  @defun void *ffi_closure_alloc (size_t @var{size}, void **@var{code})
442
445
  Allocate a chunk of memory holding @var{size} bytes. This returns a
443
446
  pointer to the writable address, and sets *@var{code} to the
@@ -500,12 +503,66 @@ After calling @code{ffi_prep_closure_loc}, you can cast @var{codeloc}
500
503
  to the appropriate pointer-to-function type.
501
504
  @end defun
502
505
 
503
- @c FIXME: example
504
-
505
506
  You may see old code referring to @code{ffi_prep_closure}. This
506
507
  function is deprecated, as it cannot handle the need for separate
507
508
  writable and executable addresses.
508
509
 
510
+ @node Closure Example
511
+ @section Closure Example
512
+
513
+ A trivial example that creates a new @code{puts} by binding
514
+ @code{fputs} with @code{stdin}.
515
+
516
+ @example
517
+ #include <stdio.h>
518
+ #include <ffi.h>
519
+
520
+ /* Acts like puts with the file given at time of enclosure. */
521
+ void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[],
522
+ FILE *stream)
523
+ @{
524
+ *ret = fputs(*(char **)args[0], stream);
525
+ @}
526
+
527
+ int main()
528
+ @{
529
+ ffi_cif cif;
530
+ ffi_type *args[1];
531
+ ffi_closure *closure;
532
+
533
+ int (*bound_puts)(char *);
534
+ int rc;
535
+
536
+ /* Allocate closure and bound_puts */
537
+ closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
538
+
539
+ if (closure)
540
+ @{
541
+ /* Initialize the argument info vectors */
542
+ args[0] = &ffi_type_pointer;
543
+
544
+ /* Initialize the cif */
545
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
546
+ &ffi_type_uint, args) == FFI_OK)
547
+ @{
548
+ /* Initialize the closure, setting stream to stdout */
549
+ if (ffi_prep_closure_loc(closure, &cif, puts_binding,
550
+ stdout, bound_puts) == FFI_OK)
551
+ @{
552
+ rc = bound_puts("Hello World!");
553
+ /* rc now holds the result of the call to fputs */
554
+ @}
555
+ @}
556
+ @}
557
+
558
+ /* Deallocate both closure, and bound_puts */
559
+ ffi_closure_free(closure);
560
+
561
+ return 0;
562
+ @}
563
+
564
+ @end example
565
+
509
566
 
510
567
  @node Missing Features
511
568
  @chapter Missing Features
@@ -525,6 +582,8 @@ There is no support for bit fields in structures.
525
582
  @item
526
583
  The closure API is
527
584
 
585
+ @c FIXME: ...
586
+
528
587
  @item
529
588
  The ``raw'' API is undocumented.
530
589
  @c argument promotion?
@@ -1,4 +1,4 @@
1
- @set UPDATED 29 December 2009
2
- @set UPDATED-MONTH December 2009
3
- @set EDITION 3.0.9
4
- @set VERSION 3.0.9
1
+ @set UPDATED 23 August 2011
2
+ @set UPDATED-MONTH August 2011
3
+ @set EDITION 3.0.10
4
+ @set VERSION 3.0.10
@@ -1,4 +1,4 @@
1
- @set UPDATED 29 December 2009
2
- @set UPDATED-MONTH December 2009
3
- @set EDITION 3.0.9
4
- @set VERSION 3.0.9
1
+ @set UPDATED 23 August 2011
2
+ @set UPDATED-MONTH August 2011
3
+ @set EDITION 3.0.10
4
+ @set VERSION 3.0.10
@@ -17,6 +17,9 @@
17
17
  /* Define this if you want extra debugging. */
18
18
  #undef FFI_DEBUG
19
19
 
20
+ /* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
21
+ #undef FFI_EXEC_TRAMPOLINE_TABLE
22
+
20
23
  /* Cannot use malloc on this target, so, we revert to alternative means */
21
24
  #undef FFI_MMAP_EXEC_WRIT
22
25
 
@@ -33,6 +36,9 @@
33
36
  */
34
37
  #undef HAVE_ALLOCA_H
35
38
 
39
+ /* Define if your assembler supports .ascii. */
40
+ #undef HAVE_AS_ASCII_PSEUDO_OP
41
+
36
42
  /* Define if your assembler supports .cfi_* directives. */
37
43
  #undef HAVE_AS_CFI_PSEUDO_OP
38
44
 
@@ -43,6 +49,12 @@
43
49
  */
44
50
  #undef HAVE_AS_SPARC_UA_PCREL
45
51
 
52
+ /* Define if your assembler supports .string. */
53
+ #undef HAVE_AS_STRING_PSEUDO_OP
54
+
55
+ /* Define if your assembler supports unwind section type. */
56
+ #undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE
57
+
46
58
  /* Define if your assembler supports PC relative relocs. */
47
59
  #undef HAVE_AS_X86_PCREL
48
60
 
@@ -125,6 +137,9 @@
125
137
  /* Define to the one symbol short name of this package. */
126
138
  #undef PACKAGE_TARNAME
127
139
 
140
+ /* Define to the home page for this package. */
141
+ #undef PACKAGE_URL
142
+
128
143
  /* Define to the version of this package. */
129
144
  #undef PACKAGE_VERSION
130
145
 
@@ -164,6 +179,9 @@
164
179
  # endif
165
180
  #endif
166
181
 
182
+ /* Define to `unsigned int' if <sys/types.h> does not define. */
183
+ #undef size_t
184
+
167
185
 
168
186
  #ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
169
187
  #ifdef LIBFFI_ASM
@@ -0,0 +1,57 @@
1
+ /* -----------------------------------------------------------------*-C-*-
2
+ libffi - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ ``Software''), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included
13
+ in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
+ DEALINGS IN THE SOFTWARE.
23
+
24
+ ----------------------------------------------------------------------- */
25
+
26
+ /* -------------------------------------------------------------------
27
+
28
+ -------------------------------------------------------------------- */
29
+
30
+ #ifndef LIBFFICONFIG_H
31
+ #define LIBFFICONFIG_H
32
+
33
+ #define HAVE_ALLOCA 1
34
+ #define HAVE_MEMCPY 1
35
+ #define HAVE_MEMORY_H 1
36
+ #define HAVE_STDLIB_H 1
37
+ #define HAVE_STRING_H 1
38
+ #define HAVE_SYS_STAT_H 1
39
+ #define HAVE_SYS_TYPES_H 1
40
+ #define STDC_HEADERS 1
41
+
42
+ #if defined(X86_WIN64)
43
+ #define SIZEOF_DOUBLE 8
44
+ #define SIZEOF_LONG_DOUBLE 0
45
+ #else
46
+ #define SIZEOF_DOUBLE 8
47
+ #define SIZEOF_LONG_DOUBLE 0
48
+ #endif
49
+
50
+ #ifdef LIBFFI_ASM
51
+ #define FFI_HIDDEN(name)
52
+ #else
53
+ #define FFI_HIDDEN
54
+ #endif
55
+
56
+ #endif /* LIBFFICONFIG_H */
57
+
@@ -1,4 +1,4 @@
1
- # Makefile.in generated by automake 1.11 from Makefile.am.
1
+ # Makefile.in generated by automake 1.11.1 from Makefile.am.
2
2
  # @configure_input@
3
3
 
4
4
  # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -39,7 +39,17 @@ subdir = include
39
39
  DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
40
40
  $(srcdir)/ffi.h.in
41
41
  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
42
- am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
42
+ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cc_maxopt.m4 \
43
+ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
44
+ $(top_srcdir)/m4/ax_check_compiler_flags.m4 \
45
+ $(top_srcdir)/m4/ax_compiler_vendor.m4 \
46
+ $(top_srcdir)/m4/ax_configure_args.m4 \
47
+ $(top_srcdir)/m4/ax_enable_builddir.m4 \
48
+ $(top_srcdir)/m4/ax_gcc_archflag.m4 \
49
+ $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
50
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
51
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
52
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
43
53
  $(top_srcdir)/configure.ac
44
54
  am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
45
55
  $(ACLOCAL_M4)
@@ -78,6 +88,7 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
78
88
  ACLOCAL = @ACLOCAL@
79
89
  ALLOCA = @ALLOCA@
80
90
  AMTAR = @AMTAR@
91
+ AM_LTLDFLAGS = @AM_LTLDFLAGS@
81
92
  AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
82
93
  AR = @AR@
83
94
  AUTOCONF = @AUTOCONF@
@@ -95,6 +106,7 @@ CPPFLAGS = @CPPFLAGS@
95
106
  CYGPATH_W = @CYGPATH_W@
96
107
  DEFS = @DEFS@
97
108
  DEPDIR = @DEPDIR@
109
+ DLLTOOL = @DLLTOOL@
98
110
  DSYMUTIL = @DSYMUTIL@
99
111
  DUMPBIN = @DUMPBIN@
100
112
  ECHO_C = @ECHO_C@
@@ -102,6 +114,7 @@ ECHO_N = @ECHO_N@
102
114
  ECHO_T = @ECHO_T@
103
115
  EGREP = @EGREP@
104
116
  EXEEXT = @EXEEXT@
117
+ FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
105
118
  FGREP = @FGREP@
106
119
  GREP = @GREP@
107
120
  HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
@@ -120,6 +133,7 @@ LN_S = @LN_S@
120
133
  LTLIBOBJS = @LTLIBOBJS@
121
134
  MAINT = @MAINT@
122
135
  MAKEINFO = @MAKEINFO@
136
+ MANIFEST_TOOL = @MANIFEST_TOOL@
123
137
  MKDIR_P = @MKDIR_P@
124
138
  NM = @NM@
125
139
  NMEDIT = @NMEDIT@
@@ -132,8 +146,10 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
132
146
  PACKAGE_NAME = @PACKAGE_NAME@
133
147
  PACKAGE_STRING = @PACKAGE_STRING@
134
148
  PACKAGE_TARNAME = @PACKAGE_TARNAME@
149
+ PACKAGE_URL = @PACKAGE_URL@
135
150
  PACKAGE_VERSION = @PACKAGE_VERSION@
136
151
  PATH_SEPARATOR = @PATH_SEPARATOR@
152
+ PRTDIAG = @PRTDIAG@
137
153
  RANLIB = @RANLIB@
138
154
  SED = @SED@
139
155
  SET_MAKE = @SET_MAKE@
@@ -146,6 +162,7 @@ abs_builddir = @abs_builddir@
146
162
  abs_srcdir = @abs_srcdir@
147
163
  abs_top_builddir = @abs_top_builddir@
148
164
  abs_top_srcdir = @abs_top_srcdir@
165
+ ac_ct_AR = @ac_ct_AR@
149
166
  ac_ct_CC = @ac_ct_CC@
150
167
  ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
151
168
  am__include = @am__include@
@@ -153,6 +170,7 @@ am__leading_dot = @am__leading_dot@
153
170
  am__quote = @am__quote@
154
171
  am__tar = @am__tar@
155
172
  am__untar = @am__untar@
173
+ ax_enable_builddir_sed = @ax_enable_builddir_sed@
156
174
  bindir = @bindir@
157
175
  build = @build@
158
176
  build_alias = @build_alias@
@@ -178,7 +196,6 @@ libdir = @libdir@
178
196
  libexecdir = @libexecdir@
179
197
  localedir = @localedir@
180
198
  localstatedir = @localstatedir@
181
- lt_ECHO = @lt_ECHO@
182
199
  mandir = @mandir@
183
200
  mkdir_p = @mkdir_p@
184
201
  oldincludedir = @oldincludedir@
@@ -189,6 +206,7 @@ psdir = @psdir@
189
206
  sbindir = @sbindir@
190
207
  sharedstatedir = @sharedstatedir@
191
208
  srcdir = @srcdir@
209
+ sys_symbol_underscore = @sys_symbol_underscore@
192
210
  sysconfdir = @sysconfdir@
193
211
  target = @target@
194
212
  target_alias = @target_alias@