Discussion:
[PATCH 2/4] Remove unused variable 'one' from sf_cos.c
k***@keithp.com
2018-08-27 18:32:29 UTC
Permalink
From: Keith Packard <***@keithp.com>

Defined, never mentioned.

Signed-off-by: Keith Packard <***@keithp.com>
---
newlib/libm/math/sf_cos.c | 6 ------
1 file changed, 6 deletions(-)

diff --git a/newlib/libm/math/sf_cos.c b/newlib/libm/math/sf_cos.c
index 8cb0eb008..fa472b173 100644
--- a/newlib/libm/math/sf_cos.c
+++ b/newlib/libm/math/sf_cos.c
@@ -16,12 +16,6 @@
#include "fdlibm.h"
#if __OBSOLETE_MATH

-#ifdef __STDC__
-static const float one=1.0;
-#else
-static float one=1.0;
-#endif
-
#ifdef __STDC__
float cosf(float x)
#else
--
2.18.0
k***@keithp.com
2018-08-27 18:32:28 UTC
Permalink
From: Keith Packard <***@keithp.com>

Newer GCC versions require a non-NULL argument to this function for
some reason.

Signed-off-by: Keith Packard <***@keithp.com>
---
newlib/libc/stdio/nano-vfscanf_float.c | 2 +-
newlib/libc/stdio/vfscanf.c | 2 +-
newlib/libc/stdio/vfwscanf.c | 2 +-
newlib/libc/stdlib/strtod.c | 4 ++--
newlib/libc/stdlib/wcstod.c | 6 +++---
5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/newlib/libc/stdio/nano-vfscanf_float.c b/newlib/libc/stdio/nano-vfscanf_float.c
index a81fe7f70..5df9f227c 100644
--- a/newlib/libc/stdio/nano-vfscanf_float.c
+++ b/newlib/libc/stdio/nano-vfscanf_float.c
@@ -330,7 +330,7 @@ fskip:
{
flp = GET_ARG (N, *ap, float *);
if (isnan (fp))
- *flp = nanf (NULL);
+ *flp = nanf ("");
else
*flp = fp;
}
diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c
index 080dcf400..9c38eebf4 100644
--- a/newlib/libc/stdio/vfscanf.c
+++ b/newlib/libc/stdio/vfscanf.c
@@ -1886,7 +1886,7 @@ __SVFSCANF_R (struct _reent *rptr,
{
flp = GET_ARG (N, ap, float *);
if (isnan (res))
- *flp = nanf (NULL);
+ *flp = nanf ("");
else
*flp = res;
}
diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c
index c3470a15c..0464b0837 100644
--- a/newlib/libc/stdio/vfwscanf.c
+++ b/newlib/libc/stdio/vfwscanf.c
@@ -1636,7 +1636,7 @@ __SVFWSCANF_R (struct _reent *rptr,
{
flp = GET_ARG (N, ap, float *);
if (isnan (res))
- *flp = nanf (NULL);
+ *flp = nanf ("");
else
*flp = res;
}
diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c
index 431d3ab07..2a76b10ce 100644
--- a/newlib/libc/stdlib/strtod.c
+++ b/newlib/libc/stdlib/strtod.c
@@ -1289,7 +1289,7 @@ strtof_l (const char *__restrict s00, char **__restrict se, locale_t loc)
{
double val = _strtod_l (_REENT, s00, se, loc);
if (isnan (val))
- return signbit (val) ? -nanf (NULL) : nanf (NULL);
+ return signbit (val) ? -nanf ("") : nanf ("");
float retval = (float) val;
#ifndef NO_ERRNO
if (isinf (retval) && !isinf (val))
@@ -1304,7 +1304,7 @@ strtof (const char *__restrict s00,
{
double val = _strtod_l (_REENT, s00, se, __get_current_locale ());
if (isnan (val))
- return signbit (val) ? -nanf (NULL) : nanf (NULL);
+ return signbit (val) ? -nanf ("") : nanf ("");
float retval = (float) val;
#ifndef NO_ERRNO
if (isinf (retval) && !isinf (val))
diff --git a/newlib/libc/stdlib/wcstod.c b/newlib/libc/stdlib/wcstod.c
index 9e0d563ef..810c5b3fd 100644
--- a/newlib/libc/stdlib/wcstod.c
+++ b/newlib/libc/stdlib/wcstod.c
@@ -228,7 +228,7 @@ _wcstof_r (struct _reent *ptr,
{
double retval = _wcstod_l (ptr, nptr, endptr, __get_current_locale ());
if (isnan (retval))
- return nanf (NULL);
+ return nanf ("");
return (float)retval;
}

@@ -253,7 +253,7 @@ wcstof_l (const wchar_t *__restrict nptr, wchar_t **__restrict endptr,
{
double val = _wcstod_l (_REENT, nptr, endptr, loc);
if (isnan (val))
- return nanf (NULL);
+ return nanf ("");
float retval = (float) val;
#ifndef NO_ERRNO
if (isinf (retval) && !isinf (val))
@@ -268,7 +268,7 @@ wcstof (const wchar_t *__restrict nptr,
{
double val = _wcstod_l (_REENT, nptr, endptr, __get_current_locale ());
if (isnan (val))
- return nanf (NULL);
+ return nanf ("");
float retval = (float) val;
#ifndef NO_ERRNO
if (isinf (retval) && !isinf (val))
--
2.18.0
Craig Howland
2018-08-27 21:21:49 UTC
Permalink
Post by k***@keithp.com
Newer GCC versions require a non-NULL argument to this function for
some reason.
---
newlib/libc/stdio/nano-vfscanf_float.c | 2 +-
newlib/libc/stdio/vfscanf.c | 2 +-
newlib/libc/stdio/vfwscanf.c | 2 +-
newlib/libc/stdlib/strtod.c | 4 ++--
newlib/libc/stdlib/wcstod.c | 6 +++---
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/newlib/libc/stdio/nano-vfscanf_float.c b/newlib/libc/stdio/nano-vfscanf_float.c
index a81fe7f70..5df9f227c 100644
--- a/newlib/libc/stdio/nano-vfscanf_float.c
+++ b/newlib/libc/stdio/nano-vfscanf_float.c
{
flp = GET_ARG (N, *ap, float *);
if (isnan (fp))
- *flp = nanf (NULL);
+ *flp = nanf ("");
else
*flp = fp;
}
...
Do we want to allow this recent GCC change to force a source change, when the
GCC change (added warning) is not a solid one?  The C standard does not require
that the argument to nan() be non-null, although invoking general, indirect,
rules (7.1.4) the behavior is perhaps undefined.  However, the Newlib nan()
function ignores the argument, which means in Newlib's case the warning is
spurious.

(The nan() definition is not totally clear, which is why I said "perhaps
undefined" in the previous paragraph.  "If tagp does not point to an n-char
sequence or an empty string, the call is equivalent to strtod("NAN", (char**)
NULL)."  Does this statement include a NULL pointer--in which case the behavior
is defined--or does it not--in which case the behavior is undefined by the
standard, although it still is in Newlib's implementation.  A NULL pointer does
not point to an n-char sequence or an empty string, thus it could be read this
way, without needing to go to the general invalid argument (which include NULL
pointer) in 7.1.4.  My personal preference in reading it is to understand that
nan(NULL) is the same as strtod("NAN", (char**)NULL).)

Using GCC 6.2.1 for an ARM64 target, there is a real code generation difference
between using nan("") and nan(NULL) (the latter of which gives a warning).  The
former apparently changes the "nan("")" into "__builtin_nan("")", while the
latter produces a function call to nan().  In other words, it appears this
change is effectively replacing Newlib-internal nan() calls with __builtin_nan()
calls.  I would guess that the same probably applies to any GCC version which
emits the warning for nan(NULL) (which mine does).

I am only asking the question and pointing out a few facts related to the
question, and don't mean to imply by asking that the change is not good, just
that these things should be considered.  For my ARM64 case, the code is smaller
and avoids a function call, so it is good from those points of view.

Craig
Joseph Myers
2018-08-27 22:10:57 UTC
Permalink
Post by Craig Howland
Do we want to allow this recent GCC change to force a source change, when the
GCC change (added warning) is not a solid one?  The C standard does not
require that the argument to nan() be non-null, although invoking general,
The argument must, as per DR#477 (resolution integrated in C17), be a
string.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2257.htm#dr_477
--
Joseph S. Myers
***@codesourcery.com
Craig Howland
2018-08-27 22:36:27 UTC
Permalink
Post by Joseph Myers
Post by Craig Howland
Do we want to allow this recent GCC change to force a source change, when the
GCC change (added warning) is not a solid one?  The C standard does not
require that the argument to nan() be non-null, although invoking general,
The argument must, as per DR#477 (resolution integrated in C17), be a
string.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2257.htm#dr_477
Good that that is being taken care of.  While this does not change the fact that
the change is not operationally needed in that the Newlib nan() ignores the
argument, it does say changing for the sake the source being compliant (with the
upcoming revision/clarification) should be done--even if generated code
changes.  With that said, the edits look good.

Craig
Corinna Vinschen
2018-08-29 14:01:27 UTC
Permalink
Post by k***@keithp.com
Newer GCC versions require a non-NULL argument to this function for
some reason.
---
newlib/libc/stdio/nano-vfscanf_float.c | 2 +-
newlib/libc/stdio/vfscanf.c | 2 +-
newlib/libc/stdio/vfwscanf.c | 2 +-
newlib/libc/stdlib/strtod.c | 4 ++--
newlib/libc/stdlib/wcstod.c | 6 +++---
5 files changed, 8 insertions(+), 8 deletions(-)
Pushed.


Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
k***@keithp.com
2018-08-27 18:32:31 UTC
Permalink
From: Keith Packard <***@keithp.com>

This macro selects a compiler option that disables recognition of
common memset/memcpy patterns and converting those to direct
memset/memcpy calls.

Signed-off-by: Keith Packard <***@keithp.com>
---
newlib/libc/machine/cris/memcpy.c | 2 ++
newlib/libc/machine/riscv/memcpy.c | 2 ++
newlib/libc/machine/spu/memcpy.c | 5 ++++-
newlib/libc/machine/spu/memcpy_ea.c | 2 ++
newlib/libc/machine/spu/memset_ea.c | 2 ++
newlib/libc/machine/visium/memcpy.c | 5 +++++
newlib/libc/machine/visium/memset.c | 6 +++++-
newlib/libc/machine/xscale/memcpy.c | 2 ++
newlib/libc/machine/xscale/memset.c | 2 ++
newlib/libc/string/memcpy.c | 2 ++
10 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/machine/cris/memcpy.c b/newlib/libc/machine/cris/memcpy.c
index c7a1af957..c314edeb6 100644
--- a/newlib/libc/machine/cris/memcpy.c
+++ b/newlib/libc/machine/cris/memcpy.c
@@ -31,6 +31,7 @@
than what we describe. An assembly file should be used instead. */

#include <stddef.h>
+#include "../../string/local.h"

/* Break even between movem and move16 is really at 38.7 * 2, but
modulo 44, so up to the next multiple of 44, we use ordinary code. */
@@ -40,6 +41,7 @@
__asm__ (".syntax no_register_prefix");

void *
+__inhibit_loop_to_libcall
memcpy(void *__restrict pdst, const void *__restrict psrc, size_t pn)
{
/* Now we want the parameters put in special registers.
diff --git a/newlib/libc/machine/riscv/memcpy.c b/newlib/libc/machine/riscv/memcpy.c
index c717f9f4b..a0ab78a0a 100644
--- a/newlib/libc/machine/riscv/memcpy.c
+++ b/newlib/libc/machine/riscv/memcpy.c
@@ -11,10 +11,12 @@

#include <string.h>
#include <stdint.h>
+#include "../../string/local.h"

#define unlikely(X) __builtin_expect (!!(X), 0)

void *
+__inhibit_loop_to_libcall
memcpy(void *__restrict aa, const void *__restrict bb, size_t n)
{
#define BODY(a, b, t) { \
diff --git a/newlib/libc/machine/spu/memcpy.c b/newlib/libc/machine/spu/memcpy.c
index dbbce8cee..0483cd23d 100644
--- a/newlib/libc/machine/spu/memcpy.c
+++ b/newlib/libc/machine/spu/memcpy.c
@@ -33,6 +33,7 @@
#include <spu_intrinsics.h>
#include <stddef.h>
#include <vec_literal.h>
+#include "../../string/local.h"

/* Copy n bytes from memory area src to memory area dest.
* The memory areas may not overlap. The memcpy subroutine
@@ -42,7 +43,9 @@
* either with prior knowledge of the alignment or special
* casing specific optimal alignments.
*/
-void * memcpy(void * __restrict__ dest, const void * __restrict__ src, size_t n)
+void *
+__inhibit_loop_to_libcall
+memcpy(void * __restrict__ dest, const void * __restrict__ src, size_t n)
{
int adjust, delta;
unsigned int soffset1, doffset1, doffset2;
diff --git a/newlib/libc/machine/spu/memcpy_ea.c b/newlib/libc/machine/spu/memcpy_ea.c
index 6dfea7abb..ae67f86b1 100644
--- a/newlib/libc/machine/spu/memcpy_ea.c
+++ b/newlib/libc/machine/spu/memcpy_ea.c
@@ -34,10 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "ea_internal.h"
#include <ea.h>
#include <spu_cache.h>
+#include "../../string/local.h"

COMPAT_EA_ALIAS (memcpy_ea);

__ea void *
+__inhibit_loop_to_libcall
memcpy_ea (__ea void *dest, __ea const void *src, size_ea_t n)
{
__ea void *curr_dest = dest;
diff --git a/newlib/libc/machine/spu/memset_ea.c b/newlib/libc/machine/spu/memset_ea.c
index a18baf206..1d6027382 100644
--- a/newlib/libc/machine/spu/memset_ea.c
+++ b/newlib/libc/machine/spu/memset_ea.c
@@ -34,10 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include <spu_cache.h>
#include "ea_internal.h"
#include <ea.h>
+#include "../../string/local.h"

COMPAT_EA_ALIAS (memset_ea);

__ea void *
+__inhibit_loop_to_libcall
memset_ea (__ea void *dest, int c, size_ea_t n)
{
__ea void *curr_dest = dest;
diff --git a/newlib/libc/machine/visium/memcpy.c b/newlib/libc/machine/visium/memcpy.c
index c5110064d..e64403135 100644
--- a/newlib/libc/machine/visium/memcpy.c
+++ b/newlib/libc/machine/visium/memcpy.c
@@ -31,6 +31,7 @@

#include <stddef.h>
#include "memcpy.h"
+#include "../../string/local.h"

#define INST_BARRIER __asm__ __volatile__ ("":::"memory");

@@ -422,6 +423,7 @@ do { \


static inline void
+__inhibit_loop_to_libcall
__int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
{
int value = n;
@@ -562,6 +564,7 @@ __int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
}

static inline void
+__inhibit_loop_to_libcall
__shrt_int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
{
int value = n;
@@ -703,6 +706,7 @@ __shrt_int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)


static inline void
+__inhibit_loop_to_libcall
__byte_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
{
int value = n;
@@ -846,6 +850,7 @@ __byte_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
/* Exposed interface. */

void *
+__inhibit_loop_to_libcall
memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
{
void *result = s1;
diff --git a/newlib/libc/machine/visium/memset.c b/newlib/libc/machine/visium/memset.c
index bad64a96d..5c3906aa6 100644
--- a/newlib/libc/machine/visium/memset.c
+++ b/newlib/libc/machine/visium/memset.c
@@ -31,6 +31,7 @@

#include <stddef.h>
#include "memset.h"
+#include "../../string/local.h"

#define SET_32_OBJECTS(out) \
do { \
@@ -228,8 +229,8 @@ do { \
out += 1; \
} while(0)

-
static inline void
+__inhibit_loop_to_libcall
__int_memset (void *__restrict s1, int val, size_t n)
{
int value = n;
@@ -369,6 +370,7 @@ __int_memset (void *__restrict s1, int val, size_t n)
}

static inline void
+__inhibit_loop_to_libcall
__short_int_memset (void *__restrict s1, int val, size_t n)
{
int value = n;
@@ -508,6 +510,7 @@ __short_int_memset (void *__restrict s1, int val, size_t n)
}

static inline void
+__inhibit_loop_to_libcall
__byte_memset (void *__restrict s1, int val, size_t n)
{
int value = n;
@@ -650,6 +653,7 @@ __byte_memset (void *__restrict s1, int val, size_t n)
/* Exposed interface. */

void *
+__inhibit_loop_to_libcall
memset (void *s, int c, size_t n)
{
void *result = s;
diff --git a/newlib/libc/machine/xscale/memcpy.c b/newlib/libc/machine/xscale/memcpy.c
index 7de967fb9..20758e159 100644
--- a/newlib/libc/machine/xscale/memcpy.c
+++ b/newlib/libc/machine/xscale/memcpy.c
@@ -6,8 +6,10 @@

#include <string.h>
#include "xscale.h"
+#include "../../string/local.h"

void *
+__inhibit_loop_to_libcall
memcpy (void *__restrict dst0, const void *__restrict src0, size_t len)
{
int dummy;
diff --git a/newlib/libc/machine/xscale/memset.c b/newlib/libc/machine/xscale/memset.c
index 4ff8d01e0..8fab2a7d1 100644
--- a/newlib/libc/machine/xscale/memset.c
+++ b/newlib/libc/machine/xscale/memset.c
@@ -6,8 +6,10 @@

#include <string.h>
#include "xscale.h"
+#include "../../string/local.h"

void *
+__inhibit_loop_to_libcall
memset (void *dst, int c, size_t len)
{
int dummy;
diff --git a/newlib/libc/string/memcpy.c b/newlib/libc/string/memcpy.c
index a1cff12d9..52f716b92 100644
--- a/newlib/libc/string/memcpy.c
+++ b/newlib/libc/string/memcpy.c
@@ -29,6 +29,7 @@ QUICKREF

#include <_ansi.h>
#include <string.h>
+#include "local.h"

/* Nonzero if either X or Y is not aligned on a "long" boundary. */
#define UNALIGNED(X, Y) \
@@ -44,6 +45,7 @@ QUICKREF
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE)

void *
+__inhibit_loop_to_libcall
memcpy (void *__restrict dst0,
const void *__restrict src0,
size_t len0)
--
2.18.0
Corinna Vinschen
2018-08-29 14:07:48 UTC
Permalink
Post by k***@keithp.com
This macro selects a compiler option that disables recognition of
common memset/memcpy patterns and converting those to direct
memset/memcpy calls.
---
newlib/libc/machine/cris/memcpy.c | 2 ++
newlib/libc/machine/riscv/memcpy.c | 2 ++
newlib/libc/machine/spu/memcpy.c | 5 ++++-
newlib/libc/machine/spu/memcpy_ea.c | 2 ++
newlib/libc/machine/spu/memset_ea.c | 2 ++
newlib/libc/machine/visium/memcpy.c | 5 +++++
newlib/libc/machine/visium/memset.c | 6 +++++-
newlib/libc/machine/xscale/memcpy.c | 2 ++
newlib/libc/machine/xscale/memset.c | 2 ++
newlib/libc/string/memcpy.c | 2 ++
10 files changed, 28 insertions(+), 2 deletions(-)
Pushed.


Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
k***@keithp.com
2018-08-27 18:32:30 UTC
Permalink
From: Keith Packard <***@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.com>
---
newlib/libm/math/e_acos.c | 5 +++++
newlib/libm/math/e_acosh.c | 5 +++++
newlib/libm/math/e_asin.c | 5 +++++
newlib/libm/math/e_atan2.c | 5 +++++
newlib/libm/math/e_atanh.c | 5 +++++
newlib/libm/math/e_cosh.c | 5 +++++
newlib/libm/math/e_exp.c | 5 +++++
newlib/libm/math/e_fmod.c | 5 +++++
newlib/libm/math/e_hypot.c | 5 +++++
newlib/libm/math/e_j0.c | 10 ++++++++++
newlib/libm/math/e_j1.c | 10 ++++++++++
newlib/libm/math/e_jn.c | 10 ++++++++++
newlib/libm/math/e_log.c | 5 +++++
newlib/libm/math/e_log10.c | 5 +++++
newlib/libm/math/e_pow.c | 5 +++++
newlib/libm/math/e_rem_pio2.c | 5 +++++
newlib/libm/math/e_remainder.c | 5 +++++
newlib/libm/math/e_scalb.c | 10 ++++++++++
newlib/libm/math/e_sinh.c | 5 +++++
newlib/libm/math/e_sqrt.c | 5 +++++
newlib/libm/math/ef_acos.c | 5 +++++
newlib/libm/math/ef_acosh.c | 5 +++++
newlib/libm/math/ef_asin.c | 5 +++++
newlib/libm/math/ef_atan2.c | 5 +++++
newlib/libm/math/ef_atanh.c | 5 +++++
newlib/libm/math/ef_cosh.c | 5 +++++
newlib/libm/math/ef_exp.c | 5 +++++
newlib/libm/math/ef_fmod.c | 5 +++++
newlib/libm/math/ef_hypot.c | 5 +++++
newlib/libm/math/ef_j0.c | 10 ++++++++++
newlib/libm/math/ef_j1.c | 10 ++++++++++
newlib/libm/math/ef_jn.c | 10 ++++++++++
newlib/libm/math/ef_log.c | 5 +++++
newlib/libm/math/ef_log10.c | 5 +++++
newlib/libm/math/ef_pow.c | 5 +++++
newlib/libm/math/ef_rem_pio2.c | 5 +++++
newlib/libm/math/ef_remainder.c | 5 +++++
newlib/libm/math/ef_scalb.c | 10 ++++++++++
newlib/libm/math/ef_sinh.c | 5 +++++
newlib/libm/math/ef_sqrt.c | 5 +++++
newlib/libm/math/er_gamma.c | 5 +++++
newlib/libm/math/er_lgamma.c | 5 +++++
newlib/libm/math/erf_gamma.c | 5 +++++
newlib/libm/math/erf_lgamma.c | 5 +++++
newlib/libm/math/w_acos.c | 6 ++----
newlib/libm/math/w_acosh.c | 7 +++----
newlib/libm/math/w_asin.c | 6 ++----
newlib/libm/math/w_atanh.c | 10 ++--------
newlib/libm/math/w_cosh.c | 8 +++-----
newlib/libm/math/w_exp.c | 6 ++----
newlib/libm/math/w_fmod.c | 6 ++----
newlib/libm/math/w_hypot.c | 6 ++----
newlib/libm/math/w_j0.c | 12 ++++--------
newlib/libm/math/w_j1.c | 12 ++++--------
newlib/libm/math/w_jn.c | 12 ++++--------
newlib/libm/math/w_log.c | 6 ++----
newlib/libm/math/w_log10.c | 6 ++----
newlib/libm/math/w_pow.c | 6 ++----
newlib/libm/math/w_remainder.c | 6 ++----
newlib/libm/math/w_scalb.c | 7 +++----
newlib/libm/math/w_sinh.c | 6 ++----
newlib/libm/math/w_sqrt.c | 6 ++----
newlib/libm/math/wf_acos.c | 6 ++----
newlib/libm/math/wf_acosh.c | 6 ++----
newlib/libm/math/wf_asin.c | 6 ++----
newlib/libm/math/wf_atanh.c | 6 ++----
newlib/libm/math/wf_cosh.c | 6 ++----
newlib/libm/math/wf_exp.c | 6 ++----
newlib/libm/math/wf_fmod.c | 6 ++----
newlib/libm/math/wf_gamma.c | 6 ++----
newlib/libm/math/wf_hypot.c | 6 ++----
newlib/libm/math/wf_j0.c | 12 ++++--------
newlib/libm/math/wf_j1.c | 12 ++++--------
newlib/libm/math/wf_jn.c | 12 ++++--------
newlib/libm/math/wf_lgamma.c | 6 ++----
newlib/libm/math/wf_log.c | 6 ++----
newlib/libm/math/wf_log10.c | 7 +++----
newlib/libm/math/wf_pow.c | 6 ++----
newlib/libm/math/wf_remainder.c | 6 ++----
newlib/libm/math/wf_scalb.c | 6 ++----
newlib/libm/math/wf_sinh.c | 6 ++----
newlib/libm/math/wf_sqrt.c | 6 ++----
newlib/libm/math/wr_gamma.c | 6 ++----
newlib/libm/math/wr_lgamma.c | 6 ++----
newlib/libm/math/wrf_gamma.c | 6 ++----
newlib/libm/math/wrf_lgamma.c | 6 ++----
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
diff --git a/newlib/libm/math/e_acosh.c b/newlib/libm/math/e_acosh.c
index 27984eb23..79b1412da 100644
--- a/newlib/libm/math/e_acosh.c
+++ b/newlib/libm/math/e_acosh.c
@@ -38,6 +38,11 @@ static double
one = 1.0,
ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */

+#ifdef _IEEE_LIBM
+double acosh(double x)
+ __attribute__((weak, alias("__ieee754_acosh")));
+#endif
+
#ifdef __STDC__
double __ieee754_acosh(double x)
#else
diff --git a/newlib/libm/math/e_asin.c b/newlib/libm/math/e_asin.c
index 4b6f45e15..2ae0dd442 100644
--- a/newlib/libm/math/e_asin.c
+++ b/newlib/libm/math/e_asin.c
@@ -68,6 +68,11 @@ qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */

+#ifdef _IEEE_LIBM
+double asin(double x)
+ __attribute__((weak, alias("__ieee754_asin")));
+#endif
+
#ifdef __STDC__
double __ieee754_asin(double x)
#else
diff --git a/newlib/libm/math/e_atan2.c b/newlib/libm/math/e_atan2.c
index 8e9650f29..f3a7c8757 100644
--- a/newlib/libm/math/e_atan2.c
+++ b/newlib/libm/math/e_atan2.c
@@ -55,6 +55,11 @@ pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */

+#ifdef _IEEE_LIBM
+double atan2(double x, double y)
+ __attribute__((weak, alias("__ieee754_atan2")));
+#endif
+
#ifdef __STDC__
double __ieee754_atan2(double y, double x)
#else
diff --git a/newlib/libm/math/e_atanh.c b/newlib/libm/math/e_atanh.c
index 58ad325f9..e2c539466 100644
--- a/newlib/libm/math/e_atanh.c
+++ b/newlib/libm/math/e_atanh.c
@@ -46,6 +46,11 @@ static const double zero = 0.0;
static double zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+double atanh(double x)
+ __attribute__((weak, alias("__ieee754_atanh")));
+#endif
+
#ifdef __STDC__
double __ieee754_atanh(double x)
#else
diff --git a/newlib/libm/math/e_cosh.c b/newlib/libm/math/e_cosh.c
index a6310bd07..91eec65cf 100644
--- a/newlib/libm/math/e_cosh.c
+++ b/newlib/libm/math/e_cosh.c
@@ -42,6 +42,11 @@ static const double one = 1.0, half=0.5, huge = 1.0e300;
static double one = 1.0, half=0.5, huge = 1.0e300;
#endif

+#ifdef _IEEE_LIBM
+double cosh(double x)
+ __attribute__((weak, alias("__ieee754_cosh")));
+#endif
+
#ifdef __STDC__
double __ieee754_cosh(double x)
#else
diff --git a/newlib/libm/math/e_exp.c b/newlib/libm/math/e_exp.c
index 81ea64dfb..1c6a88525 100644
--- a/newlib/libm/math/e_exp.c
+++ b/newlib/libm/math/e_exp.c
@@ -102,6 +102,11 @@ P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */


+#ifdef _IEEE_LIBM
+double exp(double x)
+ __attribute__((weak, alias("__ieee754_exp")));
+#endif
+
#ifdef __STDC__
double __ieee754_exp(double x) /* default IEEE double exp */
#else
diff --git a/newlib/libm/math/e_fmod.c b/newlib/libm/math/e_fmod.c
index f9739eec2..d0b607a92 100644
--- a/newlib/libm/math/e_fmod.c
+++ b/newlib/libm/math/e_fmod.c
@@ -27,6 +27,11 @@ static const double one = 1.0, Zero[] = {0.0, -0.0,};
static double one = 1.0, Zero[] = {0.0, -0.0,};
#endif

+#ifdef _IEEE_LIBM
+double fmod(double x, double y)
+ __attribute__((weak, alias("__ieee754_fmod")));
+#endif
+
#ifdef __STDC__
double __ieee754_fmod(double x, double y)
#else
diff --git a/newlib/libm/math/e_hypot.c b/newlib/libm/math/e_hypot.c
index 03f7f51e5..44c267d16 100644
--- a/newlib/libm/math/e_hypot.c
+++ b/newlib/libm/math/e_hypot.c
@@ -47,6 +47,11 @@

#ifndef _DOUBLE_IS_32BITS

+#ifdef _IEEE_LIBM
+double hypot(double x, double y)
+ __attribute__((weak, alias("__ieee754_hypot")));
+#endif
+
#ifdef __STDC__
double __ieee754_hypot(double x, double y)
#else
diff --git a/newlib/libm/math/e_j0.c b/newlib/libm/math/e_j0.c
index 13773cbf9..e98521520 100644
--- a/newlib/libm/math/e_j0.c
+++ b/newlib/libm/math/e_j0.c
@@ -91,6 +91,11 @@ static const double zero = 0.0;
static double zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+double j0(double x)
+ __attribute__((weak, alias("__ieee754_j0")));
+#endif
+
#ifdef __STDC__
double __ieee754_j0(double x)
#else
@@ -160,6 +165,11 @@ v02 = 7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */
v03 = 2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */
v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */

+#ifdef _IEEE_LIBM
+double y0(double x)
+ __attribute__((weak, alias("__ieee754_y0")));
+#endif
+
#ifdef __STDC__
double __ieee754_y0(double x)
#else
diff --git a/newlib/libm/math/e_j1.c b/newlib/libm/math/e_j1.c
index 098eb569e..895e8a511 100644
--- a/newlib/libm/math/e_j1.c
+++ b/newlib/libm/math/e_j1.c
@@ -92,6 +92,11 @@ static const double zero = 0.0;
static double zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+double j1(double x)
+ __attribute__((weak, alias("__ieee754_j1")));
+#endif
+
#ifdef __STDC__
double __ieee754_j1(double x)
#else
@@ -161,6 +166,11 @@ static double V0[5] = {
1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */
};

+#ifdef _IEEE_LIBM
+double y1(double x)
+ __attribute__((weak, alias("__ieee754_y1")));
+#endif
+
#ifdef __STDC__
double __ieee754_y1(double x)
#else
diff --git a/newlib/libm/math/e_jn.c b/newlib/libm/math/e_jn.c
index 1eea27be0..b11348f16 100644
--- a/newlib/libm/math/e_jn.c
+++ b/newlib/libm/math/e_jn.c
@@ -56,6 +56,11 @@ static const double zero = 0.00000000000000000000e+00;
static double zero = 0.00000000000000000000e+00;
#endif

+#ifdef _IEEE_LIBM
+double jn(int n, double x)
+ __attribute__((weak, alias("__ieee754_jn")));
+#endif
+
#ifdef __STDC__
double __ieee754_jn(int n, double x)
#else
@@ -216,6 +221,11 @@ static double zero = 0.00000000000000000000e+00;
if(sgn==1) return -b; else return b;
}

+#ifdef _IEEE_LIBM
+double yn(int n, double x)
+ __attribute__((weak, alias("__ieee754_yn")));
+#endif
+
#ifdef __STDC__
double __ieee754_yn(int n, double x)
#else
diff --git a/newlib/libm/math/e_log.c b/newlib/libm/math/e_log.c
index ac4a95068..a4af67bef 100644
--- a/newlib/libm/math/e_log.c
+++ b/newlib/libm/math/e_log.c
@@ -89,6 +89,11 @@ static const double zero = 0.0;
static double zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+double log(double x)
+ __attribute__((weak, alias("__ieee754_log")));
+#endif
+
#ifdef __STDC__
double __ieee754_log(double x)
#else
diff --git a/newlib/libm/math/e_log10.c b/newlib/libm/math/e_log10.c
index f7daaa1b2..60128d218 100644
--- a/newlib/libm/math/e_log10.c
+++ b/newlib/libm/math/e_log10.c
@@ -64,6 +64,11 @@ static const double zero = 0.0;
static double zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+double log10(double x)
+ __attribute__((weak, alias("__ieee754_log10")));
+#endif
+
#ifdef __STDC__
double __ieee754_log10(double x)
#else
diff --git a/newlib/libm/math/e_pow.c b/newlib/libm/math/e_pow.c
index 6d2a501a1..d1ac5b2d2 100644
--- a/newlib/libm/math/e_pow.c
+++ b/newlib/libm/math/e_pow.c
@@ -99,6 +99,11 @@ ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/

+#ifdef _IEEE_LIBM
+double pow(double x, double y)
+ __attribute__((weak, alias("__ieee754_pow")));
+#endif
+
#ifdef __STDC__
double __ieee754_pow(double x, double y)
#else
diff --git a/newlib/libm/math/e_rem_pio2.c b/newlib/libm/math/e_rem_pio2.c
index ddfecba2d..f9fa45309 100644
--- a/newlib/libm/math/e_rem_pio2.c
+++ b/newlib/libm/math/e_rem_pio2.c
@@ -82,6 +82,11 @@ pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */

+#ifdef _IEEE_LIBM
+__int32_t rem_pio2(double x, double *y)
+ __attribute__((weak, alias("__ieee754_rem_pio2")));
+#endif
+
#ifdef __STDC__
__int32_t __ieee754_rem_pio2(double x, double *y)
#else
diff --git a/newlib/libm/math/e_remainder.c b/newlib/libm/math/e_remainder.c
index ae7ce649a..fdbc8aff9 100644
--- a/newlib/libm/math/e_remainder.c
+++ b/newlib/libm/math/e_remainder.c
@@ -31,6 +31,11 @@ static double zero = 0.0;
#endif


+#ifdef _IEEE_LIBM
+double remainder(double x, double p)
+ __attribute__((weak, alias("__ieee754_remainder")));
+#endif
+
#ifdef __STDC__
double __ieee754_remainder(double x, double p)
#else
diff --git a/newlib/libm/math/e_scalb.c b/newlib/libm/math/e_scalb.c
index 0bb924b43..a5bd9a863 100644
--- a/newlib/libm/math/e_scalb.c
+++ b/newlib/libm/math/e_scalb.c
@@ -21,6 +21,16 @@

#ifndef _DOUBLE_IS_32BITS

+#ifdef _IEEE_LIBM
+#ifdef _SCALB_INT
+double scalb(double x, int fn)
+ __attribute__((weak, alias("__ieee754_scalb")));
+#else
+double scalb(double x, double fn)
+ __attribute__((weak, alias("__ieee754_scalb")));
+#endif
+#endif
+
#ifdef _SCALB_INT
#ifdef __STDC__
double __ieee754_scalb(double x, int fn)
diff --git a/newlib/libm/math/e_sinh.c b/newlib/libm/math/e_sinh.c
index cf7ebfb88..e57034262 100644
--- a/newlib/libm/math/e_sinh.c
+++ b/newlib/libm/math/e_sinh.c
@@ -39,6 +39,11 @@ static const double one = 1.0, shuge = 1.0e307;
static double one = 1.0, shuge = 1.0e307;
#endif

+#ifdef _IEEE_LIBM
+double sinh(double x)
+ __attribute__((weak, alias("__ieee754_sinh")));
+#endif
+
#ifdef __STDC__
double __ieee754_sinh(double x)
#else
diff --git a/newlib/libm/math/e_sqrt.c b/newlib/libm/math/e_sqrt.c
index 78fc52417..3a9ec699a 100644
--- a/newlib/libm/math/e_sqrt.c
+++ b/newlib/libm/math/e_sqrt.c
@@ -91,6 +91,11 @@ static const double one = 1.0, tiny=1.0e-300;
static double one = 1.0, tiny=1.0e-300;
#endif

+#ifdef _IEEE_LIBM
+double sqrt(double x)
+ __attribute__((weak, alias("__ieee754_sqrt")));
+#endif
+
#ifdef __STDC__
double __ieee754_sqrt(double x)
#else
diff --git a/newlib/libm/math/ef_acos.c b/newlib/libm/math/ef_acos.c
index f73f97de7..655bbf677 100644
--- a/newlib/libm/math/ef_acos.c
+++ b/newlib/libm/math/ef_acos.c
@@ -35,6 +35,11 @@ qS2 = 2.0209457874e+00, /* 0x4001572d */
qS3 = -6.8828397989e-01, /* 0xbf303361 */
qS4 = 7.7038154006e-02; /* 0x3d9dc62e */

+#ifdef _IEEE_LIBM
+float acosf(float x)
+ __attribute__((weak, alias("__ieee754_acosf")));
+#endif
+
#ifdef __STDC__
float __ieee754_acosf(float x)
#else
diff --git a/newlib/libm/math/ef_acosh.c b/newlib/libm/math/ef_acosh.c
index 1119c2c86..66b46f596 100644
--- a/newlib/libm/math/ef_acosh.c
+++ b/newlib/libm/math/ef_acosh.c
@@ -24,6 +24,11 @@ static float
one = 1.0,
ln2 = 6.9314718246e-01; /* 0x3f317218 */

+#ifdef _IEEE_LIBM
+float acoshf(float x)
+ __attribute__((weak, alias("__ieee754_acoshf")));
+#endif
+
#ifdef __STDC__
float __ieee754_acoshf(float x)
#else
diff --git a/newlib/libm/math/ef_asin.c b/newlib/libm/math/ef_asin.c
index c49dcbbca..2346bc6bd 100644
--- a/newlib/libm/math/ef_asin.c
+++ b/newlib/libm/math/ef_asin.c
@@ -37,6 +37,11 @@ qS2 = 2.0209457874e+00, /* 0x4001572d */
qS3 = -6.8828397989e-01, /* 0xbf303361 */
qS4 = 7.7038154006e-02; /* 0x3d9dc62e */

+#ifdef _IEEE_LIBM
+float asinf(float x)
+ __attribute__((weak, alias("__ieee754_asinf")));
+#endif
+
#ifdef __STDC__
float __ieee754_asinf(float x)
#else
diff --git a/newlib/libm/math/ef_atan2.c b/newlib/libm/math/ef_atan2.c
index d57480b03..1d8ca633a 100644
--- a/newlib/libm/math/ef_atan2.c
+++ b/newlib/libm/math/ef_atan2.c
@@ -28,6 +28,11 @@ pi_o_2 = 1.5707963705e+00, /* 0x3fc90fdb */
pi = 3.1415927410e+00, /* 0x40490fdb */
pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */

+#ifdef _IEEE_LIBM
+float atan2f(float y, float x)
+ __attribute__((weak, alias("__ieee754_atan2f")));
+#endif
+
#ifdef __STDC__
float __ieee754_atan2f(float y, float x)
#else
diff --git a/newlib/libm/math/ef_atanh.c b/newlib/libm/math/ef_atanh.c
index 74b3d3d6a..fb0dbd214 100644
--- a/newlib/libm/math/ef_atanh.c
+++ b/newlib/libm/math/ef_atanh.c
@@ -28,6 +28,11 @@ static const float zero = 0.0;
static float zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+float atanhf(float x)
+ __attribute__((weak, alias("__ieee754_atanhf")));
+#endif
+
#ifdef __STDC__
float __ieee754_atanhf(float x)
#else
diff --git a/newlib/libm/math/ef_cosh.c b/newlib/libm/math/ef_cosh.c
index bdce61a00..3c3872588 100644
--- a/newlib/libm/math/ef_cosh.c
+++ b/newlib/libm/math/ef_cosh.c
@@ -25,6 +25,11 @@ static const float one = 1.0, half=0.5, huge = 1.0e30;
static float one = 1.0, half=0.5, huge = 1.0e30;
#endif

+#ifdef _IEEE_LIBM
+float coshf(float x)
+ __attribute__((weak, alias("__ieee754_coshf")));
+#endif
+
#ifdef __STDC__
float __ieee754_coshf(float x)
#else
diff --git a/newlib/libm/math/ef_exp.c b/newlib/libm/math/ef_exp.c
index e817370ac..1f20d5ffb 100644
--- a/newlib/libm/math/ef_exp.c
+++ b/newlib/libm/math/ef_exp.c
@@ -40,6 +40,11 @@ P3 = 6.6137559770e-05, /* 0x388ab355 */
P4 = -1.6533901999e-06, /* 0xb5ddea0e */
P5 = 4.1381369442e-08; /* 0x3331bb4c */

+#ifdef _IEEE_LIBM
+float expf(float x)
+ __attribute__((weak, alias("__ieee754_expf")));
+#endif
+
#ifdef __STDC__
float __ieee754_expf(float x) /* default IEEE double exp */
#else
diff --git a/newlib/libm/math/ef_fmod.c b/newlib/libm/math/ef_fmod.c
index 53c1ba280..9a27c5dfe 100644
--- a/newlib/libm/math/ef_fmod.c
+++ b/newlib/libm/math/ef_fmod.c
@@ -27,6 +27,11 @@ static const float one = 1.0, Zero[] = {0.0, -0.0,};
static float one = 1.0, Zero[] = {0.0, -0.0,};
#endif

+#ifdef _IEEE_LIBM
+float fmodf(float x, float y)
+ __attribute__((weak, alias("__ieee754_fmodf")));
+#endif
+
#ifdef __STDC__
float __ieee754_fmodf(float x, float y)
#else
diff --git a/newlib/libm/math/ef_hypot.c b/newlib/libm/math/ef_hypot.c
index 9368eb41c..9ad0e71fa 100644
--- a/newlib/libm/math/ef_hypot.c
+++ b/newlib/libm/math/ef_hypot.c
@@ -15,6 +15,11 @@

#include "fdlibm.h"

+#ifdef _IEEE_LIBM
+float hypotf(float x, float y)
+ __attribute__((weak, alias("__ieee754_hypotf")));
+#endif
+
#ifdef __STDC__
float __ieee754_hypotf(float x, float y)
#else
diff --git a/newlib/libm/math/ef_j0.c b/newlib/libm/math/ef_j0.c
index 866cfcf96..201b27830 100644
--- a/newlib/libm/math/ef_j0.c
+++ b/newlib/libm/math/ef_j0.c
@@ -46,6 +46,11 @@ static const float zero = 0.0;
static float zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+float j0f(float x)
+ __attribute__((weak, alias("__ieee754_j0f")));
+#endif
+
#ifdef __STDC__
float __ieee754_j0f(float x)
#else
@@ -115,6 +120,11 @@ v02 = 7.6006865129e-05, /* 0x389f65e0 */
v03 = 2.5915085189e-07, /* 0x348b216c */
v04 = 4.4111031494e-10; /* 0x2ff280c2 */

+#ifdef _IEEE_LIBM
+float y0f(float x)
+ __attribute__((weak, alias("__ieee754_y0f")));
+#endif
+
#ifdef __STDC__
float __ieee754_y0f(float x)
#else
diff --git a/newlib/libm/math/ef_j1.c b/newlib/libm/math/ef_j1.c
index 01bd24cf1..4d57ff40a 100644
--- a/newlib/libm/math/ef_j1.c
+++ b/newlib/libm/math/ef_j1.c
@@ -47,6 +47,11 @@ static const float zero = 0.0;
static float zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+float j1f(float x)
+ __attribute__((weak, alias("__ieee754_j1f")));
+#endif
+
#ifdef __STDC__
float __ieee754_j1f(float x)
#else
@@ -116,6 +121,11 @@ static float V0[5] = {
1.6655924903e-11, /* 0x2d9281cf */
};

+#ifdef _IEEE_LIBM
+float y1f(float x)
+ __attribute__((weak, alias("__ieee754_y1f")));
+#endif
+
#ifdef __STDC__
float __ieee754_y1f(float x)
#else
diff --git a/newlib/libm/math/ef_jn.c b/newlib/libm/math/ef_jn.c
index e872c09c7..4481a49a7 100644
--- a/newlib/libm/math/ef_jn.c
+++ b/newlib/libm/math/ef_jn.c
@@ -29,6 +29,11 @@ static const float zero = 0.0000000000e+00;
static float zero = 0.0000000000e+00;
#endif

+#ifdef _IEEE_LIBM
+float jnf(int n, float x)
+ __attribute__((weak, alias("__ieee754_jnf")));
+#endif
+
#ifdef __STDC__
float __ieee754_jnf(int n, float x)
#else
@@ -166,6 +171,11 @@ static float zero = 0.0000000000e+00;
if(sgn==1) return -b; else return b;
}

+#ifdef _IEEE_LIBM
+float ynf(int n, float x)
+ __attribute__((weak, alias("__ieee754_ynf")));
+#endif
+
#ifdef __STDC__
float __ieee754_ynf(int n, float x)
#else
diff --git a/newlib/libm/math/ef_log.c b/newlib/libm/math/ef_log.c
index 8dc902478..160ee7057 100644
--- a/newlib/libm/math/ef_log.c
+++ b/newlib/libm/math/ef_log.c
@@ -38,6 +38,11 @@ static const float zero = 0.0;
static float zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+float logf(float x)
+ __attribute__((weak, alias("__ieee754_logf")));
+#endif
+
#ifdef __STDC__
float __ieee754_logf(float x)
#else
diff --git a/newlib/libm/math/ef_log10.c b/newlib/libm/math/ef_log10.c
index 5ab23c43f..51c57a15a 100644
--- a/newlib/libm/math/ef_log10.c
+++ b/newlib/libm/math/ef_log10.c
@@ -31,6 +31,11 @@ static const float zero = 0.0;
static float zero = 0.0;
#endif

+#ifdef _IEEE_LIBM
+float log10f(float x)
+ __attribute__((weak, alias("__ieee754_log10f")));
+#endif
+
#ifdef __STDC__
float __ieee754_log10f(float x)
#else
diff --git a/newlib/libm/math/ef_pow.c b/newlib/libm/math/ef_pow.c
index 524e3f9b0..8953dc44d 100644
--- a/newlib/libm/math/ef_pow.c
+++ b/newlib/libm/math/ef_pow.c
@@ -57,6 +57,11 @@ ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/

+#ifdef _IEEE_LIBM
+float powf(float x, float y)
+ __attribute__((weak, alias("__ieee754_powf")));
+#endif
+
#ifdef __STDC__
float __ieee754_powf(float x, float y)
#else
diff --git a/newlib/libm/math/ef_rem_pio2.c b/newlib/libm/math/ef_rem_pio2.c
index f1191d09f..73d0e3248 100644
--- a/newlib/libm/math/ef_rem_pio2.c
+++ b/newlib/libm/math/ef_rem_pio2.c
@@ -95,6 +95,11 @@ pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */
pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */
pio2_3t = 6.1232342629e-17; /* 0x248d3132 */

+#ifdef _IEEE_LIBM
+__int32_t rem_pio2f(float x, float *y)
+ __attribute__((weak, alias("__ieee754_rem_pio2f")));
+#endif
+
#ifdef __STDC__
__int32_t __ieee754_rem_pio2f(float x, float *y)
#else
diff --git a/newlib/libm/math/ef_remainder.c b/newlib/libm/math/ef_remainder.c
index 23d29d05a..7fccd95eb 100644
--- a/newlib/libm/math/ef_remainder.c
+++ b/newlib/libm/math/ef_remainder.c
@@ -22,6 +22,11 @@ static float zero = 0.0;
#endif


+#ifdef _IEEE_LIBM
+float remainderf(float x, float p)
+ __attribute__((weak, alias("__ieee754_remainderf")));
+#endif
+
#ifdef __STDC__
float __ieee754_remainderf(float x, float p)
#else
diff --git a/newlib/libm/math/ef_scalb.c b/newlib/libm/math/ef_scalb.c
index 8d973b1e7..c8cca24f7 100644
--- a/newlib/libm/math/ef_scalb.c
+++ b/newlib/libm/math/ef_scalb.c
@@ -16,6 +16,16 @@
#include "fdlibm.h"
#include <limits.h>

+#ifdef _IEEE_LIBM
+#ifdef _SCALB_INT
+float scalbf(float x, int fn)
+ __attribute__((weak, alias("__ieee754_scalbf")));
+#else
+float scalbf(float x, float fn)
+ __attribute__((weak, alias("__ieee754_scalbf")));
+#endif
+#endif
+
#ifdef _SCALB_INT
#ifdef __STDC__
float __ieee754_scalbf(float x, int fn)
diff --git a/newlib/libm/math/ef_sinh.c b/newlib/libm/math/ef_sinh.c
index a61b17294..db4c20485 100644
--- a/newlib/libm/math/ef_sinh.c
+++ b/newlib/libm/math/ef_sinh.c
@@ -21,6 +21,11 @@ static const float one = 1.0, shuge = 1.0e37;
static float one = 1.0, shuge = 1.0e37;
#endif

+#ifdef _IEEE_LIBM
+float sinhf(float x)
+ __attribute__((weak, alias("__ieee754_sinhf")));
+#endif
+
#ifdef __STDC__
float __ieee754_sinhf(float x)
#else
diff --git a/newlib/libm/math/ef_sqrt.c b/newlib/libm/math/ef_sqrt.c
index 80e7f360e..5be7ab4d0 100644
--- a/newlib/libm/math/ef_sqrt.c
+++ b/newlib/libm/math/ef_sqrt.c
@@ -21,6 +21,11 @@ static const float one = 1.0, tiny=1.0e-30;
static float one = 1.0, tiny=1.0e-30;
#endif

+#ifdef _IEEE_LIBM
+float sqrtf(float x)
+ __attribute__((weak, alias("__ieee754_sqrtf")));
+#endif
+
#ifdef __STDC__
float __ieee754_sqrtf(float x)
#else
diff --git a/newlib/libm/math/er_gamma.c b/newlib/libm/math/er_gamma.c
index 3c0e241e5..245ab822c 100644
--- a/newlib/libm/math/er_gamma.c
+++ b/newlib/libm/math/er_gamma.c
@@ -21,6 +21,11 @@

#include "fdlibm.h"

+#ifdef _IEEE_LIBM
+double gamma_r(double x, int *signgamp)
+ __attribute__((weak, alias("__ieee754_gamma_r")));
+#endif
+
#ifdef __STDC__
double __ieee754_gamma_r(double x, int *signgamp)
#else
diff --git a/newlib/libm/math/er_lgamma.c b/newlib/libm/math/er_lgamma.c
index 386a8a73b..df4f5552d 100644
--- a/newlib/libm/math/er_lgamma.c
+++ b/newlib/libm/math/er_lgamma.c
@@ -209,6 +209,11 @@ static double zero= 0.00000000000000000000e+00;
}


+#ifdef _IEEE_LIBM
+double lgamma_r(double x, int *signgamp)
+ __attribute__((weak, alias("__ieee754_lgamma_r")));
+#endif
+
#ifdef __STDC__
double __ieee754_lgamma_r(double x, int *signgamp)
#else
diff --git a/newlib/libm/math/erf_gamma.c b/newlib/libm/math/erf_gamma.c
index 9e529dce0..e7b87efe4 100644
--- a/newlib/libm/math/erf_gamma.c
+++ b/newlib/libm/math/erf_gamma.c
@@ -23,6 +23,11 @@

#include "fdlibm.h"

+#ifdef _IEEE_LIBM
+float gammaf_r(float x, int *signgamp)
+ __attribute__((weak, alias("__ieee754_gammaf_r")));
+#endif
+
#ifdef __STDC__
float __ieee754_gammaf_r(float x, int *signgamp)
#else
diff --git a/newlib/libm/math/erf_lgamma.c b/newlib/libm/math/erf_lgamma.c
index 3c6ba02af..4df4418c4 100644
--- a/newlib/libm/math/erf_lgamma.c
+++ b/newlib/libm/math/erf_lgamma.c
@@ -144,6 +144,11 @@ static float zero= 0.0000000000e+00;
}


+#ifdef _IEEE_LIBM
+float lgammaf_r(float x, int *signgamp)
+ __attribute__((weak, alias("__ieee754_lgammaf_r")));
+#endif
+
#ifdef __STDC__
float __ieee754_lgammaf_r(float x, int *signgamp)
#else
diff --git a/newlib/libm/math/w_acos.c b/newlib/libm/math/w_acos.c
index eb3e20111..2cd5247e2 100644
--- a/newlib/libm/math/w_acos.c
+++ b/newlib/libm/math/w_acos.c
@@ -70,6 +70,7 @@ MATHREF
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifndef _DOUBLE_IS_32BITS

#ifdef __STDC__
@@ -79,9 +80,6 @@ MATHREF
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_acos(x);
-#else
double z;
struct exception exc;
z = __ieee754_acos(x);
@@ -103,7 +101,7 @@ MATHREF
return exc.retval;
} else
return z;
-#endif
}

#endif /* defined(_DOUBLE_IS_32BITS) */
+#endif /* defined(_IEEE_LIBM) */
diff --git a/newlib/libm/math/w_acosh.c b/newlib/libm/math/w_acosh.c
index ac15bb1bd..5979526ab 100644
--- a/newlib/libm/math/w_acosh.c
+++ b/newlib/libm/math/w_acosh.c
@@ -76,6 +76,8 @@ MATHREF
#include "fdlibm.h"
#include <errno.h>

+
+#ifndef _IEEE_LIBM
#ifndef _DOUBLE_IS_32BITS

#ifdef __STDC__
@@ -85,9 +87,6 @@ MATHREF
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_acosh(x);
-#else
double z;
struct exception exc;
z = __ieee754_acosh(x);
@@ -109,7 +108,7 @@ MATHREF
return exc.retval;
} else
return z;
-#endif
}

#endif /* defined(_DOUBLE_IS_32BITS) */
+#endif /* defined(_IEEE_LIBM) */
diff --git a/newlib/libm/math/w_asin.c b/newlib/libm/math/w_asin.c
index 9964d75b0..a39ca9425 100644
--- a/newlib/libm/math/w_asin.c
+++ b/newlib/libm/math/w_asin.c
@@ -76,6 +76,7 @@ MATHREF

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double asin(double x) /* wrapper asin */
#else
@@ -83,9 +84,6 @@ MATHREF
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_asin(x);
-#else
double z;
struct exception exc;
z = __ieee754_asin(x);
@@ -107,7 +105,7 @@ MATHREF
return exc.retval;
} else
return z;
-#endif
}

#endif /* defined(_DOUBLE_IS_32BITS) */
+#endif
diff --git a/newlib/libm/math/w_atanh.c b/newlib/libm/math/w_atanh.c
index a87e23cc4..1be3f5da2 100644
--- a/newlib/libm/math/w_atanh.c
+++ b/newlib/libm/math/w_atanh.c
@@ -74,6 +74,7 @@ QUICKREF
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifndef _DOUBLE_IS_32BITS

#ifdef __STDC__
@@ -83,9 +84,6 @@ QUICKREF
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_atanh(x);
-#else
double z,y;
struct exception exc;
z = __ieee754_atanh(x);
@@ -122,11 +120,7 @@ QUICKREF
return exc.retval;
} else
return z;
-#endif
}

#endif /* defined(_DOUBLE_IS_32BITS) */
-
-
-
-
+#endif
diff --git a/newlib/libm/math/w_cosh.c b/newlib/libm/math/w_cosh.c
index e5b08df00..9cfa0111f 100644
--- a/newlib/libm/math/w_cosh.c
+++ b/newlib/libm/math/w_cosh.c
@@ -60,8 +60,9 @@ QUICKREF
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifndef _DOUBLE_IS_32BITS
-
+
#ifdef __STDC__
double cosh(double x) /* wrapper cosh */
#else
@@ -69,9 +70,6 @@ QUICKREF
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_cosh(x);
-#else
double z;
struct exception exc;
z = __ieee754_cosh(x);
@@ -102,7 +100,7 @@ QUICKREF
return exc.retval;
} else
return z;
-#endif
}

#endif /* defined(_DOUBLE_IS_32BITS) */
+#endif
diff --git a/newlib/libm/math/w_exp.c b/newlib/libm/math/w_exp.c
index 0c4467712..1b6e9ece8 100644
--- a/newlib/libm/math/w_exp.c
+++ b/newlib/libm/math/w_exp.c
@@ -58,6 +58,7 @@ PORTABILITY

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
static const double
#else
@@ -73,9 +74,6 @@ u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_exp(x);
-#else
double z;
struct exception exc;
z = __ieee754_exp(x);
@@ -123,8 +121,8 @@ u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
}
}
return z;
-#endif
}

#endif /* defined(_DOUBLE_IS_32BITS) */
+#endif
#endif /* __OBSOLETE_MATH */
diff --git a/newlib/libm/math/w_fmod.c b/newlib/libm/math/w_fmod.c
index df11dc34c..db8a52dfc 100644
--- a/newlib/libm/math/w_fmod.c
+++ b/newlib/libm/math/w_fmod.c
@@ -58,6 +58,7 @@ PORTABILITY

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double fmod(double x, double y) /* wrapper fmod */
#else
@@ -65,9 +66,6 @@ PORTABILITY
double x,y;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_fmod(x,y);
-#else
double z;
struct exception exc;
z = __ieee754_fmod(x,y);
@@ -93,7 +91,7 @@ PORTABILITY
return exc.retval;
} else
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/math/w_hypot.c b/newlib/libm/math/w_hypot.c
index 533702277..bb4dca845 100644
--- a/newlib/libm/math/w_hypot.c
+++ b/newlib/libm/math/w_hypot.c
@@ -55,6 +55,7 @@ PORTABILITY

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double hypot(double x, double y)/* wrapper hypot */
#else
@@ -62,9 +63,6 @@ PORTABILITY
double x,y;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_hypot(x,y);
-#else
double z;
struct exception exc;
z = __ieee754_hypot(x,y);
@@ -96,7 +94,7 @@ PORTABILITY
return exc.retval;
} else
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/math/w_j0.c b/newlib/libm/math/w_j0.c
index ab05dbdeb..d706a7714 100644
--- a/newlib/libm/math/w_j0.c
+++ b/newlib/libm/math/w_j0.c
@@ -94,6 +94,7 @@ None of the Bessel functions are in ANSI C.

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double j0(double x) /* wrapper j0 */
#else
@@ -101,9 +102,6 @@ None of the Bessel functions are in ANSI C.
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_j0(x);
-#else
struct exception exc;
double z = __ieee754_j0(x);
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
@@ -124,9 +122,10 @@ None of the Bessel functions are in ANSI C.
return exc.retval;
} else
return z;
-#endif
}
+#endif

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double y0(double x) /* wrapper y0 */
#else
@@ -134,9 +133,6 @@ None of the Bessel functions are in ANSI C.
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_y0(x);
-#else
double z;
struct exception exc;
z = __ieee754_y0(x);
@@ -183,8 +179,8 @@ None of the Bessel functions are in ANSI C.
return exc.retval;
} else
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */

