From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22854 invoked by alias); 13 Nov 2013 15:13:51 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 22845 invoked by uid 89); 13 Nov 2013 15:13:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RDNS_NONE,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pb0-f50.google.com Received: from Unknown (HELO mail-pb0-f50.google.com) (209.85.160.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 13 Nov 2013 15:13:50 +0000 Received: by mail-pb0-f50.google.com with SMTP id xb12so538707pbc.23 for ; Wed, 13 Nov 2013 07:13:44 -0800 (PST) X-Received: by 10.68.189.197 with SMTP id gk5mr41933485pbc.37.1384355624820; Wed, 13 Nov 2013 07:13:44 -0800 (PST) Received: from bubble.grove.modra.org ([101.166.26.37]) by mx.google.com with ESMTPSA id dq3sm45058383pbc.35.2013.11.13.07.13.43 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Nov 2013 07:13:44 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 7C239EA006D; Thu, 14 Nov 2013 01:43:40 +1030 (CST) Date: Wed, 13 Nov 2013 15:13:00 -0000 From: Alan Modra To: libffi-discuss@sourceware.org Subject: libffi doc fixes Message-ID: <20131113151340.GB20756@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013/txt/msg00200.txt.bz2 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 /* 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