* lib/autoconf/headers.m4 (_AC_INCLUDES_DEFAULT_REQUIREMENTS):
   Include stddef.h, stdlib.h, and string.h unconditionally.
   Don't include memory.h at all.
   Don't use AC_HEADER_STDC.
   Don't check for stddef.h, stdlib.h, string.h, or memory.h.
   For compatibility, unconditionally define STDC_HEADERS,
   HAVE_STDLIB_H, and HAVE_STRING_H.
   (AN_HEADER list): Remove C89 headers, and memory.h from list.
   (AC_HEADER_STDC): AU_DEFUN as an explicit invocation of
   _AC_INCLUDES_DEFAULT_REQUIREMENTS.
   (AC_HEADER_TIME): AU_DEFUN, and define TIME_WITH_SYS_TIME unconditionally
   as long as sys/time.h is present.
   (AC_USG, AC_MEMORY_H): Assume existence of string.h.
 * lib/autoconf/functions.m4 (_AC_FUNC_MALLOC_IF, _AC_FUNC_REALLOC_IF):
   Don't use AC_HEADER_STDC. Assume stdlib.h exists.
   (AC_FUNC_MKTIME): Don't use AC_HEADER_TIME.
   (AC_FUNC_ALLOCA): Assume stdlib.h exists.
   (_AC_LIBOBJ_FNMATCH): Assume wchar.h and wctype.h exist.
   (_AC_LIBOBJ_GETLOADAVG): Assume locale.h exists.
   (AC_FUNC_MMAP): Assume stdlib.h exists.
 * tests/tools.at: Use AC_WORDS_BIGENDIAN instead of AC_STDC_HEADERS in
   autoupdate test.

 * NEWS, doc/autoconf.texi: Document changes. Remove obsolete advice.

Signed-off-by: Zack Weinberg <za...@panix.com>
---
 NEWS                      |   24 ++++
 doc/autoconf.texi         |  314 +++++++++++++++++----------------------------
 lib/autoconf/functions.m4 |   35 +----
 lib/autoconf/headers.m4   |  179 ++++++++++----------------
 tests/tools.at            |    6 +-
 5 files changed, 218 insertions(+), 340 deletions(-)

diff --git a/NEWS b/NEWS
index 1378388..623b008 100644
--- a/NEWS
+++ b/NEWS
@@ -65,6 +65,30 @@ GNU Autoconf NEWS - User visible changes.
 - AT_TESTED arguments can use variable or command substitutions, including
   in particular $EXEEXT
 
+- AC_INCLUDES_DEFAULT has been streamlined.  It now assumes that the
+  ISO C90 headers 'stdlib.h' and 'string.h' are unconditionally
+  available, and does not include the pre-standard header 'memory.h'
+  at all.  If the POSIX header 'strings.h' exists, it will be
+  included; it is assumed to be safe to include both 'string.h' and
+  'strings.h' in the same source file.  We are not aware of any
+  current system that violates any of the above assumptions.
+
+  For compatibility's sake, the C preprocessor macros STDC_HEADERS,
+  HAVE_STDLIB_H, and HAVE_STRING_H are defined unconditionally.
+  These preprocessor macros should be considered obsolescent.
+
+  Future releases of Autoconf may reduce the set of headers checked
+  for by AC_INCLUDES_DEFAULT.
+
+- AC_HEADER_STDC and AC_HEADER_TIME are now stubs which will be
+  removed from 'configure.ac' by 'autoupdate'.  For compatibility's
+  sake, the stubs (and their 'autoupdate' replacements) continue to
+  define the C preprocessor macros STDC_HEADERS and TIME_WITH_SYS_TIME,
+  respectively, but without actually checking for the ancient systems
+  where formerly those macros would not be defined.
+
+  These macros were already labeled obsolescent in the manual.
+
 * Noteworthy changes in release 2.69 (2012-04-24) [stable]
 
 ** Autoconf now requires perl 5.6 or better (but generated configure
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index a68dc07..01d714e 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -3881,15 +3881,9 @@ protected includes, such as:
 
 @example
 @group
-#ifdef TIME_WITH_SYS_TIME
+#include <time.h>
+#ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
 #endif
 @end group
 @end example
@@ -3904,27 +3898,20 @@ of includes:
 
 @defmac AC_INCLUDES_DEFAULT (@ovar{include-directives})
 @acindex{INCLUDES_DEFAULT}
-Expand to @var{include-directives} if defined, otherwise to:
+Expand to @var{include-directives} if present and nonempty, otherwise to:
 
 @example
 @group
+#include <stddef.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
 #ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
 #endif
-#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#include <stddef.h>
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#endif
 #ifdef HAVE_STRINGS_H
 # include <strings.h>
 #endif
@@ -3940,14 +3927,12 @@ Expand to @var{include-directives} if defined, otherwise to:
 @end group
 @end example
 
-If the default includes are used, then check for the presence of these
-headers and their compatibility, i.e., you don't need to run
-@code{AC_HEADER_STDC}, nor check for @file{stdlib.h} etc.
-
-These headers are checked for in the same order as they are included.
-For instance, on some systems @file{string.h} and @file{strings.h} both
-exist, but conflict.  Then @code{HAVE_STRING_H} is defined, not
-@code{HAVE_STRINGS_H}.
+Using this macro without @var{include-directives} has the side effect of
+checking for @file{sys/types.h}, @file{sys/stat.h}, @file{strings.h},
+@file{inttypes.h}, @file{stdint.h}, and @file{unistd.h}, as if by
+@code{AC_CHECK_HEADERS}.  For backward compatibility's sake, it also
+unconditionally defines @code{HAVE_STRING_H}, @code{HAVE_STDLIB_H}, and
+@code{STDC_HEADERS}.
 @end defmac
 
 @node Alternative Programs
@@ -4876,9 +4861,7 @@ like the following, to declare it properly.
 
 @example
 @group
-#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
 #include <stddef.h>
 #ifdef HAVE_ALLOCA_H
 # include <alloca.h>
@@ -5733,6 +5716,29 @@ Posix Headers, gnulib, GNU gnulib} and @ref{Glibc Header File
 Substitutes, , Glibc Headers, gnulib, GNU gnulib}.  Please help us keep
 the gnulib list as complete as possible.
 
