summaryrefslogtreecommitdiff
path: root/doc/ref/api-foreign.texi
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2016-01-05 16:30:41 -0500
committerAndy Wingo <wingo@pobox.com>2016-12-18 23:05:15 +0100
commita396e14cb139eba37eeeea44e745bfc57bd1f37d (patch)
treed43075401d719e54382525ca09709adbaa517d4a /doc/ref/api-foreign.texi
parent546eb479b1fc7e3143b05aaeec16175d1cea0e08 (diff)
downloadguile-a396e14cb139eba37eeeea44e745bfc57bd1f37d.tar.gz
FFI: Add support for functions that set 'errno'.
Implements wishlist item <https://debbugs.gnu.org/18592>. Requested by Frank Terbeck <ft@bewatermyfriend.org>. Based on a proposed patch by Nala Ginrut <nalaginrut@gmail.com>. Patch ported to 2.2 by Andy Wingo <wingo@pobox.com>. * libguile/foreign.c (cif_to_procedure): Add 'with_errno' argument. If true, truncate result to only one return value. (scm_i_foreign_call): Separate the arguments. Always return errno. (pointer_to_procedure): New static function. (scm_pointer_to_procedure_with_errno): New C API function, implemented in terms of 'pointer_to_procedure'. (scm_pointer_to_procedure): Reimplement in terms of 'pointer_to_procedure', no longer bound to "pointer->procedure". See below. (scm_i_pointer_to_procedure): New C function bound to "pointer->procedure" which now accepts the optional #:return-errno? keyword argument, implemented in terms of 'pointer_to_procedure'. (k_return_errno): New keyword #:return-errno?. * libguile/foreign.h (scm_pointer_to_procedure_with_errno): Add prototype. * doc/ref/api-foreign.texi (Dynamic FFI): Adjust documentation. * libguile/vm-engine.c (foreign-call): Return two values.
Diffstat (limited to 'doc/ref/api-foreign.texi')
-rw-r--r--doc/ref/api-foreign.texi15
1 files changed, 11 insertions, 4 deletions
diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi
index 76614f021..527902209 100644
--- a/doc/ref/api-foreign.texi
+++ b/doc/ref/api-foreign.texi
@@ -1,7 +1,7 @@
@c -*-texinfo-*-
@c This is part of the GNU Guile Reference Manual.
-@c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 2008,
-@c 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+@c Copyright (C) 1996, 1997, 2000-2004, 2007-2014, 2016
+@c Free Software Foundation, Inc.
@c See the file guile.texi for copying conditions.
@node Foreign Function Interface
@@ -813,8 +813,11 @@ tightly packed structs and unions by hand. See the code for
Of course, the land of C is not all nouns and no verbs: there are
functions too, and Guile allows you to call them.
-@deffn {Scheme Procedure} pointer->procedure return_type func_ptr arg_types
-@deffnx {C Procedure} scm_pointer_to_procedure (return_type, func_ptr, arg_types)
+@deffn {Scheme Procedure} pointer->procedure return_type func_ptr arg_types @
+ [#:return-errno?=#f]
+@deffnx {C Function} scm_pointer_to_procedure (return_type, func_ptr, arg_types)
+@deffnx {C Function} scm_pointer_to_procedure_with_errno (return_type, func_ptr, arg_types)
+
Make a foreign function.
Given the foreign void pointer @var{func_ptr}, its argument and
@@ -825,6 +828,10 @@ and return appropriate values.
@var{arg_types} should be a list of foreign types.
@code{return_type} should be a foreign type. @xref{Foreign Types}, for
more information on foreign types.
+
+If @var{return-errno?} is true, or when calling
+@code{scm_pointer_to_procedure_with_errno}, the returned procedure will
+return two values, with @code{errno} as the second value.
@end deffn
Here is a better definition of @code{(math bessel)}: