remove another invalid skip of locking in ungetwc
[oweals/musl.git] / src / math / nearbyintl.c
index b58527c8db02ce54c8a4002b4ad40a4b0dbfc9e8..82852492f8108b875fa6c588af96aecf358475b9 100644 (file)
@@ -1,4 +1,6 @@
-#include "libm.h"
+#include <math.h>
+#include <float.h>
+
 #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
 long double nearbyintl(long double x)
 {
@@ -8,11 +10,17 @@ long double nearbyintl(long double x)
 #include <fenv.h>
 long double nearbyintl(long double x)
 {
-       fenv_t e;
+#ifdef FE_INEXACT
+       #pragma STDC FENV_ACCESS ON
+       int e;
 
-       fegetenv(&e);
+       e = fetestexcept(FE_INEXACT);
+#endif
        x = rintl(x);
-       fesetenv(&e);
+#ifdef FE_INEXACT
+       if (!e)
+               feclearexcept(FE_INEXACT);
+#endif
        return x;
 }
 #endif