]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
2006-07-07 Paolo Bonzini <bonzini@gnu.org>
authorPaolo Bonzini <bonzini@gnu.org>
Fri, 7 Jul 2006 14:21:57 +0000 (14:21 +0000)
committerPaolo Bonzini <bonzini@gnu.org>
Fri, 7 Jul 2006 14:21:57 +0000 (14:21 +0000)
* doc/autoconf.texi (Generic compiler characteristics):
Document AC_COMPUTE_INT.  Fix wrong statements on Default
Includes for AC_CHECK_SIZEOF and AC_CHECK_ALIGNOF.

* lib/autoconf/general.m4 (AC_COMPUTE_INT): New.
(_AC_COMPUTE_INT): Add obsoletion warnings.
* lib/autoconf/types.m4 (AC_CHECK_SIZEOF, AC_CHECK_ALIGNOF): Use
AC_COMPUTE_INT.

* NEWS: Document change.

ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/general.m4
lib/autoconf/types.m4
tests/mktests.sh

index 96acb228bd9117fe2c31834a0b36a3fd8aa26ada..8bcb81dec31a4f3786a2ed74da0c92a145d0b3c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-07-07  Paolo Bonzini  <bonzini@gnu.org>
+
+       * doc/autoconf.texi (Generic compiler characteristics):
+       Document AC_COMPUTE_INT.  Fix wrong statements on Default
+       Includes for AC_CHECK_SIZEOF and AC_CHECK_ALIGNOF.
+
+       * lib/autoconf/general.m4 (AC_COMPUTE_INT): New.
+       (_AC_COMPUTE_INT): Add obsoletion warnings.
+       * lib/autoconf/types.m4 (AC_CHECK_SIZEOF, AC_CHECK_ALIGNOF): Use
+       AC_COMPUTE_INT.
+
+       * NEWS: Document change.
+
 2006-07-05  Paul Eggert  <eggert@cs.ucla.edu>
 
        * doc/autoconf.texi (Volatile Objects): New section.
diff --git a/NEWS b/NEWS
index 047bb031f4460e33cd66617a586b7dabf0cdfa73..c9ea69e5e5259c601612cb5665cb3a90d87af7a8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
 * Major changes in Autoconf 2.60a
 
+** The functionality of the undocumented _AC_COMPUTE_INT is now provided
+  by a public and documented macro, AC_COMPUTE_INT.  The parameters to the
+  two macros are different, so autoupdate will not change the old private name
+  to the new one.  _AC_COMPUTE_INT may be removed in a future release.
+
 ** AC_TYPE_LONG_LONG_INT and AC_TYPE_UNSIGNED_LONG_LONG_INT now require
    that long long types be at least 64 bits wide, as C99 and tradition
    requires.  Formerly, they accepted implementations of any width.
index 8b9e509307693a8e57a851937f03da925bb7c2fc..5c06d5bcdbf32b550d33eae61d456f91007d763f 100644 (file)
@@ -6167,8 +6167,7 @@ Autoconf works around this problem by casting @code{sizeof (int)} to
 Define @code{SIZEOF_@var{type}} (@pxref{Standard Symbols}) to be the
 size in bytes of @var{type}.  If @samp{type} is unknown, it gets a size
 of 0.  If no @var{includes} are specified, the default includes are used
-(@pxref{Default Includes}).  If you provide @var{include}, be sure to
-include @file{stdio.h} which is required for this macro to run.
+(@pxref{Default Includes}).
 
 This macro now works even when cross-compiling.  The @var{unused}
 argument was used when cross-compiling.
@@ -6188,9 +6187,27 @@ defines @code{SIZEOF_INT_P} to be 8 on DEC Alpha AXP systems.
 Define @code{ALIGNOF_@var{type}} (@pxref{Standard Symbols}) to be the
 alignment in bytes of @var{type}.  If @samp{type} is unknown, it gets a size
 of 0.  If no @var{includes} are specified, the default includes are used
