This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Improving math function wrappers
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: <nd at arm dot com>, Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Date: Tue, 4 Apr 2017 18:25:02 +0100
- Subject: Re: Improving math function wrappers
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com;
- Nodisclaimer: True
- References: <AM5PR0802MB2610AA7EDC518B39F6D7152683260@AM5PR0802MB2610.eurprd08.prod.outlook.com> <AM5PR0802MB261064538EBF55E8B7CF1F7783260@AM5PR0802MB2610.eurprd08.prod.outlook.com> <alpine.DEB.2.20.1703161407060.3566@digraph.polyomino.org.uk> <58CAD45E.6050601@arm.com> <alpine.DEB.2.20.1703161816370.18031@digraph.polyomino.org.uk>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 16/03/17 18:24, Joseph Myers wrote:
> On Thu, 16 Mar 2017, Szabolcs Nagy wrote:
>> On 16/03/17 14:29, Joseph Myers wrote:
>>> On Thu, 16 Mar 2017, Wilco Dijkstra wrote:
>>>
>>>> Given other languages don't even have the concept of errno, C99 doesn't
>>>> require it, and no application ever reads errno, it is inefficient to
>>>> force the use of the wrappers in almost all cases.
>>>
>>> C99 not requiring it was an incompatible quiet change from C90.
>>
>> i think glibc only has to set errno when user code is
>> compiled with c89 compatibility and even then only for
>> math functions that were defined in c89 and then only
>> guarantee correct errno setting in default rounding mode
>> (c89 code cannot access the fenv).
>
> Incompatible quiet change means a good idea to implement the compatible
> mode ((math_errhandling & MATH_ERRNO) != 0) as far as possible. Just like
> it's a good idea to avoid size_t wider than unsigned long.
i think this would be a valid argument if
(math_errhandling & MATH_ERRNO) != 0
was the only way to get backward compatibility,
but that's not the case: errno can be clobbered
any time and thus c89 backward compatibility can
be maintained with
(math_errhandling & MATH_ERRNO) == 0
in which case there is no requirement for non-c89
math functions to set errno (or getting errno
right in non-default fenv) and thus the wrapper
can be removed from all single and long double
precision functions (and kept for double prec
c89 functions if glibc cares about compatibility).
> Compilers for non-C languages without the concept of these functions
> setting errno can of course default to -fno-math-errno by default (and
> built-in no-errno functions that can be used with -fmath-errno is
> otherwise enabled would also be desirable for fma, sqrt, etc.).
then fortran can only use no-errno functions
when those can be inlined, since extern calls
use the standard libc symbols which set errno
in glibc.