summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-04-25 19:43:59 +0200
committerBruno Haible <bruno@clisp.org>2011-04-25 19:43:59 +0200
commite3a7a9fd96b0ae812052466af59b55fa1c37bd98 (patch)
treea7d7736d507c47d5dfd45ba6eab9d0915f3f7e77
parent6829a6c0c428c91768aa4314752ba92b1340e11b (diff)
downloadgnulib-e3a7a9fd96b0ae812052466af59b55fa1c37bd98.tar.gz
strnlen: Avoid memchr related link error on old obsolete platforms.
* modules/memchr-obsolete: New file. * m4/memchr-obsolete.m4: New file. * m4/memchr.m4 (gl_FUNC_MEMCHR): Don't check whether memchr exists if gl_FUNC_MEMCHR_OBSOLETE is not also defined. * modules/memchr (Depends-on): Add memchr-obsolete. * modules/strnlen (Depends-on): Likewise. * doc/posix-functions/memchr.texi: Mention module memchr-obsolete.
-rw-r--r--ChangeLog11
-rw-r--r--doc/posix-functions/memchr.texi13
-rw-r--r--m4/memchr-obsolete.m411
-rw-r--r--m4/memchr.m416
-rw-r--r--modules/memchr1
-rw-r--r--modules/memchr-obsolete28
-rw-r--r--modules/strnlen1
7 files changed, 70 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 65ed4a015f..2a4d9fedfd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-04-25 Bruno Haible <bruno@clisp.org>
+
+ strnlen: Avoid memchr related link error on old obsolete platforms.
+ * modules/memchr-obsolete: New file.
+ * m4/memchr-obsolete.m4: New file.
+ * m4/memchr.m4 (gl_FUNC_MEMCHR): Don't check whether memchr exists if
+ gl_FUNC_MEMCHR_OBSOLETE is not also defined.
+ * modules/memchr (Depends-on): Add memchr-obsolete.
+ * modules/strnlen (Depends-on): Likewise.
+ * doc/posix-functions/memchr.texi: Mention module memchr-obsolete.
+
2011-04-25 Jim Meyering <meyering@redhat.com>
maint.mk: makefile_at_at_check extend and clean up
diff --git a/doc/posix-functions/memchr.texi b/doc/posix-functions/memchr.texi
index 3c9cfcb9d2..68a15a23f6 100644
--- a/doc/posix-functions/memchr.texi
+++ b/doc/posix-functions/memchr.texi
@@ -4,18 +4,21 @@
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/memchr.html}
-Gnulib module: memchr
+Gnulib module: memchr or memchr-obsolete
-Portability problems fixed by Gnulib:
+Portability problems fixed by either Gnulib module @code{memchr} or @code{memchr-obsolete}:
@itemize
@item
-This function is missing on some older platforms.
-
-@item
This function dereferences too much memory on some platforms:
glibc 2.10 on x86_64, IA-64; glibc 2.11 on Alpha.
@end itemize
+Portability problems fixed by Gnulib module @code{memchr-obsolete}:
+@itemize
+@item
+This function is missing on some older platforms.
+@end itemize
+
Portability problems not fixed by Gnulib:
@itemize
@end itemize
diff --git a/m4/memchr-obsolete.m4 b/m4/memchr-obsolete.m4
new file mode 100644
index 0000000000..c65f651e13
--- /dev/null
+++ b/m4/memchr-obsolete.m4
@@ -0,0 +1,11 @@
+# memchr-obsolete.m4 serial 1
+dnl Copyright (C) 2011 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_OBSOLETE],
+[
+ dnl The real code is in memchr.m4.
+ :
+])
diff --git a/m4/memchr.m4 b/m4/memchr.m4
index 3c2b313916..a544e2b4e7 100644
--- a/m4/memchr.m4
+++ b/m4/memchr.m4
@@ -1,4 +1,4 @@
-# memchr.m4 serial 10
+# memchr.m4 serial 11
dnl Copyright (C) 2002-2004, 2009-2011 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -11,10 +11,16 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
AC_CHECK_HEADERS_ONCE([sys/mman.h])
AC_CHECK_FUNCS_ONCE([mprotect])
- dnl These days, we assume memchr is present. But just in case...
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- AC_CHECK_FUNCS_ONCE([memchr])
- if test $ac_cv_func_memchr = yes; then
+ m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [
+ dnl These days, we assume memchr is present. But if support for old
+ dnl platforms is desired:
+ AC_CHECK_FUNCS_ONCE([memchr])
+ if test $ac_cv_func_memchr = no; then
+ HAVE_MEMCHR=0
+ fi
+ ])
+ 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
@@ -73,8 +79,6 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
if test "$gl_cv_func_memchr_works" != yes; then
REPLACE_MEMCHR=1
fi
- else
- HAVE_MEMCHR=0
fi
if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
AC_LIBOBJ([memchr])
diff --git a/modules/memchr b/modules/memchr
index 495f2e26bd..229b3a5bfe 100644
--- a/modules/memchr
+++ b/modules/memchr
@@ -10,6 +10,7 @@ m4/mmap-anon.m4
Depends-on:
extensions
string
+memchr-obsolete
configure.ac:
gl_FUNC_MEMCHR
diff --git a/modules/memchr-obsolete b/modules/memchr-obsolete
new file mode 100644
index 0000000000..c1033b6605
--- /dev/null
+++ b/modules/memchr-obsolete
@@ -0,0 +1,28 @@
+Description:
+memchr() function for old platforms.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+m4/memchr-obsolete.m4
+
+Depends-on:
+memchr
+
+configure.ac:
+gl_FUNC_MEMCHR_OBSOLETE
+
+Makefile.am:
+
+Include:
+<string.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
diff --git a/modules/strnlen b/modules/strnlen
index 627e6948fe..2f50c9b537 100644
--- a/modules/strnlen
+++ b/modules/strnlen
@@ -8,6 +8,7 @@ m4/strnlen.m4
Depends-on:
extensions
string
+memchr-obsolete
configure.ac:
gl_FUNC_STRNLEN