Platforms that don't have the functions
  memcmp
  memcpy
  memmove
  memset
  memchr
  dup2
  getcwd
were seen in the years 1990..1995, but had already disappeared around 2000.
There's no reason to keep the code for these obsolete platforms now,
20 years later.


2020-07-07  Bruno Haible  <br...@clisp.org>

        doc: Remove support for some very old platforms.
        * doc/posix-functions/memcmp.texi: Don't mention "older platforms".
        * doc/posix-functions/memcpy.texi: Likewise.
        * doc/posix-functions/memmove.texi: Likewise.
        * doc/posix-functions/memset.texi: Likewise.
        * doc/posix-functions/getcwd.texi: Likewise.

        memchr: Remove support for some very old platforms.
        * m4/memchr-obsolete.m4: Remove file.
        * modules/memchr-obsolete: Remove file.
        * m4/memchr.m4 (gl_FUNC_MEMCHR): Assume module 'memchr-obsolete' is
        absent. Don't define HAVE_MEMCHR.
        * lib/string.in.h (memchr): Assume HAVE_MEMCHR is 1.
        * modules/memchr (Depends-on): Remove memchr-obsolete.
        (configure.ac): Assume HAVE_MEMCHR is 1.
        * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Don't initialize
        HAVE_MEMCHR.
        * modules/string (Makefile.am): Don't substitute HAVE_MEMCHR.
        * doc/posix-functions/memchr.texi: Don't mention module
        'memchr-obsolete'.
        * m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): Assume HAVE_MEMCHR is 1.
        * m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE): Assume HAVE_MEMCHR is 1.
        * modules/strnlen (Depends-on): Remove memchr-obsolete.

        dup2: Remove support for some very old platforms.
        * m4/dup2-obsolete.m4: Remove file.
        * modules/dup2-obsolete: Remove file.
        * m4/dup2.m4 (gl_FUNC_DUP2): Assume module 'dup2-obsolete' is absent.
        Don't define HAVE_DUP2.
        * lib/unistd.in.h (dup2): Assume HAVE_DUP2 is 1.
        * lib/dup2.c: Likewise.
        * modules/dup2 (Depends-on, configure.ac): Likewise.
        (Depends-on): Remove dup2-obsolete.
        * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Don't initialize HAVE_DUP2.
        * modules/unistd (Makefile.am): Don't substitute HAVE_DUP2.
        * doc/posix-functions/dup2.texi: Don't mention module 'dup2-obsolete'.

>From cfcb5fc6b95ca04bd3c8637d4027641d07c15cbe Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Wed, 8 Jul 2020 02:52:09 +0200
Subject: [PATCH 1/3] dup2: Remove support for some very old platforms.

* m4/dup2-obsolete.m4: Remove file.
* modules/dup2-obsolete: Remove file.
* m4/dup2.m4 (gl_FUNC_DUP2): Assume module 'dup2-obsolete' is absent.
Don't define HAVE_DUP2.
* lib/unistd.in.h (dup2): Assume HAVE_DUP2 is 1.
* lib/dup2.c: Likewise.
* modules/dup2 (Depends-on, configure.ac): Likewise.
(Depends-on): Remove dup2-obsolete.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Don't initialize HAVE_DUP2.
* modules/unistd (Makefile.am): Don't substitute HAVE_DUP2.
* doc/posix-functions/dup2.texi: Don't mention module 'dup2-obsolete'.
---
 ChangeLog                     |  15 ++++
 doc/posix-functions/dup2.texi |  10 +--
 lib/dup2.c                    | 100 +++++++----------------
 lib/unistd.in.h               |   3 -
 m4/dup2-obsolete.m4           |  11 ---
 m4/dup2.m4                    | 181 ++++++++++++++++++++----------------------
 m4/unistd_h.m4                |   3 +-
 modules/dup2                  |   7 +-
 modules/dup2-obsolete         |  28 -------
 modules/unistd                |   1 -
 10 files changed, 132 insertions(+), 227 deletions(-)
 delete mode 100644 m4/dup2-obsolete.m4
 delete mode 100644 modules/dup2-obsolete

diff --git a/ChangeLog b/ChangeLog
index 5d0ba82..8d0ccf5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2020-07-07  Bruno Haible  <br...@clisp.org>
 
