fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / math / wf_sqrt.c
blob6e792c923dd2939fd8d58b7792e312ad1c5b7bc4
1 /* wf_sqrt.c -- float version of w_sqrt.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 sqrtf(x)
20 #include "fdlibm.h"
21 #include <errno.h>
23 #ifdef __STDC__
24 float sqrtf(float x) /* wrapper sqrtf */
25 #else
26 float sqrtf(x) /* wrapper sqrtf */
27 float x;
28 #endif
30 #ifdef _IEEE_LIBM
31 return __ieee754_sqrtf(x);
32 #else
33 float z;
34 struct exception exc;
35 z = __ieee754_sqrtf(x);
36 if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z;
37 if(x<(float)0.0) {
38 /* sqrtf(negative) */
39 exc.type = DOMAIN;
40 exc.name = "sqrtf";
41 exc.err = 0;
42 exc.arg1 = exc.arg2 = (double)x;
43 if (_LIB_VERSION == _SVID_)
44 exc.retval = 0.0;
45 else
46 exc.retval = 0.0/0.0;
47 if (_LIB_VERSION == _POSIX_)
48 errno = EDOM;
49 else if (!matherr(&exc)) {
50 errno = EDOM;
52 if (exc.err != 0)
53 errno = exc.err;
54 return (float)exc.retval;
55 } else
56 return z;
57 #endif
60 #ifdef _DOUBLE_IS_32BITS
62 #ifdef __STDC__
63 double sqrt(double x)
64 #else
65 double sqrt(x)
66 double x;
67 #endif
69 return (double) sqrtf((float) x);
72 #endif /* defined(_DOUBLE_IS_32BITS) */