-(@pxref{Default Includes}).  If you provide @var{include}, be sure to
-include @file{stddef.h} and @file{stdio.h} which are required for this
-macro to work correctly.
+(@pxref{Default Includes}).
+@end defmac
+
+@defmac AC_COMPUTE_INT (@var{message}, @var{cache-id}, @var{expression}, @dvar{includes, default-includes}, @ovar{if-fails})
+@acindex{COMPUTE_INT}
+Compute the value of the integer @var{expression} in @var{cache-id}.  The
+value should fit in an initializer in a C variable of type @code{signed
+long}.  To support cross compilation (in which case, the macro only works on
+hosts that use twos-complement arithmetic), it should be possible to evaluate
+the expression at compile-time.  If no @var{includes} are specified, the default
+includes are used (@pxref{Default Includes}).
+
+The macro also takes care of checking if the result is already in the
+cache, and of reporting the test on the standard output
+with @code{AC_MSG_CHECKING} (which prints @var{message}) and
+@code{AC_MSG_RESULT}.
+
+If the value cannot be determined correctly, the code in @var{if-fails}
+is executed.  The @var{if-fails} commands @emph{must have no side effects}
+except for possibly setting the variable @var{cache-id}.
+@xref{Caching Results}, for more information.
 @end defmac
 
 @defmac AC_LANG_WERROR
index 0ef455c271b8a7d885d22b51bacf0962e3dd4b02..869848d69e03b622c55a3c5b5aca0bac52c0e8a0 100644 (file)
@@ -2716,9 +2716,14 @@ m4_define([_AC_COMPUTE_INT_RUN],
                [$2=`cat conftest.val`], [$4])])
 
 
-# _AC_COMPUTE_INT(EXPRESSION, VARIABLE, PROLOGUE, IF-FAILS)
+# _AC_COMPUTE_INT(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS])
 # ---------------------------------------------------------