diff --git a/newlib/libm/math/w_j1.c b/newlib/libm/math/w_j1.c
index ba7df1566..902369ed6 100644
--- a/newlib/libm/math/w_j1.c
+++ b/newlib/libm/math/w_j1.c
@@ -20,6 +20,7 @@

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double j1(double x) /* wrapper j1 */
#else
@@ -27,9 +28,6 @@
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_j1(x);
-#else
double z;
struct exception exc;
z = __ieee754_j1(x);
@@ -51,9 +49,10 @@
return exc.retval;
} else
return z;
-#endif
}
+#endif

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double y1(double x) /* wrapper y1 */
#else
@@ -61,9 +60,6 @@
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_y1(x);
-#else
double z;
struct exception exc;
z = __ieee754_y1(x);
@@ -110,8 +106,8 @@
return exc.retval;
} else
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */

diff --git a/newlib/libm/math/w_jn.c b/newlib/libm/math/w_jn.c
index 6cadc9a01..e4cb4d157 100644
--- a/newlib/libm/math/w_jn.c
+++ b/newlib/libm/math/w_jn.c
@@ -42,6 +42,7 @@

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double jn(int n, double x) /* wrapper jn */
#else
@@ -49,9 +50,6 @@
double x; int n;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_jn(n,x);
-#else
double z;
struct exception exc;
z = __ieee754_jn(n,x);
@@ -74,9 +72,10 @@
return exc.retval;
} else
return z;
-#endif
}
+#endif

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double yn(int n, double x) /* wrapper yn */
#else
@@ -84,9 +83,6 @@
double x; int n;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_yn(n,x);
-#else
double z;
struct exception exc;
z = __ieee754_yn(n,x);
@@ -135,7 +131,7 @@
return exc.retval;
} else
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/math/w_log.c b/newlib/libm/math/w_log.c
index 5f66d26ad..9c1e9ba2d 100644
--- a/newlib/libm/math/w_log.c
+++ b/newlib/libm/math/w_log.c
@@ -54,6 +54,7 @@ PORTABILITY

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double log(double x) /* wrapper log */
#else
@@ -61,9 +62,6 @@ PORTABILITY
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_log(x);
-#else
double z;
struct exception exc;
z = __ieee754_log(x);
@@ -103,8 +101,8 @@ PORTABILITY
if (exc.err != 0)
errno = exc.err;
return exc.retval;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
#endif /* __OBSOLETE_MATH */
diff --git a/newlib/libm/math/w_log10.c b/newlib/libm/math/w_log10.c
index 3b436d539..3c4ce18aa 100644
--- a/newlib/libm/math/w_log10.c
+++ b/newlib/libm/math/w_log10.c
@@ -50,6 +50,7 @@ PORTABILITY

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double log10(double x) /* wrapper log10 */
#else
@@ -57,9 +58,6 @@ PORTABILITY
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_log10(x);
-#else
double z;
struct exception exc;
z = __ieee754_log10(x);
@@ -102,7 +100,7 @@ PORTABILITY
return exc.retval;
} else
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/math/w_pow.c b/newlib/libm/math/w_pow.c
index 9d1e396a5..46bb70f07 100644
--- a/newlib/libm/math/w_pow.c
+++ b/newlib/libm/math/w_pow.c
@@ -57,6 +57,7 @@ PORTABILITY

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double pow(double x, double y) /* wrapper pow */
#else
@@ -64,9 +65,6 @@ PORTABILITY
double x,y;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_pow(x,y);
-#else
double z;
#ifndef HUGE_VAL
#define HUGE_VAL inf
@@ -204,8 +202,8 @@ PORTABILITY
return exc.retval;
}
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
#endif /* __OBSOLETE_MATH */
diff --git a/newlib/libm/math/w_remainder.c b/newlib/libm/math/w_remainder.c
index 5b13390f9..325a1f3a9 100644
--- a/newlib/libm/math/w_remainder.c
+++ b/newlib/libm/math/w_remainder.c
@@ -46,6 +46,7 @@ PORTABILITY

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double remainder(double x, double y) /* wrapper remainder */
#else
@@ -53,9 +54,6 @@ PORTABILITY
double x,y;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_remainder(x,y);
-#else
double z;
struct exception exc;
z = __ieee754_remainder(x,y);
@@ -78,8 +76,8 @@ PORTABILITY
return exc.retval;
} else
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */

