In _IEEE_LIBM mode, use weak symbols instead of wrapper funcs [v2]

Message ID 20180920215117.3257-1-keithp@keithp.com
State Superseded
Headers show
Series
  • In _IEEE_LIBM mode, use weak symbols instead of wrapper funcs [v2]
Related show

Commit Message

Keith Packard Sept. 20, 2018, 9:51 p.m.
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.

v2:
	Use __weak_reference macro instead of using
	'__attribute__((weak, alias' to make this code portable
	to non-ELF systems.

Signed-off-by: Keith Packard <keithp@keithp.com>

---
 newlib/libm/math/e_acos.c       |  4 ++++
 newlib/libm/math/e_acosh.c      |  4 ++++
 newlib/libm/math/e_asin.c       |  4 ++++
 newlib/libm/math/e_atan2.c      |  4 ++++
 newlib/libm/math/e_atanh.c      |  4 ++++
 newlib/libm/math/e_cosh.c       |  4 ++++
 newlib/libm/math/e_exp.c        |  4 ++++
 newlib/libm/math/e_fmod.c       |  4 ++++
 newlib/libm/math/e_hypot.c      |  4 ++++
 newlib/libm/math/e_j0.c         |  8 ++++++++
 newlib/libm/math/e_j1.c         |  8 ++++++++
 newlib/libm/math/e_jn.c         |  8 ++++++++
 newlib/libm/math/e_log.c        |  4 ++++
 newlib/libm/math/e_log10.c      |  4 ++++
 newlib/libm/math/e_pow.c        |  4 ++++
 newlib/libm/math/e_rem_pio2.c   |  4 ++++
 newlib/libm/math/e_remainder.c  |  4 ++++
 newlib/libm/math/e_scalb.c      |  4 ++++
 newlib/libm/math/e_sinh.c       |  4 ++++
 newlib/libm/math/e_sqrt.c       |  4 ++++
 newlib/libm/math/ef_acos.c      |  4 ++++
 newlib/libm/math/ef_acosh.c     |  4 ++++
 newlib/libm/math/ef_asin.c      |  4 ++++
 newlib/libm/math/ef_atan2.c     |  4 ++++
 newlib/libm/math/ef_atanh.c     |  4 ++++
 newlib/libm/math/ef_cosh.c      |  4 ++++
 newlib/libm/math/ef_exp.c       |  4 ++++
 newlib/libm/math/ef_fmod.c      |  4 ++++
 newlib/libm/math/ef_hypot.c     |  4 ++++
 newlib/libm/math/ef_j0.c        |  8 ++++++++
 newlib/libm/math/ef_j1.c        |  8 ++++++++
 newlib/libm/math/ef_jn.c        |  8 ++++++++
 newlib/libm/math/ef_log.c       |  4 ++++
 newlib/libm/math/ef_log10.c     |  4 ++++
 newlib/libm/math/ef_pow.c       |  4 ++++
 newlib/libm/math/ef_rem_pio2.c  |  4 ++++
 newlib/libm/math/ef_remainder.c |  4 ++++
 newlib/libm/math/ef_scalb.c     |  4 ++++
 newlib/libm/math/ef_sinh.c      |  4 ++++
 newlib/libm/math/ef_sqrt.c      |  4 ++++
 newlib/libm/math/el_hypot.c     |  4 ++++
 newlib/libm/math/er_gamma.c     |  4 ++++
 newlib/libm/math/er_lgamma.c    |  4 ++++
 newlib/libm/math/erf_gamma.c    |  4 ++++
 newlib/libm/math/erf_lgamma.c   |  4 ++++
 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     |  6 ++----
 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 ++----
 87 files changed, 303 insertions(+), 197 deletions(-)

-- 
2.19.0

Comments

Craig Howland Sept. 21, 2018, 6:14 p.m. | #1
On 09/20/2018 05:51 PM, Keith Packard wrote:
> 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.

>

> v2:

> 	Use __weak_reference macro instead of using

> 	'__attribute__((weak, alias' to make this code portable

> 	to non-ELF systems.

>

> Signed-off-by: Keith Packard <keithp@keithp.com>

> ---

>   newlib/libm/math/e_acos.c       |  4 ++++

>   ...

>   87 files changed, 303 insertions(+), 197 deletions(-)

