summaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/ldbl-128ibm/s_rintl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/ldbl-128ibm/s_rintl.c')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_rintl.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_rintl.c b/sysdeps/ieee754/ldbl-128ibm/s_rintl.c
index 8c51ded1d6..f003609d95 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_rintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_rintl.c
@@ -1,6 +1,6 @@
/* Round to int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2016 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,10 +22,17 @@
#include <math.h>
#include <fenv.h>
+#include <math-barriers.h>
+#include <math_private.h>
#include <math_ldbl_opt.h>
#include <float.h>
#include <ieee754.h>
+#ifdef USE_AS_NEARBYINTL
+# define rintl nearbyintl
+# define __rintl __nearbyintl
+#endif
+
long double
__rintl (long double x)
@@ -44,7 +51,11 @@ __rintl (long double x)
/* Long double arithmetic, including the canonicalisation below,
only works in round-to-nearest mode. */
+#ifdef USE_AS_NEARBYINTL
+ SET_RESTORE_ROUND_NOEX (FE_TONEAREST);
+#else
fesetround (FE_TONEAREST);
+#endif
/* Convert the high double to integer. */
orig_xh = xh;
@@ -103,8 +114,16 @@ __rintl (long double x)
if (orig_xh < 0.0)
xh = -__builtin_fabs (xh);
+#ifdef USE_AS_NEARBYINTL
+ math_force_eval (xh);
+ math_force_eval (xl);
+#else
fesetround (save_round);
+#endif
}
+ else
+ /* Quiet signaling NaN arguments. */
+ xh += xh;
return ldbl_pack (xh, xl);
}