autoconf-patches
[Top][All Lists]
Advanced

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

uintmax_t


From: Akim Demaille
Subject: uintmax_t
Date: 05 Oct 2001 19:42:33 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

Paul, I would very much like to have your opinion about this guy.  I
know we once talked about this, but we (I for one) forgot to finish
what was started.  Other headers are to follow (sys/times.h, memory.h
etc. come to my mind).

I'm especially interested in your checking the *order* in which the
headers are being tested: who is more std than the other?  stdint or
inttypes?  The choice below is based on what was done, but I suspect
the converse is to be made.

Also, I arrived to this while trying to import the Fileutils' mkstemp
into GNU M4, and fell on Jim's and your macros which do complex things
around unsigned long long.  After all, if unsigned long long is
present but not very satisfying, how could it be worse than unsigned
long?

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * lib/autoconf/general.m4 (_AC_INCLUDES_DEFAULT_REQUIREMENTS)
        (AC_INCLUDES_DEFAULT): Move to...
        * lib/autoconf/headers.m4: here.
        (_AC_INCLUDES_DEFAULT_REQUIREMENTS): Include both stdint.h and
        inttypes.h if compatible.
        * doc/autoconf.texi (Default Includes): Adjust.
        (Generic Types): Explain how to replace a type such as uintmax_t.

Index: NEWS
--- NEWS Mon, 01 Oct 2001 16:36:39 +0200 akim
+++ NEWS Fri, 05 Oct 2001 19:18:56 +0200 akim
@@ -12,6 +12,9 @@
   AC_TRY_CPP, AC_TRY_COMPILE, AC_TRY_LINK and AC_TRY_RUN.
 - Licensing
   The Autoconf manual is now distributed under the terms of the GNU FDL.
+- Type replacement
+  The use of AC_CHECK_TYPES to replace a missing type such as uintmax_t
+  is presented in full length.

 ** configure
 - $LINENO
@@ -55,6 +58,9 @@
   ac_top_builddir, ac_srcpath, ac_top_srcpath, ac_buildpath,
   ac_top_buildpath.

+** Default includes
+  inttypes.h *and then* stdint.h are included if compatible.
+  Previously, if inttypes.h *or else* stdint.h were loaded.
 
 * Major changes in Autoconf 2.52
 ** Documentation
Index: doc/autoconf.texi
--- doc/autoconf.texi Fri, 05 Oct 2001 16:26:43 +0200 akim
+++ doc/autoconf.texi Fri, 05 Oct 2001 19:21:05 +0200 akim
@@ -2988,10 +2988,9 @@ @node Default Includes
 #endif
 #if HAVE_INTTYPES_H
 # include <inttypes.h>
-#else
-# if HAVE_STDINT_H
+#endif
+#if HAVE_STDINT_H
 #  include <stdint.h>
-# endif
 #endif
 #if HAVE_UNISTD_H
 # include <unistd.h>
@@ -4581,6 +4580,54 @@ @node Generic Types
 compatibility, a simple heuristics, quite safe but not totally, is
 implemented.  In case of doubt, read the documentation of the former
 @code{AC_CHECK_TYPE}, see @ref{Obsolete Macros}.
+
address@hidden 1
+
address@hidden @code{uintmax_t}
+The modern uses of @code{AC_CHECK_TYPES} rely on the same basis as
address@hidden, and not as @code{AC_REPLACE_FUNCS}.  Support for
+automatic generation of @file{system.h} is planned in a distant future
+of Autoconf, but currently you have to handle it by hand.  Let's focus
+onto @code{uintmax_t}.
+
+The header in which @code{uintmax_t} is to be found is
address@hidden, but on some systems, @file{inttypes.h} and
address@hidden collide and cannot be included together.  Nevertheless
+both are part of the default includes (@xref{Default Includes}), checked
+for presence @emph{and compatibility} by @code{AC_CHECK_HEADERS}; hence
+you need not to be aware of this incompatibility.  Therefore
address@hidden([uintmax_t])} is enough to get all the need
+preprocessor symbols: @code{HAVE_UINTMAX_T}, @code{HAVE_STDINT_H}, and
address@hidden  There only remains to know, in case
address@hidden is not defined, what default type can be used:
address@hidden long long} if supported (AC_CHECK_TYPES([unsigned long
+long])), or else @code{unsigned long}.
+
+Finally, the @file{configure.ac} snippet is:
+
address@hidden
+AC_CHECK_TYPES([unsigned long long, uintmax_t])
address@hidden example
+
address@hidden
+and @file{system.h} should include:
+
address@hidden
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+#if !HAVE_UINTMAX_T
+# if HAVE_UNSIGNED_LONG_LONG
+typedef unsigned long long uintmax_t;
+# else
+typedef unsigned long uintmax_t;
+# endif
+#endif
address@hidden example


 @node Compilers and Preprocessors
Index: lib/autoconf/general.m4
--- lib/autoconf/general.m4 Mon, 01 Oct 2001 16:36:39 +0200 akim
+++ lib/autoconf/general.m4 Fri, 05 Oct 2001 18:39:17 +0200 akim
@@ -2055,82 +2055,6 @@ AC_DEFUN([AC_RUN_LOG],
              [echo "$as_me:$LINENO: AS_ESCAPE([$1])"])])


