pipe: Set errno upon failure.
[gnulib.git] / m4 / memchr.m4
index bcfe869..94596ef 100644 (file)
@@ -1,10 +1,10 @@
-# memchr.m4 serial 6
-dnl Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
+# memchr.m4 serial 7
+dnl Copyright (C) 2002-2004, 2009-2010 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([gl_FUNC_MEMCHR],
+AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
 [
   dnl Check for prerequisites for memory fence checks.
   gl_FUNC_MMAP_ANON
@@ -25,6 +25,7 @@ AC_DEFUN([gl_FUNC_MEMCHR],
     #   http://bugzilla.redhat.com/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
     # 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([[
@@ -52,11 +53,11 @@ AC_DEFUN([gl_FUNC_MEMCHR],
     {
       int pagesize = getpagesize ();
       char *two_pages =
-       (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
-                      flags, fd, 0);
+        (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
+                       flags, fd, 0);
       if (two_pages != (char *)(-1)
-         && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
-       fence = two_pages + pagesize;
+          && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
+        fence = two_pages + pagesize;
     }
 #endif
   if (fence)