]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
AC_CHECK_SIZEOF: Fix a bug, use standard default headers, and
authorAkim Demaille <akim@epita.fr>
Mon, 7 Feb 2000 17:28:43 +0000 (17:28 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 7 Feb 2000 17:28:43 +0000 (17:28 +0000)
test.

* acgeneral.m4 (AC_CHECK_SIZEOF): Don't over quote $1, some []
were left in the C code, and had the macro fail.
Use AC_INCLUDES_DEFAULT.
* doc/autoconf.texi: Mention default includes.  Explain stdio.h
must always be given.

* tests/atspecific.m4 (TEST_MACRO): Updated the list of
exceptions.
(AT_CHECK_DEFINES): New macro, to check the content of config.h.
* tests/semantics.m4: All the tests are updated to use
AT_CHECK_DEFINES.
Test AC_CHECK_SIZEOF, AC_CHECK_HEADERS, and AC_CHECK_FUNCS.

ChangeLog
acgeneral.m4
autoconf.texi
doc/autoconf.texi
lib/autoconf/general.m4
tests/semantics.m4
tests/syntax.m4
tests/torture.m4

index 6f131f6993118f8e138de4ae467e3b1cbf45d839..ffafae377bbe2c996b9c68f7c36086d0a3251aa6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2000-02-07  Akim Demaille  <akim@epita.fr>
+
+       AC_CHECK_SIZEOF: Fix a bug, use standard default headers, and
+       test.
+
+       * acgeneral.m4 (AC_CHECK_SIZEOF): Don't over quote $1, some []
+       were left in the C code, and had the macro fail.
+       Use AC_INCLUDES_DEFAULT.
+       * doc/autoconf.texi: Mention default includes.  Explain stdio.h
+       must always be given.
+
+       * tests/atspecific.m4 (TEST_MACRO): Updated the list of
+       exceptions.
+       (AT_CHECK_DEFINES): New macro, to check the content of config.h.
+       * tests/semantics.m4: All the tests are updated to use
+       AT_CHECK_DEFINES.
+       Test AC_CHECK_SIZEOF, AC_CHECK_HEADERS, and AC_CHECK_FUNCS.
+
 2000-02-07  Akim Demaille  <akim@epita.fr>
 
        Give explicit diagnostics when an input file (for config headers;
index 56a6bc017c0019f254ad0e3275271f014edc4e2c..0453c9b8fdd58a7cbf6e9856138fe04a1758b400 100644 (file)
@@ -3043,15 +3043,14 @@ dnl shouldn't we use the default INCLUDES?
 AC_DEFUN(AC_CHECK_SIZEOF,
 [AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl
 AC_CACHE_CHECK([size of $1], ac_Sizeof,
-[AC_TRY_RUN([#include <stdio.h>
-[$3]
-int
+[AC_TRY_RUN(AC_INCLUDES_DEFAULT([$3])
+[int
 main ()
 {
   FILE *f = fopen ("conftestval", "w");
   if (!f)
-     exit (1);
-  fprintf (f, "%d\n", sizeof ([$1]));
+    exit (1);
+  fprintf (f, "%d\n", sizeof ($1));
   exit (0);
 }],
   AC_VAR_SET(ac_Sizeof, `cat conftestval`),
@@ -3062,7 +3061,9 @@ AC_VAR_POPDEF([ac_Sizeof])dnl
 ])
 
 
-dnl ### Checking for types
+## ------------------ ##
+## Checking for types ##
+## ------------------ ##
 
 
 # AC_CHECK_TYPE_INTERNAL(TYPE,
index c89ae0878d48ca802a3a3fdb6abef3f0159f5dd2..905756f2372a068eeea9d5a954a08a964c5cba80 100644 (file)
@@ -3028,15 +3028,20 @@ size_t my_strlen PARAMS ((const char *));
 
 @c FIXME: What the heck is this macro doing here?  Move it out of
 @c the way, in its proper section!!!
+@c FIXME: Explain once for all how the CPP names are built, not everywhere.
 @defmac AC_CHECK_SIZEOF (@var{type}, @ovar{cross-size}, @ovar{includes})
 @maindex CHECK_SIZEOF
 Define @code{SIZEOF_@var{uctype}} to be the size in bytes of the C (or
-C++) builtin type @var{type}, e.g. @samp{int} or @samp{char *}.  If
-@samp{type} is unknown to the compiler, it gets a size of 0.  @var{uctype}
-is @var{type}, with lowercase converted to uppercase, spaces changed to
-underscores, and asterisks changed to @samp{P}.  If cross-compiling, the
-value @var{cross-size} is used if given, otherwise @code{configure}
-exits with an error message.
+C++) type @var{type} (e.g. @samp{int}, @samp{char *} etc.).  If
+@samp{type} is unknown, it gets a size of 0.  If no @var{includes} are
+provided, the default headers are used (FIXME: point to the right
+node).  If you provide default header, make sure to include
+@file{stdio.h} which is required for this macro to run.
+
+@var{uctype} is @var{type}, with lowercase converted to uppercase,
+spaces changed to underscores, and asterisks changed to @samp{P}.  If
+cross-compiling, the value @var{cross-size} is used if given, otherwise
+@code{configure} exits with an error message.
 
 For example, the call
 @example
index c89ae0878d48ca802a3a3fdb6abef3f0159f5dd2..905756f2372a068eeea9d5a954a08a964c5cba80 100644 (file)
@@ -3028,15 +3028,20 @@ size_t my_strlen PARAMS ((const char *));
 
 @c FIXME: What the heck is this macro doing here?  Move it out of
 @c the way, in its proper section!!!
+@c FIXME: Explain once for all how the CPP names are built, not everywhere.
 @defmac AC_CHECK_SIZEOF (@var{type}, @ovar{cross-size}, @ovar{includes})
 @maindex CHECK_SIZEOF
 Define @code{SIZEOF_@var{uctype}} to be the size in bytes of the C (or
-C++) builtin type @var{type}, e.g. @samp{int} or @samp{char *}.  If
-@samp{type} is unknown to the compiler, it gets a size of 0.  @var{uctype}
-is @var{type}, with lowercase converted to uppercase, spaces changed to
-underscores, and asterisks changed to @samp{P}.  If cross-compiling, the
-value @var{cross-size} is used if given, otherwise @code{configure}
-exits with an error message.
+C++) type @var{type} (e.g. @samp{int}, @samp{char *} etc.).  If
+@samp{type} is unknown, it gets a size of 0.  If no @var{includes} are
+provided, the default headers are used (FIXME: point to the right
+node).  If you provide default header, make sure to include
+@file{stdio.h} which is required for this macro to run.
+
+@var{uctype} is @var{type}, with lowercase converted to uppercase,
+spaces changed to underscores, and asterisks changed to @samp{P}.  If
+cross-compiling, the value @var{cross-size} is used if given, otherwise
+@code{configure} exits with an error message.
 
 For example, the call
 @example
index 56a6bc017c0019f254ad0e3275271f014edc4e2c..0453c9b8fdd58a7cbf6e9856138fe04a1758b400 100644 (file)
@@ -3043,15 +3043,14 @@ dnl shouldn't we use the default INCLUDES?
 AC_DEFUN(AC_CHECK_SIZEOF,
 [AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl
 AC_CACHE_CHECK([size of $1], ac_Sizeof,
-[AC_TRY_RUN([#include <stdio.h>
-[$3]
-int
+[AC_TRY_RUN(AC_INCLUDES_DEFAULT([$3])
+[int
 main ()
 {
   FILE *f = fopen ("conftestval", "w");
   if (!f)
-     exit (1);
-  fprintf (f, "%d\n", sizeof ([$1]));
+    exit (1);
+  fprintf (f, "%d\n", sizeof ($1));
   exit (0);
 }],
   AC_VAR_SET(ac_Sizeof, `cat conftestval`),
@@ -3062,7 +3061,9 @@ AC_VAR_POPDEF([ac_Sizeof])dnl
 ])
 
 
-dnl ### Checking for types
+## ------------------ ##
+## Checking for types ##
+## ------------------ ##
 
 
 # AC_CHECK_TYPE_INTERNAL(TYPE,
index cd950bc24bd4d62f7ec173a49f3a533a45f0be32..a9052cc12f316fbbd3aca63b6f5f400d650f871d 100644 (file)
@@ -6,41 +6,93 @@ Checking the semantics of some macros.
 
 EOF
 
-dnl Check that AC_CHECK_MEMBERS performs the correct actions:
+
+dnl AC_CHECK_DECLS
+dnl --------------
+dnl Check that it performs the correct actions:
+dnl Must define NEED_NO_DECL, but not NEED_YES_DECL.
+AT_TEST_MACRO(AC_CHECK_DECLS,
+[AC_CHECK_DECLS((yes, no),,,
+                [int yes = 1;])],
+[AT_CHECK_DEFINES(
+[#define NEED_NO_DECL 1
+/* #undef NEED_YES_DECL */
+])])
+
+
+dnl AC_CHECK_FUNCS
+dnl --------------
+dnl Check that it performs the correct actions:
+dnl Must define HAVE_EXIT, but not HAVE_AUTOCONF_TIXE
+AT_TEST_MACRO(AC_CHECK_FUNCS,
+[AC_CHECK_FUNCS(exit autoconf_tixe)],
+[AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_TIXE */
+#define HAVE_EXIT 1
+])])
+
+
+
+dnl AC_CHECK_HEADERS
+dnl ----------------
+dnl Check that it performs the correct actions:
+dnl Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H.
+AT_TEST_MACRO(AC_CHECK_HEADERS,
+[AC_CHECK_HEADERS(stdio.h autoconf_io.h)],
+[AT_CHECK_DEFINES(
+[/* #undef HAVE_AUTOCONF_IO_H */
+#define HAVE_STDIO_H 1
+])])
+
+
+
+dnl AC_CHECK_MEMBERS
+dnl ----------------
+dnl Check that it performs the correct actions.
 dnl Must define HAVE_STRUCT_YES_YES, but not HAVE_STRUCT_YES_NO.
 AT_TEST_MACRO(AC_CHECK_MEMBERS,
 [AC_CHECK_MEMBERS((struct yes.yes, struct yes.no),,,
                   [struct yes { int yes ;} ;])],
-[AT_CHECK([grep HAVE_STRUCT_YES_YES config.h],,
-          [#define HAVE_STRUCT_YES_YES 1
-])
-AT_CHECK([grep HAVE_STRUCT_YES_NO config.h],,
-          [/* #undef HAVE_STRUCT_YES_NO */
+[AT_CHECK_DEFINES(
+[/* #undef HAVE_STRUCT_YES_NO */
+#define HAVE_STRUCT_YES_YES 1
 ])])
 
 
-dnl Check that AC_CHECK_TYPES performs the correct actions:
-dnl Must define HAVE_STRUCT_YES, but not HAVE_STRUCT_NO.
+
+dnl AC_CHECK_SIZEOF
+dnl --------------
+dnl Check that it performs the correct actions.
+dnl Must define HAVE_STRUCT_YES, HAVE_INT, but not HAVE_STRUCT_NO.
+dnl `int' and `struct yes' are both checked to test both the compiler
+dnl builtin types, and defined types.
 AT_TEST_MACRO(AC_CHECK_TYPES,
-[AC_CHECK_TYPES((struct yes, struct no),,,
-                [struct yes { int yes ;} ;])],
-[AT_CHECK([grep HAVE_STRUCT_YES config.h],,
-          [#define HAVE_STRUCT_YES 1
-])
-AT_CHECK([grep HAVE_STRUCT_NO config.h],,
-          [/* #undef HAVE_STRUCT_NO */
+[AC_CHECK_SIZEOF(char)
+AC_CHECK_SIZEOF(charchar,,
+[#include <stdio.h>
+typedef struct
+{
+  char a;
+  char b;
+} charchar;])],
+[AT_CHECK_DEFINES(
+[#define SIZEOF_CHAR 1
+#define SIZEOF_CHARCHAR 2
 ])])
 
 
 
-dnl Check that AC_CHECK_DECLS performs the correct actions:
-dnl Must define NEED_NO_DECL, but not NEED_YES_DECL.
-AT_TEST_MACRO(AC_CHECK_DECLS,
-[AC_CHECK_DECLS((yes, no),,,
-                [int yes = 1;])],
-[AT_CHECK([grep NEED_YES_DECL config.h],,
-          [/* #undef NEED_YES_DECL */
-])
-AT_CHECK([grep NEED_NO_DECL config.h],,
-          [#define NEED_NO_DECL 1
+dnl AC_CHECK_TYPES
+dnl --------------
+dnl Check that it performs the correct actions.
+dnl Must define HAVE_STRUCT_YES, HAVE_INT, but not HAVE_STRUCT_NO.
+dnl `int' and `struct yes' are both checked to test both the compiler
+dnl builtin types, and defined types.
+AT_TEST_MACRO(AC_CHECK_TYPES,
+[AC_CHECK_TYPES((int, struct yes, struct no),,,
+                [struct yes { int yes ;} ;])],
+[AT_CHECK_DEFINES(
+[#define HAVE_INT 1
+/* #undef HAVE_STRUCT_NO */
+#define HAVE_STRUCT_YES 1
 ])])
index 1d329958075f6bf8d39d85da48507175ac6d477b..b8e2b2826ac28e2dd376b7f5bb1340000094a647 100644 (file)
@@ -7,5 +7,3 @@ Syntax of macros and completeness of the header templates.
 EOF
 
 AT_INCLUDE(macros.m4)
-dnl That miserable test comes from the old DejaGNU testsuite.
-TEST_MACRO([AC_CHECK_SIZEOF(long *)])
index 8698ee80cf60b091b09dbb073c9d14aa915ae4f0..c3e1481e36fb664720ef5930f6ff00241235f266 100644 (file)
@@ -53,6 +53,8 @@ AT_DATA(dummy.in,
 AT_TEST_MACRO(config.status under extreme conditions,
 [AC_CONFIG_FILES(dummy)
 [define]([AC_DEFUBST_VALUE], Big_Value)
+dnl The following 4 lines are a transfert from AT_DUMMY_VAR in Autotest
+dnl to AC_DUMMY_VAR in Autoconf.
 [define]([AC_DUMMY_VAR],
 changequote({{, }})dnl
 [defn({{AT_DUMMY_VAR}})]dnl