Unless I'm missing something, there seems to be a fundamental problem with the 
approach in that the regular function definitions are unconditionally eliminated 
when the weak aliases are defined. So while this will work fine for targets 
which can do the aliases, the needed function wrappers are missing for when 
aliases do not work.  One example shown.
>

> diff --git a/newlib/libm/math/e_acos.c b/newlib/libm/math/e_acos.c

> index 319b1d56f..e2104a675 100644

> --- a/newlib/libm/math/e_acos.c

> +++ b/newlib/libm/math/e_acos.c

> @@ -59,6 +59,10 @@ qS2 =  2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */

>   qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */

>   qS4 =  7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */

>   

> +#ifdef _IEEE_LIBM

> +__weak_reference(__ieee754_acos, acos);

> +#endif

> +

>   #ifdef __STDC__

>   	double __ieee754_acos(double x)

>   #else

> ...

OK, so a weak alias of __ieee754_acos() for acos() is added when 
defined(_IEEE_LIBM).
> 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) */

But then the entire acos() function is deleted when defined(_IEEE_LIBM).  This 
is fine when the alias works, but not when the alias does not work.  That is, 
this gate also needs to know if the alias will work, rather than being based 
only on _IEEE_LIBM.

In addition, this method can potentially introduce a change in link-time 
behavior, because the library now has the primary function names as weak aliases 
instead of definite functions.  This won't necessarily make a difference while 
linking, but it could.  (While you could guess that the vast majority of uses 
would have no trouble at all, the question is if there are any which would.)  
This may or may not be acceptable, but the possibility needs to be considered 
when evaluating this approach.  (I'm pretty sure it would not affect any of my 
targets.)  Even ignoring that possibility, just the principle of having primary 
C library functions in the library as weak aliases seems like a bad idea.

Why not just abandon the alias approach and instead just re-name the ieee 
functions?  It solves both of the problems mentioned.  These edits are half-way 
there, as they get rid of the wrapper functions. But instead of adding the weak 
references, map the ieee names with the preprocessor.  It would have to be done 
in something like fdlibm.h because there are some internal calls from ieee to 
ieee, but the basic name-mapping collection could readily be retargeted.

Taking a step back, there's a higher-level question.  The Newlib math libary is 
already quite goofy with the variations in error handing, making multiple 
flavors, etc.  Is it perhaps time to give this strangeness up and just make them 
so that they are C/POSIX compliant?  This too would achieve the desired goal of 
getting rid of the wrappers.

Craig
Keith Packard Sept. 21, 2018, 7:34 p.m. | #2
Craig Howland <howland@LGSInnovations.com> writes:

> Unless I'm missing something, there seems to be a fundamental problem with the 

> approach in that the regular function definitions are unconditionally eliminated 

> when the weak aliases are defined. So while this will work fine for targets 

> which can do the aliases, the needed function wrappers are missing for when 

> aliases do not work.  One example shown.


Hrm. I note that __weak_reference is only used in the sys/linux/net
code currently, which means the definition of that macro could well be
missing on any non-linux platform and we would never know. Of course,
we'd get a compiler error if __weak_reference weren't defined, but
that's not a lot of help to a user interested in building the library.

I think I should make the use of this feature depend on whether there is a
definition of __weak_reference.

> But then the entire acos() function is deleted when defined(_IEEE_LIBM).  This 

> is fine when the alias works, but not when the alias does not work.  That is, 

> this gate also needs to know if the alias will work, rather than being based 

> only on _IEEE_LIBM.


Yup, I think it would be sufficient to check for the definition of
__weak_reference in both places; both to make the creation of the
reference work and to ensure that the wrapper is still defined when necessary.

> In addition, this method can potentially introduce a change in link-time 

> behavior, because the library now has the primary function names as weak aliases 

> instead of definite functions.  This won't necessarily make a difference while 

> linking, but it could.  (While you could guess that the vast majority of uses 

> would have no trouble at all, the question is if there are any which would.)  

> This may or may not be acceptable, but the possibility needs to be considered 

> when evaluating this approach.  (I'm pretty sure it would not affect any of my 

> targets.)  Even ignoring that possibility, just the principle of having primary 

> C library functions in the library as weak aliases seems like a bad

> idea.


That's another good point -- in looking at cdefs.h, I've found that
there's another macro, __strong_reference, which creates non-weak
symbols and should eliminate this issue.

