about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c')
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
index 88a1f3a928..5284c4da09 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
@@ -22,6 +22,7 @@
 
 #include <math_private.h>
 #include <libm-alias-double.h>
+#include <fix-fp-int-convert-overflow.h>
 
 /* For LP64, lround is an alias for llround.  */
 #ifndef _LP64
@@ -66,7 +67,17 @@ __lround (double x)
 	 FE_INVALID must be raised and the return value is
 	 unspecified.  */
 #ifdef FE_INVALID
-      if (sizeof (long int) == 4
+      if (FIX_DBL_LONG_CONVERT_OVERFLOW
+	  && !(sign == -1
+	       && (sizeof (long int) == 4
+		   ? x > (double) LONG_MIN - 0.5
+		   : x >= (double) LONG_MIN)))
+	{
+	  feraiseexcept (FE_INVALID);
+	  return sign == 1 ? LONG_MAX : LONG_MIN;
+	}
+      else if (!FIX_DBL_LONG_CONVERT_OVERFLOW
+	  && sizeof (long int) == 4
 	  && x <= (double) LONG_MIN - 0.5)
 	{
 	  /* If truncation produces LONG_MIN, the cast will not raise