about summary refs log tree commit diff
path: root/sysdeps/powerpc/powerpc64/le/fpu/w_llogb_template.c
blob: d00b71d2a34e28da2742a2788c49f4b442c472ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <math.h>
#include <errno.h>
#include <limits.h>
#include <math_private.h>
#include <fenv.h>

#if _GL_HAS_BUILTIN_ILOGB
long int
M_DECL_FUNC (__llogb) (FLOAT x)
{
  int r;
  /* Check for exceptional cases.  */
  if (! M_SUF(__builtin_test_dc_ilogb) (x, 0x7f))
    r = M_SUF (__builtin_ilogb) (x);
  else
    /* Fallback to the generic ilogb if x is NaN, Inf or subnormal.  */
    r = M_SUF (__ieee754_ilogb) (x);
  long int lr = r;
  if (__glibc_unlikely (r == FP_ILOGB0)
      || __glibc_unlikely (r == FP_ILOGBNAN)
      || __glibc_unlikely (r == INT_MAX))
    {
#if LONG_MAX != INT_MAX
      if (r == FP_ILOGB0)
	lr = FP_LLOGB0;
      else if (r == FP_ILOGBNAN)
	lr = FP_LLOGBNAN;
      else
	lr = LONG_MAX;
#endif
      __set_errno (EDOM);
      __feraiseexcept (FE_INVALID);
    }
  return lr;
}
declare_mgen_alias (__llogb, llogb)
#else
#include <math/w_llogb_template.c>
#endif