> Why not just abandon the alias approach and instead just re-name the ieee 

> functions?  It solves both of the problems mentioned.  These edits are half-way 

> there, as they get rid of the wrapper functions. But instead of adding the weak 

> references, map the ieee names with the preprocessor.  It would have to be done 

> in something like fdlibm.h because there are some internal calls from ieee to 

> ieee, but the basic name-mapping collection could readily be

> retargeted.


I didn't want to change the ABI of the library to ensure that existing
applications would still work properly. If I switch from
__weak_reference to __strong_reference, and make use of this feature
conditional upon whether that macro is defined for the platform.

> Taking a step back, there's a higher-level question.  The Newlib math libary is 

> already quite goofy with the variations in error handing, making multiple 

> flavors, etc.  Is it perhaps time to give this strangeness up and just make them 

> so that they are C/POSIX compliant?  This too would achieve the desired goal of 

> getting rid of the wrappers.


I would actually prefer the IEEE behavior as that doesn't return errors
in 'errno'. I was happy to find this mode already available in the
library as it matches what I feel are the right semantics for a deeply
embedded system.

Let me re-spin the patch to use __strong_reference, and to only perform
this operation when that macro is available. That will provide a smaller
implementation of the existing feature where possible and without
introducing a difference in the exported symbols.

-- 
-keith

Patch

diff --git a/newlib/libm/math/e_acos.c b/newlib/libm/math/e_acos.c
index 319b1d56f..e2104a675 100644
--- a/newlib/libm/math/e_acos.c
+++ b/newlib/libm/math/e_acos.c
@@ -59,6 +59,10 @@  qS2 =  2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
 qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
 qS4 =  7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_acos, 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..691f99f64 100644
--- a/newlib/libm/math/e_acosh.c
+++ b/newlib/libm/math/e_acosh.c
@@ -38,6 +38,10 @@  static double
 one	= 1.0,
 ln2	= 6.93147180559945286227e-01;  /* 0x3FE62E42, 0xFEFA39EF */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_acosh, 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..bfd9313cf 100644
--- a/newlib/libm/math/e_asin.c
+++ b/newlib/libm/math/e_asin.c
@@ -68,6 +68,10 @@  qS2 =  2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
 qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
 qS4 =  7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_asin, 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..318760c2f 100644
--- a/newlib/libm/math/e_atan2.c
+++ b/newlib/libm/math/e_atan2.c
@@ -55,6 +55,10 @@  pi_o_2  = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
 pi      = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
 pi_lo   = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_atan2, 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..f5572782e 100644
--- a/newlib/libm/math/e_atanh.c
+++ b/newlib/libm/math/e_atanh.c
@@ -46,6 +46,10 @@  static const double zero = 0.0;
 static double zero = 0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_atanh, 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..493f00bb3 100644
--- a/newlib/libm/math/e_cosh.c
+++ b/newlib/libm/math/e_cosh.c
@@ -42,6 +42,10 @@  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
+__weak_reference(__ieee754_cosh, 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..f96cc7e8b 100644
--- a/newlib/libm/math/e_exp.c
+++ b/newlib/libm/math/e_exp.c
@@ -102,6 +102,10 @@  P4   = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
 P5   =  4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
 
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_exp, 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..9f8e36b5c 100644
--- a/newlib/libm/math/e_fmod.c
+++ b/newlib/libm/math/e_fmod.c
@@ -27,6 +27,10 @@  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
+__weak_reference(__ieee754_fmod, 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..427a6b4ba 100644
--- a/newlib/libm/math/e_hypot.c
+++ b/newlib/libm/math/e_hypot.c
@@ -47,6 +47,10 @@ 
 
 #ifndef _DOUBLE_IS_32BITS
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_hypot, 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..635b5a849 100644
--- a/newlib/libm/math/e_j0.c
+++ b/newlib/libm/math/e_j0.c
@@ -91,6 +91,10 @@  static const double zero = 0.0;
 static double zero = 0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_j0, j0);
+#endif
+
 #ifdef __STDC__
 	double __ieee754_j0(double x) 
 #else
@@ -160,6 +164,10 @@  v02  =  7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */
 v03  =  2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */
 v04  =  4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_y0, 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..11d64e209 100644
--- a/newlib/libm/math/e_j1.c
+++ b/newlib/libm/math/e_j1.c
@@ -92,6 +92,10 @@  static const double zero    = 0.0;
 static double zero    = 0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_j1, j1);
