]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/ieee754/flt-32/s_llroundf.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / ieee754 / flt-32 / s_llroundf.c
index 36c66dc76ab37879f053a20f9dbf68ead6b0021f..bb6507bc837f7b5d5001a9069adc6f9527c311a1 100644 (file)
@@ -1,5 +1,5 @@
 /* Round float value to long long int.
-   Copyright (C) 1997-2014 Free Software Foundation, Inc.
+   Copyright (C) 1997-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
+#include <fenv.h>
+#include <limits.h>
 #include <math.h>
 
 #include <math_private.h>
+#include <libm-alias-float.h>
+#include <fix-fp-int-convert-overflow.h>
 
 
 long long int
 __llroundf (float x)
 {
   int32_t j0;
-  u_int32_t i;
+  uint32_t i;
   long long int result;
   int sign;
 
@@ -51,12 +55,20 @@ __llroundf (float x)
     }
   else
     {
-      /* The number is too large.  It is left implementation defined
-        what happens.  */
+#ifdef FE_INVALID
+      /* The number is too large.  Unless it rounds to LLONG_MIN,
+        FE_INVALID must be raised and the return value is
+        unspecified.  */
+      if (FIX_FLT_LLONG_CONVERT_OVERFLOW && x != (float) LLONG_MIN)
+       {
+         feraiseexcept (FE_INVALID);
+         return sign == 1 ? LLONG_MAX : LLONG_MIN;
+       }
+#endif
       return (long long int) x;
     }
 
   return sign * result;
 }
 
-weak_alias (__llroundf, llroundf)
+libm_alias_float (__llround, llround)