+	dup2: Remove support for some very old platforms.
+	* m4/dup2-obsolete.m4: Remove file.
+	* modules/dup2-obsolete: Remove file.
+	* m4/dup2.m4 (gl_FUNC_DUP2): Assume module 'dup2-obsolete' is absent.
+	Don't define HAVE_DUP2.
+	* lib/unistd.in.h (dup2): Assume HAVE_DUP2 is 1.
+	* lib/dup2.c: Likewise.
+	* modules/dup2 (Depends-on, configure.ac): Likewise.
+	(Depends-on): Remove dup2-obsolete.
+	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Don't initialize HAVE_DUP2.
+	* modules/unistd (Makefile.am): Don't substitute HAVE_DUP2.
+	* doc/posix-functions/dup2.texi: Don't mention module 'dup2-obsolete'.
+
+2020-07-07  Bruno Haible  <br...@clisp.org>
+
 	canonicalize: Trim module dependencies.
 	* lib/hash-triple.h: Group declarations.
 	* lib/hash-triple-simple.c: New file, extracted from lib/hash-triple.c.
diff --git a/doc/posix-functions/dup2.texi b/doc/posix-functions/dup2.texi
index 8635e6c..d81def5 100644
--- a/doc/posix-functions/dup2.texi
+++ b/doc/posix-functions/dup2.texi
@@ -4,9 +4,9 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html}
 
-Gnulib module: dup2 or dup2-obsolete
+Gnulib module: dup2
 
-Portability problems fixed by either Gnulib module @code{dup2} or @code{dup2-obsolete}:
+Portability problems fixed by Gnulib:
 @itemize
 @item
 This function is declared in a different header file (namely, @code{<io.h>})
@@ -53,12 +53,6 @@ large targets, which interferes with using
 AIX 7.1, FreeBSD 6.1, Cygwin 1.5.
 @end itemize
 
-Portability problems fixed by Gnulib module @code{dup2-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/lib/dup2.c b/lib/dup2.c
index 88ef259..9bc3951 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -25,28 +25,26 @@
 #include <errno.h>
 #include <fcntl.h>
 
-#if HAVE_DUP2
+#undef dup2
 
-# undef dup2
-
-# if defined _WIN32 && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
 
 /* Get declarations of the native Windows API functions.  */
-#  define WIN32_LEAN_AND_MEAN
-#  include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
 
-#  if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-#   include "msvc-inval.h"
-#  endif
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+#  include "msvc-inval.h"
+# endif
 
 /* Get _get_osfhandle.  */
-#  if GNULIB_MSVC_NOTHROW
-#   include "msvc-nothrow.h"
-#  else
-#   include <io.h>
-#  endif
+# if GNULIB_MSVC_NOTHROW
+#  include "msvc-nothrow.h"
+# else
+#  include <io.h>
+# endif
 
-#  if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
 static int
 dup2_nothrow (int fd, int desired_fd)
 {
@@ -65,9 +63,9 @@ dup2_nothrow (int fd, int desired_fd)
 
   return result;
 }
-#  else
-#   define dup2_nothrow dup2
-#  endif
+# else
+#  define dup2_nothrow dup2
+# endif
 
 static int
 ms_windows_dup2 (int fd, int desired_fd)
@@ -103,11 +101,11 @@ ms_windows_dup2 (int fd, int desired_fd)
   return result;
 }
 
-#  define dup2 ms_windows_dup2
+# define dup2 ms_windows_dup2
 
-# elif defined __KLIBC__
+#elif defined __KLIBC__
 
-#  include <InnoTekLIBC/backend.h>
+# include <InnoTekLIBC/backend.h>
 
 static int
 klibc_dup2dirfd (int fd, int desired_fd)
@@ -155,81 +153,37 @@ klibc_dup2 (int fd, int desired_fd)
   return dupfd;
 }
 
