Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Florian Weimer Newsgroups: gnu.bash.bug Subject: [PATCH] Further autoconf changes for C99 compiler support Date: Tue, 10 Sep 2019 14:22:45 +0200 Lines: 611 Approved: bug-bash@gnu.org Message-ID: References: <20190910122245.30217-1-fweimer@redhat.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Trace: usenet.stanford.edu 1568124543 3769 209.51.188.17 (10 Sep 2019 14:09:03 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 10 Sep 2019 12:22:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-Mailman-Approved-At: Tue, 10 Sep 2019 10:09:01 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20190910122245.30217-1-fweimer@redhat.com> Xref: csiph.com gnu.bash.bug:15354 These changes avoid a few additional cases of implicit function declarations and implicit ints. --- aclocal.m4 | 82 ++++++++++++++++++++++++++++++--------------------- configure | 73 ++++++++++++++++++++++++++++----------------- m4/intdiv0.m4 | 3 ++ 3 files changed, 98 insertions(+), 60 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index c42dbf3b..a384739d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -139,7 +139,7 @@ typedef int (*_bashfunc)(const char *, ...); typedef int (*_bashfunc)(); #endif #include -main() +int main() { _bashfunc pf; pf =3D (_bashfunc) printf; @@ -200,7 +200,7 @@ AC_CACHE_VAL(bash_cv_under_sys_siglist, #ifndef UNDER_SYS_SIGLIST_DECLARED extern char *_sys_siglist[]; #endif -main() +int main() { char *msg =3D (char *)_sys_siglist[2]; exit(msg =3D=3D 0); @@ -228,7 +228,7 @@ AC_CACHE_VAL(bash_cv_sys_siglist, #if !HAVE_DECL_SYS_SIGLIST extern char *sys_siglist[]; #endif -main() +int main() { char *msg =3D sys_siglist[2]; exit(msg =3D=3D 0); @@ -281,7 +281,10 @@ AC_CACHE_VAL(bash_cv_dup2_broken, #include #include #include -main() +#ifdef HAVE_UNISTD_H +#include +#endif +int main() { int fd1, fd2, fl; fd1 =3D open("/dev/null", 2); @@ -308,7 +311,8 @@ AC_DEFUN(BASH_FUNC_STRSIGNAL, [AC_MSG_CHECKING([for the existence of strsignal]) AC_CACHE_VAL(bash_cv_have_strsignal, [AC_TRY_LINK([#include -#include ], +#include +#include ], [char *s =3D (char *)strsignal(2);], bash_cv_have_strsignal=3Dyes, bash_cv_have_strsignal=3Dno)]) AC_MSG_RESULT($bash_cv_have_strsignal) @@ -329,6 +333,9 @@ AC_CACHE_VAL(bash_cv_opendir_not_robust, #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ +#ifdef HAVE_SYS_STAT_H +# include +#endif /* HAVE_SYS_STAT_H */ #if defined(HAVE_DIRENT_H) # include #else @@ -344,7 +351,7 @@ AC_CACHE_VAL(bash_cv_opendir_not_robust, # endif #endif /* HAVE_DIRENT_H */ #include -main() +int main() { DIR *dir; int fd, err; @@ -524,7 +531,7 @@ AC_TRY_RUN([ #include #include #include -main() +int main() { #ifdef HAVE_QUAD_T struct rlimit rl; @@ -609,7 +616,7 @@ getenv (name) { return "42"; } -main() +int main() { char *s; /* The next allows this program to run, but does not allow bash to link @@ -695,10 +702,13 @@ AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS, [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize) AC_CACHE_VAL(bash_cv_ulimit_maxfds, [AC_TRY_RUN([ -main() +#ifdef HAVE_ULIMIT_H +#include +#endif +int main() { long maxfds =3D ulimit(4, 0L); -exit (maxfds =3D=3D -1L); +return maxfds =3D=3D -1L; } ], bash_cv_ulimit_maxfds=3Dyes, bash_cv_ulimit_maxfds=3Dno, [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to = no) @@ -719,11 +729,11 @@ AC_CACHE_VAL(bash_cv_getcwd_malloc, #include #endif =20 -main() +int main() { char *xpwd; xpwd =3D getcwd(0, 0); - exit (xpwd =3D=3D 0); + return xpwd =3D=3D 0; } ], bash_cv_getcwd_malloc=3Dyes, bash_cv_getcwd_malloc=3Dno, [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-= compiling -- defaulting to no) @@ -768,12 +778,12 @@ AC_CACHE_VAL(bash_cv_fnm_extmatch, [AC_TRY_RUN([ #include =20 -main() +int main() { #ifdef FNM_EXTMATCH - exit (0); + return 0; #else - exit (1); + return 1; #endif } ], bash_cv_fnm_extmatch=3Dyes, bash_cv_fnm_extmatch=3Dno, @@ -799,7 +809,7 @@ AC_CACHE_VAL(bash_cv_func_sigsetjmp, #include #include =20 -main() +int main() { #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) exit (1); @@ -844,11 +854,13 @@ AC_MSG_CHECKING(whether or not strcoll and strcmp d= iffer) AC_CACHE_VAL(bash_cv_func_strcoll_broken, [AC_TRY_RUN([ #include +#include +#include #if defined (HAVE_LOCALE_H) #include #endif =20 -main(c, v) +int main(c, v) int c; char *v[]; { @@ -947,7 +959,7 @@ AC_CACHE_VAL(bash_cv_struct_stat_st_blocks, #include ], [ -main() +int main() { static struct stat a; if (a.st_blocks) return 0; @@ -1254,8 +1266,11 @@ AC_CACHE_VAL(bash_cv_pgrp_pipe, #ifdef HAVE_UNISTD_H # include #endif +#ifdef HAVE_SYS_WAIT_H +# include +#endif #include -main() +int main() { # ifdef GETPGRP_VOID # define getpgID() getpgrp() @@ -1350,13 +1365,13 @@ int s; nsigint++; } =20 -main() +int main() { nsigint =3D 0; set_signal_handler(SIGINT, sigint); kill((int)getpid(), SIGINT); kill((int)getpid(), SIGINT); - exit(nsigint !=3D 2); + return nsigint !=3D 2; } ], bash_cv_must_reinstall_sighandlers=3Dno, bash_cv_must_reinstall_sigha= ndlers=3Dyes, [AC_MSG_WARN(cannot check signal handling if cross compiling -- defau= lting to no) @@ -1433,10 +1448,11 @@ AC_CACHE_VAL(bash_cv_sys_named_pipes, #ifdef HAVE_UNISTD_H #include #endif +#include #include =20 /* Add more tests in here as appropriate. */ -main() +int main() { int fd, err; =20 @@ -1673,7 +1689,7 @@ AC_CACHE_VAL(bash_cv_unusable_rtsigs, # define NSIG 64 #endif =20 -main () +int main () { int n_sigs =3D 2 * NSIG; #ifdef SIGRTMIN @@ -1787,7 +1803,7 @@ bash_cv_wcwidth_broken, #include #include =20 -main(c, v) +int main(c, v) int c; char **v; { @@ -1855,7 +1871,7 @@ AC_CACHE_VAL(ac_cv_rl_version, =20 extern int rl_gnu_readline_p; =20 -main() +int main() { FILE *fp; fp =3D fopen("conftest.rlv", "w"); @@ -1945,7 +1961,7 @@ AC_CACHE_VAL(bash_cv_func_ctype_nonascii, #include #include =20 -main(c, v) +int main(c, v) int c; char *v[]; { @@ -1966,7 +1982,7 @@ char *v[]; r1 =3D isprint(x); x -=3D 128; r2 =3D isprint(x); - exit (r1 =3D=3D 0 || r2 =3D=3D 0); + return r1 =3D=3D 0 || r2 =3D=3D 0; } ], bash_cv_func_ctype_nonascii=3Dyes, bash_cv_func_ctype_nonascii=3Dno, [AC_MSG_WARN(cannot check ctype macros if cross compiling -- defaulti= ng to no) @@ -1991,15 +2007,15 @@ AC_CACHE_VAL(bash_cv_wcontinued_broken, #ifndef errno extern int errno; #endif -main() +int main() { int x; =20 x =3D waitpid(-1, (int *)0, WNOHANG|WCONTINUED); if (x =3D=3D -1 && errno =3D=3D EINVAL) - exit (1); + return 1; else - exit (0); + return 0; } ], bash_cv_wcontinued_broken=3Dno,bash_cv_wcontinued_broken=3Dyes, [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting= to no) @@ -2058,7 +2074,7 @@ AC_DEFUN([BASH_FUNC_SNPRINTF], #include #include =20 -main() +int main() { int n; n =3D snprintf (0, 0, "%s", "0123456"); @@ -2114,7 +2130,7 @@ foo(format, va_alist) return n; } =20 -main() +int main() { int n; n =3D foo("%s", "0123456"); @@ -2143,7 +2159,7 @@ AC_CACHE_VAL(bash_cv_wexitstatus_offset, =20 #include =20 -main(c, v) +int main(c, v) int c; char **v; { diff --git a/configure b/configure index 088118ba..a578d5b1 100755 --- a/configure +++ b/configure @@ -5396,7 +5396,7 @@ else =20 extern int rl_gnu_readline_p; =20 -main() +int main() { FILE *fp; fp =3D fopen("conftest.rlv", "w"); @@ -7881,6 +7881,9 @@ else =20 #include #include +#ifdef HAVE_UNISTD_H +#include +#endif =20 static void sigfpe_handler (int sig) @@ -15415,7 +15418,7 @@ else #include #include =20 -main(c, v) +int main(c, v) int c; char **v; { @@ -16858,7 +16861,7 @@ else #include #include =20 -main(c, v) +int main(c, v) int c; char *v[]; { @@ -16879,7 +16882,7 @@ char *v[]; r1 =3D isprint(x); x -=3D 128; r2 =3D isprint(x); - exit (r1 =3D=3D 0 || r2 =3D=3D 0); + return r1 =3D=3D 0 || r2 =3D=3D 0; } =20 _ACEOF @@ -16917,7 +16920,10 @@ else #include #include #include -main() +#ifdef HAVE_UNISTD_H +#include +#endif +int main() { int fd1, fd2, fl; fd1 =3D open("/dev/null", 2); @@ -16968,8 +16974,11 @@ else #ifdef HAVE_UNISTD_H # include #endif +#ifdef HAVE_SYS_WAIT_H +# include +#endif #include -main() +int main() { # ifdef GETPGRP_VOID # define getpgID() getpgrp() @@ -17186,7 +17195,7 @@ else #if !HAVE_DECL_SYS_SIGLIST extern char *sys_siglist[]; #endif -main() +int main() { char *msg =3D sys_siglist[2]; exit(msg =3D=3D 0); @@ -17268,7 +17277,7 @@ else #ifndef UNDER_SYS_SIGLIST_DECLARED extern char *_sys_siglist[]; #endif -main() +int main() { char *msg =3D (char *)_sys_siglist[2]; exit(msg =3D=3D 0); @@ -17673,7 +17682,7 @@ else #include #include #include -main() +int main() { #ifdef HAVE_QUAD_T struct rlimit rl; @@ -18200,7 +18209,7 @@ else =20 #include =20 -main(c, v) +int main(c, v) int c; char **v; { @@ -18528,6 +18537,7 @@ else /* end confdefs.h. */ #include #include +#include int main () { @@ -18572,6 +18582,9 @@ else #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ +#ifdef HAVE_SYS_STAT_H +# include +#endif /* HAVE_SYS_STAT_H */ #if defined(HAVE_DIRENT_H) # include #else @@ -18587,7 +18600,7 @@ else # endif #endif /* HAVE_DIRENT_H */ #include -main() +int main() { DIR *dir; int fd, err; @@ -18638,10 +18651,13 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ =20 -main() +#ifdef HAVE_ULIMIT_H +#include +#endif +int main() { long maxfds =3D ulimit(4, 0L); -exit (maxfds =3D=3D -1L); +return maxfds =3D=3D -1L; } =20 _ACEOF @@ -18716,7 +18732,7 @@ getenv (name) { return "42"; } -main() +int main() { char *s; /* The next allows this program to run, but does not allow bash to link @@ -18768,11 +18784,11 @@ else #include #endif =20 -main() +int main() { char *xpwd; xpwd =3D getcwd(0, 0); - exit (xpwd =3D=3D 0); + return xpwd =3D=3D 0; } =20 _ACEOF @@ -18824,7 +18840,7 @@ else #include #include =20 -main() +int main() { #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) exit (1); @@ -18889,11 +18905,13 @@ else /* end confdefs.h. */ =20 #include +#include +#include #if defined (HAVE_LOCALE_H) #include #endif =20 -main(c, v) +int main(c, v) int c; char *v[]; { @@ -18964,7 +18982,7 @@ else #include #include =20 -main() +int main() { int n; n =3D snprintf (0, 0, "%s", "0123456"); @@ -19043,7 +19061,7 @@ foo(format, va_alist) return n; } =20 -main() +int main() { int n; n =3D foo("%s", "0123456"); @@ -19346,13 +19364,13 @@ int s; nsigint++; } =20 -main() +int main() { nsigint =3D 0; set_signal_handler(SIGINT, sigint); kill((int)getpid(), SIGINT); kill((int)getpid(), SIGINT); - exit(nsigint !=3D 2); + return nsigint !=3D 2; } =20 _ACEOF @@ -19467,10 +19485,11 @@ else #ifdef HAVE_UNISTD_H #include #endif +#include #include =20 /* Add more tests in here as appropriate. */ -main() +int main() { int fd, err; =20 @@ -19668,15 +19687,15 @@ else #ifndef errno extern int errno; #endif -main() +int main() { int x; =20 x =3D waitpid(-1, (int *)0, WNOHANG|WCONTINUED); if (x =3D=3D -1 && errno =3D=3D EINVAL) - exit (1); + return 1; else - exit (0); + return 0; } =20 _ACEOF @@ -19784,7 +19803,7 @@ else # define NSIG 64 #endif =20 -main () +int main () { int n_sigs =3D 2 * NSIG; #ifdef SIGRTMIN diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4 index e63fcf10..92f3ae5c 100644 --- a/m4/intdiv0.m4 +++ b/m4/intdiv0.m4 @@ -33,6 +33,9 @@ changequote([,])dnl [AC_LANG_SOURCE([[ #include #include +#ifdef HAVE_UNISTD_H +#include +#endif =20 static void sigfpe_handler (int sig) --=20 2.21.0