first commit of the new libm!
[musl] / src / math / nearbyintl.c
diff --git a/src/math/nearbyintl.c b/src/math/nearbyintl.c
new file mode 100644 (file)
index 0000000..b58527c
--- /dev/null
@@ -0,0 +1,18 @@
+#include "libm.h"
+#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
+long double nearbyintl(long double x)
+{
+       return nearbyint(x);
+}
+#else
+#include <fenv.h>
+long double nearbyintl(long double x)
+{
+       fenv_t e;
+
+       fegetenv(&e);
+       x = rintl(x);
+       fesetenv(&e);
+       return x;
+}
+#endif