MinGW-w64 build fix (lacks ffs declaration)

Define ffs as __builtin_ffs if ffs is not declared but
__builtin_ffs is declared.

This problem only happens at -O0 as one of the optimization
passes substitutes ffs for __builtin_ffs.

.. this patch has been submitted to the ISL project and also
apparently merged, though it is not in the publically visible
repository yet.
diff --git a/cloog-0.16.3/isl/configure b/cloog-0.16.3/isl/configure
index a35e911..4b7f26e 100755
--- a/cloog-0.16.3/isl/configure
+++ b/cloog-0.16.3/isl/configure
@@ -12476,6 +12476,29 @@
   NEED_GET_MEMORY_FUNCTIONS_FALSE=
 fi
 
+ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "#include <strings.h>
+"
+if test "x$ac_cv_have_decl_ffs" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FFS $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "__builtin_ffs" "ac_cv_have_decl___builtin_ffs" "$ac_includes_default"
+if test "x$ac_cv_have_decl___builtin_ffs" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL___BUILTIN_FFS $ac_have_decl
+_ACEOF
+
 
 
 
diff --git a/cloog-0.16.3/isl/configure.ac b/cloog-0.16.3/isl/configure.ac
index 6b59807..8df2cbe 100644
--- a/cloog-0.16.3/isl/configure.ac
+++ b/cloog-0.16.3/isl/configure.ac
@@ -39,6 +39,8 @@
 ],[#include <gmp.h>])
 CPPFLAGS="$SAVE_CPPFLAGS"
 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
+AC_CHECK_DECLS(ffs,[],[],[#include <strings.h>])
+AC_CHECK_DECLS(__builtin_ffs,[],[],[])
 
 AX_SUBMODULE(piplib,no|system|build,no)
 
diff --git a/cloog-0.16.3/isl/isl_config.h.in b/cloog-0.16.3/isl/isl_config.h.in
index 2c1c0c9..b63f626 100644
--- a/cloog-0.16.3/isl/isl_config.h.in
+++ b/cloog-0.16.3/isl/isl_config.h.in
@@ -4,10 +4,17 @@
    */
 #undef GCC_WARN_UNUSED_RESULT
 
+/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
+#undef HAVE_DECL_FFS
+
 /* Define to 1 if you have the declaration of `mp_get_memory_functions', and
    to 0 if you don't. */
 #undef HAVE_DECL_MP_GET_MEMORY_FUNCTIONS
 
+/* Define to 1 if you have the declaration of `__builtin_ffs', and to 0 if you
+   don't. */
+#undef HAVE_DECL___BUILTIN_FFS
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/cloog-0.16.3/isl/isl_config_post.h b/cloog-0.16.3/isl/isl_config_post.h
index 86a094d..a9c23f4 100644
--- a/cloog-0.16.3/isl/isl_config_post.h
+++ b/cloog-0.16.3/isl/isl_config_post.h
@@ -1,3 +1,7 @@
 #ifndef HAVE___ATTRIBUTE__
 #define __attribute__(x)
 #endif
+
+#if (HAVE_DECL_FFS==0) && (HAVE_DECL___BUILTIN_FFS==1)
+# define ffs __builtin_ffs
+#endif
diff --git a/cloog-0.16.3/isl/isl_hash.c b/cloog-0.16.3/isl/isl_hash.c
index c997402..52e3135 100644
--- a/cloog-0.16.3/isl/isl_hash.c
+++ b/cloog-0.16.3/isl/isl_hash.c
@@ -11,6 +11,7 @@
 #include <strings.h>
 #include <isl/hash.h>
 #include <isl/ctx.h>
+#include "isl_config.h"
 
 uint32_t isl_hash_string(uint32_t hash, const char *s)
 {
diff --git a/cloog-0.17.0/isl/configure b/cloog-0.17.0/isl/configure
index 1e2d46e..b397e19 100755
--- a/cloog-0.17.0/isl/configure
+++ b/cloog-0.17.0/isl/configure
@@ -16390,6 +16390,29 @@
   NEED_GET_MEMORY_FUNCTIONS_FALSE=
 fi
 
+ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "#include <strings.h>
+"
+if test "x$ac_cv_have_decl_ffs" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FFS $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "__builtin_ffs" "ac_cv_have_decl___builtin_ffs" "$ac_includes_default"
+if test "x$ac_cv_have_decl___builtin_ffs" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL___BUILTIN_FFS $ac_have_decl
+_ACEOF
+
 
 
 
diff --git a/cloog-0.17.0/isl/configure.ac b/cloog-0.17.0/isl/configure.ac
index f8683dd..a41023c 100644
--- a/cloog-0.17.0/isl/configure.ac
+++ b/cloog-0.17.0/isl/configure.ac
@@ -50,6 +50,8 @@
 ],[#include <gmp.h>])
 CPPFLAGS="$SAVE_CPPFLAGS"
 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
+AC_CHECK_DECLS(ffs,[],[],[#include <strings.h>])
+AC_CHECK_DECLS(__builtin_ffs,[],[],[])
 
 AX_SUBMODULE(piplib,no|system|build,no)
 
diff --git a/cloog-0.17.0/isl/isl_config.h.in b/cloog-0.17.0/isl/isl_config.h.in
index 23223f8..9184504 100644
--- a/cloog-0.17.0/isl/isl_config.h.in
+++ b/cloog-0.17.0/isl/isl_config.h.in
@@ -13,10 +13,17 @@
 /* Define if Driver constructor takes CXXIsProduction argument */
 #undef HAVE_CXXISPRODUCTION
 
+/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
+#undef HAVE_DECL_FFS
+
 /* Define to 1 if you have the declaration of `mp_get_memory_functions', and
    to 0 if you don't. */
 #undef HAVE_DECL_MP_GET_MEMORY_FUNCTIONS
 
+/* Define to 1 if you have the declaration of `__builtin_ffs', and to 0 if you
+   don't. */
+#undef HAVE_DECL___BUILTIN_FFS
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/cloog-0.17.0/isl/isl_config_post.h b/cloog-0.17.0/isl/isl_config_post.h
index 86a094d..a9c23f4 100644
--- a/cloog-0.17.0/isl/isl_config_post.h
+++ b/cloog-0.17.0/isl/isl_config_post.h
@@ -1,3 +1,7 @@
 #ifndef HAVE___ATTRIBUTE__
 #define __attribute__(x)
 #endif
+
+#if (HAVE_DECL_FFS==0) && (HAVE_DECL___BUILTIN_FFS==1)
+# define ffs __builtin_ffs
+#endif
diff --git a/cloog-0.17.0/isl/isl_hash.c b/cloog-0.17.0/isl/isl_hash.c
index c997402..52e3135 100644
--- a/cloog-0.17.0/isl/isl_hash.c
+++ b/cloog-0.17.0/isl/isl_hash.c
@@ -11,6 +11,7 @@
 #include <strings.h>
 #include <isl/hash.h>
 #include <isl/ctx.h>
+#include "isl_config.h"
 
 uint32_t isl_hash_string(uint32_t hash, const char *s)
 {
diff --git a/cloog-0.18.0/isl/configure b/cloog-0.18.0/isl/configure
index 3defff0..1318fcb 100755
--- a/cloog-0.18.0/isl/configure
+++ b/cloog-0.18.0/isl/configure
@@ -17143,6 +17143,29 @@
   NEED_GET_MEMORY_FUNCTIONS_FALSE=
 fi
 
+ac_fn_c_check_decl "$LINENO" "ffs" "ac_cv_have_decl_ffs" "#include <strings.h>
+"
+if test "x$ac_cv_have_decl_ffs" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_FFS $ac_have_decl
+_ACEOF
+
+ac_fn_c_check_decl "$LINENO" "__builtin_ffs" "ac_cv_have_decl___builtin_ffs" "$ac_includes_default"
+if test "x$ac_cv_have_decl___builtin_ffs" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL___BUILTIN_FFS $ac_have_decl
+_ACEOF
+
 
 
 
diff --git a/cloog-0.18.0/isl/configure.ac b/cloog-0.18.0/isl/configure.ac
index 88de460..2e3feb1 100644
--- a/cloog-0.18.0/isl/configure.ac
+++ b/cloog-0.18.0/isl/configure.ac
@@ -62,6 +62,8 @@
 ],[#include <gmp.h>])
 CPPFLAGS="$SAVE_CPPFLAGS"
 AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
+AC_CHECK_DECLS(ffs,[],[],[#include <strings.h>])
+AC_CHECK_DECLS(__builtin_ffs,[],[],[])
 
 AX_SUBMODULE(piplib,no|system|build,no)
 
diff --git a/cloog-0.18.0/isl/isl_config.h.in b/cloog-0.18.0/isl/isl_config.h.in
index 1848db0..dbb59a3 100644
--- a/cloog-0.18.0/isl/isl_config.h.in
+++ b/cloog-0.18.0/isl/isl_config.h.in
@@ -19,10 +19,17 @@
 /* Define if Driver constructor takes CXXIsProduction argument */
 #undef HAVE_CXXISPRODUCTION
 
+/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
+#undef HAVE_DECL_FFS
+
 /* Define to 1 if you have the declaration of `mp_get_memory_functions', and
    to 0 if you don't. */
 #undef HAVE_DECL_MP_GET_MEMORY_FUNCTIONS
 
+/* Define to 1 if you have the declaration of `__builtin_ffs', and to 0 if you
+   don't. */
+#undef HAVE_DECL___BUILTIN_FFS
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
diff --git a/cloog-0.18.0/isl/isl_config_post.h b/cloog-0.18.0/isl/isl_config_post.h
index 86a094d..a9c23f4 100644
--- a/cloog-0.18.0/isl/isl_config_post.h
+++ b/cloog-0.18.0/isl/isl_config_post.h
@@ -1,3 +1,7 @@
 #ifndef HAVE___ATTRIBUTE__
 #define __attribute__(x)
 #endif
+
+#if (HAVE_DECL_FFS==0) && (HAVE_DECL___BUILTIN_FFS==1)
+# define ffs __builtin_ffs
+#endif
diff --git a/cloog-0.18.0/isl/isl_hash.c b/cloog-0.18.0/isl/isl_hash.c
index 7b96c51..bd75a0d 100644
--- a/cloog-0.18.0/isl/isl_hash.c
+++ b/cloog-0.18.0/isl/isl_hash.c
@@ -11,6 +11,7 @@
 #include <strings.h>
 #include <isl/hash.h>
 #include <isl/ctx.h>
+#include "isl_config.h"
 
 uint32_t isl_hash_string(uint32_t hash, const char *s)
 {