From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: math_errhandling definition
Date: Mon, 18 Nov 2013 00:13:25 +0100 [thread overview]
Message-ID: <20131117231325.GZ1685@port70.net> (raw)
In-Reply-To: <20131117215454.GA9505@duality.lan>
* Bobby Bingham <koorogi@koorogi.info> [2013-11-17 15:54:54 -0600]:
> I think the definition of math_errhandling is wrong on a couple
> architectures. C99 (7.12) says:
>
> If the expression math_errhandling & MATH_ERREXCEPT can be nonzero,
> the implementation shall define the macros FE_DIVBYZERO, FE_INVALID,
> and FE_OVERFLOW in <fenv.h>.
>
> math.h always defines math_errhandling as 2 (MATH_ERREXCEPT), but
> whether those FE_* macros are defined or not is architecture-dependent.
> In particular, ARM only defines them if __ARM_PCS_VFP is defined, and
> microblaze does not define them.
>
> It looks like if the architecture doesn't support floating point
> exceptions, math_errhandling must be MATH_ERRNO. This in turn requires
> that the various math functions set errno appropriately, which it
> doesn't look like musl's do.
yes, but..
musl aims to support annex f
annex f requires math_errhandling & MATH_ERREXCEPT to be true
ie math errors are reported as floating-point exceptions
according to ieee 754 semantics
annex f also requires all five ieee status flags to be defined
FE_OVERFLOW, FE_UNDERFLOW, FE_DIVBYZERO, FE_INVALID, FE_INEXACT
(c99 requires that unsupported flags are not defined and has
weaker requirements without annex f as you quoted)
unfortunately c99 made it (nearly) impossible to implement
floating-point with ieee exception semantics in software and
indeed gcc does not provide exceptions for fpu-less archs
(unless the underlying arch has hw registers for it)
this is fixed in c11 which changed signal handler semantics wrt
the floating-point environment and introduced thread storage
duration (however libgcc does not implement fp status flags with
thread storage duration just yet)
musl can only support annex f if the underlying hardware
(or on fpu-less archs the compiler or kernel fp emulation)
support ieee754
in short this should be reported against libgcc
in theory we could support MATH_ERRNO on such platforms, but
it would be a significant effort and still would not give useful
fp semantics other than slightly stricter c99 conformance
next prev parent reply other threads:[~2013-11-17 23:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-17 21:54 Bobby Bingham
2013-11-17 23:13 ` Szabolcs Nagy [this message]
2013-11-18 19:59 ` Rich Felker
2013-11-20 5:27 ` Bobby Bingham
2013-11-20 20:50 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131117231325.GZ1685@port70.net \
--to=nsz@port70.net \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).