Re: [PATCH 3/4] In _IEEE_LIBM mode, use weak symbols instead of wrapper funcs

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Aug 27 14:28, Joel Sherrill wrote:
> On Mon, Aug 27, 2018 at 2:23 PM, Craig Howland <[email protected]>
> wrote:
> 
> > On 08/27/2018 02:32 PM, [email protected] wrote:
> >
> >> From: Keith Packard <[email protected]>
> >>
> >> When the math library is compiled to just use bare IEEE_LIBM mode, many
> >> public functions are just wrappers around the __ieee754 version.
> >> Eliminate the extra function by creating a weak alias symbol for the
> >> public name directly from the ieee754 name.
> >>
> >> Signed-off-by: Keith Packard <[email protected]>
> >> ---
> >>   newlib/libm/math/e_acos.c       |  5 +++++
> >>   ...
> >>   86 files changed, 360 insertions(+), 197 deletions(-)
> >>
> >> diff --git a/newlib/libm/math/e_acos.c b/newlib/libm/math/e_acos.c
> >> index 319b1d56f..25509c0f0 100644
> >> --- a/newlib/libm/math/e_acos.c
> >> +++ b/newlib/libm/math/e_acos.c
> >> @@ -59,6 +59,11 @@ qS2 =  2.02094576023350569471e+00, /* 0x40002AE5,
> >> 0x9C598AC8 */
> >>   qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
> >>   qS4 =  7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
> >>   +#ifdef _IEEE_LIBM
> >> +double acos(double x)
> >> +       __attribute__((weak, alias("__ieee754_acos")));
> >> +#endif
> >> +
> >>   #ifdef __STDC__
> >>         double __ieee754_acos(double x)
> >>   #else
> >> ...
> >>
> > While this is a nice idea, it is a problem for targets which don't support
> > weak aliases (i.e. those without proper object file support for them).
> > (Does anyone know for certain if this is a real problem instead of just a
> > theoretical one?  (I'd guess so.)  All my Newlib targets are ELF.)  An
> > alternative implementation could be macro definitions in math.h.
> 
> 
> My suggestion is to use the macro __weak_reference() from newlib's
> sys/cdefs.h which appears to account for ELF and not-ELF.
> 
> This is from FreeBSD so I would have confidence that they got it right.

Sounds good to me.  Also... who's setting IEEE_LIBM and where?  I don't
see any way to set this in the entire tree.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAluGpsEACgkQ9TYGna5E
T6DFug/+L++Z0qTeyYhQhVDZT+Tr6zZhf5mKRJErPmj324WUaqsE7Od4yYCG7Pr1
ce0ko96uk+y0kqMVjtnXbJsjFva59mOuLn/u45avgZIf3S4tPuoe11QF9NsrXo9c
Ds2IJ6RkQZHoU+7pxXrhzhrJGVFB4W9pzp1nTJDMNmUD12KDGywWhY+0kFZf7yB2
Di/n/V0ZhjHmb1bkZO7i9yGDy0T9CQlkV/O23uMWbHwG7NAlR77YPO9CiFXZLN9D
Fk+CxYJ0whwBoa2fS81zIRUbKGNAgrmDMMWW6qml12FhyeKTSTOddGTWDdpdODMT
acvqzSHWYH6KYoEcKGyb/4n1i90jff80203MW9X1IUaNRO1FgdVUYxcvXJPv2Zme
pugXJTzacnz4cis+1drh/Jqf5NHUjKtYT8mGV6MsEsnC56z0GIDFY8mNF5IpN6Hm
99qXRLI/FWA23Tk/Xhlm5/awU9MLvDw+Zspre/AC307Yt9hhjkUvInnjnTcjyu6q
Gm9ZiuDtMo26994+CVmQ0cSW99D5T8IwGQN20XgXtGvJhJMmqbECuH0/7TA5HOPZ
x3RRahLVo2G0LdKTocbAEXl2NY8eSXaR1X+WbqVOV1Udc9df2ocT7shH2r3C8tJS
PlFkduWPlPnKTXsVGp99Y9xIr8Yu31AV7DydVK2e2Fuo6uBZNxM=
=ugTX
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.