-## ------------------ ##
-## Default includes.  ##
-## ------------------ ##
-
-# Always use the same set of default headers for all the generic
-# macros.  It is easier to document, to extend, and to understand than
-# having specific defaults for each macro.
-
-# _AC_INCLUDES_DEFAULT_REQUIREMENTS
-# ---------------------------------
-# Required when AC_INCLUDES_DEFAULT uses its default branch.
-AC_DEFUN([_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 <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-#  include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-#  include <memory.h>
-# endif
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-#  include <stdint.h>
-# endif
-#endif
-#if HAVE_UNISTD_H
-# 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_INCLUDES_DEFAULT_REQUIREMENTS
-
-
-# AC_INCLUDES_DEFAULT([INCLUDES])
-# -------------------------------
-# If INCLUDES is empty, expand in default includes, otherwise in
-# INCLUDES.
-# In most cases INCLUDES is not double quoted as it should, and if
-# for instance INCLUDES = `#include <stdio.h>' then unless we force
-# a newline, the hash will swallow the closing paren etc. etc.
-# The usual failure.
-# Take no risk: for the newline.
-AC_DEFUN([AC_INCLUDES_DEFAULT],
-[m4_ifval([$1], [$1
-],
-          [AC_REQUIRE([_AC_INCLUDES_DEFAULT_REQUIREMENTS])dnl
-$ac_includes_default])])
-
-
-

 ## ------------------------ ##
 ## Examining declarations.  ##
Index: lib/autoconf/headers.m4
--- lib/autoconf/headers.m4 Tue, 18 Sep 2001 20:53:46 +0200 akim
+++ lib/autoconf/headers.m4 Fri, 05 Oct 2001 19:10:55 +0200 akim
@@ -53,7 +53,8 @@
 # Table of contents
 #
 # 1. Generic tests for headers
-# 2. Tests for specific headers
+# 2. Default includes
+# 3. Tests for specific headers


 ## ------------------------------ ##
@@ -195,8 +196,86 @@ AC_DEFUN([AC_CHECK_HEADERS],



+## --------------------- ##
+## 2. Default includes.  ##
+## --------------------- ##
+
+
+# Always use the same set of default headers for all the generic
+# macros.  It is easier to document, to extend, and to understand than
+# having specific defaults for each macro.
+
+# _AC_INCLUDES_DEFAULT_REQUIREMENTS
+# ---------------------------------
+# Required when AC_INCLUDES_DEFAULT uses its default branch.
+AC_DEFUN([_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 <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_UNISTD_H
+# 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_INCLUDES_DEFAULT_REQUIREMENTS
+
+
+# AC_INCLUDES_DEFAULT([INCLUDES])
+# -------------------------------
+# If INCLUDES is empty, expand in default includes, otherwise in
+# INCLUDES.
+# In most cases INCLUDES is not double quoted as it should, and if
+# for instance INCLUDES = `#include <stdio.h>' then unless we force
+# a newline, the hash will swallow the closing paren etc. etc.
+# The usual failure.
+# Take no risk: for the newline.
+AC_DEFUN([AC_INCLUDES_DEFAULT],
+[m4_ifval([$1], [$1
+],
+          [AC_REQUIRE([_AC_INCLUDES_DEFAULT_REQUIREMENTS])dnl
+$ac_includes_default])])
+
+
+
+
+
 ## ------------------------------- ##
-## 2. Tests for specific headers.  ##
+## 3. Tests for specific headers.  ##
 ## ------------------------------- ##


Index: lib/autoconf/types.m4
--- lib/autoconf/types.m4 Mon, 01 Oct 2001 16:36:39 +0200 akim
+++ lib/autoconf/types.m4 Fri, 05 Oct 2001 18:45:18 +0200 akim
@@ -78,7 +78,7 @@

 # _AC_CHECK_TYPE_NEW(TYPE,
 #                   [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-#                   [INCLUDES])
+#                   [INCLUDES = DEFAULT-INCLUDES])
 # ------------------------------------------------------------
 # Check whether the type TYPE is supported by the system, maybe via the
 # the provided includes.  This macro implements the former task of
@@ -157,7 +157,7 @@ m4_define([_AC_CHECK_TYPE_NEW],

 # AC_CHECK_TYPES(TYPES,
 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-#                [INCLUDES])
+#                [INCLUDES = DEFAULT-INCLUDES])
 # --------------------------------------------------------
 # TYPES is an m4 list.  There are no ambiguities here, we mean the newer
 # AC_CHECK_TYPE.
@@ -212,7 +212,7 @@ m4_define([_AC_CHECK_TYPE_MAYBE_TYPE_P],
 #  or
 # AC_CHECK_TYPE(TYPE,
 #              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-#              [INCLUDES])
+#              [INCLUDES = DEFAULT-INCLUDES])
 # -------------------------------------------------------
 #
 # Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW.



reply via email to

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