rtld: increase TLS storage space (bug 2566)
[dragonfly.git] / lib / libm / src / e_hypotf.c
1 /* e_hypotf.c -- float version of e_hypot.c.
2  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3  */
4
5 /*
6  * ====================================================
7  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8  *
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  * ====================================================
14  *
15  * $FreeBSD: head/lib/msun/src/e_hypotf.c 226380 2011-10-15 07:00:28Z das $
16  */
17
18 #include "math.h"
19 #include "math_private.h"
20
21 float
22 __ieee754_hypotf(float x, float y)
23 {
24         float a,b,t1,t2,y1,y2,w;
25         int32_t j,k,ha,hb;
26
27         GET_FLOAT_WORD(ha,x);
28         ha &= 0x7fffffff;
29         GET_FLOAT_WORD(hb,y);
30         hb &= 0x7fffffff;
31         if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;}
32         a = fabsf(a);
33         b = fabsf(b);
34         if((ha-hb)>0xf000000) {return a+b;} /* x/y > 2**30 */
35         k=0;
36         if(ha > 0x58800000) {   /* a>2**50 */
37            if(ha >= 0x7f800000) {       /* Inf or NaN */
38                /* Use original arg order iff result is NaN; quieten sNaNs. */
39                w = fabsf(x+0.0F)-fabsf(y+0.0F);
40                if(ha == 0x7f800000) w = a;
41                if(hb == 0x7f800000) w = b;
42                return w;
43            }
44            /* scale a and b by 2**-68 */
45            ha -= 0x22000000; hb -= 0x22000000;  k += 68;
46            SET_FLOAT_WORD(a,ha);
47            SET_FLOAT_WORD(b,hb);
48         }
49         if(hb < 0x26800000) {   /* b < 2**-50 */
50             if(hb <= 0x007fffff) {      /* subnormal b or 0 */
51                 if(hb==0) return a;
52                 SET_FLOAT_WORD(t1,0x7e800000);  /* t1=2^126 */
53                 b *= t1;
54                 a *= t1;
55                 k -= 126;
56             } else {            /* scale a and b by 2^68 */
57                 ha += 0x22000000;       /* a *= 2^68 */
58                 hb += 0x22000000;       /* b *= 2^68 */
59                 k -= 68;
60                 SET_FLOAT_WORD(a,ha);
61                 SET_FLOAT_WORD(b,hb);
62             }
63         }
64     /* medium size a and b */
65         w = a-b;
66         if (w>b) {
67             SET_FLOAT_WORD(t1,ha&0xfffff000);
68             t2 = a-t1;
69             w  = __ieee754_sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
70         } else {
71             a  = a+a;
72             SET_FLOAT_WORD(y1,hb&0xfffff000);
73             y2 = b - y1;
74             SET_FLOAT_WORD(t1,(ha+0x00800000)&0xfffff000);
75             t2 = a - t1;
76             w  = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
77         }
78         if(k!=0) {
79             SET_FLOAT_WORD(t1,0x3f800000+(k<<23));
80             return t1*w;
81         } else return w;
82 }