+When we say that a header ``may require'' some set of other headers, we
+mean that it may be necessary for you to manually include those other
+headers first, or the contents of the first header will fail to compile.
+When checking for these headers, you must provide the
+potentially-required headers in the @var{includes} argument to
+@code{AC_CHECK_HEADER} or @code{AC_CHECK_HEADERS}, or the check will
+fail spuriously.  @code{AC_INCLUDES_DEFAULT} (@pxref{Default Includes})
+arranges to include a number of common requirements and should normally
+come first in your @var{includes}.  For example, @file{net/if.h} may
+require @file{sys/types.h}, @file{sys/socket.h}, or both, and
+@code{AC_INCLUDES_DEFAULT} handles @file{sys/types.h} but not
+@file{sys/socket.h}, so you should check for it like this:
+
+@example
+AC_CHECK_HEADERS([sys/socket.h])
+AC_CHECK_HEADERS([net/if.h], [], [],
+[AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+])
+@end example
+
 @table @asis
 
 @item @file{limits.h}
@@ -5741,96 +5747,67 @@ In C99 and later, @file{limits.h} defines @code{LLONG_MIN},
 environments (e.g., default GCC 4.0.2 + glibc 2.4) do not
 define them.
 
+@item @file{memory.h}
+@hdrindex{memory.h}
+This header file is obsolete; use @file{string.h} instead.
+
+@item @file{strings.h}
+@hdrindex{strings.h}
+On some systems, this is the only header that declares
+@code{strcasecmp}, @code{strncasecmp}, and @code{ffs}.
+
+This header may or may not include @file{string.h} for you.  However, on
+all recent systems it is safe to include both @file{string.h} and
+@file{strings.h} in the same source file.
+
 @item @file{inttypes.h} vs.@: @file{stdint.h}
 @hdrindex{inttypes.h}
 @hdrindex{stdint.h}
-In C99 and later, @file{inttypes.h} includes
-@file{stdint.h}, so there's no need to include @file{stdint.h}
-separately in a standard environment.  Some implementations have
-@file{inttypes.h} but not @file{stdint.h} (e.g., Solaris 7), but we don't
-know of any implementation that has @file{stdint.h} but not
-@file{inttypes.h}.
+C99 specifies that @file{inttypes.h} includes @file{stdint.h}, so there's
+no need to include @file{stdint.h} separately in a standard environment.
+However, some implementations have @file{inttypes.h} but not @file{stdint.h}
+(e.g., Solaris 7), and some have @file{stdint.h} but not @file{inttypes.h}
+(e.g. MSVC 2012).  Therefore, it is necessary to check for each and include
+each only if available.
 
 @item @file{linux/irda.h}
 @hdrindex{linux/irda.h}
-It requires @file{linux/types.h} and @file{sys/socket.h}.
+This header may require @file{linux/types.h} and/or @file{sys/socket.h}.
 
 @item @file{linux/random.h}
 @hdrindex{linux/random.h}
-It requires @file{linux/types.h}.
+This header may require @file{linux/types.h}.
 
 @item @file{net/if.h}
 @hdrindex{net/if.h}
