-This is ../libffi/doc/libffi.info, produced by makeinfo version 4.13
-from ../libffi/doc/libffi.texi.
+This is doc/libffi.info, produced by makeinfo version 4.12 from
+./doc/libffi.texi.
This manual is for Libffi, a portable foreign-function interface
library.
- Copyright (C) 2008, 2010 Red Hat, Inc.
+ Copyright (C) 2008 Red Hat, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU General Public License as
included in the section entitled "GNU General Public License".
-INFO-DIR-SECTION Development
+INFO-DIR-SECTION
START-INFO-DIR-ENTRY
* libffi: (libffi). Portable foreign-function interface library.
END-INFO-DIR-ENTRY
This manual is for Libffi, a portable foreign-function interface
library.
- Copyright (C) 2008, 2010 Red Hat, Inc.
+ Copyright (C) 2008 Red Hat, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU General Public License as
* Types:: libffi type descriptions.
* Multiple ABIs:: Different passing styles on one platform.
* The Closure API:: Writing a generic function.
-* Closure Example:: A closure example.
\1f
File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
necessarily platform-specific.
\1f
-File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multiple ABIs, Up: Using libffi
+File: libffi.info, Node: The Closure API, Prev: Multiple ABIs, Up: Using libffi
2.5 The Closure API
===================
executable addresses.
\1f
-File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using libffi
-
-2.6 Closure Example
-===================
-
-A trivial example that creates a new `puts' by binding `fputs' with
-`stdin'.
-
- #include <stdio.h>
- #include <ffi.h>
-
- /* Acts like puts with the file given at time of enclosure. */
- void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[],
- FILE *stream)
- {
- *ret = fputs(*(char **)args[0], stream);
- }
-
- int main()
- {
- ffi_cif cif;
- ffi_type *args[1];
- ffi_closure *closure;
-
- int (*bound_puts)(char *);
- int rc;
-
- /* Allocate closure and bound_puts */
- closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
-
- if (closure)
- {
- /* Initialize the argument info vectors */
- args[0] = &ffi_type_pointer;
-
- /* Initialize the cif */
- if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
- &ffi_type_uint, args) == FFI_OK)
- {
- /* Initialize the closure, setting stream to stdout */
- if (ffi_prep_closure_loc(closure, &cif, puts_binding,
- stdout, bound_puts) == FFI_OK)
- {
- rc = bound_puts("Hello World!");
- /* rc now holds the result of the call to fputs */
- }
- }
- }
-
- /* Deallocate both closure, and bound_puts */
- ffi_closure_free(closure);
-
- return 0;
- }
-
-\1f
File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
3 Missing Features
* closures: The Closure API. (line 13)
* FFI: Introduction. (line 31)
* ffi_call: The Basics. (line 41)
-* ffi_closure_alloc: The Closure API. (line 19)
+* ffi_closure_alloca: The Closure API. (line 19)
* ffi_closure_free: The Closure API. (line 26)
* FFI_CLOSURES: The Closure API. (line 13)
* ffi_prep_cif: The Basics. (line 16)
\1f
Tag Table:
-Node: Top\7f706
-Node: Introduction\7f1448
-Node: Using libffi\7f3084
-Node: The Basics\7f3570
-Node: Simple Example\7f6177
-Node: Types\7f7204
-Node: Primitive Types\7f7487
-Node: Structures\7f9307
-Node: Type Example\7f10167
-Node: Multiple ABIs\7f11390
-Node: The Closure API\7f11761
-Node: Closure Example\7f14705
-Node: Missing Features\7f16264
-Node: Index\7f16757
+Node: Top\7f670
+Node: Introduction\7f1406
+Node: Using libffi\7f3042
+Node: The Basics\7f3477
+Node: Simple Example\7f6084
+Node: Types\7f7111
+Node: Primitive Types\7f7394
+Node: Structures\7f9214
+Node: Type Example\7f10074
+Node: Multiple ABIs\7f11297
+Node: The Closure API\7f11668
+Node: Missing Features\7f14588
+Node: Index\7f15081
\1f
End Tag Table