New upstream version 1.9
[debian/gzip] / m4 / memchr.m4
index 25d32f0ec99966f29cc0157bbf600c01fe640129..83c65c11e321548f9d14b5762c7a26a92831a5dd 100644 (file)
@@ -1,11 +1,13 @@
-# memchr.m4 serial 12
-dnl Copyright (C) 2002-2004, 2009-2016 Free Software Foundation, Inc.
+# memchr.m4 serial 13
+dnl Copyright (C) 2002-2004, 2009-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
 [
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
   dnl Check for prerequisites for memory fence checks.
   gl_FUNC_MMAP_ANON
   AC_CHECK_HEADERS_ONCE([sys/mman.h])
@@ -23,10 +25,10 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
   if test $HAVE_MEMCHR = 1; then
     # Detect platform-specific bugs in some versions of glibc:
     # memchr should not dereference anything with length 0
-    #   http://bugzilla.redhat.com/499689
+    #   https://bugzilla.redhat.com/show_bug.cgi?id=499689
     # memchr should not dereference overestimated length after a match
-    #   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
-    #   http://sourceware.org/bugzilla/show_bug.cgi?id=10162
+    #   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
+    #   https://sourceware.org/bugzilla/show_bug.cgi?id=10162
     # Assume that memchr works on platforms that lack mprotect.
     AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
       [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
@@ -73,12 +75,21 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
         result |= 4;
     }
   return result;
-]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no],
-      [dnl Be pessimistic for now.
-       gl_cv_func_memchr_works="guessing no"])])
-    if test "$gl_cv_func_memchr_works" != yes; then
-      REPLACE_MEMCHR=1
-    fi
+]])],
+         [gl_cv_func_memchr_works=yes],
+         [gl_cv_func_memchr_works=no],
+         [case "$host_os" in
+                    # Guess yes on native Windows.
+            mingw*) gl_cv_func_memchr_works="guessing yes" ;;
+                    # Be pessimistic for now.
+            *)      gl_cv_func_memchr_works="guessing no" ;;
+          esac
+         ])
+      ])
+    case "$gl_cv_func_memchr_works" in
+      *yes) ;;
+      *) REPLACE_MEMCHR=1 ;;
+    esac
   fi
 ])