[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_COMPUTE_INT's arguments
From: |
Paul Eggert |
Subject: |
Re: AC_COMPUTE_INT's arguments |
Date: |
Fri, 01 Sep 2006 22:40:31 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Bruno Haible <address@hidden> writes:
> After all, the user wants to output a message can do so himself, with
> AC_MSG_CHECKING and AC_MSG_RESULT.
Good point. But the same argument applies to caching too, no? So
AC_COMPUTE_INT shouldn't cache either.
That being said, it's nice to have the convenience macro that does the
commonly-needed thing. Let's call it AC_CACHE_CHECK_INT since it's a
combination of AC_CACHE_CHECK and AC_COMPUTE_INT; that's a better
naming convention anyway.
I've installed the following change into CVS, along those lines.
Comments?
(This will necessitate another beta for Autoconf, since it's a
significant change.)
2006-09-01 Paul Eggert <address@hidden>
* NEWS: New macro AC_CACHE_CHECK_INT. It replaces the
old AC_COMPUTE_INT, which now behaves like _AC_COMPUTE_INT
except the first two arguments are reversed.
* doc/autoconf.texi (Caching Results): New macro AC_CACHE_CHECK_INT.
(Generic Compiler Characteristics): AC_COMPUTE_INT no longer
caches nor outputs a diagnostic. Suggested by Bruno Haible.
* lib/autoconf/general.m4 (AC_CACHE_CHECK_INT): New macro,
equivalent to the old AC_COMPUTE_INT.
(AC_COMPUTE_INT): No longer caches or reports. New signature.
All uses changed to AC_CACHE_CHECK_INT.
* tests/base.at (AC_CACHE_CHECK_INT): New test.
* tests/mktests.sh (ac_exclude_lsit): Add AC_CACHE_CHECK_INT.
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.399
diff -p -u -r1.399 NEWS
--- NEWS 31 Aug 2006 22:38:30 -0000 1.399
+++ NEWS 2 Sep 2006 05:32:28 -0000
@@ -9,6 +9,10 @@
New programs should use the Gnulib counterparts of these macros.
We have no current plans to remove them from Autoconf.
+** AC_CACHE_CHECK_INT
+ New macro, with the behavior of the 2.60a AC_COMPUTE_INT macro.
+ AC_COMPUTE_INT no longer caches or reports results.
+
* Major changes in Autoconf 2.60a (2006-08-25)
** GNU M4 1.4.6 or later is now recommended. At least one "make check"
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1075
diff -p -u -r1.1075 autoconf.texi
--- doc/autoconf.texi 31 Aug 2006 22:38:30 -0000 1.1075
+++ doc/autoconf.texi 2 Sep 2006 05:32:29 -0000
@@ -6233,24 +6233,17 @@ of 0. If no @var{includes} are specifie
(@pxref{Default Includes}).
@end defmac
address@hidden AC_COMPUTE_INT (@var{message}, @var{cache-id}, @var{expression},
@dvar{includes, default-includes}, @ovar{if-fails})
address@hidden AC_COMPUTE_INT (@var{var}, @var{expression}, @dvar{includes,
default-includes}, @ovar{action-if-fails})
@acindex{COMPUTE_INT}
-Compute the value of the integer @var{expression} in @var{cache-id}. The
+Store into the shell variable @var{var} the value of the integer
address@hidden 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
address@hidden
-
-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}.
address@hidden Results}, for more information.
+Execute @var{action-if-fails} if the value cannot be determined correctly.
@end defmac
@defmac AC_LANG_WERROR
@@ -8492,6 +8485,22 @@ The @var{commands-to-set-it} @emph{must
setting the variable @var{cache-id}, see below.
@end defmac
address@hidden AC_CACHE_CHECK_INT (@var{message}, @var{cache-id},
@var{expression}, @dvar{includes, default-includes}, @ovar{action-if-fails})
address@hidden
+This is a convenience macro for invoking @code{AC_COMPUTE_INT} to store
+into @var{cache-id} the value of the integer @var{expression}.
+
+This macro also checks whether the result is cached,
+and reports the test on the standard output
+with @code{AC_MSG_CHECKING} (which prints @var{message}) and
address@hidden
+
+Execute @var{action-if-fails} if the value cannot be determined correctly.
+Commands in @var{action-if-fails} must have no side effects
+except for possibly setting the variable @var{cache-id}.
address@hidden Results}, for more information.
address@hidden defmac
+
It is common to find buggy macros using @code{AC_CACHE_VAL} or
@code{AC_CACHE_CHECK}, because people are tempted to call
@code{AC_DEFINE} in the @var{commands-to-set-it}. Instead, the code that
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.927
diff -p -u -r1.927 general.m4
--- lib/autoconf/general.m4 26 Aug 2006 03:48:31 -0000 1.927
+++ lib/autoconf/general.m4 2 Sep 2006 05:32:29 -0000
@@ -1934,6 +1934,14 @@ AS_LITERAL_IF([$2],
AC_MSG_RESULT([$ac_res])])dnl
])
+# AC_CACHE_CHECK_INT(MESSAGE, CACHE-ID, EXPRESSION,
+# [PROLOGUE = DEFAULT-INCLUDES], [IF-FAILS])
+# -------------------------------------------------------------
+AC_DEFUN([AC_CACHE_CHECK_INT],
+[AC_CACHE_CHECK([$1], [$2],
+ [AC_COMPUTE_INT([$2], [$3], [$4], [$5])])
+])# AC_CACHE_CHECK_INT
+
## ---------------------- ##
@@ -2719,39 +2727,27 @@ m4_define([_AC_COMPUTE_INT_RUN],
[$2=`cat conftest.val`], [$4])])
-# _AC_COMPUTE_INT(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS])
-# ---------------------------------------------------------
-# 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_COMPUTE_INT(VARIABLE, EXPRESSION, PROLOGUE, [IF-FAILS])
+# ----------------------------------------------------------
+AC_DEFUN([AC_COMPUTE_INT],
[AC_LANG_COMPILER_REQUIRE()dnl
if test "$cross_compiling" = yes; then
- _AC_COMPUTE_INT_COMPILE([$1], [$2], [$3], [$4])
+ _AC_COMPUTE_INT_COMPILE([$2], [$1], [$3], [$4])
else
- _AC_COMPUTE_INT_RUN([$1], [$2], [$3], [$4])
+ _AC_COMPUTE_INT_RUN([$2], [$1], [$3], [$4])
fi
rm -f conftest.val[]dnl
+])# _AC_COMPUTE_INT
+
+# _AC_COMPUTE_INT(EXPRESSION, VARIABLE, PROLOGUE, [IF-FAILS])
+# -----------------------------------------------------------
+# FIXME: this private interface was used by several packages.
+# Give them time to transition to AC_COMPUTE_INT and then delete this one.
+AC_DEFUN([_AC_COMPUTE_INT],
+[AC_COMPUTE_INT([$2], [$1], [$3], [$4])
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: lib/autoconf/types.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/types.m4,v
retrieving revision 1.43
diff -p -u -r1.43 types.m4
--- lib/autoconf/types.m4 15 Aug 2006 16:28:09 -0000 1.43
+++ lib/autoconf/types.m4 2 Sep 2006 05:32:29 -0000
@@ -684,15 +684,15 @@ AC_CHECK_TYPE([$1], [], [], [$3])
# 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_CACHE_CHECK_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.])
@@ -707,18 +707,18 @@ AC_DEFUN([AC_CHECK_ALIGNOF],
AC_CHECK_TYPE([$1], [], [], [$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])
+AC_CACHE_CHECK_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_;],
- [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])
+ [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.])
Index: tests/base.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/base.at,v
retrieving revision 1.38
diff -p -u -r1.38 base.at
--- tests/base.at 5 Jun 2006 08:18:33 -0000 1.38
+++ tests/base.at 2 Sep 2006 05:32:29 -0000
@@ -220,6 +220,31 @@ AT_CHECK_CONFIGURE([-q])
AT_CLEANUP
+## -------------------- ##
+## AC_CACHE_CHECK_INT. ##
+## -------------------- ##
+-
+# Make sure AC_CACHE_CHECK_INT fails properly.
+
+AT_SETUP([AC_CACHE_CHECK_INT])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CACHE_CHECK_INT([for division by zero],
+ [my_cv_divide_by_zero],
+ [1 / 0],
+ [],
+ [my_cv_divide_by_zero=failed])
+test "$my_cv_divide_by_zero" = failed ||
+ AC_MSG_ERROR([1 / 0 did not fail])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
## ---------------- ##
## AC_TRY_COMMAND. ##
## ---------------- ##
Index: tests/mktests.sh
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.55
diff -p -u -r1.55 mktests.sh
--- tests/mktests.sh 7 Jul 2006 14:21:57 -0000 1.55
+++ tests/mktests.sh 2 Sep 2006 05:32:29 -0000
@@ -86,7 +86,7 @@ ac_exclude_list='
# Need an argument.
/^AC_(CANONICALIZE|PREFIX_PROGRAM|PREREQ)$/ {next}
/^AC_(SEARCH_LIBS|REPLACE_FUNCS)$/ {next}
- /^AC_COMPUTE_INT$/ {next}
+ /^AC_(CACHE_CHECK|COMPUTE)_INT$/ {next}
# Performed in the semantics tests.
/^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|(TARGET_)?TOOL|TYPE)S?$/
{next}
- Re: AC_COMPUTE_INT's arguments,
Paul Eggert <=
- Re: AC_COMPUTE_INT's arguments, Ralf Wildenhues, 2006/09/02
- Re: AC_COMPUTE_INT's arguments, Stepan Kasal, 2006/09/02
- Re: AC_COMPUTE_INT's arguments, Paul Eggert, 2006/09/02
- Re: AC_COMPUTE_INT's arguments, Ralf Wildenhues, 2006/09/03
- Re: AC_COMPUTE_INT's arguments, Stepan Kasal, 2006/09/04
- Re: AC_COMPUTE_INT's arguments, Ralf Wildenhues, 2006/09/04
- Re: AC_COMPUTE_INT's arguments, Stepan Kasal, 2006/09/06