-m4_define([_AC_COMPUTE_INT],
+# FIXME: this private interface was used by several packages.
+# Give them time to transition to AC_COMPUTE_INT (which is cleaner)
+# and then delete this one.  Or if they do not transition,
+# it may make sense to limit the code duplication and use
+# _AC_COMPUTE_INT from within the public macro.
+AC_DEFUN([_AC_COMPUTE_INT],
 [AC_LANG_COMPILER_REQUIRE()dnl
 if test "$cross_compiling" = yes; then
   _AC_COMPUTE_INT_COMPILE([$1], [$2], [$3], [$4])
@@ -2726,4 +2731,24 @@ else
   _AC_COMPUTE_INT_RUN([$1], [$2], [$3], [$4])
 fi
 rm -f conftest.val[]dnl
+AC_DIAGNOSE([obsolete],
+[The macro `_AC_COMPUTE_INT' is obsolete and will be deleted in a
+future version or Autoconf.  Hence, it is suggested that you use
+instead the public AC_COMPUTE_INT macro.  Note that the arguments are
+slightly different between the two.])dnl
 ])# _AC_COMPUTE_INT
+
+# AC_COMPUTE_INT(MESSAGE, CACHE-ID, EXPRESSION, [PROLOGUE = DEFAULT-INCLUDES],
+#               [IF-FAILS])
+# ---------------------------------------------------------
+AC_DEFUN([AC_COMPUTE_INT],
+[AC_LANG_COMPILER_REQUIRE()dnl
+AC_CACHE_CHECK([$1], [$2],
+[if test "$cross_compiling" = yes; then
+  _AC_COMPUTE_INT_COMPILE([$3], [$2], [AC_INCLUDES_DEFAULT([$4])], [$5])
+else
+  _AC_COMPUTE_INT_RUN([$3], [$2], [AC_INCLUDES_DEFAULT([$4])], [$5])
+fi
+rm -f conftest.val[]dnl
+])
+])# AC_COMPUTE_INT
index 560efa899f1384eeefa5753f3f0cef36960ad4b6..1c45101ed7e8144e0a352cc649b60e5005fa5ac6 100644 (file)
@@ -680,20 +680,20 @@ AC_DEFUN([AC_CHECK_SIZEOF],
 [AS_LITERAL_IF([$1], [],
               [AC_FATAL([$0: requires literal arguments])])dnl
 AC_CHECK_TYPE([$1], [], [], [$3])
-AC_CACHE_CHECK([size of $1], AS_TR_SH([ac_cv_sizeof_$1]),
-[if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
-  # The cast to long int works around a bug in the HP C Compiler
-  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-  # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-  # This bug is HP SR number 8606223364.
-  _AC_COMPUTE_INT([(long int) (sizeof (ac__type_sizeof_))],
-                 [AS_TR_SH([ac_cv_sizeof_$1])],
-                 [AC_INCLUDES_DEFAULT([$3])
-                  typedef $1 ac__type_sizeof_;],
-                 [AC_MSG_FAILURE([cannot compute sizeof ($1)], 77)])
-else
-  AS_TR_SH([ac_cv_sizeof_$1])=0
-fi])dnl
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+AC_COMPUTE_INT([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])],
+              [(long int) (sizeof (ac__type_sizeof_))],
+              [AC_INCLUDES_DEFAULT([$3])
+               typedef $1 ac__type_sizeof_;],
+              [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
+                AC_MSG_FAILURE([cannot compute sizeof ($1)], 77)
+              else
+                AS_TR_SH([ac_cv_sizeof_$1])=0
+              fi])
+
 AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), $AS_TR_SH([ac_cv_sizeof_$1]),
                   [The size of `$1', as computed by sizeof.])
 ])# AC_CHECK_SIZEOF
@@ -705,21 +705,21 @@ AC_DEFUN([AC_CHECK_ALIGNOF],
 [AS_LITERAL_IF([$1], [],
               [AC_FATAL([$0: requires literal arguments])])dnl
 AC_CHECK_TYPE([$1], [], [], [$2])
-AC_CACHE_CHECK([alignment of $1], AS_TR_SH([ac_cv_alignof_$1]),
-[if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
-  # The cast to long int works around a bug in the HP C Compiler,
-  # see AC_CHECK_SIZEOF for more information.
-  _AC_COMPUTE_INT([(long int) offsetof (ac__type_alignof_, y)],
-                 [AS_TR_SH([ac_cv_alignof_$1])],
-                 [AC_INCLUDES_DEFAULT([$2])
+# The cast to long int works around a bug in the HP C Compiler,
+# see AC_CHECK_SIZEOF for more information.
+AC_COMPUTE_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$1])],
+              [(long int) offsetof (ac__type_alignof_, y)],
+              [AC_INCLUDES_DEFAULT([$2])
 #ifndef offsetof
 # define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
 #endif
 typedef struct { char x; $1 y; } ac__type_alignof_;],
-                 [AC_MSG_FAILURE([cannot compute alignment of ($1)], 77)])
-else
-  AS_TR_SH([ac_cv_alignof_$1])=0
-fi])dnl
+              [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
+                AC_MSG_FAILURE([cannot compute alignment of $1], 77)
+              else
+                AS_TR_SH([ac_cv_alignof_$1])=0
+              fi])
+
 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1), $AS_TR_SH([ac_cv_alignof_$1]),
                   [The normal alignment of `$1', in bytes.])
 ])# AC_CHECK_ALIGNOF
index db3316f6272057fbac961d920cbe6053bf444ed8..ac2e1e5a4169aab310113431ba30daf56ee8b6a0 100755 (executable)
@@ -86,6 +86,7 @@ ac_exclude_list='
        # Need an argument.
        /^AC_(CANONICALIZE|PREFIX_PROGRAM|PREREQ)$/ {next}
        /^AC_(SEARCH_LIBS|REPLACE_FUNCS)$/ {next}
+       /^AC_COMPUTE_INT$/ {next}
 
        # Performed in the semantics tests.
        /^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|(TARGET_)?TOOL|TYPE)S?$/ {next}