1/* s_logbl.c -- long double version of s_logb.c.
2 */
3
4/*
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 *
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
11 * is preserved.
12 * ====================================================
13 */
14
15#if defined(LIBM_SCCS) && !defined(lint)
16static char rcsid[] = "$NetBSD: $";
17#endif
18
19/*
20 * long double logbl(x)
21 * IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
22 * Use ilogb instead.
23 */
24
25#include <math.h>
26#include <math_private.h>
27#include <libm-alias-ldouble.h>
28#include <math-use-builtins.h>
29
30_Float128
31__logbl (_Float128 x)
32{
33#if USE_LOGBL_BUILTIN
34 return __builtin_logbl (x);
35#else
36 /* Use generic implementation. */
37 int64_t lx, hx, ex;
38
39 GET_LDOUBLE_WORDS64 (hx, lx, x);
40 hx &= 0x7fffffffffffffffLL; /* high |x| */
41 if ((hx | lx) == 0)
42 return -1.0 / fabsl (x);
43 if (hx >= 0x7fff000000000000LL)
44 return x * x;
45 if ((ex = hx >> 48) == 0) /* IEEE 754 logb */
46 {
47 /* POSIX specifies that denormal number is treated as
48 though it were normalized. */
49 int ma;
50 if (hx == 0)
51 ma = __builtin_clzll (lx) + 64;
52 else
53 ma = __builtin_clzll (hx);
54 ex -= ma - 16;
55 }
56 return (_Float128) (ex - 16383);
57#endif /* ! USE_LOGBL_BUILTIN */
58}
59
60libm_alias_ldouble (__logb, logb)
61

source code of glibc/sysdeps/ieee754/ldbl-128/s_logbl.c