From: Paul Eggert Date: Mon, 3 Apr 2006 03:18:39 +0000 (+0000) Subject: * NEWS: AC_PROG_CC and AC_PROG_CXX no longer declare 'exit'. X-Git-Tag: AUTOCONF-2.59c~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a71c24a704ec0570ba99be909fffbc044d50908b;p=thirdparty%2Fautoconf.git * NEWS: AC_PROG_CC and AC_PROG_CXX no longer declare 'exit'. * doc/autoconf.texi (Function Portability): Mention that C++ has trouble with 'exit'. (Guidelines): Test programs shouldn't use 'exit'. * lib/autoconf/c.m4 (_AC_PROG_CXX_EXIT_DECLARATION): Remove; all uses removed. (AC_LANG_INT_SAVE(C), AC_C_BIGENDIAN): Return from 'main' instead of calling 'exit'. * lib/autoconf/functions.m4 (_AC_LIBOBJ_ALLOCA, AC_FUNC_CLOSEDIR_VOID): (_AC_FUNC_FNMATCH_IF, AC_FUNC_GETGROUPS): (AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, _AC_FUNC_MALLOC_IF): (AC_FUNC_MEMCMP, AC_FUNC_MKTIME, AC_FUNC_MMAP, _AC_FUNC_REALLOC_IF): (AC_FUNC_SETPGRP, _AC_FUNC_STAT, AC_FUNC_STRTOD, AC_FUNC_STRERROR_R): (AC_FUNC_STRNLEN, AC_FUNC_SETVBUF_REVERSED, AC_FUNC_UTIME_NULL): (_AC_FUNC_FORK, _AC_FUNC_VFORK, AC_FUNC_WAIT3): Likewise. * lib/autoconf/headers.m4 (AC_HEADER_STDC): Likewise. * lib/autoconf/specific.m4 (AC_SYS_RESTARTABLE_SYSCALLS): Likewise. * lib/autoconf/types.m4 (AC_TYPE_GETGROUPS): Likewise. * tests/compile.at: Likewsie. --- diff --git a/ChangeLog b/ChangeLog index 73f3632e1..503fe6402 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2006-04-02 Paul Eggert + + * NEWS: AC_PROG_CC and AC_PROG_CXX no longer declare 'exit'. + * doc/autoconf.texi (Function Portability): Mention that C++ + has trouble with 'exit'. + (Guidelines): Test programs shouldn't use 'exit'. + * lib/autoconf/c.m4 (_AC_PROG_CXX_EXIT_DECLARATION): + Remove; all uses removed. + (AC_LANG_INT_SAVE(C), AC_C_BIGENDIAN): + Return from 'main' instead of calling 'exit'. + * lib/autoconf/functions.m4 (_AC_LIBOBJ_ALLOCA, AC_FUNC_CLOSEDIR_VOID): + (_AC_FUNC_FNMATCH_IF, AC_FUNC_GETGROUPS): + (AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK, _AC_FUNC_MALLOC_IF): + (AC_FUNC_MEMCMP, AC_FUNC_MKTIME, AC_FUNC_MMAP, _AC_FUNC_REALLOC_IF): + (AC_FUNC_SETPGRP, _AC_FUNC_STAT, AC_FUNC_STRTOD, AC_FUNC_STRERROR_R): + (AC_FUNC_STRNLEN, AC_FUNC_SETVBUF_REVERSED, AC_FUNC_UTIME_NULL): + (_AC_FUNC_FORK, _AC_FUNC_VFORK, AC_FUNC_WAIT3): Likewise. + * lib/autoconf/headers.m4 (AC_HEADER_STDC): Likewise. + * lib/autoconf/specific.m4 (AC_SYS_RESTARTABLE_SYSCALLS): Likewise. + * lib/autoconf/types.m4 (AC_TYPE_GETGROUPS): Likewise. + * tests/compile.at: Likewsie. + 2006-04-02 Stepan Kasal * lib/autoconf/c.m4 (AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC): Call diff --git a/NEWS b/NEWS index 277d21b81..46e8a40c4 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,13 @@ Now checks for X11/Xlib.h and XrmInitialize (X proper) rather than X11/Intrinsic.h and XtMalloc (Xt). +** AC_PROG_CC, AC_PROG_CXX + No longer automatically arrange to declare the 'exit' function of C, + when a C++ compiler is used. Standard Autoconf macros no longer use + 'exit', so this is no longer an issue for them. If you use C++, and + want to call 'exit', you'll have to arrange for its declaration + yourself. But we now suggest you return from 'main' instead. + ** AC_PROG_CC_C89, AC_PROG_CC_C99 New macros for ISO C99 support. AC_PROG_CC_C89 and AC_PROG_CC_C99 check for ANSI C89 and ISO C99 support respectively. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index caddff2a1..6f611bf31 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -3838,10 +3838,15 @@ additions. Please help us keeping it as complete as possible. @item @code{exit} @c @fuindex exit @prindex @code{exit} -Did you know that, on some older hosts, @code{exit} returns @code{int}? +On ancient hosts, @code{exit} returned @code{int}. This is because @code{exit} predates @code{void}, and there was a long tradition of it returning @code{int}. +On more-modern hosts, the problem more likely is that @code{exit} is not +declared, due to C++ problems of some sort or another. For this reason +we suggest that test programs not invoke @code{exit}, but return from +@code{main} instead. + @item @code{free} @c @fuindex free @prindex @code{free} @@ -6599,7 +6604,7 @@ environment variable) on a trivial @file{Imakefile} and examining the will disable this method. If this method fails to find the X Window System, @command{configure} -will look for the files in several directories where they often reside. +will look for the files in several directories where they often reside. If either method is successful, set the shell variables @code{x_includes} and @code{x_libraries} to their locations, unless they are in directories the compiler searches by default. @@ -7002,9 +7007,9 @@ Test programs should not write anything to the standard output. They should return 0 if the test succeeds, nonzero otherwise, so that success can be distinguished easily from a core dump or other failure; segmentation violations and other failures produce a nonzero exit -status. Test programs should @code{exit}, not @code{return}, from -@code{main}, because on some systems (old Suns, at least) the argument -to @code{return} in @code{main} is ignored. +status. Test programs should @code{return}, not @code{exit}, from +@code{main}, because on some systems (notably C++ compilers masquerading +as C compilers) @code{exit} is not declared. Test programs can use @code{#if} or @code{#ifdef} to check the values of preprocessor macros defined by tests that have already run. For diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 75f4f533a..cfc72096b 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -278,22 +278,22 @@ static unsigned long int ulongval () { return $2; } [ FILE *f = fopen ("conftest.val", "w"); if (! f) - exit (1); + return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) - exit (1); + return 1; fprintf (f, "%ld\n", i); } else { unsigned long int i = ulongval (); if (i != ($2)) - exit (1); + return 1; fprintf (f, "%lu\n", i); } - exit (ferror (f) || fclose (f) != 0); + return ferror (f) || fclose (f) != 0; ])]) @@ -552,14 +552,6 @@ _AC_LANG_COMPILER_GNU GCC=`test $ac_compiler_gnu = yes && echo yes` _AC_PROG_CC_G _AC_PROG_CC_C89 -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -_AC_COMPILE_IFELSE([@%:@ifndef __cplusplus - choke me -@%:@endif], - [_AC_PROG_CXX_EXIT_DECLARATION]) AC_LANG_POP(C)dnl ])# AC_PROG_CC @@ -786,7 +778,6 @@ _AC_COMPILER_EXEEXT _AC_LANG_COMPILER_GNU GXX=`test $ac_compiler_gnu = yes && echo yes` _AC_PROG_CXX_G -_AC_PROG_CXX_EXIT_DECLARATION AC_LANG_POP(C++)dnl ])# AC_PROG_CXX @@ -833,43 +824,6 @@ fi[]dnl ])# _AC_PROG_CXX_G -# _AC_PROG_CXX_EXIT_DECLARATION -# ----------------------------- -# If doesn't already provide a valid prototype for exit, -# determine the appropriate prototype and put it in confdefs.h. -# This macro is run only when testing a C++ compiler, but it generates -# a prototype that is also appropriate for C compilers in order to -# support a mixed C/C++ configuration environment. -# We don't need to worry about this for C, since we include -# if it is available, and that method works for all C compilers. -m4_define([_AC_PROG_CXX_EXIT_DECLARATION], -[for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'extern "C" __declspec(dllimport) void exit (int);' \ - 'void exit (int);' -do - _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration -@%:@include ], - [exit (42);])], - [], - [continue]) - _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration], - [exit (42);])], - [break]) -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi -])# _AC_PROG_CXX_EXIT_DECLARATION - - # ------------------------------ # # 3d. The Objective C compiler. # # ------------------------------ # @@ -1381,7 +1335,7 @@ AC_RUN_IFELSE( char c[sizeof (long int)]; } u; u.l = 1; - exit (u.c[sizeof (long int) - 1] == 1); + return u.c[sizeof (long int) - 1] == 1; ]])], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index 3dc8280a5..a8fab59c4 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -298,7 +298,7 @@ find_stack_direction () int main () { - exit (find_stack_direction () < 0); + return find_stack_direction () < 0; }])], [ac_cv_c_stack_direction=1], [ac_cv_c_stack_direction=-1], @@ -389,15 +389,14 @@ AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works, struct stat before, after; if (creat (f, 0600) < 0) - exit (1); + return 1; if (stat (f, &before) < 0) - exit (1); + return 1; if (chown (f, (uid_t) -1, (gid_t) -1) == -1) - exit (1); + return 1; if (stat (f, &after) < 0) - exit (1); - exit ((before.st_uid == after.st_uid - && before.st_gid == after.st_gid) ? 0 : 1); + return 1; + return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid); ]])], [ac_cv_func_chown_works=yes], [ac_cv_func_chown_works=no], @@ -426,7 +425,7 @@ AC_CACHE_CHECK([whether closedir returns void], int closedir (); #endif ], - [[exit (closedir (opendir (".")) != 0);]])], + [[return closedir (opendir (".")) != 0;]])], [ac_cv_func_closedir_void=no], [ac_cv_func_closedir_void=yes], [ac_cv_func_closedir_void=yes])]) @@ -478,7 +477,7 @@ AC_DEFUN([_AC_FUNC_FNMATCH_IF], # define y(a, b, c) (fnmatch (a, b, c) == 0) # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH) ], - [exit + [return (!(y ("a*", "abc", 0) && n ("d*/*1", "d/s/1", FNM_PATHNAME) && y ("a\\\\bc", "abc", 0) @@ -602,7 +601,7 @@ if test $ac_cv_func_getgroups = yes; then AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works, [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */ - exit (getgroups (0, 0) == -1 ? 1 : 0);]])], + return getgroups (0, 0) == -1;]])], [ac_cv_func_getgroups_works=yes], [ac_cv_func_getgroups_works=no], [ac_cv_func_getgroups_works=no]) @@ -815,7 +814,7 @@ if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then /* Linux will dereference the symlink and fail. That is better in the sense that it means we will not have to compile and use the lstat wrapper. */ - exit (lstat ("conftest.sym/", &sbuf) ? 0 : 1);])], + return lstat ("conftest.sym/", &sbuf) != 0;])], [ac_cv_func_lstat_dereferences_slashed_symlink=yes], [ac_cv_func_lstat_dereferences_slashed_symlink=no], [ac_cv_func_lstat_dereferences_slashed_symlink=no]) @@ -853,7 +852,7 @@ AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull, char *malloc (); #endif ]], - [exit (malloc (0) ? 0 : 1);])], + [return ! malloc (0);])], [ac_cv_func_malloc_0_nonnull=yes], [ac_cv_func_malloc_0_nonnull=no], [ac_cv_func_malloc_0_nonnull=no])]) @@ -911,7 +910,7 @@ AC_DEFUN([AC_FUNC_MEMCMP], /* Some versions of memcmp are not 8-bit clean. */ char c0 = '\100', c1 = '\200', c2 = '\201'; if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) - exit (1); + return 1; /* The Next x86 OpenStep bug shows up only when comparing 16 bytes or more and with at least one buffer not starting on a 4-byte boundary. @@ -927,9 +926,9 @@ AC_DEFUN([AC_FUNC_MEMCMP], strcpy (a, "--------01111111"); strcpy (b, "--------10000000"); if (memcmp (a, b, 16) >= 0) - exit (1); + return 1; } - exit (0); + return 0; } ]])], [ac_cv_func_memcmp_working=yes], @@ -985,9 +984,9 @@ static char *tz_strings[] = { }; #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) -/* Fail if mktime fails to convert a date in the spring-forward gap. +/* Return 0 if mktime fails to convert a date in the spring-forward gap. Based on a problem report from Andreas Jaeger. */ -static void +static int spring_forward_gap () { /* glibc (up to about 1998-10-07) failed this test. */ @@ -1006,29 +1005,27 @@ spring_forward_gap () tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = -1; - if (mktime (&tm) == (time_t)-1) - exit (1); + return mktime (&tm) != (time_t) -1; } -static void +static int mktime_test1 (now) time_t now; { struct tm *lt; - if ((lt = localtime (&now)) && mktime (lt) != now) - exit (1); + return ! (lt = localtime (&now)) || mktime (lt) == now; } -static void +static int mktime_test (now) time_t now; { - mktime_test1 (now); - mktime_test1 ((time_t) (time_t_max - now)); - mktime_test1 ((time_t) (time_t_min + now)); + return (mktime_test1 (now) + && mktime_test1 ((time_t) (time_t_max - now)) + && mktime_test1 ((time_t) (time_t_min + now))); } -static void +static int irix_6_4_bug () { /* Based on code from Ariel Faigon. */ @@ -1041,11 +1038,10 @@ irix_6_4_bug () tm.tm_sec = 0; tm.tm_isdst = -1; mktime (&tm); - if (tm.tm_mon != 2 || tm.tm_mday != 31) - exit (1); + return tm.tm_mon == 2 && tm.tm_mday == 31; } -static void +static int bigtime_test (j) int j; { @@ -1067,8 +1063,9 @@ bigtime_test (j) && lt->tm_wday == tm.tm_wday && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) - exit (1); + return 0; } + return 1; } int @@ -1095,18 +1092,20 @@ main () putenv (tz_strings[i]); for (t = 0; t <= time_t_max - delta; t += delta) - mktime_test (t); - mktime_test ((time_t) 1); - mktime_test ((time_t) (60 * 60)); - mktime_test ((time_t) (60 * 60 * 24)); + if (! mktime_test (t)) + return 1; + if (! (mktime_test ((time_t) 1) + && mktime_test ((time_t) (60 * 60)) + && mktime_test ((time_t) (60 * 60 * 24)))) + return 1; for (j = 1; 0 < j; j *= 2) - bigtime_test (j); - bigtime_test (j - 1); + if (! bigtime_test (j)) + return 1; + if (! bigtime_test (j - 1)) + return 1; } - irix_6_4_bug (); - spring_forward_gap (); - exit (0); + return ! (irix_6_4_bug () && spring_forward_gap ()); }]])], [ac_cv_func_working_mktime=yes], [ac_cv_func_working_mktime=no], @@ -1211,15 +1210,15 @@ main () /* First, make a file with some known garbage in it. */ data = (char *) malloc (pagesize); if (!data) - exit (1); + return 1; for (i = 0; i < pagesize; ++i) *(data + i) = rand (); umask (0); fd = creat ("conftest.mmap", 0600); if (fd < 0) - exit (1); + return 1; if (write (fd, data, pagesize) != pagesize) - exit (1); + return 1; close (fd); /* Next, try to mmap the file at a fixed address which already has @@ -1227,17 +1226,17 @@ main () we see the same garbage. */ fd = open ("conftest.mmap", O_RDWR); if (fd < 0) - exit (1); + return 1; data2 = (char *) malloc (2 * pagesize); if (!data2) - exit (1); + return 1; data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1); if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0L)) - exit (1); + return 1; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data2 + i)) - exit (1); + return 1; /* Finally, make sure that changes to the mapped area do not percolate back to the file as seen by read(). (This is a bug on @@ -1246,14 +1245,14 @@ main () *(data2 + i) = *(data2 + i) + 1; data3 = (char *) malloc (pagesize); if (!data3) - exit (1); + return 1; if (read (fd, data3, pagesize) != pagesize) - exit (1); + return 1; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data3 + i)) - exit (1); + return 1; close (fd); - exit (0); + return 0; }]])], [ac_cv_func_mmap_fixed_mapped=yes], [ac_cv_func_mmap_fixed_mapped=no], @@ -1313,7 +1312,7 @@ AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull, char *realloc (); #endif ]], - [exit (realloc (0, 0) ? 0 : 1);])], + [return ! realloc (0, 0);])], [ac_cv_func_realloc_0_nonnull=yes], [ac_cv_func_realloc_0_nonnull=no], [ac_cv_func_realloc_0_nonnull=no])]) @@ -1395,7 +1394,7 @@ AC_DEFUN([AC_FUNC_SETPGRP], [/* 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. */ - exit (setpgrp (1,1) == -1 ? 0 : 1);])], + return setpgrp (1,1) != -1;])], [ac_cv_func_setpgrp_void=no], [ac_cv_func_setpgrp_void=yes], [AC_MSG_ERROR([cannot check setpgrp when cross compiling])])]) @@ -1421,9 +1420,9 @@ AC_CACHE_CHECK([whether $1 accepts an empty string], [ac_cv_func_$1_empty_string_bug], [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[struct stat sbuf; - exit ($1 ("", &sbuf) ? 1 : 0);]])], - [ac_cv_func_$1_empty_string_bug=yes], + return $1 ("", &sbuf) == 0;]])], [ac_cv_func_$1_empty_string_bug=no], + [ac_cv_func_$1_empty_string_bug=yes], [ac_cv_func_$1_empty_string_bug=yes])]) if test $ac_cv_func_$1_empty_string_bug = yes; then AC_LIBOBJ([$1]) @@ -1476,7 +1475,7 @@ main() double value; value = strtod (string, &term); if (value != 69 || term != (string + 4)) - exit (1); + return 1; } { @@ -1486,9 +1485,9 @@ main() char *term; strtod (string, &term); if (term != string && *(term - 1) == 0) - exit (1); + return 1; } - exit (0); + return 0; } ]])], ac_cv_func_strtod=yes, @@ -1535,7 +1534,7 @@ AC_CACHE_CHECK([whether strerror_r returns char *], extern char *strerror_r ();], [[char buf[100]; char x = *strerror_r (0, buf, sizeof buf); - exit (!isalpha (x));]])], + return ! isalpha (x);]])], ac_cv_func_strerror_r_char_p=yes, , :) fi ]) @@ -1575,9 +1574,9 @@ AC_DEFUN([AC_FUNC_STRNLEN], { int expected = i <= S_LEN ? i : S_LEN; if (strnlen (S, i) != expected) - exit (1); + return 1; } - exit (0); + return 0; ]])], [ac_cv_func_strnlen_working=yes], [ac_cv_func_strnlen_working=no], @@ -1619,9 +1618,9 @@ AC_CACHE_CHECK(whether setvbuf arguments are reversed, is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ char buf; if (setvbuf (stdout, _IOLBF, &buf, 1) != 0) - exit (1); + return 1; putchar ('\r'); - exit (0); /* Non-reversed systems SEGV here. */]])], + return 0; /* Non-reversed systems SEGV here. */]])], [ac_cv_func_setvbuf_reversed=yes], [], [[: # Assume setvbuf is not reversed when cross-compiling.]])] @@ -1646,7 +1645,7 @@ AN_FUNCTION([strcoll], [AC_FUNC_STRCOLL]) AC_DEFUN([AC_FUNC_STRCOLL], [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works, [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], - [[exit (strcoll ("abc", "def") >= 0 || + [[return (strcoll ("abc", "def") >= 0 || strcoll ("ABC", "DEF") >= 0 || strcoll ("123", "456") >= 0)]])], ac_cv_func_strcoll_works=yes, @@ -1674,11 +1673,11 @@ AC_DEFUN([AC_FUNC_UTIME_NULL], # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong. AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[struct stat s, t; - exit (!(stat ("conftest.data", &s) == 0 - && utime ("conftest.data", 0) == 0 - && stat ("conftest.data", &t) == 0 - && t.st_mtime >= s.st_mtime - && t.st_mtime - s.st_mtime < 120));]])], + return ! (stat ("conftest.data", &s) == 0 + && utime ("conftest.data", 0) == 0 + && stat ("conftest.data", &t) == 0 + && t.st_mtime >= s.st_mtime + && t.st_mtime - s.st_mtime < 120);]])], ac_cv_func_utime_null=yes, ac_cv_func_utime_null=no, ac_cv_func_utime_null=no)]) @@ -1749,9 +1748,7 @@ AC_DEFUN([_AC_FUNC_FORK], [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [ /* By Ruediger Kuhlmann. */ - if (fork() < 0) - exit (1); - exit (0); + return fork () < 0; ])], [ac_cv_func_fork_works=yes], [ac_cv_func_fork_works=no], @@ -1837,7 +1834,7 @@ main () while (wait(&status) != child) ; - exit( + return ( /* Was there some problem with vforking? */ child < 0 @@ -1932,8 +1929,8 @@ main () wait3(&i, 0, &r); /* Avoid "text file busy" from rm on fast HP-UX machines. */ sleep(2); - exit (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0 - && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0); + return (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0 + && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0); } }]])], [ac_cv_func_wait3_rusage=yes], diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4 index 43e15f0ff..28d831cb6 100644 --- a/lib/autoconf/headers.m4 +++ b/lib/autoconf/headers.m4 @@ -643,8 +643,8 @@ main () for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) - exit (2); - exit (0); + return 2; + return 0; }]])], , ac_cv_header_stdc=no, :) fi]) if test $ac_cv_header_stdc = yes; then diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 1d141659e..de949047e 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -280,7 +280,7 @@ main () sleep (3); kill (getppid (), SIGINT); sleep (3); - exit (0); + return 0; } signal (SIGINT, ucatch); @@ -289,7 +289,7 @@ main () if (status == -1) wait (&i); - exit (status == -1); + return status == -1; }])], [ac_cv_sys_restartable_syscalls=yes], [ac_cv_sys_restartable_syscalls=no])]) diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4 index 64a57ef0e..0f6f64fa3 100644 --- a/lib/autoconf/types.m4 +++ b/lib/autoconf/types.m4 @@ -139,7 +139,7 @@ # (not necessarily size_t etc.). Equally, instead of defining an unused # variable, we just use a cast to avoid warnings from the compiler. # Suggested by Paul Eggert. -# +# # Now, the next issue is that C++ disallows defining types inside casts # and inside `sizeof()', but we would like to allow unnamed structs, for # use inside AC_CHECK_SIZEOF, for example. So we create a typedef of the @@ -280,7 +280,7 @@ main () /* Exit non-zero if getgroups seems to require an array of ints. This happens when gid_t is short int but getgroups modifies an array of ints. */ - exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0); + return n > 0 && gidset[n] != val.gval; }]])], [ac_cv_type_getgroups=gid_t], [ac_cv_type_getgroups=int], diff --git a/tests/compile.at b/tests/compile.at index b56b02a7a..a7d613922 100644 --- a/tests/compile.at +++ b/tests/compile.at @@ -2,7 +2,7 @@ AT_BANNER([Low level compiling/preprocessing macros.]) -# Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -116,19 +116,19 @@ AT_SETUP([AC_RUN_IFELSE]) AT_DATA([configure.ac], [[AC_INIT -AC_RUN_IFELSE([AC_LANG_PROGRAM([], [exit (0)])], +AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0])], [], - [AC_MSG_ERROR([saw `exit 0' as a failure])]) + [AC_MSG_ERROR([saw `return 0' as a failure])]) -AC_RUN_IFELSE([AC_LANG_PROGRAM([], [exit (2)])], - [AC_MSG_ERROR([saw `exit 2' as a success])], +AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 2])], + [AC_MSG_ERROR([saw `return 2' as a success])], [status=$? test $status != 2 && AC_MSG_ERROR([did not get as 2 exit status: $status])]) # The old stinky one. -AC_TRY_RUN([int main () { exit (3); }], - [AC_MSG_ERROR([saw `exit 3' as a success])], +AC_TRY_RUN([int main () { return 3; }], + [AC_MSG_ERROR([saw `return 3' as a success])], [status=$? test $status != 3 && AC_MSG_ERROR([did not get 3 as exit status: $status])])