diff --git a/newlib/libm/math/w_scalb.c b/newlib/libm/math/w_scalb.c
index c32496892..b1aa1c9b0 100644
--- a/newlib/libm/math/w_scalb.c
+++ b/newlib/libm/math/w_scalb.c
@@ -22,6 +22,8 @@

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
+
#ifdef __STDC__
#ifdef _SCALB_INT
double scalb(double x, int fn) /* wrapper scalb */
@@ -37,9 +39,6 @@
#endif
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_scalb(x,fn);
-#else
double z;
#ifndef HUGE_VAL
#define HUGE_VAL inf
@@ -88,7 +87,7 @@
if(!finite(fn)) errno = ERANGE;
#endif
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/math/w_sinh.c b/newlib/libm/math/w_sinh.c
index 340a7112d..77136c83d 100644
--- a/newlib/libm/math/w_sinh.c
+++ b/newlib/libm/math/w_sinh.c
@@ -66,6 +66,7 @@ QUICKREF

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double sinh(double x) /* wrapper sinh */
#else
@@ -73,9 +74,6 @@ QUICKREF
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_sinh(x);
-#else
double z;
struct exception exc;
z = __ieee754_sinh(x);
@@ -106,7 +104,7 @@ QUICKREF
return exc.retval;
} else
return z;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/math/w_sqrt.c b/newlib/libm/math/w_sqrt.c
index 61d42fcec..793426294 100644
--- a/newlib/libm/math/w_sqrt.c
+++ b/newlib/libm/math/w_sqrt.c
@@ -47,6 +47,7 @@ PORTABILITY
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifndef _DOUBLE_IS_32BITS

