[Piglit] [PATCH 4/7] tests/util: Consolidate the MSVC ffs implementations.

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


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

---
 .../spec/arb_texture_cube_map_array/cubemap-lod.c  | 21 -------------------
 tests/spec/arb_texture_cube_map_array/cubemap.c    | 21 -------------------
 tests/texturing/cubemap-shader.c                   | 21 -------------------
 tests/texturing/cubemap.c                          | 21 -------------------
 tests/util/piglit-util.h                           | 24 ++++++++++++++++++++--
 5 files changed, 22 insertions(+), 86 deletions(-)

diff --git a/tests/spec/arb_texture_cube_map_array/cubemap-lod.c b/tests/spec/arb_texture_cube_map_array/cubemap-lod.c
index 1f5eaf8..ceb347b 100644
--- a/tests/spec/arb_texture_cube_map_array/cubemap-lod.c
+++ b/tests/spec/arb_texture_cube_map_array/cubemap-lod.c
@@ -96,27 +96,6 @@ static GLuint program_cube_array_biased;
 static GLuint frag_shader_cube_array_explicit;
 static GLuint program_cube_array_explicit;
 
-#if defined(_MSC_VER)
-/**
- * Find the first bit set in i and return the index set of that bit.
- */
-static int
-ffs(int i)
-{
-	int bit;
-
-	if (i == 0) {
-		return 0;
-	}
-
-	for (bit = 1; !(i & 1); bit++) {
-		i = i >> 1;
-	}
-
-	return bit;
-}
-#endif
-
 static void
 set_image(int level, int size, int *color)
 {
diff --git a/tests/spec/arb_texture_cube_map_array/cubemap.c b/tests/spec/arb_texture_cube_map_array/cubemap.c
index 95f1220..1cef33a 100644
--- a/tests/spec/arb_texture_cube_map_array/cubemap.c
+++ b/tests/spec/arb_texture_cube_map_array/cubemap.c
@@ -90,27 +90,6 @@ static const char *frag_shader =
 
 static GLuint program_cube_array;
 
-#if defined(_MSC_VER)
-/**
- * Find the first bit set in i and return the index set of that bit.
- */
-static int
-ffs(int i)
-{
-	int bit;
-
-	if (i == 0) {
-		return 0;
-	}
-
-	for (bit = 1; !(i & 1); bit++) {
-		i = i >> 1;
-	}
-
-	return bit;
-}
-#endif
-
 static void
 set_image(int level, int size, int *color)
 {
diff --git a/tests/texturing/cubemap-shader.c b/tests/texturing/cubemap-shader.c
index 049cca2..fd1e282 100644
--- a/tests/texturing/cubemap-shader.c
+++ b/tests/texturing/cubemap-shader.c
@@ -94,27 +94,6 @@ static const char *frag_shader_lod =
 static GLuint frag_shader_cube;
 static GLuint program_cube;
 
-#if defined(_MSC_VER)
-/**
- * Find the first bit set in i and return the index set of that bit.
- */
-static int
-ffs(int i)
-{
-	int bit;
-
-	if (i == 0) {
-		return 0;
-	}
-
-	for (bit = 1; !(i & 1); bit++) {
-		i = i >> 1;
-	}
-
-	return bit;
-}
-#endif
-
 static void
 set_face_image(int level, GLenum face, int size, int color)
 {
diff --git a/tests/texturing/cubemap.c b/tests/texturing/cubemap.c
index 6d8f061..a09df72 100644
--- a/tests/texturing/cubemap.c
+++ b/tests/texturing/cubemap.c
@@ -51,27 +51,6 @@ static GLfloat colors[][3] = {
 	{0.0, 1.0, 0.0},
 };
 
-#if defined(_MSC_VER)
-/**
- * Find the first bit set in i and return the index set of that bit.
- */
-static int
-ffs(int i)
-{
-	int bit;
-
-	if (i == 0) {
-		return 0;
-	}
-
-	for (bit = 1; !(i & 1); bit++) {
-		i = i >> 1;
-	}
-
-	return bit;
-}
-#endif
-
 static void
 set_face_image(int level, GLenum face, int size, int color)
 {
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 1c1d27e..24ee405 100755
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -91,9 +91,29 @@ int asprintf(char **strp, const char *fmt, ...) PRINTFLIKE(2, 3);
 #ifndef HAVE_FFS
 #ifdef __MINGW32__
 #define ffs __builtin_ffs
-#endif
-#endif
+#else /* !__MINGW32__ */
+
+/**
+ * Find the first bit set in i and return the index set of that bit.
+ */
+static inline int
+ffs(int i)
+{
+	int bit;
+
+	if (i == 0) {
+		return 0;
+	}
+
+	for (bit = 1; !(i & 1); bit++) {
+		i = i >> 1;
+	}
+
+	return bit;
+}
 
+#endif /* !__MINGW32__ */
+#endif /* !HAVE_FFS*/
 
 enum piglit_result {
 	PIGLIT_PASS,
-- 
1.9.1



More information about the Piglit mailing list