about summary refs log tree commit diff
diff options
context:
space:
mode:
authornsz <nsz@port70.net>2012-03-18 20:40:43 +0100
committernsz <nsz@port70.net>2012-03-18 20:40:43 +0100
commit65db00983f3fa5449f20f2694477f9d5116f6ea5 (patch)
treeb71e3a7354cc64caff3ac8707c278df512cfeb36
parent9b6899f2c5cec70af6cea80ead7ba98fd2366ce9 (diff)
downloadmusl-65db00983f3fa5449f20f2694477f9d5116f6ea5.tar.gz
musl-65db00983f3fa5449f20f2694477f9d5116f6ea5.tar.xz
musl-65db00983f3fa5449f20f2694477f9d5116f6ea5.zip
make lrint and llrint functions work without fenv support
-rw-r--r--src/math/llrint.c2
-rw-r--r--src/math/llrintf.c2
-rw-r--r--src/math/llrintl.c7
-rw-r--r--src/math/lrint.c2
-rw-r--r--src/math/lrintf.c2
-rw-r--r--src/math/lrintl.c7
6 files changed, 16 insertions, 6 deletions
diff --git a/src/math/llrint.c b/src/math/llrint.c
index ee783b8e..4f583ae5 100644
--- a/src/math/llrint.c
+++ b/src/math/llrint.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-/* assumes LLONG_MAX > 2^53, see comments in lrint.c */
+/* uses LLONG_MAX > 2^53, see comments in lrint.c */
 
 long long llrint(double x)
 {
diff --git a/src/math/llrintf.c b/src/math/llrintf.c
index e41b6d41..96949a00 100644
--- a/src/math/llrintf.c
+++ b/src/math/llrintf.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-/* assumes LLONG_MAX > 2^24, see comments in lrint.c */
+/* uses LLONG_MAX > 2^24, see comments in lrint.c */
 
 long long llrintf(float x)
 {
diff --git a/src/math/llrintl.c b/src/math/llrintl.c
index f1cc47ed..32bb8b03 100644
--- a/src/math/llrintl.c
+++ b/src/math/llrintl.c
@@ -8,7 +8,7 @@ long long llrintl(long double x)
 {
 	return llrint(x);
 }
-#else
+#elif defined(FE_INEXACT)
 /*
 see comments in lrint.c
 
@@ -27,4 +27,9 @@ long long llrintl(long double x)
 	/* conversion */
 	return x;
 }
+#else
+long long llrintl(long double x)
+{
+	return rintl(x);
+}
 #endif
diff --git a/src/math/lrint.c b/src/math/lrint.c
index feba28d0..67091835 100644
--- a/src/math/lrint.c
+++ b/src/math/lrint.c
@@ -25,7 +25,7 @@ otherwise LONG_MAX and LONG_MIN can be represented exactly
 as a double.
 */
 
-#if LONG_MAX < 1U<<53
+#if LONG_MAX < 1U<<53 && defined(FE_INEXACT)
 long lrint(double x)
 {
 	int e;
diff --git a/src/math/lrintf.c b/src/math/lrintf.c
index 34d1081c..ca0b6a46 100644
--- a/src/math/lrintf.c
+++ b/src/math/lrintf.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-/* assumes LONG_MAX > 2^24, see comments in lrint.c */
+/* uses LONG_MAX > 2^24, see comments in lrint.c */
 
 long lrintf(float x)
 {
diff --git a/src/math/lrintl.c b/src/math/lrintl.c
index 0e579bc5..5eb1ba7e 100644
--- a/src/math/lrintl.c
+++ b/src/math/lrintl.c
@@ -8,7 +8,7 @@ long lrintl(long double x)
 {
 	return lrint(x);
 }
-#else
+#elif defined(FE_INEXACT)
 /*
 see comments in lrint.c
 
@@ -27,4 +27,9 @@ long lrintl(long double x)
 	/* conversion */
 	return x;
 }
+#else
+long lrintl(long double x)
+{
+	return rintl(x);
+}
 #endif