]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/ieee754/ldbl-128ibm/s_logbl.c
Fix ldbl-128ibm "set but not used" warnings.
[thirdparty/glibc.git] / sysdeps / ieee754 / ldbl-128ibm / s_logbl.c
1 /* s_logbl.c -- long double version of s_logb.c.
2 * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz.
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
16 /*
17 * long double logbl(x)
18 * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
19 * Use ilogb instead.
20 */
21
22 #include <math.h>
23 #include <math_private.h>
24 #include <math_ldbl_opt.h>
25
26 long double
27 __logbl (long double x)
28 {
29 int64_t hx, rhx;
30 int64_t lx __attribute__ ((unused));
31
32 GET_LDOUBLE_WORDS64 (hx, lx, x);
33 hx &= 0x7fffffffffffffffLL; /* high |x| */
34 if (hx == 0)
35 return -1.0 / fabs (x);
36 if (hx >= 0x7ff0000000000000LL)
37 return x * x;
38 if (__builtin_expect ((rhx = hx >> 52) == 0, 0))
39 {
40 /* POSIX specifies that denormal number is treated as
41 though it were normalized. */
42 rhx -= __builtin_clzll (hx) - 12;
43 }
44 return (long double) (rhx - 1023);
45 }
46
47 long_double_symbol (libm, __logbl, logbl);