math: tgammal.c fixes
[oweals/musl.git] / src / math / nearbyintf.c
index e4bdb26c5c9be6aa5754944be2ec5546f9c4070d..092e9ffae56e96b7d24003ea9d34adb9b4ea6e0d 100644 (file)
@@ -1,11 +1,18 @@
 #include <fenv.h>
-#include "libm.h"
+#include <math.h>
 
-float nearbyintf(float x) {
-       fenv_t e;
+float nearbyintf(float x)
+{
+#ifdef FE_INEXACT
+       #pragma STDC FENV_ACCESS ON
+       int e;
 
-       fegetenv(&e);
+       e = fetestexcept(FE_INEXACT);
+#endif
        x = rintf(x);
-       fesetenv(&e);
+#ifdef FE_INEXACT
+       if (!e)
+               feclearexcept(FE_INEXACT);
+#endif
        return x;
 }