[PATCH 5/5] libm: Control errno support with _IEEE_LIBM configuration parameter

Keith Packard keithp@keithp.com
Wed Aug 5 15:58:22 GMT 2020


Corinna Vinschen via Newlib <newlib@sourceware.org> writes:

> This math stuff is a bit over my head.  IIUC, the default is
> NOT setting _IEEE_LIBM, which results in the defauklt behaviour
> today.  That's what I care most about: Not introducing backward
> incompatible settings into Cygwin.

TL;DR summary:

The only effect on Cygwin will be to enable errno reporting for the few
functions coming from libm/math.

Longer discussion:

There are a lot of inter-related standards and I feel like I'm
down the rabbit hole on a lot of this. I think this particular issue can
be understood at a fairly high level as one of identifying inconsistent
semantics across the math library and then trying to identify ways to
fix that.

The new math code (libm/common) has errno enabled unless you set
WANT_ERRNO=0 (which no included configuration does).

The old math code (libm/math) has the errno code compiled-in unless you
define _IEEE_LIBM (which no configuration does). When _IEEE_LIBM is
defined, most (but not all) of the errno-setting code is removed.
However, the errno code in libm/math is also controlled by a run-time
conditional, _LIB_VERSION, which blocks the errno behavior *unless* the
global variable _LIB_VERSION is set to _POSIX_, which is not the default
on anything other than the spu build.

So, the current Cygwin behavior has most functions always setting errno
(those from libm/common), but some functions (those from libm/math) only
setting errno if the application happens to know about _LIB_VERSION and
sets that to _POSIX_.

This patch tries to simplify things so that one single global
compile-time define, _IEEE_LIBM, controls whether errno is ever modified
by the math library, and removes the run-time behavior controlled by
_LIB_VERSION.

-- 
-keith
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20200805/7d45cd9f/attachment.sig>


More information about the Newlib mailing list