aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-03-03 19:08:04 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2023-03-09 17:20:35 +0300
commit48255935e3f7f1b23852fc6cd811943263c102e8 (patch)
treeea9b138ce3759ffde3fb66eaaea78432ec7dd61f
parent41ceade78dee1d75ebc46e691bc2acdfbc9e31ff (diff)
downloadlibmicrohttpd-48255935e3f7f1b23852fc6cd811943263c102e8.tar.gz
libmicrohttpd-48255935e3f7f1b23852fc6cd811943263c102e8.zip
configure: fixed some compiler warnings for checks
Fixed compatibility with future compilers versions
-rw-r--r--configure.ac253
1 files changed, 203 insertions, 50 deletions
diff --git a/configure.ac b/configure.ac
index 639c15ba..b3b666db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -843,7 +843,8 @@ AX_CHECK_COMPILE_FLAG([[-Werror=attributes]],
843 AC_MSG_CHECKING([[whether -Werror=attributes actually works]]) 843 AC_MSG_CHECKING([[whether -Werror=attributes actually works]])
844 CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -Werror=attributes" 844 CFLAGS="${CFLAGS_ac} ${user_CFLAGS} -Werror=attributes"
845 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 845 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
846 [[__attribute__((non_existing_attrb_dummy)) int SimpleFunc(void) {return 3;}]], [[int r = SimpleFunc(); if (r) return r;]])], 846 [[__attribute__((non_existing_attrb_dummy)) static int SimpleFunc(void) {return 3;}]],
847 [[int r = SimpleFunc(); if (r) return r;]])],
847 [ 848 [
848 AC_MSG_RESULT([[no]]) 849 AC_MSG_RESULT([[no]])
849 errattr_CFLAGS="" 850 errattr_CFLAGS=""
@@ -1591,7 +1592,17 @@ AM_CONDITIONAL([HAVE_LISTEN_SHUTDOWN], [test "x$mhd_cv_host_shtdwn_trgr_select"
1591# SENDMSG. Should we check for SCM_RIGHTS instead? 1592# SENDMSG. Should we check for SCM_RIGHTS instead?
1592# https://lists.x.org/archives/xorg-devel/2013-November/038687.html 1593# https://lists.x.org/archives/xorg-devel/2013-November/038687.html
1593AC_SEARCH_LIBS([sendmsg], [socket], [AC_DEFINE([HAVE_SENDMSG],[1],[Define if your platform supports sendmsg])]) 1594AC_SEARCH_LIBS([sendmsg], [socket], [AC_DEFINE([HAVE_SENDMSG],[1],[Define if your platform supports sendmsg])])
1594AC_CHECK_FUNCS([writev]) 1595MHD_CHECK_FUNC([writev],
1596 [[#include <sys/uio.h>]],
1597 [[
1598 struct iovec iov[2];
1599 char some_str[4] = "OK\n";
1600 iov[0].iov_base = (void *) some_str;
1601 iov[0].iov_len = 3;
1602 if (0 > writev(1, iov, 1))
1603 return 2;
1604 ]]
1605)
1595 1606
1596AC_C_BIGENDIAN 1607AC_C_BIGENDIAN
1597AC_C_VARARRAYS 1608AC_C_VARARRAYS
@@ -1614,14 +1625,14 @@ AS_VAR_IF([mhd_cv_macro___func___avail], ["yes"],
1614) 1625)
1615AC_CACHE_CHECK([[whether __builtin_bswap32() is available]], 1626AC_CACHE_CHECK([[whether __builtin_bswap32() is available]],
1616 [[mhd_cv_func___builtin_bswap32_avail]], [dnl 1627 [[mhd_cv_func___builtin_bswap32_avail]], [dnl
1617 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint32_t a = 1; uint32_t b = __builtin_bswap32(a); a = b;]])], 1628 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint32_t a = 1; uint32_t b = __builtin_bswap32(a); a = b; (void) a;]])],
1618 [[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]]) 1629 [[mhd_cv_func___builtin_bswap32_avail="yes"]],[[mhd_cv_func___builtin_bswap32_avail="no"]])
1619]) 1630])
1620AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]], 1631AS_IF([[test "x$mhd_cv_func___builtin_bswap32_avail" = "xyes"]],
1621 [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have __builtin_bswap32() builtin function])]) 1632 [AC_DEFINE([[MHD_HAVE___BUILTIN_BSWAP32]], [[1]], [Define to 1 if you have __builtin_bswap32() builtin function])])
1622AC_CACHE_CHECK([[whether __builtin_bswap64() is available]], 1633AC_CACHE_CHECK([[whether __builtin_bswap64() is available]],
1623 [[mhd_cv_func___builtin_bswap64_avail]], [dnl 1634 [[mhd_cv_func___builtin_bswap64_avail]], [dnl
1624 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint64_t a = 1; uint32_t b = __builtin_bswap64(a); a = b;]])], 1635 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include<stdint.h>]], [[uint64_t a = 1; uint64_t b = __builtin_bswap64(a); a = b; (void) a;]])],
1625 [[mhd_cv_func___builtin_bswap64_avail="yes"]], [[mhd_cv_func___builtin_bswap64_avail="no"]]) 1636 [[mhd_cv_func___builtin_bswap64_avail="yes"]], [[mhd_cv_func___builtin_bswap64_avail="no"]])
1626]) 1637])
1627AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]], 1638AS_IF([[test "x$mhd_cv_func___builtin_bswap64_avail" = "xyes"]],
@@ -1698,24 +1709,55 @@ AC_ARG_ENABLE([[poll]],
1698 ) 1709 )
1699 1710
1700AS_IF([test "$enable_poll" != "no"], 1711AS_IF([test "$enable_poll" != "no"],
1701 [AS_IF([test "$os_is_native_w32" != "yes"], 1712 [
1702 AC_CHECK_HEADERS([poll.h], 1713 AS_IF([test "$os_is_native_w32" != "yes"],
1703 [AC_CHECK_FUNCS([poll], [have_poll='yes'], [have_poll='no'])], 1714 [
1704 [], 1715 AC_CHECK_HEADERS([poll.h],
1705 [AC_INCLUDES_DEFAULT]), 1716 [
1706 [AC_MSG_CHECKING([for WSAPoll()]) 1717 MHD_CHECK_FUNC([poll],
1707 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 1718 [[
1719#include <poll.h>
1720 ]],
1721 [[
1722 struct pollfd fds[2];
1723
1724 fds[0].fd = 0;
1725 fds[0].events = POLLIN;
1726 if (0 > poll(fds, 1, 0))
1727 return 2;
1728 ]],
1729 [have_poll='yes'], [have_poll='no']
1730 )
1731 ], [], [AC_INCLUDES_DEFAULT]
1732 )
1733 ],
1734 [
1735 AC_MSG_CHECKING([for WSAPoll()])
1736 AC_LINK_IFELSE(
1737 [
1738 AC_LANG_PROGRAM(
1739 [[
1708#include <winsock2.h> 1740#include <winsock2.h>
1709 ]],[[ 1741 ]],[[
1710WSAPOLLFD fda[2]; 1742WSAPOLLFD fda[2];
1711WSAPoll(fda, 2, 0);]])], 1743WSAPoll(fda, 2, 0);
1712 [have_poll='yes' 1744 ]]
1713 AC_DEFINE([HAVE_POLL],[1]) 1745 )
1714 ],[have_poll='no']) 1746 ],
1715 AC_MSG_RESULT([$have_poll])]) 1747 [
1716 AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"], 1748 have_poll='yes'
1717 [AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])]) 1749 AC_DEFINE([HAVE_POLL],[1])
1718 enable_poll="$have_poll"]) 1750 ],
1751 [have_poll='no']
1752 )
1753 AC_MSG_RESULT([$have_poll])
1754 ]
1755 )
1756 AS_IF([test "$enable_poll" = "yes" && test "$have_poll" != "yes"],
1757 [AC_MSG_ERROR([[Support for poll was explicitly requested but cannot be enabled on this platform.]])])
1758 enable_poll="$have_poll"
1759 ]
1760)
1719 1761
1720AC_ARG_ENABLE([[epoll]], 1762AC_ARG_ENABLE([[epoll]],
1721 [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])], 1763 [AS_HELP_STRING([[--enable-epoll[=ARG]]], [enable epoll support (yes, no, auto) [auto]])],
@@ -1750,8 +1792,10 @@ AS_IF([test "x$enable_epoll" = "xyes"],
1750 AC_LANG_PROGRAM([[ 1792 AC_LANG_PROGRAM([[
1751#include <sys/epoll.h> 1793#include <sys/epoll.h>
1752 ]], [[ 1794 ]], [[
1753int fd; 1795 if (0 > epoll_create1(EPOLL_CLOEXEC))
1754fd = epoll_create1(EPOLL_CLOEXEC);]])], 1796 return 3;
1797 ]]
1798 )],
1755 [mhd_cv_have_epoll_create1=yes], 1799 [mhd_cv_have_epoll_create1=yes],
1756 [mhd_cv_have_epoll_create1=no])]) 1800 [mhd_cv_have_epoll_create1=no])])
1757 AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[ 1801 AS_IF([test "x$mhd_cv_have_epoll_create1" = "xyes"],[
@@ -1769,7 +1813,7 @@ AC_CACHE_CHECK([for supported 'noreturn' keyword], [mhd_cv_decl_noreturn],
1769#include <stdlib.h> 1813#include <stdlib.h>
1770#endif 1814#endif
1771 1815
1772${decl_noret} void myexitfunc(int code) 1816${decl_noret} static void myexitfunc(int code)
1773{ 1817{
1774#ifdef HAVE_STDLIB_H 1818#ifdef HAVE_STDLIB_H
1775 exit (code); 1819 exit (code);
@@ -2276,7 +2320,68 @@ AC_INCLUDES_DEFAULT
2276AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of inter-thread communication]])]) 2320AS_IF([[test -z "$use_itc"]], [AC_MSG_ERROR([[cannot find usable type of inter-thread communication]])])
2277 2321
2278 2322
2279AC_CHECK_FUNCS_ONCE([accept4 gmtime_r memmem snprintf]) 2323MHD_CHECK_FUNC([accept4],
2324 [[
2325#if defined(HAVE_SYS_TYPES_H)
2326# include <sys/types.h>
2327#endif
2328#include <sys/socket.h>
2329 ]],
2330 [
2331 struct sockaddr sk_addr;
2332 socklen_t addr_size;
2333 if (0 > accept4(0, &sk_addr, &addr_size, 0))
2334 return 3;
2335 ]
2336)
2337MHD_CHECK_FUNC([gmtime_r],
2338 [[
2339#if defined(HAVE_SYS_TYPES_H)
2340# include <sys/types.h>
2341#endif
2342#include <time.h>
2343 ]],
2344 [[
2345 time_t timer = (time_t) 0;
2346 struct tm res;
2347
2348 if (&res != gmtime_r(&timer, &res))
2349 return 3;
2350 ]]
2351)
2352MHD_CHECK_FUNC([memmem],
2353 [[
2354#if defined(HAVE_STDDEF_H)
2355# include <stddef.h>
2356#elif defined(HAVE_STDLIB_H)
2357# include <stdlib.h>
2358#endif /* HAVE_STDLIB_H */
2359#include <string.h>
2360 ]],
2361 [[
2362 const char *haystack = "abc";
2363 size_t hslen = 3;
2364 const char *needle = "b";
2365 size_t needlelen = 1;
2366
2367 if ((haystack + 1) != memmem(haystack, hslen, needle, needlelen))
2368 return 3;
2369 ]]
2370)
2371MHD_CHECK_FUNC([snprintf],
2372 [[
2373#include <stdio.h>
2374 ]],
2375 [[
2376 char buf[2];
2377
2378 if (1 != snprintf(buf, 2, "a"))
2379 return 3;
2380 /* Do not use the next check to avoid compiler warning */
2381 /* if (4 != snprintf(buf, 2, "abcd"))
2382 return 4; */
2383 ]]
2384)
2280AC_CHECK_DECL([gmtime_s], 2385AC_CHECK_DECL([gmtime_s],
2281 [ 2386 [
2282 AC_MSG_CHECKING([[whether gmtime_s is in C11 form]]) 2387 AC_MSG_CHECKING([[whether gmtime_s is in C11 form]])
@@ -2433,46 +2538,36 @@ choke me now
2433 ] 2538 ]
2434) 2539)
2435 2540
2436AS_VAR_SET_IF([ac_cv_func_gettimeofday], [mhd_cv_func_gettimeofday="${ac_cv_func_gettimeofday}"]) 2541MHD_CHECK_FUNC([[gettimeofday]],
2437AC_CACHE_CHECK([[for gettimeofday(2)]], [mhd_cv_func_gettimeofday], [ 2542 [[
2438 AC_LINK_IFELSE(
2439 [
2440 AC_LANG_PROGRAM(
2441 [[
2442#ifdef HAVE_SYS_TIME_H 2543#ifdef HAVE_SYS_TIME_H
2443#include <sys/time.h> 2544#include <sys/time.h>
2444#endif /* HAVE_SYS_TIME_H */ 2545#endif /* HAVE_SYS_TIME_H */
2445#ifdef HAVE_TIME_H 2546#ifdef HAVE_TIME_H
2446#include <time.h> 2547#include <time.h>
2447#endif /* HAVE_TIME_H */ 2548#endif /* HAVE_TIME_H */
2448 ]], 2549 ]],
2449 [[ 2550 [[
2450 struct timeval tv; 2551 struct timeval tv;
2451 if (0 != gettimeofday (&tv, (void*) 0)) 2552 if (0 != gettimeofday (&tv, (void*) 0))
2452 return 1; 2553 return 1;
2453 ]] 2554 ]]
2454 )
2455 ], [[mhd_cv_func_gettimeofday="yes"]], [[mhd_cv_func_gettimeofday="no"]]
2456 )
2457])
2458AS_VAR_IF([mhd_cv_func_gettimeofday], ["yes"],
2459 [AC_DEFINE([HAVE_GETTIMEOFDAY], [1], [Define to 1 if you have `gettimeofday' function.])]
2460) 2555)
2461 2556
2462# IPv6 2557# IPv6
2463AC_MSG_CHECKING(for IPv6) 2558AC_MSG_CHECKING(for IPv6)
2464AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 2559AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2465#include <stdio.h> 2560#include <stdio.h>
2466#if HAVE_NETINET_IN_H 2561#ifdef HAVE_NETINET_IN_H
2467#include <netinet/in.h> 2562#include <netinet/in.h>
2468#endif 2563#endif
2469#if HAVE_SYS_SOCKET_H 2564#ifdef HAVE_SYS_SOCKET_H
2470#include <sys/socket.h> 2565#include <sys/socket.h>
2471#endif 2566#endif
2472#if HAVE_WINSOCK2_H 2567#ifdef HAVE_WINSOCK2_H
2473#include <winsock2.h> 2568#include <winsock2.h>
2474#endif 2569#endif
2475#if HAVE_WS2TCPIP_H 2570#ifdef HAVE_WS2TCPIP_H
2476#include <ws2tcpip.h> 2571#include <ws2tcpip.h>
2477#endif 2572#endif
2478]], [[ 2573]], [[
@@ -2610,7 +2705,45 @@ AM_CONDITIONAL([MHD_HAVE_LIBMAGIC], [[test "x$mhd_have_libmagic" = "xyes"]])
2610# large file support (> 4 GB) 2705# large file support (> 4 GB)
2611AC_SYS_LARGEFILE 2706AC_SYS_LARGEFILE
2612AC_FUNC_FSEEKO 2707AC_FUNC_FSEEKO
2613AC_CHECK_FUNCS([lseek64 pread64 pread]) 2708MHD_CHECK_FUNC([lseek64],
2709 [[
2710#if defined(HAVE_SYS_TYPES_H)
2711# include <sys/types.h>
2712#endif
2713#include <unistd.h>
2714 ]],
2715 [[
2716 if (((off64_t) -1) == lseek64(0, (off64_t) 0, SEEK_SET))
2717 return 3;
2718 ]]
2719)
2720MHD_CHECK_FUNC([pread64],
2721 [[
2722#if defined(HAVE_SYS_TYPES_H)
2723# include <sys/types.h>
2724#endif
2725#include <unistd.h>
2726 ]],
2727 [[
2728 char buf[5];
2729 if (0 > pread64(0, (void *) buf, 1, (off64_t) 0))
2730 return 3;
2731 ]]
2732)
2733MHD_CHECK_FUNC([pread],
2734 [[
2735#if defined(HAVE_SYS_TYPES_H)
2736# include <sys/types.h>
2737#endif
2738#include <unistd.h>
2739 ]],
2740 [[
2741 char buf[5];
2742 if (0 > pread(0, (void *) buf, 1, 0))
2743 return 3;
2744 ]]
2745)
2746
2614 2747
2615# check for various sendfile functions 2748# check for various sendfile functions
2616AC_ARG_ENABLE([sendfile], 2749AC_ARG_ENABLE([sendfile],
@@ -2654,7 +2787,16 @@ ssize_t sendfile(int, int, off_t*, size_t);
2654 AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).]) 2787 AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have linux-style sendfile(2).])
2655 found_sendfile="yes, Linux-style" 2788 found_sendfile="yes, Linux-style"
2656 AC_MSG_RESULT([[yes]]) 2789 AC_MSG_RESULT([[yes]])
2657 AC_CHECK_FUNCS([sendfile64]) 2790 MHD_CHECK_FUNC([sendfile64],
2791 [[
2792#include <sys/sendfile.h>
2793 ]],
2794 [[
2795 off64_t f_offset = (off64_t) 0;
2796 if (0 > sendfile64 (0, 1, &f_offset, 1))
2797 return 3;
2798 ]]
2799 )
2658 ], 2800 ],
2659 [AC_MSG_RESULT([[no]]) 2801 [AC_MSG_RESULT([[no]])
2660 ] 2802 ]
@@ -2781,7 +2923,18 @@ ssize_t sendfile(int out_fd, int in_fd,
2781 MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS" 2923 MHD_LIBDEPS="-lsendfile $MHD_LIBDEPS"
2782 MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG" 2924 MHD_LIBDEPS_PKGCFG="-lsendfile $MHD_LIBDEPS_PKGCFG"
2783 AC_MSG_RESULT([[yes]]) 2925 AC_MSG_RESULT([[yes]])
2784 AC_CHECK_FUNCS([sendfile64]) 2926 MHD_CHECK_FUNC([sendfile64],
2927 [[
2928#include <sys/types.h>
2929#include <sys/socket.h>
2930#include <sys/sendfile.h>
2931 ]],
2932 [[
2933 off64_t f_offset = (off64_t) 0;
2934 if (0 > sendfile64 (0, 1, &f_offset, 1))
2935 return 3;
2936 ]]
2937 )
2785 ], 2938 ],
2786 [AC_MSG_RESULT([[no]]) 2939 [AC_MSG_RESULT([[no]])
2787 ] 2940 ]
@@ -4410,22 +4563,22 @@ int main(int argc, char *argv[])
4410 test_undf_prog=' 4563 test_undf_prog='
4411#include <stdio.h> 4564#include <stdio.h>
4412 4565
4413void func_out_b(char *arr) 4566static void func_out_b(char *arr)
4414{ 4567{
4415 arr[0] = 0; 4568 arr[0] = 0;
4416 arr[16] = 2; 4569 arr[16] = 2;
4417} 4570}
4418 4571
4419unsigned int int_deref(void *ptr) 4572static unsigned int int_deref(void *ptr)
4420{ 4573{
4421 return (*((int*)ptr)) + 2; 4574 return (*((unsigned int*)ptr)) + 2;
4422} 4575}
4423 4576
4424int func1(void) 4577static int func1(void)
4425{ 4578{
4426 char chr[16]; 4579 char chr[16];
4427 func_out_b (chr); 4580 func_out_b (chr);
4428 return int_deref(chr + 1) + int_deref(chr + 2); 4581 return (int) (int_deref(chr + 1) + int_deref(chr + 2));
4429} 4582}
4430 4583
4431int main(void) 4584int main(void)