+#endif
+
 #ifdef __STDC__
 	double __ieee754_j1(double x) 
 #else
@@ -161,6 +165,10 @@  static double V0[5] = {
   1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */
 };
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_y1, 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..6fc77898a 100644
--- a/newlib/libm/math/e_jn.c
+++ b/newlib/libm/math/e_jn.c
@@ -56,6 +56,10 @@  static const double zero  =  0.00000000000000000000e+00;
 static double zero  =  0.00000000000000000000e+00;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_jn, jn);
+#endif
+
 #ifdef __STDC__
 	double __ieee754_jn(int n, double x)
 #else
@@ -216,6 +220,10 @@  static double zero  =  0.00000000000000000000e+00;
 	if(sgn==1) return -b; else return b;
 }
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_yn, 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..41263d489 100644
--- a/newlib/libm/math/e_log.c
+++ b/newlib/libm/math/e_log.c
@@ -89,6 +89,10 @@  static const double zero   =  0.0;
 static double zero   =  0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_log, 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..47dfc3b5c 100644
--- a/newlib/libm/math/e_log10.c
+++ b/newlib/libm/math/e_log10.c
@@ -64,6 +64,10 @@  static const double zero   =  0.0;
 static double zero   =  0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_log10, 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..bac60d0e3 100644
--- a/newlib/libm/math/e_pow.c
+++ b/newlib/libm/math/e_pow.c
@@ -99,6 +99,10 @@  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
+__weak_reference(__ieee754_pow, 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..a4362d234 100644
--- a/newlib/libm/math/e_rem_pio2.c
+++ b/newlib/libm/math/e_rem_pio2.c
@@ -82,6 +82,10 @@  pio2_2t =  2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
 pio2_3  =  2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
 pio2_3t =  8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_rem_pio2, 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..1e2dcdae3 100644
--- a/newlib/libm/math/e_remainder.c
+++ b/newlib/libm/math/e_remainder.c
@@ -31,6 +31,10 @@  static double zero = 0.0;
 #endif
 
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_remainder, 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 4d8bb8b71..ac8c45ddf 100644
--- a/newlib/libm/math/e_scalb.c
+++ b/newlib/libm/math/e_scalb.c
@@ -21,6 +21,10 @@ 
 
 #ifndef _DOUBLE_IS_32BITS
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_scalb, scalb);
+#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..bcdb31098 100644
--- a/newlib/libm/math/e_sinh.c
+++ b/newlib/libm/math/e_sinh.c
@@ -39,6 +39,10 @@  static const double one = 1.0, shuge = 1.0e307;
 static double one = 1.0, shuge = 1.0e307;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_sinh, 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..99f842dae 100644
--- a/newlib/libm/math/e_sqrt.c
+++ b/newlib/libm/math/e_sqrt.c
@@ -91,6 +91,10 @@  static	const double	one	= 1.0, tiny=1.0e-300;
 static	double	one	= 1.0, tiny=1.0e-300;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_sqrt, 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..25c5ed4dc 100644
--- a/newlib/libm/math/ef_acos.c
+++ b/newlib/libm/math/ef_acos.c
@@ -35,6 +35,10 @@  qS2 =  2.0209457874e+00, /* 0x4001572d */
 qS3 = -6.8828397989e-01, /* 0xbf303361 */
 qS4 =  7.7038154006e-02; /* 0x3d9dc62e */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_acosf, 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..ad14d4808 100644
--- a/newlib/libm/math/ef_acosh.c
+++ b/newlib/libm/math/ef_acosh.c
@@ -24,6 +24,10 @@  static float
 one	= 1.0,
 ln2	= 6.9314718246e-01;  /* 0x3f317218 */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_acoshf, 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..2d4049220 100644
--- a/newlib/libm/math/ef_asin.c
+++ b/newlib/libm/math/ef_asin.c
@@ -37,6 +37,10 @@  qS2 =  2.0209457874e+00, /* 0x4001572d */
 qS3 = -6.8828397989e-01, /* 0xbf303361 */
 qS4 =  7.7038154006e-02; /* 0x3d9dc62e */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_asinf, 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..eace469fc 100644
