Skip to content
  • Mark H Weaver's avatar
    FFI: Add support for functions that set 'errno'. · a396e14c
    Mark H Weaver authored and Andy Wingo's avatar Andy Wingo committed
    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.
    a396e14c