fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / math / wf_hypot.c
blobc04ace1102c17a8016bad6984a4ce4a7fd328400
1 /* wf_hypot.c -- float version of w_hypot.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 * ====================================================
17 * wrapper hypotf(x,y)
20 #include "fdlibm.h"
21 #include <errno.h>
23 #ifdef __STDC__
24 float hypotf(float x, float y) /* wrapper hypotf */
25 #else
26 float hypotf(x,y) /* wrapper hypotf */
27 float x,y;
28 #endif
30 #ifdef _IEEE_LIBM
31 return __ieee754_hypotf(x,y);
32 #else
33 float z;
34 struct exception exc;
35 z = __ieee754_hypotf(x,y);
36 if(_LIB_VERSION == _IEEE_) return z;
37 if((!finitef(z))&&finitef(x)&&finitef(y)) {
38 /* hypotf(finite,finite) overflow */
39 #ifndef HUGE_VAL
40 #define HUGE_VAL inf
41 double inf = 0.0;
43 SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
44 #endif
45 exc.type = OVERFLOW;
46 exc.name = "hypotf";
47 exc.err = 0;
48 exc.arg1 = (double)x;
49 exc.arg2 = (double)y;
50 if (_LIB_VERSION == _SVID_)
51 exc.retval = HUGE;
52 else
53 exc.retval = HUGE_VAL;
54 if (_LIB_VERSION == _POSIX_)
55 errno = ERANGE;
56 else if (!matherr(&exc)) {
57 errno = ERANGE;
59 if (exc.err != 0)
60 errno = exc.err;
61 return (float)exc.retval;
62 } else
63 return z;
64 #endif
67 #ifdef _DOUBLE_IS_32BITS
69 #ifdef __STDC__
70 double hypot(double x, double y)
71 #else
72 double hypot(x,y)
73 double x,y;
74 #endif
76 return (double) hypotf((float) x, (float) y);
79 #endif /* defined(_DOUBLE_IS_32BITS) */