[Piglit] [PATCH] Define ffs for MinGW.

Vinson Lee vlee at freedesktop.org
Fri Jan 24 22:50:17 PST 2014


Fixes several MinGW ffs implicit-function-declaration warnings.

cubemap.c: In function 'piglit_display':
cubemap.c:271:4: warning: implicit declaration of function 'ffs' [-Wimplicit-function-declaration]
    y_offset += row_dim * 2 + (ffs(dim) + 3) * PAD;
    ^

Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
 CMakeLists.txt           | 1 +
 tests/util/config.h.in   | 1 +
 tests/util/piglit-util.h | 6 ++++++
 3 files changed, 8 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d77c7bd..e72df27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -356,6 +356,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${piglit_BINARY_DIR}/bin)
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${piglit_BINARY_DIR}/bin)
 
 check_function_exists(asprintf  HAVE_ASPRINTF)
+check_function_exists(ffs       HAVE_FFS)
 check_function_exists(strchrnul HAVE_STRCHRNUL)
 check_function_exists(strndup   HAVE_STRNDUP)
 check_function_exists(fopen_s   HAVE_FOPEN_S)
diff --git a/tests/util/config.h.in b/tests/util/config.h.in
index 691a249..c6e23db 100644
--- a/tests/util/config.h.in
+++ b/tests/util/config.h.in
@@ -1,4 +1,5 @@
 #cmakedefine HAVE_ASPRINTF
+#cmakedefine HAVE_FFS
 #cmakedefine HAVE_STRCHRNUL
 #cmakedefine HAVE_FOPEN_S
 #cmakedefine HAVE_SETRLIMIT
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index db880c7..96b31d5 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -88,6 +88,12 @@ lround(double x) {
 int asprintf(char **strp, const char *fmt, ...) PRINTFLIKE(2, 3);
 #endif /* HAVE_ASPRINTF */
 
+#ifndef HAVE_FFS
+#ifdef __MINGW32__
+#define ffs __builtin_ffs
+#endif
+#endif
+
 // Trick from http://tdistler.com/2011/03/24/how-to-define-nan-not-a-number-on-windows
 #ifndef INFINITY
 #  define INFINITY (FLT_MAX + FLT_MAX)
-- 
1.8.5.3



More information about the Piglit mailing list