about summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-128/s_llroundl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/ldbl-128/s_llroundl.c')
-rw-r--r--sysdeps/ieee754/ldbl-128/s_llroundl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sysdeps/ieee754/ldbl-128/s_llroundl.c b/sysdeps/ieee754/ldbl-128/s_llroundl.c
index e5dd145333..bfc81cc534 100644
--- a/sysdeps/ieee754/ldbl-128/s_llroundl.c
+++ b/sysdeps/ieee754/ldbl-128/s_llroundl.c
@@ -23,7 +23,7 @@
 #include <math.h>
 
 #include <math_private.h>
-
+#include <fix-fp-int-convert-overflow.h>
 
 long long int
 __llroundl (long double x)
@@ -78,7 +78,14 @@ __llroundl (long double x)
 	 FE_INVALID must be raised and the return value is
 	 unspecified.  */
 #ifdef FE_INVALID
-      if (x <= (long double) LLONG_MIN - 0.5L)
+      if (FIX_LDBL_LLONG_CONVERT_OVERFLOW
+	  && !(sign == -1 && x > (long double) LLONG_MIN - 0.5L))
+	{
+	  feraiseexcept (FE_INVALID);
+	  return sign == 1 ? LLONG_MAX : LLONG_MIN;
+	}
+      else if (!FIX_LDBL_LLONG_CONVERT_OVERFLOW
+	       && x <= (long double) LLONG_MIN - 0.5L)
 	{
 	  /* If truncation produces LLONG_MIN, the cast will not raise
 	     the exception, but may raise "inexact".  */