[PATCH 3/4] In _IEEE_LIBM mode, use weak symbols instead of wrapper funcs
Craig Howland
howland@LGSInnovations.com
Mon Aug 27 19:28:00 GMT 2018
On 08/27/2018 02:32 PM, keithp@keithp.com wrote:
> From: Keith Packard <keithp@keithp.com>
>
> 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 <keithp@keithp.com>
> ---
> 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.
Craig
More information about the Newlib
mailing list