-On Darwin, this file requires that @file{sys/socket.h} be included
-beforehand.  One should run:
-
-@example
-AC_CHECK_HEADERS([sys/socket.h])
-AC_CHECK_HEADERS([net/if.h], [], [],
-[#include <stdio.h>
-#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#include <stddef.h>
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-])
-@end example
+This header may require @file{sys/types.h} and/or @file{sys/socket.h}.
 
 @item @file{netinet/if_ether.h}
 @hdrindex{netinet/if_ether.h}
-On Darwin, this file requires that @file{stdio.h} and
-@file{sys/socket.h} be included beforehand.  One should run:
-
-@example
-AC_CHECK_HEADERS([sys/socket.h])
-AC_CHECK_HEADERS([netinet/if_ether.h], [], [],
-[#include <stdio.h>
-#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#include <stddef.h>
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-])
-@end example
-
-@item @file{stdint.h}
-See above, item @file{inttypes.h} vs.@: @file{stdint.h}.
-
-@item @file{stdlib.h}
-@hdrindex{stdlib.h}
-On many systems (e.g., Darwin), @file{stdio.h} is a prerequisite.
+This header may require some combination of @file{sys/types.h},
+@file{sys/socket.h}, @file{netinet/in.h}, and @file{net/if.h}.
 
 @item @file{sys/mount.h}
 @hdrindex{sys/mount.h}
-On FreeBSD 4.8 on ia32 and using gcc version 2.95.4,
-@file{sys/params.h} is a prerequisite.
+This header may require @file{sys/params.h}.
 
 @item @file{sys/ptem.h}
 @hdrindex{sys/ptem.h}
-On Solaris 8, @file{sys/stream.h} is a prerequisite.
+This header may require @file{sys/stream.h}.
 
 @item @file{sys/socket.h}
 @hdrindex{sys/socket.h}
-On Darwin, @file{stdlib.h} is a prerequisite.
+This header may require @file{sys/types.h}.
 
 @item @file{sys/ucred.h}
 @hdrindex{sys/ucred.h}
-On Tru64 5.1, @file{sys/types.h} is a prerequisite.
+This header may require @file{sys/types.h}.
 
 @item @file{X11/extensions/scrnsaver.h}
 @hdrindex{X11/extensions/scrnsaver.h}
 Using XFree86, this header requires @file{X11/Xlib.h}, which is probably
 so required that you might not even consider looking for it.
 
-@example
-AC_CHECK_HEADERS([X11/extensions/scrnsaver.h], [], [],
-[[#include <X11/Xlib.h>
-]])
-@end example
 @end table
 
 
@@ -6024,91 +6001,45 @@ does not.
 @defmac AC_HEADER_STDC
 @acindex{HEADER_STDC}
 @cvindex STDC_HEADERS
-@hdrindex{stdlib.h}
-@hdrindex{stdarg.h}
-@hdrindex{string.h}
-@hdrindex{float.h}
+@hdrindex{assert.h}
 @hdrindex{ctype.h}
+@hdrindex{errno.h}
+@hdrindex{float.h}
+@hdrindex{iso646.h}
+@hdrindex{limits.h}
+@hdrindex{locale.h}
+@hdrindex{math.h}
+@hdrindex{setjmp.h}
+@hdrindex{signal.h}
+@hdrindex{stdarg.h}
+@hdrindex{stddef.h}
+@hdrindex{stdio.h}
+@hdrindex{stdlib.h}
+@hdrindex{string.h}
+@hdrindex{time.h}
+@hdrindex{wchar.h}
+@hdrindex{wctype.h}
 @caindex header_stdc
-Define @code{STDC_HEADERS} if the system has C header files
-conforming to ANSI C89 (ISO C90).
-Specifically, this macro checks for @file{stdlib.h}, @file{stdarg.h},
-@file{string.h}, and @file{float.h}; if the system has those, it
-probably has the rest of the C89 header files.  This macro also
-checks whether @file{string.h} declares @code{memchr} (and thus
-presumably the other @code{mem} functions), whether @file{stdlib.h}
-declare @code{free} (and thus presumably @code{malloc} and other related
-functions), and whether the @file{ctype.h} macros work on characters
-with the high bit set, as the C standard requires.
 