#ifdef __STDC__
@@ -56,9 +57,6 @@ PORTABILITY
double x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_sqrt(x);
-#else
struct exception exc;
double z;
z = __ieee754_sqrt(x);
@@ -82,7 +80,7 @@ PORTABILITY
return exc.retval;
} else
return z;
-#endif
}

#endif /* defined(_DOUBLE_IS_32BITS) */
+#endif /* defined(_IEEE_LIBM) */
diff --git a/newlib/libm/math/wf_acos.c b/newlib/libm/math/wf_acos.c
index 8154c795e..c945600a9 100644
--- a/newlib/libm/math/wf_acos.c
+++ b/newlib/libm/math/wf_acos.c
@@ -20,11 +20,9 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
float acosf(float x) /* wrapper acosf */
{
-#ifdef _IEEE_LIBM
- return __ieee754_acosf(x);
-#else
float z;
struct exception exc;
z = __ieee754_acosf(x);
@@ -46,8 +44,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_acosh.c b/newlib/libm/math/wf_acosh.c
index fc8ec3a0a..9d0165e66 100644
--- a/newlib/libm/math/wf_acosh.c
+++ b/newlib/libm/math/wf_acosh.c
@@ -21,6 +21,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float acoshf(float x) /* wrapper acoshf */
#else
@@ -28,9 +29,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_acoshf(x);
-#else
float z;
struct exception exc;
z = __ieee754_acoshf(x);
@@ -52,8 +50,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_asin.c b/newlib/libm/math/wf_asin.c
index 385de5499..ff5815211 100644
--- a/newlib/libm/math/wf_asin.c
+++ b/newlib/libm/math/wf_asin.c
@@ -22,6 +22,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float asinf(float x) /* wrapper asinf */
#else
@@ -29,9 +30,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_asinf(x);
-#else
float z;
struct exception exc;
z = __ieee754_asinf(x);
@@ -53,8 +51,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_atanh.c b/newlib/libm/math/wf_atanh.c
index 565630411..d69c344ab 100644
--- a/newlib/libm/math/wf_atanh.c
+++ b/newlib/libm/math/wf_atanh.c
@@ -19,6 +19,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float atanhf(float x) /* wrapper atanhf */
#else
@@ -26,9 +27,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_atanhf(x);
-#else
float z,y;
struct exception exc;
z = __ieee754_atanhf(x);
@@ -65,8 +63,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_cosh.c b/newlib/libm/math/wf_cosh.c
index 02eb12472..68cbc0754 100644
--- a/newlib/libm/math/wf_cosh.c
+++ b/newlib/libm/math/wf_cosh.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float coshf(float x) /* wrapper coshf */
#else
@@ -27,9 +28,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_coshf(x);
-#else
float z;
struct exception exc;
z = __ieee754_coshf(x);
@@ -60,8 +58,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_exp.c b/newlib/libm/math/wf_exp.c
index f16af1d1b..277cd025b 100644
--- a/newlib/libm/math/wf_exp.c
+++ b/newlib/libm/math/wf_exp.c
@@ -21,6 +21,7 @@
#if __OBSOLETE_MATH
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
static const float
#else
@@ -36,9 +37,6 @@ u_threshold= -1.0397208405e+02; /* 0xc2cff1b5 */
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_expf(x);
-#else
float z;
struct exception exc;
z = __ieee754_expf(x);
@@ -86,8 +84,8 @@ u_threshold= -1.0397208405e+02; /* 0xc2cff1b5 */
}
}
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_fmod.c b/newlib/libm/math/wf_fmod.c
index 030ca3e7a..af6683baf 100644
--- a/newlib/libm/math/wf_fmod.c
+++ b/newlib/libm/math/wf_fmod.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float fmodf(float x, float y) /* wrapper fmodf */
#else
@@ -27,9 +28,6 @@
float x,y;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_fmodf(x,y);
-#else
float z;
struct exception exc;
z = __ieee754_fmodf(x,y);
@@ -55,8 +53,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_gamma.c b/newlib/libm/math/wf_gamma.c
index 1204f3999..a1b5d171f 100644
--- a/newlib/libm/math/wf_gamma.c
+++ b/newlib/libm/math/wf_gamma.c
@@ -18,6 +18,7 @@
#include <reent.h>
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float gammaf(float x)
#else
@@ -25,9 +26,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
-#else
float y;
struct exception exc;
y = __ieee754_gammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
@@ -75,8 +73,8 @@
return (float)exc.retval;
} else
return y;
+}
#endif
-}

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_hypot.c b/newlib/libm/math/wf_hypot.c
index c04ace110..15310a678 100644
--- a/newlib/libm/math/wf_hypot.c
+++ b/newlib/libm/math/wf_hypot.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float hypotf(float x, float y) /* wrapper hypotf */
#else
@@ -27,9 +28,6 @@
float x,y;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_hypotf(x,y);
-#else
float z;
struct exception exc;
z = __ieee754_hypotf(x,y);
@@ -61,8 +59,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_j0.c b/newlib/libm/math/wf_j0.c
index 1f7f5ede5..8ed93d926 100644
--- a/newlib/libm/math/wf_j0.c
+++ b/newlib/libm/math/wf_j0.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float j0f(float x) /* wrapper j0f */
#else
@@ -27,9 +28,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_j0f(x);
-#else
struct exception exc;
float z = __ieee754_j0f(x);
if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
@@ -50,9 +48,10 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float y0f(float x) /* wrapper y0f */
#else
@@ -60,9 +59,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_y0f(x);
-#else
float z;
struct exception exc;
z = __ieee754_y0f(x);
@@ -109,8 +105,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_j1.c b/newlib/libm/math/wf_j1.c
index b91962881..86aadf0e5 100644
--- a/newlib/libm/math/wf_j1.c
+++ b/newlib/libm/math/wf_j1.c
@@ -21,6 +21,7 @@
#include <errno.h>


