autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Make AC_COMPUTE_INT public


From: Paolo Bonzini
Subject: Re: [PATCH] Make AC_COMPUTE_INT public
Date: Wed, 28 Jun 2006 15:20:05 +0200
User-agent: Thunderbird 1.5.0.4 (Macintosh/20060530)

Paolo Bonzini wrote:

First, AC_COMPUTE_INT doesn't need to have the exact same arguments
that _AC_COMPUTE_INT has.  If there's some extra argument that it
should have for public consumption, we can add it.

That's right, and that's what I did. The two parameters of AC_COMPUTE_INT are now the same as for AC_CACHE_CHECK. Note that the macros are m4_defun-ed, not AC_DEFUN-ed, to avoid failures in the testsuite from setting an empty variable. Anyway AC_COMPUTE_INT is tested by AC_CHECK_SIZEOF and AC_CHECK_ALIGNOF.

Second, I don't see why we can't compute the cache variable name from
the second argument of _AC_COMPUTE_INT.  That is a shell variable
name, and we can prepend ac_cv_whatever_ to it.
I think that's dangerous, because the same shell variable could be used in multiple invocations of _AC_COMPUTE_INT.

And if I attached the patch, that would be much better.

Regression tested on i686-pc-linux-gnu.

Paolo
2006-06-19  Paolo Bonzini  <address@hidden>

        * 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): m4_defun it and add obsoletion warnings.
        * lib/autoconf/types.m4 (AC_CHECK_SIZEOF, AC_CHECK_ALIGNOF): Use
        AC_COMPUTE_INT.
        * NEWS: Document change.

Index: NEWS
===================================================================
RCS file: /sources/autoconf/autoconf/NEWS,v
retrieving revision 1.389
diff -p -u -r1.389 NEWS
--- NEWS        23 Jun 2006 19:09:49 -0000      1.389
+++ NEWS        28 Jun 2006 13:16:44 -0000
@@ -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 functions are different, so autoupdate will change the old private name
+  to the new one.  _AC_COMPUTE_INT may be removed in a future release.
+
 
 * Major changes in Autoconf 2.60
 
cvs diff: Diffing bin
Index: doc/autoconf.texi
===================================================================
RCS file: /sources/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1054
diff -p -u -r1.1054 autoconf.texi
--- doc/autoconf.texi   23 Jun 2006 14:56:30 -0000      1.1054
+++ doc/autoconf.texi   28 Jun 2006 13:16:46 -0000
@@ -6170,8 +6170,7 @@ Autoconf works around this problem by ca
 Define @address@hidden (@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.
@@ -6191,9 +6190,27 @@ defines @code{SIZEOF_INT_P} to be 8 on D
 Define @address@hidden (@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}).
address@hidden defmac
+
address@hidden AC_COMPUTE_INT (@var{message}, @var{cache-id}, @var{expression}, 
@dvar{includes, default-includes}, @ovar{if-fails})
address@hidden
+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
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 passibly setting the variable @var{cache-id}.
address@hidden Results}, for more information.
 @end defmac
 
 @defmac AC_LANG_WERROR
cvs diff: Diffing lib
Index: lib/autoconf/general.m4
===================================================================
RCS file: /sources/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.925
diff -p -u -r1.925 general.m4
--- lib/autoconf/general.m4     7 Jun 2006 05:35:46 -0000       1.925
+++ lib/autoconf/general.m4     28 Jun 2006 13:16:46 -0000
@@ -2716,9 +2716,9 @@ 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],
+m4_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 +2726,22 @@ 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: 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])
+# ---------------------------------------------------------
+m4_defun([AC_COMPUTE_INT],
+[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: /sources/autoconf/autoconf/lib/autoconf/types.m4,v
retrieving revision 1.39
diff -p -u -r1.39 types.m4
--- lib/autoconf/types.m4       19 Jun 2006 18:28:12 -0000      1.39
+++ lib/autoconf/types.m4       28 Jun 2006 13:16:46 -0000
@@ -670,20 +670,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
@@ -695,21 +695,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

reply via email to

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