[Piglit] [PATCH 4/9] util: Don't redefine math.h functions on MSVC 2013.

jfonseca at vmware.com jfonseca at vmware.com
Tue Apr 29 10:57:49 PDT 2014


From: José Fonseca <jfonseca at vmware.com>

MSVC 2013 provides all math.h functions that were missing in previous
versions.
---
 tests/texturing/shaders/common.c |  7 -------
 tests/util/piglit-util.h         | 18 ++++++++++++++----
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tests/texturing/shaders/common.c b/tests/texturing/shaders/common.c
index ac85e7a..b377bbc 100644
--- a/tests/texturing/shaders/common.c
+++ b/tests/texturing/shaders/common.c
@@ -122,13 +122,6 @@ static float max3(float x, float y, float z)
 	return max2(x, max2(y, z));
 }
 
-#if defined(_MSC_VER)
-static float log2f(float x)
-{
-	return logf(x) * 1.442695041f;
-}
-#endif
-
 /**
  * Compute the number of miplevels, as well as the dimensions (width, height,
  * depth/number of array slices) of each level.
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 760cdca..86b5c18 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -35,10 +35,6 @@ extern "C" {
 #include <windows.h>
 #endif
 
-#if defined(_MSC_VER)
-#define log2(x) (log(x) / log(2))
-#endif
-
 #include <assert.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -59,6 +55,18 @@ extern "C" {
 
 #define snprintf sprintf_s
 
+#if _MSC_VER < 1800
+
+static __inline double
+log2(double x) {
+	return log(x) * M_LOG2E;
+}
+
+static __inline float
+log2f(float x) {
+	return (float) log2(x);
+}
+
 static __inline double
 round(double x) {
 	return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5);
@@ -74,6 +82,8 @@ lround(double x) {
 	return (long)round(x);
 }
 
+#endif /* _MSC_VER < 1800 */
+
 #ifndef va_copy
 #ifdef __va_copy
 #define va_copy(dest, src) __va_copy((dest), (src))
-- 
1.9.1



More information about the Piglit mailing list