fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / math / wf_log10.c
blob15fa5d939b578a70b7f570d5bcc78ec5a150efa3
1 /* wf_log10.c -- float version of w_log10.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
12 * is preserved.
13 * ====================================================
16 /*
17 * wrapper log10f(X)
20 #include "fdlibm.h"
21 #include <errno.h>
23 #ifdef __STDC__
24 float log10f(float x) /* wrapper log10f */
25 #else
26 float log10f(x) /* wrapper log10f */
27 float x;
28 #endif
30 #ifdef _IEEE_LIBM
31 return __ieee754_log10f(x);
32 #else
33 float z;
34 struct exception exc;
35 z = __ieee754_log10f(x);
36 if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z;
37 if(x<=(float)0.0) {
38 #ifndef HUGE_VAL
39 #define HUGE_VAL inf
40 double inf = 0.0;
42 SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
43 #endif
44 exc.name = "log10f";
45 exc.err = 0;
46 exc.arg1 = exc.arg2 = (double)x;
47 if (_LIB_VERSION == _SVID_)
48 exc.retval = -HUGE;
49 else
50 exc.retval = -HUGE_VAL;
51 if(x==(float)0.0) {
52 /* log10f(0) */
53 exc.type = SING;
54 if (_LIB_VERSION == _POSIX_)
55 errno = ERANGE;
56 else if (!matherr(&exc)) {
57 errno = EDOM;
59 } else {
60 /* log10f(x<0) */
61 exc.type = DOMAIN;
62 if (_LIB_VERSION == _POSIX_)
63 errno = EDOM;
64 else if (!matherr(&exc)) {
65 errno = EDOM;
68 if (exc.err != 0)
69 errno = exc.err;
70 return (float)exc.retval;
71 } else
72 return z;
73 #endif
76 #ifdef _DOUBLE_IS_32BITS
78 #ifdef __STDC__
79 double log10(double x)
80 #else
81 double log10(x)
82 double x;
83 #endif
85 return (double) log10f((float) x);
88 #endif /* defined(_DOUBLE_IS_32BITS) */