bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: old platforms (was: Re: propose removing strnlen dependency on memch


From: Bruno Haible
Subject: Re: old platforms (was: Re: propose removing strnlen dependency on memchr)
Date: Sun, 24 Apr 2011 13:28:52 +0200
User-agent: KMail/1.9.9

Hi Paul,

> I propose that we remove this dependency, as
> the bugs fixed by the memchr module are not tickled by
> the gnulib strnlen implementation.

This is true for the current main target platforms. However, the memchr module
also documents this:

  Portability problems fixed by Gnulib:
    * This function is missing on some older platforms.
    ...

I don't believe it makes much sense for gnulib to behave inconsistently on
platforms which lack memchr(): On one hand, the 'strnlen' module will now
lead to a link error, on the other hand, the 'memchr' module - when used
explicitly - will provide a memchr() function.

We could go the simple way and just ditch all "obsolete" modules and all
code that is marked to be needed for "old platforms" or "older platforms".
But I believe some programs, like 'tar', want to be portable even to older
hosts than is currently our minimum horizont (HP-UX 11, AIX 5, Solaris 7 or 8),
and therefore just ditching the functionality is not right.

Instead, the approach I would favour is to move the functionality to 'obsolete'
modules - that you will not see in Emacs because dependencies to obsolete
modules are dropped by default [1] -, so that gnulib does not have to act as
a portability killer to some programs which desire portability to very old
platforms.

Here's a proposed patch. I've verified that with it:

1) ./gnulib-tool --create-testdir --dir=/tmp/testdir strnlen
produces a testdir without lib/memchr* nor m4/memchr*, and configure does not
do any memchr related checks - which is what you want.

2) ./gnulib-tool --create-testdir --dir=/tmp/testdir --with-obsolete strnlen
produces a testdir with lib/memchr.c, and configure does
  checking for memchr... yes
  checking whether memchr works... yes
as it should.

[1] http://www.gnu.org/software/gnulib/manual/html_node/Obsolete-modules.html


2011-04-24  Bruno Haible  <address@hidden>

        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.

=========================== modules/memchr-obsolete ===========================
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
============================ m4/memchr-obsolete.m4 ============================
# 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.
  :
])
===============================================================================
--- doc/posix-functions/memchr.texi.orig        Sun Apr 24 13:22:50 2011
+++ doc/posix-functions/memchr.texi     Sun Apr 24 13:09:16 2011
@@ -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.
-
address@hidden
 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}:
address@hidden
address@hidden
+This function is missing on some older platforms.
address@hidden itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @end itemize
--- m4/memchr.m4.orig   Sun Apr 24 13:28:08 2011
+++ m4/memchr.m4        Sun Apr 24 13:28:02 2011
@@ -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_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 @@
     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])
--- modules/memchr.orig Sun Apr 24 13:22:50 2011
+++ modules/memchr      Sun Apr 24 13:22:39 2011
@@ -10,6 +10,7 @@
 Depends-on:
 extensions
 string
+memchr-obsolete
 
 configure.ac:
 gl_FUNC_MEMCHR
--- modules/strnlen.orig        Sun Apr 24 13:22:50 2011
+++ modules/strnlen     Sun Apr 24 13:10:01 2011
@@ -8,6 +8,7 @@
 Depends-on:
 extensions
 string
+memchr-obsolete
 
 configure.ac:
 gl_FUNC_STRNLEN

-- 
In memoriam Siamanto <http://en.wikipedia.org/wiki/Siamanto>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]