-If you use this macro, your code can refer to @code{STDC_HEADERS} to
-determine whether the system has conforming header files (and probably C
-library functions).
-
-This macro caches its result in the @code{ac_cv_header_stdc} variable.
-
-This macro is obsolescent, as current systems have conforming header
-files.  New programs need not use this macro.
-
-@hdrindex{string.h}
-@hdrindex{strings.h}
-Nowadays @file{string.h} is part of the C standard and declares functions like
-@code{strcpy}, and @file{strings.h} is standardized by Posix and declares
-BSD functions like @code{bcopy}; but
-historically, string functions were a major sticking point in this area.
-If you still want to worry about portability to ancient systems without
-standard headers, there is so much variation
-that it is probably easier to declare the functions you use than to
-figure out exactly what the system header files declare.  Some ancient systems
-contained a mix of functions from the C standard and from BSD;
-some were mostly standard but lacked @samp{memmove}; some defined the
-BSD functions as macros in @file{string.h} or
-@file{strings.h}; some had only the BSD functions but
-@file{string.h}; some declared the memory functions in @file{memory.h},
-some in @file{string.h}; etc.  It is probably sufficient to check for
-one string function and one memory function; if the library had the
-standard versions of those then it probably had most of the others.
-If you put the following in @file{configure.ac}:
-
-@example
-# This example is obsolescent.
-# Nowadays you can omit these macro calls.
-AC_HEADER_STDC
-AC_CHECK_FUNCS([strchr memcpy])
-@end example
-
-@noindent
-then, in your code, you can use declarations like this:
-
-@example
-@group
-/* This example is obsolescent.
-   Nowadays you can just #include <string.h>.  */
-#ifdef STDC_HEADERS
-# include <string.h>
-#else
-# ifndef HAVE_STRCHR
-#  define strchr index
-#  define strrchr rindex
-# endif
-char *strchr (), *strrchr ();
-# ifndef HAVE_MEMCPY
-#  define memcpy(d, s, n) bcopy ((s), (d), (n))
-#  define memmove(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-@end group
-@end example
-
-@noindent
-If you use a function like @code{memchr}, @code{memset}, @code{strtok},
-or @code{strspn}, which have no BSD equivalent, then macros don't
-suffice to port to ancient hosts; you must provide an implementation of
-each function.  An easy
-way to incorporate your implementations only when needed (since the ones
-in system C libraries may be hand optimized) is to, taking @code{memchr}
-for example, put it in @file{memchr.c} and use
-@samp{AC_REPLACE_FUNCS([memchr])}.
+This macro is obsolescent.  Its sole effect is to make sure that all the
+headers that are included by @code{AC_INCLUDES_DEFAULT} (@pxref{Default
+Includes}), but not part of ISO C90, have been checked for.
+
+All hosted environments that are still of interest for portable code
+provide all of the headers specified in ISO C90 (as amended in 1995):
+@file{assert.h}, @file{ctype.h}, @file{errno.h}, @file{float.h},
+@file{iso646.h}, @file{limits.h}, @file{locale.h}, @file{math.h},
+@file{setjmp.h}, @file{signal.h}, @file{stdarg.h}, @file{stddef.h},
+@file{stdio.h}, @file{stdlib.h}, @file{string.h}, @file{time.h},
+@file{wchar.h}, and @file{wctype.h}.
+
+If your program needs to be portable to a @emph{freestanding}
+environment, such as an embedded OS that doesn't provide all of the
+facilities of the C90 standard library, you should use
+@code{AC_CHECK_HEADERS} to check for the headers that might not be
+available there.  Note that @code{AC_INCLUDES_DEFAULT} assumes that
+@file{stddef.h}, @file{stdio.h}, @file{stdlib.h}, and @file{string.h}
+are unconditionally available.
 @end defmac
 
 @defmac AC_HEADER_SYS_WAIT
@@ -6177,38 +6108,23 @@ The way to check whether the system supports Posix is:
 @hdrindex{sys/time.h}
 @caindex header_time
 If a program may include both @file{time.h} and @file{sys/time.h},
-define @code{TIME_WITH_SYS_TIME}.  On some ancient systems,
-@file{sys/time.h} included @file{time.h}, but @file{time.h} was not
-protected against multiple inclusion, so programs could not explicitly
-include both files.  This macro is useful in programs that use, for
-example, @code{struct timeval} as well as
-@code{struct tm}.  It is best used in conjunction with
-@code{HAVE_SYS_TIME_H}, which can be checked for using
-@code{AC_CHECK_HEADERS([sys/time.h])}.
+define @code{TIME_WITH_SYS_TIME}.
+
+This macro is obsolescent, as all current systems that provide
+@file{sys/time.h} allow it to be used together with @file{time.h}, and
+@file{time.h} is ubiquitous.  If you need both headers, check for
+@file{sys/time.h} using @code{AC_CHECK_HEADERS}, then use
 
 @example
 @group
-#ifdef TIME_WITH_SYS_TIME
+#include <time.h>
+#ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
 #endif
 @end group
 @end example
-
-@noindent
-This macro caches its result in the @code{ac_cv_header_time} variable.
-
-This macro is obsolescent, as current systems can include both files
-when they exist.  New programs need not use this macro.
 @end defmac
 