+#ifndef _IEEE_LIBM
#ifdef __STDC__
float j1f(float x) /* wrapper j1f */
#else
@@ -28,9 +29,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_j1f(x);
-#else
float z;
struct exception exc;
z = __ieee754_j1f(x);
@@ -52,9 +50,10 @@
return exc.retval;
} else
return z;
-#endif
}
+#endif

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float y1f(float x) /* wrapper y1f */
#else
@@ -62,9 +61,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_y1f(x);
-#else
float z;
struct exception exc;
z = __ieee754_y1f(x);
@@ -111,8 +107,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_jn.c b/newlib/libm/math/wf_jn.c
index 837b6b703..0bd49a79b 100644
--- a/newlib/libm/math/wf_jn.c
+++ b/newlib/libm/math/wf_jn.c
@@ -17,6 +17,7 @@
#include <errno.h>


+#ifndef _IEEE_LIBM
#ifdef __STDC__
float jnf(int n, float x) /* wrapper jnf */
#else
@@ -24,9 +25,6 @@
float x; int n;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_jnf(n,x);
-#else
float z;
struct exception exc;
z = __ieee754_jnf(n,x);
@@ -49,9 +47,10 @@
return exc.retval;
} else
return z;
-#endif
}
+#endif

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float ynf(int n, float x) /* wrapper ynf */
#else
@@ -59,9 +58,6 @@
float x; int n;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_ynf(n,x);
-#else
float z;
struct exception exc;
z = __ieee754_ynf(n,x);
@@ -110,8 +106,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_lgamma.c b/newlib/libm/math/wf_lgamma.c
index f1bf0c019..01aaacad9 100644
--- a/newlib/libm/math/wf_lgamma.c
+++ b/newlib/libm/math/wf_lgamma.c
@@ -18,6 +18,7 @@
#include <reent.h>
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float lgammaf(float x)
#else
@@ -25,9 +26,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
-#else
float y;
struct exception exc;
y = __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
@@ -69,8 +67,8 @@
return (float)exc.retval;
} else
return y;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_log.c b/newlib/libm/math/wf_log.c
index 07be8d63c..3ed01653a 100644
--- a/newlib/libm/math/wf_log.c
+++ b/newlib/libm/math/wf_log.c
@@ -21,6 +21,7 @@
#if __OBSOLETE_MATH
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float logf(float x) /* wrapper logf */
#else
@@ -28,9 +29,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_logf(x);
-#else
float z;
struct exception exc;
z = __ieee754_logf(x);
@@ -69,8 +67,8 @@
if (exc.err != 0)
errno = exc.err;
return (float)exc.retval;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_log10.c b/newlib/libm/math/wf_log10.c
index 11c595637..a201c7336 100644
--- a/newlib/libm/math/wf_log10.c
+++ b/newlib/libm/math/wf_log10.c
@@ -20,6 +20,8 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
+ return __ieee754_log10f(x);
#ifdef __STDC__
float log10f(float x) /* wrapper log10f */
#else
@@ -27,9 +29,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_log10f(x);
-#else
float z;
struct exception exc;
z = __ieee754_log10f(x);
@@ -71,8 +70,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_pow.c b/newlib/libm/math/wf_pow.c
index f753b5226..7ab2b7cca 100644
--- a/newlib/libm/math/wf_pow.c
+++ b/newlib/libm/math/wf_pow.c
@@ -21,6 +21,7 @@
#if __OBSOLETE_MATH
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float powf(float x, float y) /* wrapper powf */
#else
@@ -28,9 +29,6 @@
float x,y;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_powf(x,y);
-#else
float z;
struct exception exc;
z=__ieee754_powf(x,y);
@@ -164,8 +162,8 @@
return (float)exc.retval;
}
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_remainder.c b/newlib/libm/math/wf_remainder.c
index f38c23785..b976e3616 100644
--- a/newlib/libm/math/wf_remainder.c
+++ b/newlib/libm/math/wf_remainder.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float remainderf(float x, float y) /* wrapper remainder */
#else
@@ -27,9 +28,6 @@
float x,y;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_remainderf(x,y);
-#else
float z;
struct exception exc;
z = __ieee754_remainderf(x,y);
@@ -52,8 +50,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_scalb.c b/newlib/libm/math/wf_scalb.c
index d2c3cd2aa..58df3dfc6 100644
--- a/newlib/libm/math/wf_scalb.c
+++ b/newlib/libm/math/wf_scalb.c
@@ -22,6 +22,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
#ifdef _SCALB_INT
float scalbf(float x, int fn) /* wrapper scalbf */
@@ -37,9 +38,6 @@
#endif
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_scalbf(x,fn);
-#else
float z;
#ifndef HUGE_VAL
#define HUGE_VAL inf
@@ -88,8 +86,8 @@
if(!finitef(fn)) errno = ERANGE;
#endif
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_sinh.c b/newlib/libm/math/wf_sinh.c
index 80c7a8e6e..9657ad8fc 100644
--- a/newlib/libm/math/wf_sinh.c
+++ b/newlib/libm/math/wf_sinh.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float sinhf(float x) /* wrapper sinhf */
#else
@@ -27,9 +28,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_sinhf(x);
-#else
float z;
struct exception exc;
z = __ieee754_sinhf(x);
@@ -60,8 +58,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wf_sqrt.c b/newlib/libm/math/wf_sqrt.c
index 4536ba0ac..784fa0df7 100644
--- a/newlib/libm/math/wf_sqrt.c
+++ b/newlib/libm/math/wf_sqrt.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float sqrtf(float x) /* wrapper sqrtf */
#else
@@ -27,9 +28,6 @@
float x;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_sqrtf(x);
-#else
float z;
struct exception exc;
z = __ieee754_sqrtf(x);
@@ -54,8 +52,8 @@
return (float)exc.retval;
} else
return z;
-#endif
}
+#endif

#ifdef _DOUBLE_IS_32BITS

diff --git a/newlib/libm/math/wr_gamma.c b/newlib/libm/math/wr_gamma.c
index 0092ed02c..17f02be82 100644
--- a/newlib/libm/math/wr_gamma.c
+++ b/newlib/libm/math/wr_gamma.c
@@ -20,6 +20,7 @@

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double gamma_r(double x, int *signgamp) /* wrapper lgamma_r */
#else
@@ -27,9 +28,6 @@
double x; int *signgamp;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_gamma_r(x,signgamp);
-#else
double y;
struct exception exc;
y = __ieee754_gamma_r(x,signgamp);
@@ -70,7 +68,7 @@
return exc.retval;
} else
return y;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/math/wr_lgamma.c b/newlib/libm/math/wr_lgamma.c
index c59c1cce9..ef38d9525 100644
--- a/newlib/libm/math/wr_lgamma.c
+++ b/newlib/libm/math/wr_lgamma.c
@@ -20,6 +20,7 @@

#ifndef _DOUBLE_IS_32BITS

+#ifndef _IEEE_LIBM
#ifdef __STDC__
double lgamma_r(double x, int *signgamp) /* wrapper lgamma_r */
#else
@@ -27,9 +28,6 @@
double x; int *signgamp;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgamma_r(x,signgamp);
-#else
double y;
struct exception exc;
y = __ieee754_lgamma_r(x,signgamp);
@@ -71,7 +69,7 @@
return exc.retval;
} else
return y;
-#endif
}
+#endif

