[Piglit] [PATCH 2/7] tests/util: Centralize MSVC max/min macros workarounds.

jfonseca at vmware.com jfonseca at vmware.com
Fri Nov 7 06:21:25 PST 2014


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

undefining max/min seems unavoidable, but at least it can be done in a
single place.
---
 tests/spec/glsl-1.30/execution/fs-texelFetch-2D.c       | 3 ---
 tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c | 3 ---
 tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c    | 3 ---
 tests/util/piglit-util.h                                | 5 +++++
 4 files changed, 5 insertions(+), 9 deletions(-)
 mode change 100644 => 100755 tests/util/piglit-util.h

diff --git a/tests/spec/glsl-1.30/execution/fs-texelFetch-2D.c b/tests/spec/glsl-1.30/execution/fs-texelFetch-2D.c
index 66aee58..86edff7 100644
--- a/tests/spec/glsl-1.30/execution/fs-texelFetch-2D.c
+++ b/tests/spec/glsl-1.30/execution/fs-texelFetch-2D.c
@@ -63,9 +63,6 @@ static const char frag[] =
 "	gl_FragColor = texel;\n"
 "}\n";
 
-#ifdef _MSC_VER
-#undef max
-#endif
 static float max(float x, float y) { return (x > y) ? x : y; }
 
 enum piglit_result
diff --git a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
index f461d58..dfbadc7 100644
--- a/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
+++ b/tests/spec/glsl-1.30/execution/fs-texelFetchOffset-2D.c
@@ -61,9 +61,6 @@ static const char frag[] =
 "	gl_FragColor = texel;\n"
 "}\n";
 
-#ifdef _MSC_VER
-#undef max
-#endif
 static float max(float x, float y) { return (x > y) ? x : y; }
 
 enum piglit_result
diff --git a/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c b/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c
index be9efc3..69cfa10 100644
--- a/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c
+++ b/tests/spec/glsl-1.30/execution/fs-textureOffset-2D.c
@@ -64,9 +64,6 @@ static const char fragtexlodoffset[] =
 "	gl_FragColor = texel;\n"
 "}\n";
 
-#ifdef _MSC_VER
-#undef max
-#endif
 static float max(float x, float y) { return (x > y) ? x : y; }
 
 enum piglit_result
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
old mode 100644
new mode 100755
index ad3622e..cc3b421
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -49,6 +49,11 @@ extern "C" {
 
 #if defined(_MSC_VER)
 
+/* windows.h won't define min/max macros if NOMINMAX is defined, however
+ * stdlib.h will still define them for C files regardless... */
+#undef max
+#undef min
+
 #if !defined(__cplusplus) && !defined(inline)
 #define inline __inline
 #endif
-- 
1.9.1



More information about the Piglit mailing list