This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC] Using protected for math symbols
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, nd <nd at arm dot com>
- Date: Fri, 29 Sep 2017 16:58:12 +0000
- Subject: Re: [RFC] Using protected for math symbols
- Authentication-results: sourceware.org; auth=none
- References: <DB6PR0801MB2053F4FB2315A96BA5D7E32F837E0@DB6PR0801MB2053.eurprd08.prod.outlook.com>
On Fri, 29 Sep 2017, Wilco Dijkstra wrote:
> An alternative approach to this is to completely remove the __sqrt
> variants and use protected symbol visibility. This means math functions
> are defined using their real name, internal calls use the real name and
> don't generate PLT calls, and no more weak/redirect magic is needed.
Protected visibility is best avoided in general.
https://www.airs.com/blog/archives/307
> -__sqrt (double x)
> +sqrt (double x)
> {
> if (__builtin_expect (isless (x, 0.0), 0) && _LIB_VERSION != _IEEE_)
> return __kernel_standard (x, x, 26); /* sqrt(negative) */
>
> return __ieee754_sqrt (x);
> }
> -libm_alias_double (__sqrt, sqrt)
Having names such as __sqrt is convenient even if they aren't called
anywhere, as it allows libm_alias_double to be used as a uniform way of
getting sqrt, sqrtl (in long double = double case), sqrtl compat symbol
(in case where long double used to = double), sqrtf64 (in future) and
sqrtf32x (in future) all defined at once.
--
Joseph S. Myers
joseph@codesourcery.com