public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* libffi doc fixes
@ 2013-11-13 15:13 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2013-11-13 15:13 UTC (permalink / raw)
  To: libffi-discuss

This enshrines the current testsuite practice of using ffi_arg for
returned values.  It would be reasonable and logical to use the actual
return argument type as passed to ffi_prep_cif, but this would mean
changing a large number of tests that use ffi_arg and all backends
that write results to an ffi_arg.

	* doc/libffi.texi: Correct example code.

diff --git a/doc/libffi.texi b/doc/libffi.texi
index eca11dc..d13c5c0 100644
--- a/doc/libffi.texi
+++ b/doc/libffi.texi
@@ -214,7 +214,7 @@ int main()
   ffi_type *args[1];
   void *values[1];
   char *s;
-  int rc;
+  ffi_arg rc;
   
   /* Initialize the argument info vectors */    
   args[0] = &ffi_type_pointer;
@@ -222,7 +222,7 @@ int main()
   
   /* Initialize the cif */
   if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, 
-		       &ffi_type_uint, args) == FFI_OK)
+		       &ffi_type_sint, args) == FFI_OK)
     @{
       s = "Hello World!";
       ffi_call(&cif, puts, &rc, values);
@@ -414,6 +414,7 @@ Here is the corresponding code to describe this struct to
       int i;
 
       tm_type.size = tm_type.alignment = 0;
+      tm_type.type = FFI_TYPE_STRUCT;
       tm_type.elements = &tm_type_elements;
     
       for (i = 0; i < 9; i++)
@@ -540,7 +541,7 @@ 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, unsigned int *ret, void* args[], 
+void puts_binding(ffi_cif *cif, ffi_arg *ret, void* args[], 
                   FILE *stream)
 @{
   *ret = fputs(*(char **)args[0], stream);
@@ -565,7 +566,7 @@ int main()
 
       /* Initialize the cif */
       if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
-                       &ffi_type_uint, args) == FFI_OK)
+                       &ffi_type_sint, args) == FFI_OK)
         @{
           /* Initialize the closure, setting stream to stdout */
           if (ffi_prep_closure_loc(closure, &cif, puts_binding, 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-11-13 15:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-13 15:13 libffi doc fixes Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).