[Mesa-dev] [PATCH] swr: clean up c++ feature flag test to not deal with IFS

Chuck Atkins chuck.atkins at kitware.com
Fri Jul 1 15:43:23 UTC 2016


Cc: Tim Rowley <timothy.o.rowley at intel.com>
Signed-off-by: Chuck Atkins <chuck.atkins at kitware.com>
---
 configure.ac | 43 ++++++++++++++++++-------------------------
 1 file changed, 18 insertions(+), 25 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8321e8e..844e91c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2331,37 +2331,30 @@ swr_llvm_check() {
 }
 
 swr_require_cxx_feature_flags() {
-    feature_name="$1"
-    preprocessor_test="$2"
-    option_list="$3"
-    output_var="$4"
+    local feature_name="$1"
+    local output_var="$2"
+    local preprocessor_test="$3"
+    shift 3
 
     AC_MSG_CHECKING([whether $CXX supports $feature_name])
     AC_LANG_PUSH([C++])
     save_CXXFLAGS="$CXXFLAGS"
-    save_IFS="$IFS"
-    IFS=","
     found=0
-    for opts in $option_list
-    do
-        unset IFS
-        CXXFLAGS="$opts $save_CXXFLAGS"
+    while test $# -gt 0; do
+        CXXFLAGS="$save_CXXFLAGS $1"
         AC_COMPILE_IFELSE(
             [AC_LANG_PROGRAM(
                 [   #if !($preprocessor_test)
                     #error
                     #endif
                 ])],
-            [found=1; break],
-            [])
-        IFS=","
+            [eval "$output_var=\"\$1\""; found=1; break;],
+            [shift])
     done
-    IFS="$save_IFS"
     CXXFLAGS="$save_CXXFLAGS"
     AC_LANG_POP([C++])
     if test $found -eq 1; then
-        AC_MSG_RESULT([$opts])
-        eval "$output_var=\$opts"
+        AC_MSG_RESULT([ifelse([$1],,[yes],[$1])])
         return 0
     fi
     AC_MSG_RESULT([no])
@@ -2438,19 +2431,19 @@ if test -n "$with_gallium_drivers"; then
         xswr)
             swr_llvm_check "swr"
 
-            swr_require_cxx_feature_flags "C++11" "__cplusplus >= 201103L" \
-                ",-std=c++11" \
-                SWR_CXX11_CXXFLAGS
+            swr_require_cxx_feature_flags "C++11" SWR_CXX11_CXXFLAGS \
+                "__cplusplus >= 201103L" \
+                "" "-std=c++11"
             AC_SUBST([SWR_CXX11_CXXFLAGS])
 
-            swr_require_cxx_feature_flags "AVX" "defined(__AVX__)" \
-                ",-mavx,-march=core-avx" \
-                SWR_AVX_CXXFLAGS
+            swr_require_cxx_feature_flags "AVX" SWR_AVX_CXXFLAGS \
+                "defined(__AVX__)" \
+                "" "-mavx" "-march=core-avx"
             AC_SUBST([SWR_AVX_CXXFLAGS])
 
-            swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" \
-                ",-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2" \
-                SWR_AVX2_CXXFLAGS
+            swr_require_cxx_feature_flags "AVX2" SWR_AVX2_CXXFLAGS \
+                "defined(__AVX2__)" \
+                "" "-mavx2 -mfma -mbmi2 -mf16c" "-march=core-avx2"
             AC_SUBST([SWR_AVX2_CXXFLAGS])
 
             HAVE_GALLIUM_SWR=yes
-- 
2.5.5



More information about the mesa-dev mailing list