-#  define dup2 klibc_dup2
-# endif
+# define dup2 klibc_dup2
+#endif
 
 int
 rpl_dup2 (int fd, int desired_fd)
 {
   int result;
 
-# ifdef F_GETFL
+#ifdef F_GETFL
   /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
      On Cygwin 1.5.x, dup2 (1, 1) returns 0.
      On Cygwin 1.7.17, dup2 (1, -1) dumps core.
      On Cygwin 1.7.25, dup2 (1, 256) can dump core.
      On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC.  */
-#  if HAVE_SETDTABLESIZE
+# if HAVE_SETDTABLESIZE
   setdtablesize (desired_fd + 1);
-#  endif
+# endif
   if (desired_fd < 0)
     fd = desired_fd;
   if (fd == desired_fd)
     return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
-# endif
+#endif
 
   result = dup2 (fd, desired_fd);
 
   /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x.  */
   if (result == -1 && errno == EMFILE)
     errno = EBADF;
-# if REPLACE_FCHDIR
+#if REPLACE_FCHDIR
   if (fd != desired_fd && result != -1)
     result = _gl_register_dup (fd, result);
-# endif
-  return result;
-}
-
-#else /* !HAVE_DUP2 */
-
-/* On older platforms, dup2 did not exist.  */
-
-# ifndef F_DUPFD
-static int
-dupfd (int fd, int desired_fd)
-{
-  int duplicated_fd = dup (fd);
-  if (duplicated_fd < 0 || duplicated_fd == desired_fd)
-    return duplicated_fd;
-  else
-    {
-      int r = dupfd (fd, desired_fd);
-      int e = errno;
-      close (duplicated_fd);
-      errno = e;
-      return r;
-    }
-}
-# endif
-
-int
-dup2 (int fd, int desired_fd)
-{
-  int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd;
-  if (result == -1 || fd == desired_fd)
-    return result;
-  close (desired_fd);
-# ifdef F_DUPFD
-  result = fcntl (fd, F_DUPFD, desired_fd);
-#  if REPLACE_FCHDIR
-  if (0 <= result)
-    result = _gl_register_dup (fd, result);
-#  endif
-# else
-  result = dupfd (fd, desired_fd);
-# endif
-  if (result == -1 && (errno == EMFILE || errno == EINVAL))
-    errno = EBADF;
+#endif
   return result;
 }
-#endif /* !HAVE_DUP2 */
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 71904fe..3a49813 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -408,9 +408,6 @@ _GL_WARN_ON_USE (dup, "dup is unportable - "
 _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
 _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
 # else
-#  if !@HAVE_DUP2@
-_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
-#  endif
 _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
 # endif
 _GL_CXXALIASWARN (dup2);
diff --git a/m4/dup2-obsolete.m4 b/m4/dup2-obsolete.m4
deleted file mode 100644
index 5e72403..0000000
--- a/m4/dup2-obsolete.m4
+++ /dev/null
@@ -1,11 +0,0 @@
-# dup2-obsolete.m4 serial 1
-dnl Copyright (C) 2011-2020 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_DUP2_OBSOLETE],
-[
-  dnl The real code is in dup2.m4.
-  :
-])
diff --git a/m4/dup2.m4 b/m4/dup2.m4
index 21b1ecc..462bfd0 100644
--- a/m4/dup2.m4
+++ b/m4/dup2.m4
@@ -1,4 +1,4 @@
-#serial 25
+#serial 26
 dnl Copyright (C) 2002, 2005, 2007, 2009-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,107 +8,94 @@ AC_DEFUN([gl_FUNC_DUP2],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
-  m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
-    AC_CHECK_FUNCS_ONCE([dup2])
-    if test $ac_cv_func_dup2 = no; then
-      HAVE_DUP2=0
-    fi
-  ], [
-    AC_DEFINE([HAVE_DUP2], [1], [Define to 1 if you have the 'dup2' function.])
-  ])
-  if test $HAVE_DUP2 = 1; then
-    AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
-      [AC_RUN_IFELSE([
-         AC_LANG_PROGRAM(
-           [[#include <errno.h>
-             #include <fcntl.h>
-             #include <limits.h>
-             #include <sys/resource.h>
-             #include <unistd.h>
-             #ifndef RLIM_SAVED_CUR
-             # define RLIM_SAVED_CUR RLIM_INFINITY
-             #endif
-             #ifndef RLIM_SAVED_MAX
-             # define RLIM_SAVED_MAX RLIM_INFINITY
-             #endif
-           ]],
-           [[int result = 0;
-             int bad_fd = INT_MAX;
-             struct rlimit rlim;
-             if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
-                 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
-                 && rlim.rlim_cur != RLIM_INFINITY
-                 && rlim.rlim_cur != RLIM_SAVED_MAX
-                 && rlim.rlim_cur != RLIM_SAVED_CUR)
-               bad_fd = rlim.rlim_cur;
-             #ifdef FD_CLOEXEC
-               if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
-                 result |= 1;
-             #endif
-             if (dup2 (1, 1) != 1)
-               result |= 2;
-             #ifdef FD_CLOEXEC
-               if (fcntl (1, F_GETFD) != FD_CLOEXEC)
-                 result |= 4;
-             #endif
-             close (0);
-             if (dup2 (0, 0) != -1)
-               result |= 8;
-             /* Many gnulib modules require POSIX conformance of EBADF.  */
-             if (dup2 (2, bad_fd) == -1 && errno != EBADF)
-               result |= 16;
-             /* Flush out some cygwin core dumps.  */
-             if (dup2 (2, -1) != -1 || errno != EBADF)
-               result |= 32;
-             dup2 (2, 255);
-             dup2 (2, 256);
-             /* On OS/2 kLIBC, dup2() does not work on a directory fd.  */
-             {
-               int fd = open (".", O_RDONLY);
-               if (fd == -1)
-                 result |= 64;
-               else if (dup2 (fd, fd + 1) == -1)
-                 result |= 128;
-
-               close (fd);
-             }
-             return result;]])
-        ],
-        [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
-        [case "$host_os" in
-           mingw*) # on this platform, dup2 always returns 0 for success
-             gl_cv_func_dup2_works="guessing no" ;;
-           cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
-             gl_cv_func_dup2_works="guessing no" ;;
-           aix* | freebsd*)
-                   # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
-                   # not EBADF.
-             gl_cv_func_dup2_works="guessing no" ;;
-           haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
-             gl_cv_func_dup2_works="guessing no" ;;
-           *-android*) # implemented using dup3(), which fails if oldfd == newfd
-             gl_cv_func_dup2_works="guessing no" ;;
-           os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd.
-             gl_cv_func_dup2_works="guessing no" ;;
-           *) gl_cv_func_dup2_works="guessing yes" ;;
-         esac])
-      ])
-    case "$gl_cv_func_dup2_works" in
-      *yes) ;;
-      *)
-        REPLACE_DUP2=1
-        AC_CHECK_FUNCS([setdtablesize])
-        ;;
-    esac
-  fi
+  AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
+    [AC_RUN_IFELSE([
+       AC_LANG_PROGRAM(
+         [[#include <errno.h>
+           #include <fcntl.h>
+           #include <limits.h>
+           #include <sys/resource.h>
+           #include <unistd.h>
+           #ifndef RLIM_SAVED_CUR
+           # define RLIM_SAVED_CUR RLIM_INFINITY
+           #endif
+           #ifndef RLIM_SAVED_MAX
+           # define RLIM_SAVED_MAX RLIM_INFINITY
+           #endif
+         ]],
+         [[int result = 0;
+           int bad_fd = INT_MAX;
+           struct rlimit rlim;
+           if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
+               && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
+               && rlim.rlim_cur != RLIM_INFINITY
+               && rlim.rlim_cur != RLIM_SAVED_MAX
+               && rlim.rlim_cur != RLIM_SAVED_CUR)
+             bad_fd = rlim.rlim_cur;
+           #ifdef FD_CLOEXEC
+             if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
+               result |= 1;
+           #endif
+           if (dup2 (1, 1) != 1)
+             result |= 2;
+           #ifdef FD_CLOEXEC
+             if (fcntl (1, F_GETFD) != FD_CLOEXEC)
+               result |= 4;
+           #endif
+           close (0);
+           if (dup2 (0, 0) != -1)
+             result |= 8;
+           /* Many gnulib modules require POSIX conformance of EBADF.  */
+           if (dup2 (2, bad_fd) == -1 && errno != EBADF)
+             result |= 16;
+           /* Flush out some cygwin core dumps.  */
+           if (dup2 (2, -1) != -1 || errno != EBADF)
+             result |= 32;
+           dup2 (2, 255);
+           dup2 (2, 256);
+           /* On OS/2 kLIBC, dup2() does not work on a directory fd.  */
+           {
+             int fd = open (".", O_RDONLY);
+             if (fd == -1)
+               result |= 64;
+             else if (dup2 (fd, fd + 1) == -1)
+               result |= 128;
+             close (fd);
+           }
+           return result;]])
+      ],
+      [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
+      [case "$host_os" in
+         mingw*) # on this platform, dup2 always returns 0 for success
+           gl_cv_func_dup2_works="guessing no" ;;
+         cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+           gl_cv_func_dup2_works="guessing no" ;;
+         aix* | freebsd*)
+                 # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
+                 # not EBADF.
+           gl_cv_func_dup2_works="guessing no" ;;
+         haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
+           gl_cv_func_dup2_works="guessing no" ;;
+         *-android*) # implemented using dup3(), which fails if oldfd == newfd
+           gl_cv_func_dup2_works="guessing no" ;;
+         os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd.
+           gl_cv_func_dup2_works="guessing no" ;;
+         *) gl_cv_func_dup2_works="guessing yes" ;;
+       esac])
+    ])
+  case "$gl_cv_func_dup2_works" in
+    *yes) ;;
+    *)
+      REPLACE_DUP2=1
+      AC_CHECK_FUNCS([setdtablesize])
+      ;;
+  esac
   dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
   dnl to keep fchdir's bookkeeping up-to-date.
   m4_ifdef([gl_FUNC_FCHDIR], [
     gl_TEST_FCHDIR
     if test $HAVE_FCHDIR = 0; then
-      if test $HAVE_DUP2 = 1; then
-        REPLACE_DUP2=1
-      fi
+      REPLACE_DUP2=1
     fi
   ])
 ])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index dfa38f8..b4734da 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 80
+# unistd_h.m4 serial 81
 dnl Copyright (C) 2006-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -120,7 +120,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_CHOWN=1;           AC_SUBST([HAVE_CHOWN])
   HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE])
-  HAVE_DUP2=1;            AC_SUBST([HAVE_DUP2])
   HAVE_DUP3=1;            AC_SUBST([HAVE_DUP3])
   HAVE_EUIDACCESS=1;      AC_SUBST([HAVE_EUIDACCESS])
   HAVE_FACCESSAT=1;       AC_SUBST([HAVE_FACCESSAT])
diff --git a/modules/dup2 b/modules/dup2
index 2ad65d1..70a28de 100644
--- a/modules/dup2
+++ b/modules/dup2
@@ -7,13 +7,12 @@ m4/dup2.m4
 
 Depends-on:
 unistd
-dup2-obsolete
-msvc-inval      [test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1]
-msvc-nothrow    [test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1]
+msvc-inval      [test $REPLACE_DUP2 = 1]
+msvc-nothrow    [test $REPLACE_DUP2 = 1]
 
 configure.ac:
 gl_FUNC_DUP2
-if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
+if test $REPLACE_DUP2 = 1; then
   AC_LIBOBJ([dup2])
   gl_PREREQ_DUP2
 fi
diff --git a/modules/dup2-obsolete b/modules/dup2-obsolete
deleted file mode 100644
index 243bed1..0000000
--- a/modules/dup2-obsolete
+++ /dev/null
@@ -1,28 +0,0 @@
-Description:
-dup2() function for old platforms.
-
-Status:
-obsolete
-
-Notice:
-This module is obsolete.
-
-Files:
-m4/dup2-obsolete.m4
-
-Depends-on:
-dup2
-
-configure.ac:
-gl_FUNC_DUP2_OBSOLETE
-
-Makefile.am:
-
-Include:
-<unistd.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
diff --git a/modules/unistd b/modules/unistd
index 5550646..b14faaa 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -94,7 +94,6 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      < $(srcdir)/unistd.in.h | \
 	  sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
 	      -e 's|@''HAVE_COPY_FILE_RANGE''@|$(HAVE_COPY_FILE_RANGE)|g' \
-	      -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
 	      -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
 	      -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
 	      -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
-- 
2.7.4

>From 707090c9ed6a16bc4b152be300578761e34b2bed Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Wed, 8 Jul 2020 03:19:54 +0200
Subject: [PATCH 2/3] memchr: Remove support for some very old platforms.

* m4/memchr-obsolete.m4: Remove file.
* modules/memchr-obsolete: Remove file.
* m4/memchr.m4 (gl_FUNC_MEMCHR): Assume module 'memchr-obsolete' is
absent. Don't define HAVE_MEMCHR.
* lib/string.in.h (memchr): Assume HAVE_MEMCHR is 1.
* modules/memchr (Depends-on): Remove memchr-obsolete.
(configure.ac): Assume HAVE_MEMCHR is 1.
* m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Don't initialize
HAVE_MEMCHR.
* modules/string (Makefile.am): Don't substitute HAVE_MEMCHR.
* doc/posix-functions/memchr.texi: Don't mention module
'memchr-obsolete'.
* m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): Assume HAVE_MEMCHR is 1.
* m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE): Assume HAVE_MEMCHR is 1.
* modules/strnlen (Depends-on): Remove memchr-obsolete.
---
 ChangeLog                       | 17 +++++++++++
 doc/posix-functions/memchr.texi | 10 ++-----
 lib/string.in.h                 |  5 ----
 m4/memchr-obsolete.m4           | 11 -------
 m4/memchr.m4                    | 66 +++++++++++++++++------------------------
 m4/strcasestr.m4                |  4 +--
 m4/string_h.m4                  |  3 +-
 m4/strstr.m4                    |  4 +--
 modules/memchr                  |  3 +-
 modules/memchr-obsolete         | 28 -----------------
 modules/string                  |  1 -
 modules/strnlen                 |  1 -
 12 files changed, 53 insertions(+), 100 deletions(-)
 delete mode 100644 m4/memchr-obsolete.m4
 delete mode 100644 modules/memchr-obsolete

diff --git a/ChangeLog b/ChangeLog
index 8d0ccf5..a1642ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2020-07-07  Bruno Haible  <br...@clisp.org>
 
+	memchr: Remove support for some very old platforms.
+	* m4/memchr-obsolete.m4: Remove file.
+	* modules/memchr-obsolete: Remove file.
+	* m4/memchr.m4 (gl_FUNC_MEMCHR): Assume module 'memchr-obsolete' is
+	absent. Don't define HAVE_MEMCHR.
+	* lib/string.in.h (memchr): Assume HAVE_MEMCHR is 1.
+	* modules/memchr (Depends-on): Remove memchr-obsolete.
+	(configure.ac): Assume HAVE_MEMCHR is 1.
+	* m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Don't initialize
+	HAVE_MEMCHR.
+	* modules/string (Makefile.am): Don't substitute HAVE_MEMCHR.
+	* doc/posix-functions/memchr.texi: Don't mention module
+	'memchr-obsolete'.
+	* m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): Assume HAVE_MEMCHR is 1.
+	* m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE): Assume HAVE_MEMCHR is 1.
+	* modules/strnlen (Depends-on): Remove memchr-obsolete.
+
 	dup2: Remove support for some very old platforms.
 	* m4/dup2-obsolete.m4: Remove file.
 	* modules/dup2-obsolete: Remove file.
diff --git a/doc/posix-functions/memchr.texi b/doc/posix-functions/memchr.texi
index 38d5b66..5ceb71f 100644
--- a/doc/posix-functions/memchr.texi
+++ b/doc/posix-functions/memchr.texi
@@ -4,9 +4,9 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/memchr.html}
 
-Gnulib module: memchr or memchr-obsolete
+Gnulib module: memchr
 
-Portability problems fixed by either Gnulib module @code{memchr} or @code{memchr-obsolete}:
+Portability problems fixed by Gnulib:
 @itemize
 @item
 This function dereferences too much memory on some platforms:
@@ -17,12 +17,6 @@ of an @code{unsigned char} on some platforms:
 Android 5.0.
 @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/lib/string.in.h b/lib/string.in.h
index 77ccf94..c18efa7 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -134,11 +134,6 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
                                   _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
 # else
-#  if ! @HAVE_MEMCHR@
-_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
-                                  _GL_ATTRIBUTE_PURE
-                                  _GL_ARG_NONNULL ((1)));
-#  endif
   /* On some systems, this function is defined as an overloaded function:
        extern "C" { const void * std::memchr (const void *, int, size_t); }
        extern "C++" { void * std::memchr (void *, int, size_t); }  */
diff --git a/m4/memchr-obsolete.m4 b/m4/memchr-obsolete.m4
deleted file mode 100644
index 7305a77..0000000
--- a/m4/memchr-obsolete.m4
+++ /dev/null
@@ -1,11 +0,0 @@
-# memchr-obsolete.m4 serial 1
-dnl Copyright (C) 2011-2020 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 91eec88..81e8f98 100644
--- a/m4/memchr.m4
+++ b/m4/memchr.m4
@@ -1,4 +1,4 @@
-# memchr.m4 serial 15
+# memchr.m4 serial 16
 dnl Copyright (C) 2002-2004, 2009-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,26 +14,17 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
   AC_CHECK_FUNCS_ONCE([mprotect])
 
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
-  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
-    #   https://bugzilla.redhat.com/show_bug.cgi?id=499689
-    # memchr should not dereference overestimated length after a match
-    #   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
-    #   https://sourceware.org/bugzilla/show_bug.cgi?id=10162
-    # memchr should cast the second argument to 'unsigned char'.
-    #   This bug exists in Android 4.3.
-    # 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([[
+  # Detect platform-specific bugs in some versions of glibc:
+  # memchr should not dereference anything with length 0
+  #   https://bugzilla.redhat.com/show_bug.cgi?id=499689
+  # memchr should not dereference overestimated length after a match
+  #   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
+  #   https://sourceware.org/bugzilla/show_bug.cgi?id=10162
+  # memchr should cast the second argument to 'unsigned char'.
+  #   This bug exists in Android 4.3.
+  # 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([[
 #include <string.h>
 #if HAVE_SYS_MMAN_H
 # include <fcntl.h>
@@ -87,23 +78,22 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
   }
   return result;
 ]])],
-         [gl_cv_func_memchr_works=yes],
-         [gl_cv_func_memchr_works=no],
-         [case "$host_os" in
-                             # Guess no on Android.
-            linux*-android*) gl_cv_func_memchr_works="guessing no" ;;
-                             # Guess yes on native Windows.
-            mingw*)          gl_cv_func_memchr_works="guessing yes" ;;
-                             # If we don't know, obey --enable-cross-guesses.
-            *)               gl_cv_func_memchr_works="$gl_cross_guess_normal" ;;
-          esac
-         ])
-      ])
-    case "$gl_cv_func_memchr_works" in
-      *yes) ;;
-      *) REPLACE_MEMCHR=1 ;;
-    esac
-  fi
+       [gl_cv_func_memchr_works=yes],
+       [gl_cv_func_memchr_works=no],
+       [case "$host_os" in
+                           # Guess no on Android.
+          linux*-android*) gl_cv_func_memchr_works="guessing no" ;;
+                           # Guess yes on native Windows.
+          mingw*)          gl_cv_func_memchr_works="guessing yes" ;;
+                           # If we don't know, obey --enable-cross-guesses.
+          *)               gl_cv_func_memchr_works="$gl_cross_guess_normal" ;;
+        esac
+       ])
+    ])
+  case "$gl_cv_func_memchr_works" in
+    *yes) ;;
+    *) REPLACE_MEMCHR=1 ;;
+  esac
 ])
 
 # Prerequisites of lib/memchr.c.
diff --git a/m4/strcasestr.m4 b/m4/strcasestr.m4
index 4c2275f..ee22873 100644
--- a/m4/strcasestr.m4
+++ b/m4/strcasestr.m4
@@ -1,4 +1,4 @@
-# strcasestr.m4 serial 25
+# strcasestr.m4 serial 26
 dnl Copyright (C) 2005, 2007-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
   if test $ac_cv_func_strcasestr = no; then
     HAVE_STRCASESTR=0
   else
-    if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
+    if test $REPLACE_MEMCHR = 1; then
       REPLACE_STRCASESTR=1
     else
       dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index cc51337..516b346 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -5,7 +5,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 23
+# serial 24
 
 # Written by Paul Eggert.
 
@@ -87,7 +87,6 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   HAVE_EXPLICIT_BZERO=1;        AC_SUBST([HAVE_EXPLICIT_BZERO])
   HAVE_FFSL=1;                  AC_SUBST([HAVE_FFSL])
   HAVE_FFSLL=1;                 AC_SUBST([HAVE_FFSLL])
-  HAVE_MEMCHR=1;                AC_SUBST([HAVE_MEMCHR])
   HAVE_DECL_MEMMEM=1;           AC_SUBST([HAVE_DECL_MEMMEM])
   HAVE_MEMPCPY=1;               AC_SUBST([HAVE_MEMPCPY])
   HAVE_DECL_MEMRCHR=1;          AC_SUBST([HAVE_DECL_MEMRCHR])
diff --git a/m4/strstr.m4 b/m4/strstr.m4
index a2ec337..5291107 100644
--- a/m4/strstr.m4
+++ b/m4/strstr.m4
@@ -1,4 +1,4 @@
-# strstr.m4 serial 21
+# strstr.m4 serial 22
 dnl Copyright (C) 2008-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
 [
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MEMCHR])
-  if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
+  if test $REPLACE_MEMCHR = 1; then
     REPLACE_STRSTR=1
   else
     dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092
diff --git a/modules/memchr b/modules/memchr
index ed80e0c..3a413a2 100644
--- a/modules/memchr
+++ b/modules/memchr
@@ -10,11 +10,10 @@ m4/mmap-anon.m4
 Depends-on:
 extensions
 string
-memchr-obsolete
 
 configure.ac:
 gl_FUNC_MEMCHR
-if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
+if test $REPLACE_MEMCHR = 1; then
   AC_LIBOBJ([memchr])
   gl_PREREQ_MEMCHR
 fi
diff --git a/modules/memchr-obsolete b/modules/memchr-obsolete
deleted file mode 100644
index c1a6e43..0000000
--- a/modules/memchr-obsolete
+++ /dev/null
@@ -1,28 +0,0 @@
-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:
-all
diff --git a/modules/string b/modules/string
index 67209d5..bc87bc8 100644
--- a/modules/string
+++ b/modules/string
@@ -73,7 +73,6 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
 	      -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
 	      -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
-	      -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
 	      -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
 	      -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
 	      -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
diff --git a/modules/strnlen b/modules/strnlen
index c781671..ea5658a 100644
--- a/modules/strnlen
+++ b/modules/strnlen
@@ -8,7 +8,6 @@ m4/strnlen.m4
 Depends-on:
 string
 extensions