-
 @defmac AC_HEADER_TIOCGWINSZ
 @acindex{HEADER_TIOCGWINSZ}
 @cvindex GWINSZ_IN_SYS_IOCTL
@@ -23547,9 +23463,7 @@ Replaced by @code{AC_HEADER_MAJOR} (@pxref{AC_HEADER_MAJOR}).
 Used to define @code{NEED_MEMORY_H} if the @code{mem} functions were
 defined in @file{memory.h}.  Today it is equivalent to
 @samp{AC_CHECK_HEADERS([memory.h])} (@pxref{AC_CHECK_HEADERS}).  Adjust
-your code to depend upon
-@code{HAVE_MEMORY_H}, not @code{NEED_MEMORY_H}; see @ref{Standard
-Symbols}.
+your code to get the @code{mem} functions from @file{string.h} instead.
 @end defmac
 
 @defmac AC_MINGW32
@@ -23799,7 +23713,9 @@ Replaced by @code{AC_HEADER_STAT} (@pxref{AC_HEADER_STAT}).
 
 @defmac AC_STDC_HEADERS
 @acindex{STDC_HEADERS}
-Replaced by @code{AC_HEADER_STDC} (@pxref{AC_HEADER_STDC}).
+Replaced by @code{AC_HEADER_STDC} (@pxref{AC_HEADER_STDC}), which
+is itself obsolete.  Nowadays it is safe to assume the facilities of C90
+exist.
 @end defmac
 
 @defmac AC_STRCOLL
@@ -23897,7 +23813,9 @@ Replaced by @code{AC_STRUCT_TIMEZONE} (@pxref{AC_STRUCT_TIMEZONE}).
 
 @defmac AC_TIME_WITH_SYS_TIME
 @acindex{TIME_WITH_SYS_TIME}