#endif /* defined(_DOUBLE_IS_32BITS) */
diff --git a/newlib/libm/math/wrf_gamma.c b/newlib/libm/math/wrf_gamma.c
index ae285f564..4cb3cc1a1 100644
--- a/newlib/libm/math/wrf_gamma.c
+++ b/newlib/libm/math/wrf_gamma.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float gammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */
#else
@@ -27,9 +28,6 @@
float x; int *signgamp;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_gammaf_r(x,signgamp);
-#else
float y;
struct exception exc;
y = __ieee754_gammaf_r(x,signgamp);
@@ -70,5 +68,5 @@
return (float)exc.retval;
} else
return y;
-#endif
}
+#endif
diff --git a/newlib/libm/math/wrf_lgamma.c b/newlib/libm/math/wrf_lgamma.c
index 73985e271..60e4b9952 100644
--- a/newlib/libm/math/wrf_lgamma.c
+++ b/newlib/libm/math/wrf_lgamma.c
@@ -20,6 +20,7 @@
#include "fdlibm.h"
#include <errno.h>

+#ifndef _IEEE_LIBM
#ifdef __STDC__
float lgammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */
#else
@@ -27,9 +28,6 @@
float x; int *signgamp;
#endif
{
-#ifdef _IEEE_LIBM
- return __ieee754_lgammaf_r(x,signgamp);
-#else
float y;
struct exception exc;
y = __ieee754_lgammaf_r(x,signgamp);
@@ -71,5 +69,5 @@
return (float)exc.retval;
} else
return y;
-#endif
}
+#endif
--
2.18.0
Craig Howland
2018-08-27 19:23:38 UTC
Permalink
Post by k***@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.
---
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
Joel Sherrill
2018-08-27 19:28:14 UTC
Permalink
Post by Craig Howland
Post by k***@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.
---
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.