-memchr-obsolete [test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1]
 
 configure.ac:
 gl_FUNC_STRNLEN
-- 
2.7.4

>From 3f53c355dd2efa18317f53d24c8b19b8a278674f Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Wed, 8 Jul 2020 03:21:36 +0200
Subject: [PATCH 3/3] doc: Remove support for some very old platforms.

* doc/posix-functions/memcmp.texi: Don't mention "older platforms".
* doc/posix-functions/memcpy.texi: Likewise.
* doc/posix-functions/memmove.texi: Likewise.
* doc/posix-functions/memset.texi: Likewise.
* doc/posix-functions/getcwd.texi: Likewise.
---
 ChangeLog                        | 7 +++++++
 doc/posix-functions/getcwd.texi  | 2 --
 doc/posix-functions/memcmp.texi  | 2 --
 doc/posix-functions/memcpy.texi  | 2 --
 doc/posix-functions/memmove.texi | 2 --
 doc/posix-functions/memset.texi  | 2 --
 6 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a1642ef..9cac500 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2020-07-07  Bruno Haible  <br...@clisp.org>
 
+	doc: Remove support for some very old platforms.
+	* doc/posix-functions/memcmp.texi: Don't mention "older platforms".
+	* doc/posix-functions/memcpy.texi: Likewise.
+	* doc/posix-functions/memmove.texi: Likewise.
+	* doc/posix-functions/memset.texi: Likewise.
+	* doc/posix-functions/getcwd.texi: Likewise.
+
 	memchr: Remove support for some very old platforms.
 	* m4/memchr-obsolete.m4: Remove file.
 	* modules/memchr-obsolete: Remove file.
diff --git a/doc/posix-functions/getcwd.texi b/doc/posix-functions/getcwd.texi
index 5ad8c9d..35b23eb 100644
--- a/doc/posix-functions/getcwd.texi
+++ b/doc/posix-functions/getcwd.texi
@@ -34,8 +34,6 @@ mingw.
 Portability problems fixed by Gnulib module @code{getcwd}:
 @itemize
 @item
-This function is missing on some older platforms.
-@item
 This function does not handle long file names (greater than @code{PATH_MAX})
 correctly on some platforms:
 glibc on Linux 2.4.20, Mac OS X 10.5, FreeBSD 6.4, NetBSD 5.1, OpenBSD 4.9, AIX 7.1.
diff --git a/doc/posix-functions/memcmp.texi b/doc/posix-functions/memcmp.texi
index 99fb810..204208c 100644
--- a/doc/posix-functions/memcmp.texi
+++ b/doc/posix-functions/memcmp.texi
@@ -9,8 +9,6 @@ Gnulib module: memcmp
 Portability problems fixed by Gnulib:
 @itemize
 @item
-This function is missing on some older platforms.
-@item
 This function fails when comparing 16 bytes or more and with at least one
 buffer not starting on a 4-byte boundary on some older platforms:
 NeXTstep/x86.
diff --git a/doc/posix-functions/memcpy.texi b/doc/posix-functions/memcpy.texi
index 5200f69..ac68a70 100644
--- a/doc/posix-functions/memcpy.texi
+++ b/doc/posix-functions/memcpy.texi
@@ -9,8 +9,6 @@ Gnulib module: memcpy
 Portability problems fixed by Gnulib:
 @itemize
 @item
-This function is missing on some older platforms.
-@item
 This function cannot be called from plain inline or extern inline functions
 on some platforms:
 OS X 10.8.
diff --git a/doc/posix-functions/memmove.texi b/doc/posix-functions/memmove.texi
index 7da46c6..bad1428 100644
--- a/doc/posix-functions/memmove.texi
+++ b/doc/posix-functions/memmove.texi
@@ -9,8 +9,6 @@ Gnulib module: memmove
 Portability problems fixed by Gnulib:
 @itemize
 @item
-This function is missing on some older platforms.
-@item
 This function cannot be called from plain inline or extern inline functions
 on some platforms:
 OS X 10.8.
diff --git a/doc/posix-functions/memset.texi b/doc/posix-functions/memset.texi
index 5e3cc80..6658b09 100644
--- a/doc/posix-functions/memset.texi
+++ b/doc/posix-functions/memset.texi
@@ -9,8 +9,6 @@ Gnulib module: memset
 Portability problems fixed by Gnulib:
 @itemize
 @item
-This function is missing on some older platforms.
-@item
 This function cannot be called from plain inline or extern inline functions
 on some platforms:
 OS X 10.8.
-- 
2.7.4

Reply via email to