rtld: increase TLS storage space (bug 2566)
[dragonfly.git] / lib / libm / src / s_logb.c
1 /* @(#)s_logb.c 5.1 93/09/24 */
2 /* $FreeBSD: head/lib/msun/src/s_logb.c 176101 2008-02-08 01:22:13Z bde $ */
3 /*
4  * ====================================================
5  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6  *
7  * Developed at SunPro, a Sun Microsystems, Inc. business.
8  * Permission to use, copy, modify, and distribute this
9  * software is freely granted, provided that this notice
10  * is preserved.
11  * ====================================================
12  */
13
14 /*
15  * double logb(x)
16  * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
17  * Use ilogb instead.
18  */
19
20 #include <float.h>
21
22 #include "math.h"
23 #include "math_private.h"
24
25 static const double
26 two54 = 1.80143985094819840000e+16;     /* 43500000 00000000 */
27
28 double
29 logb(double x)
30 {
31         int32_t lx,ix;
32         EXTRACT_WORDS(ix,lx,x);
33         ix &= 0x7fffffff;                       /* high |x| */
34         if((ix|lx)==0) return -1.0/fabs(x);
35         if(ix>=0x7ff00000) return x*x;
36         if(ix<0x00100000) {
37                 x *= two54;              /* convert subnormal x to normal */
38                 GET_HIGH_WORD(ix,x);
39                 ix &= 0x7fffffff;
40                 return (double) ((ix>>20)-1023-54);
41         } else
42                 return (double) ((ix>>20)-1023);
43 }
44
45 #if (LDBL_MANT_DIG == 53)
46 __weak_reference(logb, logbl);
47 #endif