--joel
Post by Craig Howland
Craig
Corinna Vinschen
2018-08-29 13:59:29 UTC
Permalink
Post by Joel Sherrill
Post by Craig Howland
Post by k***@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.
---
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
Keith Packard
2018-08-29 16:32:46 UTC
Permalink
Post by Corinna Vinschen
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.
I've created a parallel 'meson' based build system for smaller embedded
systems which allows this as an option. Anything to save bytes in flash.

https://salsa.debian.org/electronics-team/toolchains/newlib-nano
--
-keith
Corinna Vinschen
2018-08-29 14:01:47 UTC
Permalink
Post by k***@keithp.com
Defined, never mentioned.
---
newlib/libm/math/sf_cos.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/newlib/libm/math/sf_cos.c b/newlib/libm/math/sf_cos.c
index 8cb0eb008..fa472b173 100644
--- a/newlib/libm/math/sf_cos.c
+++ b/newlib/libm/math/sf_cos.c
@@ -16,12 +16,6 @@
#include "fdlibm.h"
#if __OBSOLETE_MATH
-#ifdef __STDC__
-static const float one=1.0;
-#else
-static float one=1.0;
-#endif
-
#ifdef __STDC__
float cosf(float x)
#else
--
2.18.0
Pushed.


Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
Loading...