GNU bug report logs - #18592
FFI should have portable access to ‘errno’

Previous Next

Package: guile;

Reported by: Frank Terbeck <ft <at> bewatermyfriend.org>

Date: Tue, 30 Sep 2014 20:21:01 UTC

Severity: wishlist

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mark H Weaver <mhw <at> netris.org>
To: Nala Ginrut <nalaginrut <at> gmail.com>
Cc: 18592 <at> debbugs.gnu.org, tomas <at> tuxteam.de
Subject: bug#18592: FFI should have portable access to ‘errno’
Date: Tue, 05 Jan 2016 10:08:09 -0500
Nala Ginrut <nalaginrut <at> gmail.com> writes:

> On Tue, 2016-01-05 at 08:49 +0100, tomas <at> tuxteam.de wrote:
>> Sorry for intervening from the peanut gallery, but if I understood Mark
>> correctly, he only was proposing to introduce a second function for the
>> C API (to keep backward compatibility at the linking-to-C level). At the
>> Guile source level, I guess all can be subsumed under one function.

Yes, Tomás is correct.  For the Scheme API, I would prefer to keep just
one procedure 'pointer->procedure' that accepts an optional
#:return-errno? keyword argument, as we had previously agreed.

> If we want to combine them in Scheme level, we have to change the name
> "pointer->procedure" in  C level, since it's registered with SCM_DEFINE.

That's right, the C function name in the SCM_DEFINE construct would need
to have a different name and be private, perhaps something like
'scm_i_pointer_to_procedure_with_keywords'.

> Dunno if it breaks the ABI too.

As long as there still exists a 'scm_pointer_to_procedure' function with
the same signature and semantics as it has now, that will preserve ABI
compatibility.

More specifically, here's what I'd suggest:

* A new, static, 'pointer_to_procedure' C function that inherits the
  signature and body of 'scm_pointer_to_procedure' but with a new and
  required 'return_errno' argument.  The other functions below would be
  wrappers for this function.

* A new private 'scm_i_pointer_to_procedure_with_keywords' C function,
  defined using SCM_DEFINE and bound to 'pointer->procedure' in Scheme,
  that uses 'scm_c_bind_keyword_arguments' and calls
  'pointer_to_procedure'.

* The C API function 'scm_pointer_to_procedure', which has the same
  arguments as in Guile 2.0.11 and calls 'pointer_to_procedure' with
  'return_errno' set to SCM_BOOL_F.

* A new C API function 'scm_pointer_to_procedure_with_errno', which is
  identical to 'scm_pointer_to_procedure' except that it calls
  'pointer_to_procedure' with 'return_errno' set to SCM_BOOL_T.

The only change to foreign.h would be to add a prototype for
'scm_pointer_to_procedure_with_errno'.

What do you think?

      Regards,
        Mark




This bug report was last modified 8 years and 338 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.