--- a/newlib/libm/math/ef_atan2.c
+++ b/newlib/libm/math/ef_atan2.c
@@ -28,6 +28,10 @@  pi_o_2  = 1.5707963705e+00, /* 0x3fc90fdb */
 pi      = 3.1415927410e+00,  /* 0x40490fdb */
 pi_lo   = -8.7422776573e-08; /* 0xb3bbbd2e */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_atan2f, 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..f0c3f3859 100644
--- a/newlib/libm/math/ef_atanh.c
+++ b/newlib/libm/math/ef_atanh.c
@@ -28,6 +28,10 @@  static const float zero = 0.0;
 static float zero = 0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_atanhf, 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..0e8b8a0f4 100644
--- a/newlib/libm/math/ef_cosh.c
+++ b/newlib/libm/math/ef_cosh.c
@@ -25,6 +25,10 @@  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
+__weak_reference(__ieee754_coshf, 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..a5a3ad465 100644
--- a/newlib/libm/math/ef_exp.c
+++ b/newlib/libm/math/ef_exp.c
@@ -40,6 +40,10 @@  P3   =  6.6137559770e-05, /* 0x388ab355 */
 P4   = -1.6533901999e-06, /* 0xb5ddea0e */
 P5   =  4.1381369442e-08; /* 0x3331bb4c */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_expf, 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..338e6b586 100644
--- a/newlib/libm/math/ef_fmod.c
+++ b/newlib/libm/math/ef_fmod.c
@@ -27,6 +27,10 @@  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
+__weak_reference(__ieee754_fmodf, 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..447f97f8f 100644
--- a/newlib/libm/math/ef_hypot.c
+++ b/newlib/libm/math/ef_hypot.c
@@ -15,6 +15,10 @@ 
 
 #include "fdlibm.h"
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_hypotf, 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..d3cf10300 100644
--- a/newlib/libm/math/ef_j0.c
+++ b/newlib/libm/math/ef_j0.c
@@ -46,6 +46,10 @@  static const float zero = 0.0;
 static float zero = 0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_j0f, j0f);
+#endif
+
 #ifdef __STDC__
 	float __ieee754_j0f(float x) 
 #else
@@ -115,6 +119,10 @@  v02  =  7.6006865129e-05, /* 0x389f65e0 */
 v03  =  2.5915085189e-07, /* 0x348b216c */
 v04  =  4.4111031494e-10; /* 0x2ff280c2 */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_y0f, 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..f377e9a8c 100644
--- a/newlib/libm/math/ef_j1.c
+++ b/newlib/libm/math/ef_j1.c
@@ -47,6 +47,10 @@  static const float zero    = 0.0;
 static float zero    = 0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_j1f, j1f);
+#endif
+
 #ifdef __STDC__
 	float __ieee754_j1f(float x) 
 #else
@@ -116,6 +120,10 @@  static float V0[5] = {
   1.6655924903e-11, /* 0x2d9281cf */
 };
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_y1f, 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..8e4710b53 100644
--- a/newlib/libm/math/ef_jn.c
+++ b/newlib/libm/math/ef_jn.c
@@ -29,6 +29,10 @@  static const float zero  =  0.0000000000e+00;
 static float zero  =  0.0000000000e+00;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_jnf, jnf);
+#endif
+
 #ifdef __STDC__
 	float __ieee754_jnf(int n, float x)
 #else
@@ -166,6 +170,10 @@  static float zero  =  0.0000000000e+00;
 	if(sgn==1) return -b; else return b;
 }
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_ynf, 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..25c41299b 100644
--- a/newlib/libm/math/ef_log.c
+++ b/newlib/libm/math/ef_log.c
@@ -38,6 +38,10 @@  static const float zero   =  0.0;
 static float zero   =  0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_logf, 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..dfacac35f 100644
--- a/newlib/libm/math/ef_log10.c
+++ b/newlib/libm/math/ef_log10.c
@@ -31,6 +31,10 @@  static const float zero   =  0.0;
 static float zero   =  0.0;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_log10f, 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..6c3fab53e 100644
