Fix sample closure code
authorAndrew Haley <aph@redhat.com>
Sat, 16 Nov 2013 11:35:51 +0000 (06:35 -0500)
committerAnthony Green <green@moxielogic.com>
Sat, 16 Nov 2013 11:35:51 +0000 (06:35 -0500)
ChangeLog
doc/libffi.info
doc/libffi.texi
doc/stamp-vti
doc/version.texi

index ad13df5d27b239271f86d9ca3602b746afd9ab93..d6bbd59ef1b0dfeb9c0dec15237aeae61fa9e73d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-15  Andrew Haley  <aph@redhat.com>
+
+       * doc/libffi.texi (Closure Example): Fix the sample code.
+       * doc/libffi.info, doc/stamp-vti, doc/version.texi: Rebuilt.
+
 2013-11-15  Andrew Haley  <aph@redhat.com>
 
        * testsuite/libffi.call/va_struct1.c (main): Fix broken test.
index 4d42f5be1dac7305efa0c08b0c9a18952ef771e6..de69aaf42beb2e2794273f6a62415f9489442670 100644 (file)
@@ -478,19 +478,21 @@ A trivial example that creates a new 'puts' by binding 'fputs' with
      #include <ffi.h>
 
      /* Acts like puts with the file given at time of enclosure. */
-     void puts_binding(ffi_cif *cif, ffi_arg *ret, void* args[],
-                       FILE *stream)
+     void puts_binding(ffi_cif *cif, void *ret, void* args[],
+                       void *stream)
      {
-       *ret = fputs(*(char **)args[0], stream);
+       *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
      }
 
+     typedef int (*puts_t)(char *);
+
      int main()
      {
        ffi_cif cif;
        ffi_type *args[1];
        ffi_closure *closure;
 
-       int (*bound_puts)(char *);
+       void *bound_puts;
        int rc;
 
        /* Allocate closure and bound_puts */
@@ -509,7 +511,7 @@ A trivial example that creates a new 'puts' by binding 'fputs' with
                if (ffi_prep_closure_loc(closure, &cif, puts_binding,
                                         stdout, bound_puts) == FFI_OK)
                  {
-                   rc = bound_puts("Hello World!");
+                   rc = ((puts_t)bound_puts)("Hello World!");
                    /* rc now holds the result of the call to fputs */
                  }
              }
@@ -610,7 +612,7 @@ Node: Type Example\7f11207
 Node: Multiple ABIs\7f12473
 Node: The Closure API\7f12844
 Node: Closure Example\7f15788
-Node: Missing Features\7f17342
-Node: Index\7f17795
+Node: Missing Features\7f17396
+Node: Index\7f17849
 \1f
 End Tag Table
index d13c5c028e76336163a18aaab701908dd2e9a09c..57dae0b84cd8df758795200d73f6f3c37b2606c4 100644 (file)
@@ -541,21 +541,23 @@ A trivial example that creates a new @code{puts} by binding
 #include <ffi.h>
 
 /* Acts like puts with the file given at time of enclosure. */
-void puts_binding(ffi_cif *cif, ffi_arg *ret, void* args[], 
-                  FILE *stream)
+void puts_binding(ffi_cif *cif, void *ret, void* args[],
+                  void *stream)
 @{
-  *ret = fputs(*(char **)args[0], stream);
+  *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
 @}
 
+typedef int (*puts_t)(char *);
+
 int main()
 @{
   ffi_cif cif;
   ffi_type *args[1];
   ffi_closure *closure;
 
-  int (*bound_puts)(char *);
+  void *bound_puts;
   int rc;
-  
+
   /* Allocate closure and bound_puts */
   closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
 
@@ -569,10 +571,10 @@ int main()
                        &ffi_type_sint, args) == FFI_OK)
         @{
           /* Initialize the closure, setting stream to stdout */
-          if (ffi_prep_closure_loc(closure, &cif, puts_binding, 
+          if (ffi_prep_closure_loc(closure, &cif, puts_binding,
                                    stdout, bound_puts) == FFI_OK)
             @{
-              rc = bound_puts("Hello World!");
+              rc = ((puts_t)bound_puts)("Hello World!");
               /* rc now holds the result of the call to fputs */
             @}
         @}
index 3c7f7b217f233d0b78e762a8ff3c5341c8963c89..9a06fab5fc995d6b83b183f66b2be3ea4970309f 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 13 November 2013
+@set UPDATED 16 November 2013
 @set UPDATED-MONTH November 2013
 @set EDITION 3.0.14-rc0
 @set VERSION 3.0.14-rc0
index 3c7f7b217f233d0b78e762a8ff3c5341c8963c89..9a06fab5fc995d6b83b183f66b2be3ea4970309f 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 13 November 2013
+@set UPDATED 16 November 2013
 @set UPDATED-MONTH November 2013
 @set EDITION 3.0.14-rc0
 @set VERSION 3.0.14-rc0