From cdf466e75ed70395f2b765aaac348446c9d12eed Mon Sep 17 00:00:00 2001 From: Marcus Comstedt <marcus@mc.pp.se> Date: Thu, 31 Dec 2020 11:27:27 +0100 Subject: [PATCH] Backport configure fixes from 8.1 --- src/aclocal.m4 | 2 + src/configure.in | 65 +++++++++++++++++++++++++--- src/fd_control.c | 1 + src/modules/Java/configure.in | 6 ++- src/modules/_Image_TIFF/configure.in | 1 + src/modules/_Stdio/configure.in | 30 ++++++++++++- 6 files changed, 95 insertions(+), 10 deletions(-) diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 041ccb368f..156a9a0763 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -1816,6 +1816,7 @@ AC_DEFUN(PIKE_CHECK_ABI_LIB_DIR, LDFLAGS="${LDFLAGS} $add_ldflags -lm" AC_TRY_RUN([ #include <stdio.h> +#include <stdlib.h> #include <math.h> int main(int argc, char **argv) { @@ -1829,6 +1830,7 @@ int main(int argc, char **argv) add_ldflags="" ],[AC_TRY_LINK([ #include <stdio.h> +#include <stdlib.h> #include <math.h> ],[ double (*foo)(double) = ceil; diff --git a/src/configure.in b/src/configure.in index 33991c09a1..5aa19b759f 100644 --- a/src/configure.in +++ b/src/configure.in @@ -672,6 +672,9 @@ case "$pike_cv_sys_os" in export SDL_CONFIG fi ;; + Darwin*) + ac_cv_func_getpagesize="no" + ;; esac # Skip if user does not wish to use smartlink binary. @@ -2972,6 +2975,7 @@ for YACC in pyacc byacc "bison -y" yacc "None"; do cat >conftest.y<<\EOF %pure_parser %{ +#include <stdlib.h> void parse(); void yyerror(char *); %} @@ -3085,6 +3089,7 @@ void yyerror(char *fel) { errors++; } EOF if $YACC -d conftest.y 1>&AC_FD_CC 2>&AC_FD_CC; then AC_TRY_COMPILE([ +#include <stdlib.h> #include "y.tab.c" ],[ yyparse(); @@ -3146,6 +3151,7 @@ EOF cat conftest.y 1>&AC_FD_CC if $YACC -d conftest.y 1>&AC_FD_CC 2>&AC_FD_CC; then AC_TRY_LINK([ +#include <stdlib.h> #include "y.tab.c" ], [ yyparse(); @@ -3191,7 +3197,7 @@ if test "$ac_cv_c_const" = "yes"; then AC_TRY_COMPILE([ const int foo(int bar) { return bar; } ], [ - return bar(0); + return foo(0); ], [ pike_cv_c_really_const=yes ], [ @@ -3257,8 +3263,8 @@ AC_CHECK_HEADERS(winsock2.h sys/rusage.h time.h sys/time.h sys/types.h \ crt/signal.h sys/id.h mach-o/dyld.h sys/ptrace.h \ thread.h dlfcn.h dld.h dl.h sys/times.h sched.h \ sys/procfs.h sys/ioct.h sys/socket.h sys/uio.h fcntl.h \ - malloc.h netinet/in.h sys/wait.h windows.h grp.h pwd.h \ - passwd.h group.h winsock.h signal.h sys/file.h poll.h \ + malloc.h netinet/in.h arpa/inet.h sys/wait.h windows.h grp.h \ + pwd.h passwd.h group.h winsock.h signal.h sys/file.h poll.h \ sys/poll.h socket.h ieeefp.h fp_class.h floatingpoint.h \ float.h sys/priocntl.h sys/sched.h winbase.h errno.h \ stddef.h sys/termio.h sys/termios.h \ @@ -3956,6 +3962,7 @@ int main(int argc, char **argv) #define _THREAD_SAFE #define _MIT_POSIX_THREADS 1 +#include <stdlib.h> #include <pthread.h> void *foo(void *bar) { pthread_exit(0); return 0; } @@ -3986,6 +3993,7 @@ int main() #define _THREAD_SAFE #define _MIT_POSIX_THREADS 1 +#include <stdlib.h> #include <pthread.h> void *foo(void *bar) { pthread_exit(0); return 0; } @@ -4199,6 +4207,7 @@ pthread_t gazonk; #define _THREAD_SAFE #define _MIT_POSIX_THREADS 1 +#include <stdlib.h> #include <pthread.h> void *foo(void *bar) { return (void *)getpid(); } @@ -4277,6 +4286,7 @@ extern pthread_t bar; #define _REENTRANT #define _THREAD_SAFE #define _MIT_POSIX_THREADS 1 +#include <stdlib.h> #include <thread.h> #ifdef _UNIXWARE_THREADS_ #include <synch.h> @@ -4350,6 +4360,7 @@ if test "x$pike_cv_sys_os" = "xWindows_NT" -o "x$pike_cv_sys_os" = "xAmigaOS"; t rm -f confdefs.out.2 >/dev/null 2>&1 || : AC_TRY_RUN([ #include <stdio.h> +#include <stdlib.h> static int depth=0; FILE *f; @@ -4986,6 +4997,9 @@ AC_TRY_COMPILE([ #ifdef HAVE_DIRECT_H #include <direct.h> #endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif ],[ mkdir("conftestdir",0666); ],pike_cv_func_mkdir_args=2,pike_cv_func_mkdir_args=1) @@ -5042,6 +5056,7 @@ MY_CHECK_FUNCTION(_isnan, # with AC_CHECK_FUNCS(). MY_CHECK_FUNCTION(isfinite, [ +#include <stdlib.h> #include <math.h> ], [ int t = isfinite(0.0); @@ -5063,6 +5078,7 @@ AC_CACHE_VAL(pike_cv_broken_f_setfd, [ #include <fcntl.h> #endif /* HAVE_FCNTL_H */ #include <stdio.h> +#include <stdlib.h> #ifndef FD_CLOEXEC #define FD_CLOEXEC 1 #endif /* FD_CLOEXEC */ @@ -5599,6 +5615,7 @@ AC_CACHE_VAL(pike_cv_hardware_stack_direction, [ AC_TRY_RUN([ #include <stdio.h> +#include <stdlib.h> static int find_stack_direction(void *foo, int cnt) { if (cnt) return 1*find_stack_direction(foo, cnt>>1); @@ -5910,6 +5927,7 @@ fi ######################################################################## MY_CHECK_FUNCTION(fork, [ +#include <stdlib.h> #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif @@ -5923,6 +5941,7 @@ MY_CHECK_FUNCTION(fork, ######################################################################## MY_CHECK_FUNCTION(fpsetmask, [ +#include <stdlib.h> #include <math.h> #ifdef HAVE_FLOATINGPOINT_H #include <floatingpoint.h> @@ -5938,6 +5957,7 @@ MY_CHECK_FUNCTION(fpsetmask, ######################################################################## MY_CHECK_FUNCTION(fpsetround, [ +#include <stdlib.h> #include <math.h> #ifdef HAVE_FLOATINGPOINT_H #include <floatingpoint.h> @@ -5957,6 +5977,7 @@ MY_CHECK_FUNCTION(fpsetround, ######################################################################## MY_CHECK_FUNCTION(isless, [ +#include <stdlib.h> #include <math.h> #ifdef HAVE_FLOATINGPOINT_H #include <floatingpoint.h> @@ -5973,6 +5994,7 @@ MY_CHECK_FUNCTION(isless, ######################################################################## MY_CHECK_FUNCTION(isunordered, [ +#include <stdlib.h> #include <math.h> #ifdef HAVE_FLOATINGPOINT_H #include <floatingpoint.h> @@ -5990,6 +6012,7 @@ MY_CHECK_FUNCTION(isunordered, ######################################################################## MY_CHECK_FUNCTION(dlopen, [ +#include <stdlib.h> #include <dlfcn.h> ], [ dlopen(0, 0); @@ -5999,6 +6022,7 @@ MY_CHECK_FUNCTION(dlopen, ######################################################################## MY_CHECK_FUNCTION(rint, [ +#include <stdlib.h> #include <math.h> #ifdef HAVE_FLOATINGPOINT_H #include <floatingpoint.h> @@ -6023,6 +6047,7 @@ MY_CHECK_FUNCTION(rint, ############################################################################# MY_CHECK_FUNCTION(GetSystemTimeAsFileTime, [ +#include <stdlib.h> #ifdef HAVE_WINDOWS_H #include <windows.h> #endif @@ -6037,6 +6062,7 @@ MY_CHECK_FUNCTION(GetSystemTimeAsFileTime, ############################################################################# MY_CHECK_FUNCTION(gethostname, [ +#include <stdlib.h> #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -6071,6 +6097,7 @@ fi AC_MSG_CHECKING([for union wait (old BSD convention)]) AC_CACHE_VAL(pike_cv_union_wait, [ AC_TRY_COMPILE([ +#include <stdlib.h> #ifdef HAVE_SYS_WAIT_H #include <sys/wait.h> #endif /* HAVE_SYS_WAIT_H */ @@ -6104,6 +6131,7 @@ AC_MSG_CHECKING(how to extract an unsigned char) AC_CACHE_VAL(pike_cv_method_extract_uchar, [ AC_TRY_RUN([ +#include <stdlib.h> int main() { char i,*p; @@ -6129,6 +6157,7 @@ AC_MSG_CHECKING(how to extract a signed char) AC_CACHE_VAL(pike_cv_method_extract_char, [ AC_TRY_RUN([ +#include <stdlib.h> int main() { char i,*p; @@ -6153,6 +6182,7 @@ AC_MSG_CHECKING(if float conversion can cause SIGFPE) AC_CACHE_VAL(pike_cv_sys_idiot_sigfpe, [ AC_TRY_RUN([ +#include <stdlib.h> #include <math.h> #ifdef HAVE_FLOATINGPOINT_H @@ -6201,6 +6231,7 @@ if test $pike_cv_sys_idiot_sigfpe = yes ; then OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $OPTIMIZE" AC_TRY_RUN([ +#include <stdlib.h> #include <math.h> #ifdef HAVE_FLOATINGPOINT_H @@ -6247,6 +6278,7 @@ if test $TEST_IGNORE_SIGFPE = yes; then OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $OPTIMIZE" AC_TRY_RUN([ +#include <stdlib.h> #include <signal.h> #include <math.h> int counter=0; @@ -6290,6 +6322,7 @@ fi # pike_cv_sys_idiot_sigfpe ############################################################################# define(float_check, [[ +#include <stdlib.h> #include <math.h> #define TY $1 #define TEST_$1 @@ -6603,6 +6636,7 @@ AC_MSG_CHECKING(if __func__ exists and works) AC_CACHE_VAL(pike_cv_have_working___func__, [ AC_TRY_RUN([ +#include <stdlib.h> #ifdef HAVE_STRING_H #include <string.h> #else /* !HAVE_STRING_H */ @@ -6628,6 +6662,7 @@ AC_MSG_CHECKING(if __FUNCTION__ exists and works) AC_CACHE_VAL(pike_cv_have_working___FUNCTION__, [ AC_TRY_RUN([ +#include <stdlib.h> #ifdef HAVE_STRING_H #include <string.h> #else /* !HAVE_STRING_H */ @@ -6690,6 +6725,7 @@ AC_MSG_CHECKING(for lc __declspec) AC_CACHE_VAL(pike_cv_lc___declspec, [ AC_TRY_RUN([ +#include <stdlib.h> #include <stdarg.h> __declspec(noreturn) void fatal(char *foo,...); @@ -6707,6 +6743,7 @@ int main() { exit(0); } ], pike_cv_lc___declspec=yes, pike_cv_lc___declspec=no, [ echo $ac_n "crosscompiling... $ac_c" 1>&6 AC_TRY_LINK([ +#include <stdlib.h> #include <stdarg.h> __declspec(noreturn) void fatal(char *foo,...); @@ -6946,6 +6983,9 @@ AC_CACHE_VAL(pike_cv_system_oob_working,[ #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif #ifdef HAVE_SYS_POLL_H #include <sys/poll.h> #endif @@ -6953,6 +6993,9 @@ AC_CACHE_VAL(pike_cv_system_oob_working,[ #ifdef HAVE_SYS_FILE_H #include <sys/file.h> #endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif #define SP_DEBUG(X) fprintf X @@ -7414,6 +7457,7 @@ AC_MSG_CHECKING(if gettimeofday takes two arguments) AC_CACHE_VAL(pike_cv_func_gettimeofday_has_two_args, [ AC_TRY_RUN([ +#include <stdlib.h> #if TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> @@ -7444,6 +7488,7 @@ int main() { ], [ pike_cv_func_gettimeofday_has_two_args=no ], [ AC_TRY_LINK([ +#include <stdlib.h> #if TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> @@ -7975,7 +8020,8 @@ AC_CACHE_VAL(pike_cv_sys_ccshared,[ fi OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $CCSHARED" - AC_TRY_COMPILE([], [exit(0);], + AC_TRY_COMPILE([#include <stdlib.h> + ], [exit(0);], pike_cv_sys_ccshared="$CCSHARED", pike_cv_sys_ccshared='') CFLAGS="$OLD_CFLAGS" ]) @@ -8022,7 +8068,8 @@ then UnixWare*|OpenUNIX*) LINKFORSHARED="-fpic -Wl,-Bexport";; FreeBSD*) - AC_TRY_RUN([int main(){exit( + AC_TRY_RUN([#include <stdlib.h> +int main(){exit( #ifdef __ELF__ 0 #else @@ -8051,7 +8098,8 @@ then UnixWare*|OpenUNIX*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";; FreeBSD*) - AC_TRY_RUN([int main(){exit( + AC_TRY_RUN([#include <stdlib.h> +int main(){exit( #ifdef __ELF__ 0 #else @@ -8067,7 +8115,8 @@ fi OLD_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $LINKFORSHARED" - AC_TRY_RUN([int main() { exit(0); }], + AC_TRY_RUN([#include <stdlib.h> +int main() { exit(0); }], pike_cv_sys_linkforshared="$LINKFORSHARED", pike_cv_sys_linkforshared='', pike_cv_sys_linkforshared='') CFLAGS="$OLD_CFLAGS" ]) @@ -8094,6 +8143,7 @@ AC_CACHE_VAL(pike_cv_sys_dynamic_loading, cat >conftest.c <<EOF #include <stdio.h> #include <stdlib.h> +extern void testfunc2(void); #if __GNUC__ >= 4 __attribute__ ((visibility("default"))) # endif @@ -8124,6 +8174,7 @@ EOF ;; esac AC_TRY_RUN([ +#include <stdlib.h> #define TESTING #include "dynamic_load.c" #if __GNUC__ >= 4 diff --git a/src/fd_control.c b/src/fd_control.c index 8c2a8eb6cf..88e630c94a 100644 --- a/src/fd_control.c +++ b/src/fd_control.c @@ -247,6 +247,7 @@ int accept4(int fd, struct sockaddr *addr, ACCEPT_SIZE_T *addrlen, int flags) #ifdef TESTING +#include <stdlib.h> #if defined(HAVE_WINSOCK_H) && defined(USE_IOCTLSOCKET_FIONBIO) int main() diff --git a/src/modules/Java/configure.in b/src/modules/Java/configure.in index b3bcf8193c..da1f70581d 100644 --- a/src/modules/Java/configure.in +++ b/src/modules/Java/configure.in @@ -337,7 +337,7 @@ if test "x$with_java" = xyes; then AC_SYS_COMPILER_FLAG(-DMACOSX, define_macosx, CPPFLAGS) ]) - AC_CHECK_HEADERS(jni.h winbase.h ffi.h ffi/ffi.h libffi/ffi.h setjmp.h) + AC_CHECK_HEADERS(jni.h winbase.h ffi.h ffi/ffi.h libffi/ffi.h setjmp.h unistd.h) if test x"$pike_cv_option_framework_JavaVM" = xyes ; then AC_CHECK_HEADERS(JavaVM/jni.h) @@ -519,6 +519,10 @@ if test "x$with_java" = xyes; then #include <setjmp.h> #endif #include <stdio.h> +#include <stdlib.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif #ifdef __NT__ #include <windows.h> #include "ntdl.c" diff --git a/src/modules/_Image_TIFF/configure.in b/src/modules/_Image_TIFF/configure.in index dc2fd15097..ca889a2ed4 100644 --- a/src/modules/_Image_TIFF/configure.in +++ b/src/modules/_Image_TIFF/configure.in @@ -41,6 +41,7 @@ if test x$with_tifflib = xyes ; then #endif #include <tiffio.h> #include <stdio.h> +#include <stdlib.h> #include <errno.h> int main(int argc, char **argv) { diff --git a/src/modules/_Stdio/configure.in b/src/modules/_Stdio/configure.in index f466b61fbf..2e7333f8b4 100644 --- a/src/modules/_Stdio/configure.in +++ b/src/modules/_Stdio/configure.in @@ -284,7 +284,20 @@ if test "$ac_cv_func_sendfile" = "yes"; then ], [ /* Try HPUX */ return (int)sendfile(0,0,0,0,(void *)0,0); - ], [ pike_cv_sendfile_args=6 ], [ pike_cv_sendfile_args=4 ]) + ], [ pike_cv_sendfile_args=6 ], [ + AC_TRY_COMPILE([ +#include <sys/types.h> +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif /* HAVE_SYS_SOCKET_H */ +#ifdef HAVE_SYS_UIO_H +#include <sys/uio.h> +#endif /* HAVE_SYS_UIO_H */ + ], [ + /* Try Linux */ + return sendfile(0,0,(void *)0,0); + ], [ pike_cv_sendfile_args=4 ], [ pike_cv_sendfile_args=bad ]) + ]) ]) ]) if test "$pike_cv_sendfile_args" = "7"; then @@ -376,7 +389,12 @@ if test "$ac_cv_func_sendfile" = "yes"; then AC_DEFINE(HAVE_HPUX_SENDFILE) fi else - AC_MSG_RESULT([4 - Linux style]) + if test "$pike_cv_sendfile_args" = "4"; then + AC_MSG_RESULT([4 - Linux style]) + else + AC_MSG_RESULT(failed - disabling use of sendfile) + AC_DEFINE(HAVE_BROKEN_SENDFILE) + fi fi fi else @@ -400,6 +418,7 @@ if test x$ac_cv_func_getxattr = xyes ; then #ifndef POSIX_SOURCE #define POSIX_SOURCE #endif +#include <stdlib.h> #include <sys/types.h> #ifdef HAVE_SYS_XATTR_H #include <sys/xattr.h> @@ -424,6 +443,7 @@ if test x$ac_cv_func_getxattr = xyes ; then #ifndef POSIX_SOURCE #define POSIX_SOURCE #endif +#include <stdlib.h> #include <sys/types.h> #ifdef HAVE_SYS_XATTR_H #include <sys/xattr.h> @@ -474,6 +494,7 @@ if test x$ac_cv_func_readdir_r = xyes ; then #ifndef POSIX_SOURCE #define POSIX_SOURCE #endif +#include <stdlib.h> #include <sys/types.h> #ifdef HAVE_DIRENT_H #include <dirent.h> @@ -525,6 +546,7 @@ if test x$pike_cv_func_posix_readdir_r = xyes ; then #ifndef POSIX_SOURCE #define POSIX_SOURCE #endif +#include <stdlib.h> #include <sys/errno.h> #ifdef HAVE_DIRENT_H #include <dirent.h> @@ -609,6 +631,7 @@ else #ifndef POSIX_SOURCE #define POSIX_SOURCE #endif +#include <stdlib.h> #include <sys/errno.h> #ifdef HAVE_DIRENT_H #include <dirent.h> @@ -843,6 +866,7 @@ if test x$ac_cv_func_statfs = xyes ; then #ifndef POSIX_SOURCE #define POSIX_SOURCE #endif +#include <stdlib.h> #ifdef HAVE_SYS_PARAM_H #include <sys/param.h> #endif @@ -1080,6 +1104,7 @@ AC_CACHE_VAL(pike_cv_func_failsafe_strerror, AC_TRY_RUN([ #include <stdio.h> #include <string.h> +#include <stdlib.h> int main() { int e; @@ -1116,6 +1141,7 @@ AC_TRY_RUN([ #define POSIX_SOURCE #endif #include <stdio.h> +#include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> #include <netinet/in.h> -- GitLab