--- a/newlib/libm/math/ef_pow.c
+++ b/newlib/libm/math/ef_pow.c
@@ -57,6 +57,10 @@  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
+__weak_reference(__ieee754_powf, 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..051d43143 100644
--- a/newlib/libm/math/ef_rem_pio2.c
+++ b/newlib/libm/math/ef_rem_pio2.c
@@ -95,6 +95,10 @@  pio2_2t =  6.0770999344e-11, /* 0x2e85a308 */
 pio2_3  =  6.0770943833e-11, /* 0x2e85a300 */
 pio2_3t =  6.1232342629e-17; /* 0x248d3132 */
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_rem_pio2f, 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..17ee05283 100644
--- a/newlib/libm/math/ef_remainder.c
+++ b/newlib/libm/math/ef_remainder.c
@@ -22,6 +22,10 @@  static float zero = 0.0;
 #endif
 
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_remainderf, 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..ac524f676 100644
--- a/newlib/libm/math/ef_scalb.c
+++ b/newlib/libm/math/ef_scalb.c
@@ -16,6 +16,10 @@ 
 #include "fdlibm.h"
 #include <limits.h>
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_scalbf, scalbf);
+#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..b166f0f02 100644
--- a/newlib/libm/math/ef_sinh.c
+++ b/newlib/libm/math/ef_sinh.c
@@ -15,6 +15,10 @@ 
 
 #include "fdlibm.h"
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_sinhf, sinhf);
+#endif
+
 #ifdef __STDC__
 static const float one = 1.0, shuge = 1.0e37;
 #else
diff --git a/newlib/libm/math/ef_sqrt.c b/newlib/libm/math/ef_sqrt.c
index 80e7f360e..f68f893ab 100644
--- a/newlib/libm/math/ef_sqrt.c
+++ b/newlib/libm/math/ef_sqrt.c
@@ -21,6 +21,10 @@  static	const float	one	= 1.0, tiny=1.0e-30;
 static	float	one	= 1.0, tiny=1.0e-30;
 #endif
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_sqrtf, sqrtf);
+#endif
+
 #ifdef __STDC__
 	float __ieee754_sqrtf(float x)
 #else
diff --git a/newlib/libm/math/el_hypot.c b/newlib/libm/math/el_hypot.c
index 737cde36b..e5cbe7b23 100644
--- a/newlib/libm/math/el_hypot.c
+++ b/newlib/libm/math/el_hypot.c
@@ -6,6 +6,10 @@ 
 
 #include "fdlibm.h"
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_hypotl, hypotl);
+#endif
+
 long double
 __ieee754_hypotl (long double x, long double y)
 {
diff --git a/newlib/libm/math/er_gamma.c b/newlib/libm/math/er_gamma.c
index 3c0e241e5..6f42c9243 100644
--- a/newlib/libm/math/er_gamma.c
+++ b/newlib/libm/math/er_gamma.c
@@ -21,6 +21,10 @@ 
 
 #include "fdlibm.h"
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_gamma_r, 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..6144a169b 100644
--- a/newlib/libm/math/er_lgamma.c
+++ b/newlib/libm/math/er_lgamma.c
@@ -209,6 +209,10 @@  static double zero=  0.00000000000000000000e+00;
 }
 
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_lgamma_r, 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..f310675cb 100644
--- a/newlib/libm/math/erf_gamma.c
+++ b/newlib/libm/math/erf_gamma.c
@@ -23,6 +23,10 @@ 
 
 #include "fdlibm.h"
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_gammaf_r, 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..eb6e6c662 100644
--- a/newlib/libm/math/erf_lgamma.c
+++ b/newlib/libm/math/erf_lgamma.c
@@ -144,6 +144,10 @@  static float zero=  0.0000000000e+00;
 }
 
 
+#ifdef _IEEE_LIBM
+__weak_reference(__ieee754_lgammaf_r, 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..6a2d99943 100644
--- a/newlib/libm/math/wf_log10.c
+++ b/newlib/libm/math/wf_log10.c
@@ -20,6 +20,7 @@ 
 #include "fdlibm.h"
 #include <errno.h>
 
+#ifndef _IEEE_LIBM
 #ifdef __STDC__
 	float log10f(float x)		/* wrapper log10f */
 #else
@@ -27,9 +28,6 @@ 
 	float x;
 #endif
 {
-#ifdef _IEEE_LIBM
-	return __ieee754_log10f(x);
-#else
 	float z;
 	struct exception exc;
 	z = __ieee754_log10f(x);
@@ -71,8 +69,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