[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
port Autoconf to C99 rules for 'exit'
From: |
Paul Eggert |
Subject: |
port Autoconf to C99 rules for 'exit' |
Date: |
Mon, 03 May 2004 13:23:05 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
I'm following up to this old thread:
http://mail.gnu.org/archive/html/bug-autoconf/2003-12/msg00067.html
http://mail.gnu.org/archive/html/bug-autoconf/2003-12/msg00064.html
Basically, the problem is that C99 and some pedantic compilers require
that 'exit' must be declared (typically by stdlib.h) before being
used. I installed the following patch to Autoconf to support this.
2004-05-03 Paul Eggert <address@hidden>
Port to C99, which requires that 'exit' be declared.
* lib/autoconf/c.m4 (AC_C_BIGENDIAN): Use AC_INCLUDES_DEFAULT
to ensure that stdlib.h is included.
* lib/autoconf/functions.m4 (_AC_LIBOBJ_ALLOCA, AC_FUNC_SETPGRP,
AC_FUNC_STRTOD, AC_FUNC_SETVBUF_REVERSED, AC_FUNC_FORK, _AC_FUNC_FORK,
_AC_FUNC_VFORK, AC_FUNC_WAIT3): Likewise.
* lib/autoconf/specific.m4 (AC_SYS_RESTARTABLE_SYSCALLS): Likewise.
* lib/autoconf/types.m4 (AC_TYPE_GETGROUPS): Likewise.
* lib/autoconf/headers.m4 (AC_HEADER_STDC): Include <stdlib.h>
when using 'exit' in a test; C99 requires that 'exit' be declared.
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.186
diff -p -u -r1.186 c.m4
--- lib/autoconf/c.m4 20 Apr 2004 20:15:20 -0000 1.186
+++ lib/autoconf/c.m4 3 May 2004 20:13:30 -0000
@@ -983,9 +983,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#inc
])], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=no])],
[# It does not; compile a test program.
AC_RUN_IFELSE(
-[AC_LANG_SOURCE([[int
-main ()
-{
+[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
/* Are we little or big endian? From Harbison&Steele. */
union
{
@@ -994,7 +992,7 @@ main ()
} u;
u.l = 1;
exit (u.c[sizeof (long int) - 1] == 1);
-}]])],
+]])],
[ac_cv_c_bigendian=no],
[ac_cv_c_bigendian=yes],
[# try to guess the endianness by grepping values into an object file
Index: lib/autoconf/functions.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v
retrieving revision 1.82
diff -p -u -r1.82 functions.m4
--- lib/autoconf/functions.m4 30 Mar 2004 07:55:26 -0000 1.82
+++ lib/autoconf/functions.m4 3 May 2004 20:13:34 -0000
@@ -279,7 +279,8 @@ fi
AC_CACHE_CHECK([stack direction for C alloca],
[ac_cv_c_stack_direction],
[AC_RUN_IFELSE([AC_LANG_SOURCE(
-[int
+[AC_INCLUDES_DEFAULT
+int
find_stack_direction ()
{
static char *addr = 0;
@@ -1387,11 +1388,7 @@ AN_FUNCTION([setpgrp], [AC_FUNC_SETPGRP]
AC_DEFUN([AC_FUNC_SETPGRP],
[AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
[AC_RUN_IFELSE(
-[AC_LANG_PROGRAM(
-[#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-],
+[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
[/* If this system has a BSD-style setpgrp which takes arguments,
setpgrp(1, 1) will fail with ESRCH and return -1, in that case
exit successfully. */
@@ -1462,7 +1459,10 @@ AC_DEFUN([AC_FUNC_STRTOD],
[AC_SUBST(POW_LIB)dnl
AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
+]AC_INCLUDES_DEFAULT[
+#ifndef strtod
double strtod ();
+#endif
int
main()
{
@@ -1609,7 +1609,7 @@ AC_CACHE_CHECK(whether setvbuf arguments
# Try running it.
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
- [[#include <stdio.h>]],
+ [AC_INCLUDES_DEFAULT],
[[/* This call has the arguments reversed.
A reversed system may check and see that the address of buf
is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */
@@ -1699,7 +1699,7 @@ AN_FUNCTION([fork], [AC_FUNC_FORK])
AN_FUNCTION([vfork], [AC_FUNC_FORK])
AC_DEFUN([AC_FUNC_FORK],
[AC_REQUIRE([AC_TYPE_PID_T])dnl
-AC_CHECK_HEADERS(unistd.h vfork.h)
+AC_CHECK_HEADERS(vfork.h)
AC_CHECK_FUNCS(fork vfork)
if test "x$ac_cv_func_fork" = xyes; then
_AC_FUNC_FORK
@@ -1742,21 +1742,17 @@ fi
# -------------
AC_DEFUN([_AC_FUNC_FORK],
[AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
- [AC_RUN_IFELSE([/* By Ruediger Kuhlmann. */
- #include <sys/types.h>
- #if HAVE_UNISTD_H
- # include <unistd.h>
- #endif
- /* Some systems only have a dummy stub for fork() */
- int main ()
- {
- if (fork() < 0)
- exit (1);
- exit (0);
- }],
- [ac_cv_func_fork_works=yes],
- [ac_cv_func_fork_works=no],
- [ac_cv_func_fork_works=cross])])]
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+ [
+ /* By Ruediger Kuhlmann. */
+ if (fork() < 0)
+ exit (1);
+ exit (0);
+ ])],
+ [ac_cv_func_fork_works=yes],
+ [ac_cv_func_fork_works=no],
+ [ac_cv_func_fork_works=cross])])]
)# _AC_FUNC_FORK
@@ -1765,14 +1761,8 @@ AC_DEFUN([_AC_FUNC_FORK],
AC_DEFUN([_AC_FUNC_VFORK],
[AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+]AC_INCLUDES_DEFAULT[
#include <sys/wait.h>
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
#if HAVE_VFORK_H
# include <vfork.h>
#endif
@@ -1909,10 +1899,9 @@ Remove this `AC_FUNC_WAIT3' and adjust y
AC_CACHE_CHECK([for wait3 that fills in rusage],
[ac_cv_func_wait3_rusage],
[AC_RUN_IFELSE([AC_LANG_SOURCE(
-[[#include <sys/types.h>
+[AC_INCLUDES_DEFAULT[
#include <sys/time.h>
#include <sys/resource.h>
-#include <stdio.h>
/* HP-UX has wait3 but does not fill in rusage at all. */
int
main ()
Index: lib/autoconf/specific.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/specific.m4,v
retrieving revision 1.359
diff -p -u -r1.359 specific.m4
--- lib/autoconf/specific.m4 30 Jan 2004 14:21:36 -0000 1.359
+++ lib/autoconf/specific.m4 3 May 2004 20:13:36 -0000
@@ -255,18 +255,14 @@ old systems that lack `sigaction' and `S
this macro unless you need to support very old systems like 4.2BSD and
SVR3.])dnl
AC_REQUIRE([AC_HEADER_SYS_WAIT])dnl
-AC_CHECK_HEADERS(unistd.h)
AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
[AC_RUN_IFELSE([AC_LANG_SOURCE(
[/* Exit 0 (true) if wait returns something other than -1,
i.e. the pid of the child, which means that wait was restarted
after getting the signal. */
-#include <sys/types.h>
+AC_INCLUDES_DEFAULT
#include <signal.h>
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
#if HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
Index: lib/autoconf/types.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/types.m4,v
retrieving revision 1.28
diff -p -u -r1.28 types.m4
--- lib/autoconf/types.m4 30 Mar 2004 07:55:26 -0000 1.28
+++ lib/autoconf/types.m4 3 May 2004 20:13:36 -0000
@@ -253,7 +253,7 @@ AC_DEFUN([AC_TYPE_GETGROUPS],
AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
[AC_RUN_IFELSE([AC_LANG_SOURCE(
[[/* Thanks to Mike Rendell for this test. */
-#include <sys/types.h>
+]AC_INCLUDES_DEFAULT[
#define NGID 256
#undef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
Index: lib/autoconf/headers.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/headers.m4,v
retrieving revision 1.39
diff -p -u -r1.39 headers.m4
--- lib/autoconf/headers.m4 30 Mar 2004 07:55:26 -0000 1.39
+++ lib/autoconf/headers.m4 3 May 2004 20:13:36 -0000
@@ -589,6 +589,7 @@ if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
AC_RUN_IFELSE([AC_LANG_SOURCE(
[[#include <ctype.h>
+#include <stdlib.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
@@ -608,7 +609,7 @@ main ()
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
- exit(2);
+ exit (2);
exit (0);
}]])], , ac_cv_header_stdc=no, :)
fi])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- port Autoconf to C99 rules for 'exit',
Paul Eggert <=