add PTHREAD_NULL
[musl.git] / src / math / lrintl.c
blobb2a8106d7c6a1710eea10791fdf72d88df541d95
1 #include <limits.h>
2 #include <fenv.h>
3 #include "libm.h"
6 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
7 long lrintl(long double x)
9 return lrint(x);
11 #elif defined(FE_INEXACT)
13 see comments in lrint.c
15 Note that if LONG_MAX == 0x7fffffffffffffff && LDBL_MANT_DIG == 64
16 then x == 2**63 - 0.5 is the only input that overflows and
17 raises inexact (with tonearest or upward rounding mode)
19 long lrintl(long double x)
21 #pragma STDC FENV_ACCESS ON
22 int e;
24 e = fetestexcept(FE_INEXACT);
25 x = rintl(x);
26 if (!e && (x > LONG_MAX || x < LONG_MIN))
27 feclearexcept(FE_INEXACT);
28 /* conversion */
29 return x;
31 #else
32 long lrintl(long double x)
34 return rintl(x);
36 #endif