1 #include <math.h>
2 #include <errno.h>
3 #include <limits.h>
4 #include <math_private.h>
5 #include <fenv.h>
6 
7 #if _GL_HAS_BUILTIN_ILOGB
8 long int
M_DECL_FUNC(__llogb)9 M_DECL_FUNC (__llogb) (FLOAT x)
10 {
11   int r;
12   /* Check for exceptional cases.  */
13   if (! M_SUF(__builtin_test_dc_ilogb) (x, 0x7f))
14     r = M_SUF (__builtin_ilogb) (x);
15   else
16     /* Fallback to the generic ilogb if x is NaN, Inf or subnormal.  */
17     r = M_SUF (__ieee754_ilogb) (x);
18   long int lr = r;
19   if (__glibc_unlikely (r == FP_ILOGB0)
20       || __glibc_unlikely (r == FP_ILOGBNAN)
21       || __glibc_unlikely (r == INT_MAX))
22     {
23 #if LONG_MAX != INT_MAX
24       if (r == FP_ILOGB0)
25 	lr = FP_LLOGB0;
26       else if (r == FP_ILOGBNAN)
27 	lr = FP_LLOGBNAN;
28       else
29 	lr = LONG_MAX;
30 #endif
31       __set_errno (EDOM);
32       __feraiseexcept (FE_INVALID);
33     }
34   return lr;
35 }
36 declare_mgen_alias (__llogb, llogb)
37 #else
38 #include <math/w_llogb_template.c>
39 #endif
40