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: Fri, 07 Jul 2006 16:25:14 +0200
User-agent: Thunderbird 1.5.0.4 (Macintosh/20060530)


Other than these minor nits, and since nobody else complained any more,
I don't see a reason against applying your patch.
Me neither.  Thanks, Paolo -- can you please revise your patch?
Sure, here's what I just committed after retesting.

Richard, this is actually pointless for GCC because autoconf now has a portable macro called AC_CHECK_ALIGNOF. However, I guess upgrading 2.59 to 2.60 is not a good thing to do now, so that'll have to wait for GCC's stage1.

Paolo
2006-07-07  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): 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        6 Jul 2006 16:49:09 -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 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.
+
 
 * Major changes in Autoconf 2.60
 
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   6 Jul 2006 16:49:19 -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 possibly setting the variable @var{cache-id}.
address@hidden Results}, for more information.
 @end defmac
 
 @defmac AC_LANG_WERROR
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     6 Jul 2006 16:49:22 -0000
@@ -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: 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       6 Jul 2006 16:49:22 -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
Index: tests/mktests.sh
===================================================================
RCS file: /sources/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.54
diff -p -u -r1.54 mktests.sh
--- tests/mktests.sh    10 Apr 2006 21:00:40 -0000      1.54
+++ tests/mktests.sh    6 Jul 2006 16:49:24 -0000
@@ -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}

reply via email to

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