-Replaced by @code{AC_HEADER_TIME} (@pxref{AC_HEADER_TIME}).
+Replaced by @code{AC_HEADER_TIME} (@pxref{AC_HEADER_TIME}), which is
+itself obsolete; nowadays one need only do
+@samp{AC_CHECK_HEADERS([sys/time.h])}.
 @end defmac
 
 @defmac AC_TRY_COMPILE (@var{includes}, @var{function-body}, @
@@ -24043,7 +23961,7 @@ Same as @samp{AC_CHECK_HEADERS([unistd.h])} (@pxref{AC_CHECK_HEADERS}).
 @defmac AC_USG
 @acindex{USG}
 @cvindex USG
-Define @code{USG} if the BSD string functions are defined in
+Define @code{USG} if the BSD string functions are @emph{not} defined in
 @file{strings.h}.  You should no longer depend upon @code{USG}, but on
 @code{HAVE_STRING_H}; see @ref{Standard Symbols}.
 @end defmac
diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index b544fcd..eb8afb8 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -380,9 +380,7 @@ AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
   ac_cv_func_alloca_works=yes
 else
   AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+[[#include <stdlib.h>
 #include <stddef.h>
 #ifndef alloca
 # ifdef __GNUC__
@@ -566,7 +564,6 @@ AC_REQUIRE([AC_FUNC_ALLOCA])dnl
 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
 AC_CHECK_DECLS([getenv])
 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmempcpy])
-AC_CHECK_HEADERS([wchar.h wctype.h])
 AC_LIBOBJ([fnmatch])
 AC_CONFIG_LINKS([$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h])
 AC_DEFINE(fnmatch, rpl_fnmatch,
@@ -683,7 +680,6 @@ AC_CHECK_HEADER(sys/dg_sys_info.h,
  AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
  AC_CHECK_LIB(dgc, dg_sys_info)])
 
-AC_CHECK_HEADER(locale.h)
 AC_CHECK_FUNCS(setlocale)
 
 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
@@ -905,17 +901,11 @@ fi
 # ------------------------------------
 # If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
 AC_DEFUN([_AC_FUNC_MALLOC_IF],
-[AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
-AC_CHECK_HEADERS(stdlib.h)
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
 AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
 [AC_RUN_IFELSE(
 [AC_LANG_PROGRAM(
-[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-# include <stdlib.h>
-#else
-char *malloc ();
-#endif
+[[#include <stdlib.h>
 ]],
 		 [return ! malloc (0);])],
 	       [ac_cv_func_malloc_0_nonnull=yes],
@@ -1013,8 +1003,7 @@ test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
 # --------------
 AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
 AC_DEFUN([AC_FUNC_MKTIME],
-[AC_REQUIRE([AC_HEADER_TIME])dnl
-AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
+[AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
 AC_CHECK_FUNCS_ONCE(alarm)
 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
@@ -1228,7 +1217,7 @@ AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
 AN_FUNCTION([mmap], [AC_FUNC_MMAP])
 AC_DEFUN([AC_FUNC_MMAP],
 [AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
-AC_CHECK_HEADERS_ONCE([stdlib.h unistd.h sys/param.h])
+AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h])
 AC_CHECK_FUNCS([getpagesize])
 AC_CACHE_CHECK([for working mmap], [ac_cv_func_mmap_fixed_mapped],
 [AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
@@ -1260,10 +1249,6 @@ AC_CACHE_CHECK([for working mmap], [ac_cv_func_mmap_fixed_mapped],
 #include <fcntl.h>
 #include <sys/mman.h>
 
-#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
-char *malloc ();
-#endif
-
 /* This mess was copied from the GNU getpagesize.h.  */
 #ifndef HAVE_GETPAGESIZE
 # ifdef _SC_PAGESIZE
@@ -1424,17 +1409,11 @@ AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
 # -------------------------------------
 # If `realloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
 AC_DEFUN([_AC_FUNC_REALLOC_IF],
-[AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
-AC_CHECK_HEADERS(stdlib.h)
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
 AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
 [AC_RUN_IFELSE(
 [AC_LANG_PROGRAM(
-[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-# include <stdlib.h>
-#else
-char *realloc ();
-#endif
+[[#include <stdlib.h>
 ]],
 		 [return ! realloc (0, 0);])],
 	       [ac_cv_func_realloc_0_nonnull=yes],
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 0474e63..6fe1380 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -227,28 +227,21 @@ m4_define([_AC_HEADERS_EXPANSION],
 # _AC_INCLUDES_DEFAULT_REQUIREMENTS
 # ---------------------------------
 # Required when AC_INCLUDES_DEFAULT uses its default branch.
-AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
+AC_DEFUN_ONCE([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
 [m4_divert_text([DEFAULTS],
 [# Factoring default headers for most tests.
 dnl If ever you change this variable, please keep autoconf.texi in sync.
 ac_includes_default="\
+#include <stddef.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
 #ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
 #endif
-#if defined STDC_HEADERS || defined HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#include <stddef.h>
-#ifdef HAVE_STRING_H
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#endif
 #ifdef HAVE_STRINGS_H
 # include <strings.h>
 #endif
@@ -262,11 +255,19 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 ])dnl
-AC_REQUIRE([AC_HEADER_STDC])dnl
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h],
-		 [], [], $ac_includes_default)
+AC_CHECK_HEADERS([sys/types.h sys/stat.h strings.h inttypes.h stdint.h unistd.h],
+                 [], [], [$ac_includes_default])
+dnl For backward compatibility, provide unconditional AC_DEFINEs of
+dnl HAVE_STDLIB_H, HAVE_STRING_H, and STDC_HEADERS.
+AC_DEFINE(HAVE_STDLIB_H, 1,
+  [Always define to 1, for backward compatibility.
+   You can assume <stdlib.h> exists.])
+AC_DEFINE(HAVE_STRING_H, 1,
+  [Always define to 1, for backward compatibility.
+   You can assume <string.h> exists.])
+AC_DEFINE(STDC_HEADERS, 1,
+  [Always define to 1, for backward compatibility.
+   You can assume the C90 standard headers exist.])
 ])# _AC_INCLUDES_DEFAULT_REQUIREMENTS
 
 
@@ -293,23 +294,22 @@ $ac_includes_default])])
 ## 3. Headers to check with AC_CHECK_HEADERS.  ##
 ## ------------------------------------------- ##
 
-# errno.h is portable.
+# There is no longer any need to check for headers that are part of
+# ISO C90 (as amended): assert.h, ctype.h, errno.h, float.h, iso646.h,
+# limits.h, locale.h, math.h, setjmp.h, signal.h, stdarg.h, stddef.h,
+# stdio.h, stdlib.h, string.h, time.h, wchar.h, wctype.h.
 
 AN_HEADER([OS.h],               [AC_CHECK_HEADERS])
 AN_HEADER([argz.h],             [AC_CHECK_HEADERS])
 AN_HEADER([arpa/inet.h],        [AC_CHECK_HEADERS])
 AN_HEADER([fcntl.h],            [AC_CHECK_HEADERS])
 AN_HEADER([fenv.h],             [AC_CHECK_HEADERS])
-AN_HEADER([float.h],            [AC_CHECK_HEADERS])
 AN_HEADER([fs_info.h],          [AC_CHECK_HEADERS])
 AN_HEADER([inttypes.h],         [AC_CHECK_HEADERS])
 AN_HEADER([langinfo.h],         [AC_CHECK_HEADERS])
 AN_HEADER([libintl.h],          [AC_CHECK_HEADERS])
-AN_HEADER([limits.h],           [AC_CHECK_HEADERS])
-AN_HEADER([locale.h],           [AC_CHECK_HEADERS])
 AN_HEADER([mach/mach.h],        [AC_CHECK_HEADERS])
 AN_HEADER([malloc.h],           [AC_CHECK_HEADERS])
-AN_HEADER([memory.h],           [AC_CHECK_HEADERS])
 AN_HEADER([mntent.h],           [AC_CHECK_HEADERS])
 AN_HEADER([mnttab.h],           [AC_CHECK_HEADERS])
 AN_HEADER([netdb.h],            [AC_CHECK_HEADERS])
@@ -319,11 +319,8 @@ AN_HEADER([nlist.h],            [AC_CHECK_HEADERS])
 AN_HEADER([paths.h],            [AC_CHECK_HEADERS])
 AN_HEADER([sgtty.h],            [AC_CHECK_HEADERS])
 AN_HEADER([shadow.h],           [AC_CHECK_HEADERS])
-AN_HEADER([stddef.h],           [AC_CHECK_HEADERS])
 AN_HEADER([stdint.h],           [AC_CHECK_HEADERS])
 AN_HEADER([stdio_ext.h],        [AC_CHECK_HEADERS])
-AN_HEADER([stdlib.h],           [AC_CHECK_HEADERS])
-AN_HEADER([string.h],           [AC_CHECK_HEADERS])
 AN_HEADER([strings.h],          [AC_CHECK_HEADERS])
 AN_HEADER([sys/acl.h],          [AC_CHECK_HEADERS])
 AN_HEADER([sys/file.h],         [AC_CHECK_HEADERS])
@@ -351,10 +348,6 @@ AN_HEADER([utime.h],            [AC_CHECK_HEADERS])
 AN_HEADER([utmp.h],             [AC_CHECK_HEADERS])
 AN_HEADER([utmpx.h],            [AC_CHECK_HEADERS])
 AN_HEADER([values.h],           [AC_CHECK_HEADERS])
-AN_HEADER([wchar.h],            [AC_CHECK_HEADERS])
-AN_HEADER([wctype.h],           [AC_CHECK_HEADERS])
-
-
 
 ## ------------------------------- ##
 ## 4. Tests for specific headers.  ##
@@ -592,7 +585,7 @@ AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
 
 # AC_HEADER_STDBOOL
 # -----------------
-# Define HAVE_STDBOOL_H if tdbool.h that conforms to C99.
+# Define HAVE_STDBOOL_H if the system provides stdbool.h that conforms to C99.
 AC_DEFUN([AC_HEADER_STDBOOL],
 [AC_CHECK_HEADER_STDBOOL
 if test $ac_cv_header_stdbool_h = yes; then
@@ -601,62 +594,17 @@ fi
 ])# AC_HEADER_STDBOOL
 
 
-# AC_HEADER_STDC
+# AU::AC_HEADER_STDC
 # --------------
-AC_DEFUN([AC_HEADER_STDC],
-[AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-]])],
-		    [ac_cv_header_stdc=yes],
-		    [ac_cv_header_stdc=no])
-
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
-fi
-
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  AC_RUN_IFELSE([AC_LANG_SOURCE(
-[[#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-		   (('a' <= (c) && (c) <= 'i') \
-		     || ('j' <= (c) && (c) <= 'r') \
-		     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-	|| toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}]])], , ac_cv_header_stdc=no, :)
-fi])
-if test $ac_cv_header_stdc = yes; then
-  AC_DEFINE(STDC_HEADERS, 1,
-	    [Define to 1 if you have the ANSI C header files.])
-fi
-])# AC_HEADER_STDC
-
+AU_DEFUN([AC_HEADER_STDC],
+[
+# Autoupdate added the following line to ensure that your configure
+# script's behavior did not change.  It is probably safe to remove.
+_AC_INCLUDES_DEFAULT_REQUIREMENTS
+],
+ [The preprocessor macro `STDC_HEADERS' is obsolete.  Except in
+  unusual embedded environments, you can safely include all ISO C90
+  headers unconditionally.])
 
 # AC_HEADER_SYS_WAIT
 # ------------------
@@ -685,25 +633,23 @@ fi
 ])# AC_HEADER_SYS_WAIT
 
 
-# AC_HEADER_TIME
+# AU::AC_HEADER_TIME
 # --------------
-AC_DEFUN([AC_HEADER_TIME],
-[AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
-  ac_cv_header_time,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-],
-[if ((struct tm *) 0)
-return 0;])],
-		   [ac_cv_header_time=yes],
-		   [ac_cv_header_time=no])])
-if test $ac_cv_header_time = yes; then
+AU_DEFUN([AC_HEADER_TIME],
+[AC_CHECK_HEADERS([sys/time.h])
+# Obsolete code to be removed.
+if test $ac_cv_header_sys_time_h = yes; then
   AC_DEFINE(TIME_WITH_SYS_TIME, 1,
 	    [Define to 1 if you can safely include both <sys/time.h>
-	     and <time.h>.])
+	     and <time.h>.  This macro is obsolete.])
 fi
-])# AC_HEADER_TIME
+# End of obsolete code.
+], [Update your code to rely only on HAVE_SYS_TIME_H,
+then remove this warning and the obsolete code below it.
+All current systems provide time.h; it need not be checked for.
+Not all systems provide sys/time.h, but those that do, all allow
+you to include it and time.h simultaneously.])
+# AC_HEADER_TIME
 
 
 # _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
@@ -765,9 +711,10 @@ AU_DEFUN([AC_UNISTD_H],
 
 # AU::AC_USG
 # ----------
-# Define `USG' if string functions are in strings.h.
+# Define `USG' if string functions are *not* in strings.h.
 AU_DEFUN([AC_USG],
-[AC_MSG_CHECKING([for BSD string and memory functions])
+[# Obsolete code to be removed.
+AC_MSG_CHECKING([for BSD string and memory functions])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
 				[[rindex(0, 0); bzero(0, 0);]])],
 	       [AC_MSG_RESULT(yes)],
@@ -776,9 +723,13 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
 			  [Define to 1 if you do not have <strings.h>, index,
 			   bzero, etc... This symbol is obsolete, you should
 			   not depend upon it.])])
-AC_CHECK_HEADERS(string.h)],
-[Remove `AC_MSG_CHECKING', `AC_LINK_IFELSE' and this warning
-when you adjust your code to use HAVE_STRING_H.])
+AC_DEFINE(HAVE_STRING_H, 1,
+          [Define to 1 if you have the <string.h> header file.])
+# End of obsolete code.
+],
+[Update your code to use string.h, then remove this
+warning and the code below it. It is not necessary
+to check for string.h.])
 
 
 # AU::AC_MEMORY_H
@@ -795,13 +746,19 @@ when you adjust your code to use HAVE_STRING_H.])
 # But it is better to check for both headers, and alias NEED_MEMORY_H to
 # HAVE_MEMORY_H.
 AU_DEFUN([AC_MEMORY_H],
-[AC_CHECK_HEADER(memory.h,
-		[AC_DEFINE([NEED_MEMORY_H], 1,
-			   [Same as `HAVE_MEMORY_H', don't depend on me.])])
-AC_CHECK_HEADERS(string.h memory.h)],
-[Remove this warning and
-`AC_CHECK_HEADER(memory.h, AC_DEFINE(...))' when you adjust your code to
-use HAVE_STRING_H and HAVE_MEMORY_H, not NEED_MEMORY_H.])
+[# Obsolete code to be removed.
+AC_CHECK_HEADERS(memory.h)
+if test $ac_cv_header_memory_h = yes; then
+   AC_DEFINE([NEED_MEMORY_H], 1,
+             [Same as `HAVE_MEMORY_H', don't depend on me.])
+fi
+AC_DEFINE(HAVE_STRING_H, 1,
+          [Define to 1 if you have the <string.h> header file.])
+# End of obsolete code.
+],
+[Update your code to use string.h, then remove this
+warning and the code below it.  It is not necessary
+to check for string.h.])
 
 
 # AU::AC_DIR_HEADER
diff --git a/tests/tools.at b/tests/tools.at
index cace11a..294fb60 100644
--- a/tests/tools.at
+++ b/tests/tools.at
@@ -955,7 +955,7 @@ AC_DEFUN([FOO], [$#])
 AU_ALIAS([BAZ],[FOO])
 test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1
 AC_PROG_CC
-AC_STDC_HEADERS
+AC_WORDS_BIGENDIAN
 AC_OUTPUT
 ]])
 
@@ -963,8 +963,8 @@ AC_OUTPUT
 AT_CHECK_AUTOUPDATE
 AT_CHECK_AUTOCONF
 AT_CHECK_CONFIGURE
-AT_CHECK([grep 'AC_HEADER_STDC[(]' configure.ac], 1, [ignore], [ignore])
-AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
+AT_CHECK([grep 'AC_C_BIGENDIAN[(]' configure.ac], 1, [ignore], [ignore])
+AT_CHECK([grep 'AC_C_BIGENDIAN' configure.ac], 0, [ignore], [ignore])
 
 AT_CLEANUP
 

Reply via email to