3 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
4 dnl -------------------------------------------------
5 dnl Verifies if the compiler actually halts after the
6 dnl compilation phase without generating any object
7 dnl code file, when the source compiles with errors.
9 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
10 AC_MSG_CHECKING([if compiler halts on compilation errors])
14 force compilation error
18 AC_MSG_ERROR([compiler does not halt on compilation errors.])
25 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
26 dnl -------------------------------------------------
27 dnl Verifies if the compiler actually halts after the
28 dnl compilation phase without generating any object
29 dnl code file, when the source code tries to define a
30 dnl type for a constant array with negative dimension.
32 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
33 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
34 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
37 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
43 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
50 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
51 dnl -------------------------------------------------
52 dnl Use the C preprocessor to find out if the given object-style symbol
53 dnl is defined and get its expansion. This macro will not use default
54 dnl includes even if no INCLUDES argument is given. This macro will run
55 dnl silently when invoked with three arguments. If the expansion would
56 dnl result in a set of double-quoted strings the returned expansion will
57 dnl actually be a single double-quoted string concatenating all them.
59 AC_DEFUN([CURL_CHECK_DEF], [
60 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
61 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
62 if test -z "$SED"; then
63 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
65 if test -z "$GREP"; then
66 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
68 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
78 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
79 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
80 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
81 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
82 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
86 if test -z "$tmp_exp"; then
87 AS_VAR_SET(ac_HaveDef, no)
88 ifelse($3,,[AC_MSG_RESULT([no])])
90 AS_VAR_SET(ac_HaveDef, yes)
91 AS_VAR_SET(ac_Def, $tmp_exp)
92 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
94 AS_VAR_POPDEF([ac_Def])dnl
95 AS_VAR_POPDEF([ac_HaveDef])dnl
99 dnl CARES_CHECK_AIX_ALL_SOURCE
100 dnl -------------------------------------------------
101 dnl Provides a replacement of traditional AC_AIX with
102 dnl an uniform behaviour across all autoconf versions,
103 dnl and with our own placement rules.
105 AC_DEFUN([CARES_CHECK_AIX_ALL_SOURCE], [
106 AH_VERBATIM([_ALL_SOURCE],
107 [/* Define to 1 if OS is AIX. */
111 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
112 AC_BEFORE([$0], [CARES_CONFIGURE_REENTRANT])dnl
113 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
114 AC_EGREP_CPP([yes_this_is_aix],[
120 AC_DEFINE(_ALL_SOURCE)
127 dnl CURL_CHECK_HEADER_WINDOWS
128 dnl -------------------------------------------------
129 dnl Check for compilable and valid windows.h header
131 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
132 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
136 #ifndef WIN32_LEAN_AND_MEAN
137 #define WIN32_LEAN_AND_MEAN
141 #if defined(__CYGWIN__) || defined(__CEGCC__)
142 HAVE_WINDOWS_H shall not be defined.
148 ac_cv_header_windows_h="yes"
150 ac_cv_header_windows_h="no"
153 case "$ac_cv_header_windows_h" in
155 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
156 [Define to 1 if you have the windows.h header file.])
157 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
158 [Define to avoid automatic inclusion of winsock.h])
164 dnl CURL_CHECK_NATIVE_WINDOWS
165 dnl -------------------------------------------------
166 dnl Check if building a native Windows target
168 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
169 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
170 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
171 if test "$ac_cv_header_windows_h" = "no"; then
172 ac_cv_native_windows="no"
177 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
178 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
181 Not a native Windows build target.
185 ac_cv_native_windows="yes"
187 ac_cv_native_windows="no"
191 case "$ac_cv_native_windows" in
193 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
194 [Define to 1 if you are building a native Windows target.])
200 dnl CURL_CHECK_HEADER_WINSOCK
201 dnl -------------------------------------------------
202 dnl Check for compilable and valid winsock.h header
204 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
205 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
206 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
210 #ifndef WIN32_LEAN_AND_MEAN
211 #define WIN32_LEAN_AND_MEAN
216 #if defined(__CYGWIN__) || defined(__CEGCC__)
217 HAVE_WINSOCK_H shall not be defined.
219 int dummy=WSACleanup();
223 ac_cv_header_winsock_h="yes"
225 ac_cv_header_winsock_h="no"
228 case "$ac_cv_header_winsock_h" in
230 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
231 [Define to 1 if you have the winsock.h header file.])
237 dnl CURL_CHECK_HEADER_WINSOCK2
238 dnl -------------------------------------------------
239 dnl Check for compilable and valid winsock2.h header
241 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
242 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
243 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
247 #ifndef WIN32_LEAN_AND_MEAN
248 #define WIN32_LEAN_AND_MEAN
251 #include <winsock2.h>
253 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
254 HAVE_WINSOCK2_H shall not be defined.
256 int dummy=2*IPPROTO_ESP;
260 ac_cv_header_winsock2_h="yes"
262 ac_cv_header_winsock2_h="no"
265 case "$ac_cv_header_winsock2_h" in
267 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
268 [Define to 1 if you have the winsock2.h header file.])
274 dnl CURL_CHECK_HEADER_WS2TCPIP
275 dnl -------------------------------------------------
276 dnl Check for compilable and valid ws2tcpip.h header
278 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
279 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
280 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
284 #ifndef WIN32_LEAN_AND_MEAN
285 #define WIN32_LEAN_AND_MEAN
288 #include <winsock2.h>
289 #include <ws2tcpip.h>
291 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
292 HAVE_WS2TCPIP_H shall not be defined.
294 int dummy=2*IP_PKTINFO;
298 ac_cv_header_ws2tcpip_h="yes"
300 ac_cv_header_ws2tcpip_h="no"
303 case "$ac_cv_header_ws2tcpip_h" in
305 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
306 [Define to 1 if you have the ws2tcpip.h header file.])
312 dnl CURL_CHECK_HEADER_MALLOC
313 dnl -------------------------------------------------
314 dnl Check for compilable and valid malloc.h header,
315 dnl and check if it is needed even with stdlib.h
317 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
318 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
323 void *p = malloc(10);
324 void *q = calloc(10,10);
329 ac_cv_header_malloc_h="yes"
331 ac_cv_header_malloc_h="no"
334 if test "$ac_cv_header_malloc_h" = "yes"; then
335 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
336 [Define to 1 if you have the malloc.h header file.])
342 void *p = malloc(10);
343 void *q = calloc(10,10);
348 curl_cv_need_header_malloc_h="no"
350 curl_cv_need_header_malloc_h="yes"
353 case "$curl_cv_need_header_malloc_h" in
355 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
356 [Define to 1 if you need the malloc.h header file even with stdlib.h])
363 dnl CURL_CHECK_HEADER_MEMORY
364 dnl -------------------------------------------------
365 dnl Check for compilable and valid memory.h header,
366 dnl and check if it is needed even with stdlib.h for
367 dnl memory related functions.
369 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
370 AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
375 void *p = malloc(10);
376 void *q = calloc(10,10);
381 ac_cv_header_memory_h="yes"
383 ac_cv_header_memory_h="no"
386 if test "$ac_cv_header_memory_h" = "yes"; then
387 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
388 [Define to 1 if you have the memory.h header file.])
394 void *p = malloc(10);
395 void *q = calloc(10,10);
400 curl_cv_need_header_memory_h="no"
402 curl_cv_need_header_memory_h="yes"
405 case "$curl_cv_need_header_memory_h" in
407 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
408 [Define to 1 if you need the memory.h header file even with stdlib.h])
415 dnl CURL_CHECK_TYPE_SOCKLEN_T
416 dnl -------------------------------------------------
417 dnl Check for existing socklen_t type, and provide
418 dnl an equivalent type if socklen_t not available
420 AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
421 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
422 AC_CHECK_TYPE([socklen_t], ,[
423 dnl socklen_t not available
424 AC_CACHE_CHECK([for socklen_t equivalent],
425 [curl_cv_socklen_t_equiv], [
426 curl_cv_socklen_t_equiv="unknown"
427 for arg1 in 'int' 'SOCKET'; do
428 for arg2 in "struct sockaddr" void; do
429 for t in int size_t unsigned long "unsigned long"; do
430 if test "$curl_cv_socklen_t_equiv" = "unknown"; then
434 #ifdef HAVE_WINDOWS_H
435 #ifndef WIN32_LEAN_AND_MEAN
436 #define WIN32_LEAN_AND_MEAN
439 #ifdef HAVE_WINSOCK2_H
440 #include <winsock2.h>
442 #ifdef HAVE_WINSOCK_H
446 #define GETPEERNCALLCONV PASCAL
448 #ifdef HAVE_SYS_TYPES_H
449 #include <sys/types.h>
451 #ifdef HAVE_SYS_SOCKET_H
452 #include <sys/socket.h>
454 #define GETPEERNCALLCONV
456 extern int GETPEERNCALLCONV getpeername($arg1, $arg2 *, $t *);
459 getpeername(0,0,&len);
462 curl_cv_socklen_t_equiv="$t"
469 case "$curl_cv_socklen_t_equiv" in
471 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
474 AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
475 [Type to use in place of socklen_t when system does not provide it.])
480 #ifdef HAVE_WINDOWS_H
481 #ifndef WIN32_LEAN_AND_MEAN
482 #define WIN32_LEAN_AND_MEAN
485 #ifdef HAVE_WINSOCK2_H
486 #include <winsock2.h>
487 #ifdef HAVE_WS2TCPIP_H
488 #include <ws2tcpip.h>
492 #ifdef HAVE_SYS_TYPES_H
493 #include <sys/types.h>
495 #ifdef HAVE_SYS_SOCKET_H
496 #include <sys/socket.h>
503 dnl CURL_CHECK_FUNC_GETNAMEINFO
504 dnl -------------------------------------------------
505 dnl Test if the getnameinfo function is available,
506 dnl and check the types of five of its arguments.
507 dnl If the function succeeds HAVE_GETNAMEINFO will be
508 dnl defined, defining the types of the arguments in
509 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
510 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
511 dnl and also defining the type qualifier of first
512 dnl argument in GETNAMEINFO_QUAL_ARG1.
514 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
515 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
516 AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
517 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
519 AC_MSG_CHECKING([for getnameinfo])
521 AC_LANG_FUNC_LINK_TRY([getnameinfo])
524 curl_cv_getnameinfo="yes"
527 curl_cv_getnameinfo="no"
530 if test "$curl_cv_getnameinfo" != "yes"; then
531 AC_MSG_CHECKING([deeper for getnameinfo])
539 curl_cv_getnameinfo="yes"
541 AC_MSG_RESULT([but still no])
542 curl_cv_getnameinfo="no"
546 if test "$curl_cv_getnameinfo" != "yes"; then
547 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
551 #ifdef HAVE_WINDOWS_H
552 #ifndef WIN32_LEAN_AND_MEAN
553 #define WIN32_LEAN_AND_MEAN
556 #ifdef HAVE_WINSOCK2_H
557 #include <winsock2.h>
558 #ifdef HAVE_WS2TCPIP_H
559 #include <ws2tcpip.h>
563 #ifdef HAVE_SYS_TYPES_H
564 #include <sys/types.h>
566 #ifdef HAVE_SYS_SOCKET_H
567 #include <sys/socket.h>
574 getnameinfo(0, 0, 0, 0, 0, 0, 0);
578 curl_cv_getnameinfo="yes"
580 AC_MSG_RESULT([but still no])
581 curl_cv_getnameinfo="no"
585 if test "$curl_cv_getnameinfo" = "yes"; then
586 AC_CACHE_CHECK([types of arguments for getnameinfo],
587 [curl_cv_func_getnameinfo_args], [
588 curl_cv_func_getnameinfo_args="unknown"
589 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
590 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
591 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
592 for gni_arg7 in 'int' 'unsigned int'; do
593 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
597 #ifdef HAVE_WINDOWS_H
598 #ifndef WIN32_LEAN_AND_MEAN
599 #define WIN32_LEAN_AND_MEAN
601 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
603 #define _WIN32_WINNT 0x0501
606 #ifdef HAVE_WINSOCK2_H
607 #include <winsock2.h>
608 #ifdef HAVE_WS2TCPIP_H
609 #include <ws2tcpip.h>
612 #define GNICALLCONV WSAAPI
614 #ifdef HAVE_SYS_TYPES_H
615 #include <sys/types.h>
617 #ifdef HAVE_SYS_SOCKET_H
618 #include <sys/socket.h>
625 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
631 $gni_arg46 hostlen=0;
632 $gni_arg46 servlen=0;
634 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
637 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
645 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
646 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
647 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
649 gni_prev_IFS=$IFS; IFS=','
650 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
654 gni_qual_type_arg1=$[1]
656 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
657 [Define to the type of arg 2 for getnameinfo.])
658 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
659 [Define to the type of args 4 and 6 for getnameinfo.])
660 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
661 [Define to the type of arg 7 for getnameinfo.])
665 case $prev_sh_opts in
673 case "$gni_qual_type_arg1" in
676 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
680 gni_type_arg1=$gni_qual_type_arg1
684 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
685 [Define to the type qualifier of arg 1 for getnameinfo.])
686 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
687 [Define to the type of arg 1 for getnameinfo.])
689 case $prev_sh_opts in
697 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
698 [Define to 1 if you have the getnameinfo function.])
699 ac_cv_func_getnameinfo="yes"
705 dnl TYPE_SOCKADDR_STORAGE
706 dnl -------------------------------------------------
707 dnl Check for struct sockaddr_storage. Most IPv6-enabled
708 dnl hosts have it, but AIX 4.3 is one known exception.
710 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
712 AC_CHECK_TYPE([struct sockaddr_storage],
713 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
714 [if struct sockaddr_storage is defined]), ,
717 #ifdef HAVE_WINDOWS_H
718 #ifndef WIN32_LEAN_AND_MEAN
719 #define WIN32_LEAN_AND_MEAN
722 #ifdef HAVE_WINSOCK2_H
723 #include <winsock2.h>
726 #ifdef HAVE_SYS_TYPES_H
727 #include <sys/types.h>
729 #ifdef HAVE_SYS_SOCKET_H
730 #include <sys/socket.h>
732 #ifdef HAVE_NETINET_IN_H
733 #include <netinet/in.h>
735 #ifdef HAVE_ARPA_INET_H
736 #include <arpa/inet.h>
743 dnl CURL_CHECK_NI_WITHSCOPEID
744 dnl -------------------------------------------------
745 dnl Check for working NI_WITHSCOPEID in getnameinfo()
747 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
748 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
749 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
750 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
751 netdb.h netinet/in.h arpa/inet.h)
753 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
754 [ac_cv_working_ni_withscopeid], [
763 #ifdef HAVE_SYS_TYPES_H
764 #include <sys/types.h>
766 #ifdef HAVE_SYS_SOCKET_H
767 #include <sys/socket.h>
772 #ifdef HAVE_NETINET_IN_H
773 #include <netinet/in.h>
775 #ifdef HAVE_ARPA_INET_H
776 #include <arpa/inet.h>
779 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
780 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
781 struct sockaddr_storage sa;
783 unsigned char sa[256];
785 char hostbuf[NI_MAXHOST];
787 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
788 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
789 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
790 int fd = socket(AF_INET6, SOCK_STREAM, 0);
793 return 1; /* Error creating socket */
795 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
797 perror("getsockname()");
798 return 2; /* Error retrieving socket name */
800 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
802 printf("rc = %s\n", gai_strerror(rc));
803 return 3; /* Error translating socket address */
805 return 0; /* Ok, NI_WITHSCOPEID works */
807 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
809 ]]) # AC-LANG-PROGRAM
811 # Exit code == 0. Program worked.
812 ac_cv_working_ni_withscopeid="yes"
814 # Exit code != 0. Program failed.
815 ac_cv_working_ni_withscopeid="no"
817 # Program is not run when cross-compiling. So we assume
818 # NI_WITHSCOPEID will work if we are able to compile it.
821 #include <sys/types.h>
822 #include <sys/socket.h>
825 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
828 ac_cv_working_ni_withscopeid="yes"
830 ac_cv_working_ni_withscopeid="no"
831 ]) # AC-COMPILE-IFELSE
834 case "$ac_cv_working_ni_withscopeid" in
836 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
837 [Define to 1 if NI_WITHSCOPEID exists and works.])
843 dnl CURL_CHECK_FUNC_RECV
844 dnl -------------------------------------------------
845 dnl Test if the socket recv() function is available,
846 dnl and check its return type and the types of its
847 dnl arguments. If the function succeeds HAVE_RECV
848 dnl will be defined, defining the types of the arguments
849 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
850 dnl and RECV_TYPE_ARG4, defining the type of the function
851 dnl return value in RECV_TYPE_RETV.
853 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
854 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
855 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
856 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
858 AC_MSG_CHECKING([for recv])
862 #ifdef HAVE_WINDOWS_H
863 #ifndef WIN32_LEAN_AND_MEAN
864 #define WIN32_LEAN_AND_MEAN
867 #ifdef HAVE_WINSOCK2_H
868 #include <winsock2.h>
870 #ifdef HAVE_WINSOCK_H
875 #ifdef HAVE_SYS_TYPES_H
876 #include <sys/types.h>
878 #ifdef HAVE_SYS_SOCKET_H
879 #include <sys/socket.h>
893 if test "$curl_cv_recv" = "yes"; then
894 AC_CACHE_CHECK([types of args and return type for recv],
895 [curl_cv_func_recv_args], [
896 curl_cv_func_recv_args="unknown"
897 for recv_retv in 'int' 'ssize_t'; do
898 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
899 for recv_arg2 in 'char *' 'void *'; do
900 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
901 for recv_arg4 in 'int' 'unsigned int'; do
902 if test "$curl_cv_func_recv_args" = "unknown"; then
906 #ifdef HAVE_WINDOWS_H
907 #ifndef WIN32_LEAN_AND_MEAN
908 #define WIN32_LEAN_AND_MEAN
911 #ifdef HAVE_WINSOCK2_H
912 #include <winsock2.h>
914 #ifdef HAVE_WINSOCK_H
918 #define RECVCALLCONV PASCAL
920 #ifdef HAVE_SYS_TYPES_H
921 #include <sys/types.h>
923 #ifdef HAVE_SYS_SOCKET_H
924 #include <sys/socket.h>
928 extern $recv_retv RECVCALLCONV
929 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
935 $recv_retv res = recv(s, buf, len, flags);
938 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
947 if test "$curl_cv_func_recv_args" = "unknown"; then
948 AC_MSG_ERROR([Cannot find proper types to use for recv args])
950 recv_prev_IFS=$IFS; IFS=','
951 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
955 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
956 [Define to the type of arg 1 for recv.])
957 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
958 [Define to the type of arg 2 for recv.])
959 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
960 [Define to the type of arg 3 for recv.])
961 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
962 [Define to the type of arg 4 for recv.])
963 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
964 [Define to the function return type for recv.])
966 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
967 [Define to 1 if you have the recv function.])
968 ac_cv_func_recv="yes"
971 AC_MSG_ERROR([Unable to link function recv])
976 dnl CURL_CHECK_FUNC_SEND
977 dnl -------------------------------------------------
978 dnl Test if the socket send() function is available,
979 dnl and check its return type and the types of its
980 dnl arguments. If the function succeeds HAVE_SEND
981 dnl will be defined, defining the types of the arguments
982 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
983 dnl and SEND_TYPE_ARG4, defining the type of the function
984 dnl return value in SEND_TYPE_RETV, and also defining the
985 dnl type qualifier of second argument in SEND_QUAL_ARG2.
987 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
988 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
989 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
990 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
992 AC_MSG_CHECKING([for send])
996 #ifdef HAVE_WINDOWS_H
997 #ifndef WIN32_LEAN_AND_MEAN
998 #define WIN32_LEAN_AND_MEAN
1000 #include <windows.h>
1001 #ifdef HAVE_WINSOCK2_H
1002 #include <winsock2.h>
1004 #ifdef HAVE_WINSOCK_H
1005 #include <winsock.h>
1009 #ifdef HAVE_SYS_TYPES_H
1010 #include <sys/types.h>
1012 #ifdef HAVE_SYS_SOCKET_H
1013 #include <sys/socket.h>
1020 AC_MSG_RESULT([yes])
1027 if test "$curl_cv_send" = "yes"; then
1028 AC_CACHE_CHECK([types of args and return type for send],
1029 [curl_cv_func_send_args], [
1030 curl_cv_func_send_args="unknown"
1031 for send_retv in 'int' 'ssize_t'; do
1032 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1033 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
1034 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1035 for send_arg4 in 'int' 'unsigned int'; do
1036 if test "$curl_cv_func_send_args" = "unknown"; then
1040 #ifdef HAVE_WINDOWS_H
1041 #ifndef WIN32_LEAN_AND_MEAN
1042 #define WIN32_LEAN_AND_MEAN
1044 #include <windows.h>
1045 #ifdef HAVE_WINSOCK2_H
1046 #include <winsock2.h>
1048 #ifdef HAVE_WINSOCK_H
1049 #include <winsock.h>
1052 #define SENDCALLCONV PASCAL
1054 #ifdef HAVE_SYS_TYPES_H
1055 #include <sys/types.h>
1057 #ifdef HAVE_SYS_SOCKET_H
1058 #include <sys/socket.h>
1060 #define SENDCALLCONV
1062 extern $send_retv SENDCALLCONV
1063 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
1068 $send_retv res = send(s, 0, len, flags);
1071 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1080 if test "$curl_cv_func_send_args" = "unknown"; then
1081 AC_MSG_ERROR([Cannot find proper types to use for send args])
1083 send_prev_IFS=$IFS; IFS=','
1084 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1088 send_qual_type_arg2=$[2]
1090 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1091 [Define to the type of arg 1 for send.])
1092 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1093 [Define to the type of arg 3 for send.])
1094 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1095 [Define to the type of arg 4 for send.])
1096 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1097 [Define to the function return type for send.])
1101 case $prev_sh_opts in
1109 case "$send_qual_type_arg2" in
1111 send_qual_arg2=const
1112 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1116 send_type_arg2=$send_qual_type_arg2
1120 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1121 [Define to the type qualifier of arg 2 for send.])
1122 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1123 [Define to the type of arg 2 for send.])
1125 case $prev_sh_opts in
1133 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1134 [Define to 1 if you have the send function.])
1135 ac_cv_func_send="yes"
1138 AC_MSG_ERROR([Unable to link function send])
1143 dnl CURL_CHECK_FUNC_RECVFROM
1144 dnl -------------------------------------------------
1145 dnl Test if the socket recvfrom() function is available,
1146 dnl and check its return type and the types of its
1147 dnl arguments. If the function succeeds HAVE_RECVFROM
1148 dnl will be defined, defining the types of the arguments
1149 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1150 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1151 dnl function return value in RECVFROM_TYPE_RETV.
1152 dnl Notice that the types returned for pointer arguments
1153 dnl will actually be the type pointed by the pointer.
1155 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1156 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1157 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1158 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1160 AC_MSG_CHECKING([for recvfrom])
1164 #ifdef HAVE_WINDOWS_H
1165 #ifndef WIN32_LEAN_AND_MEAN
1166 #define WIN32_LEAN_AND_MEAN
1168 #include <windows.h>
1169 #ifdef HAVE_WINSOCK2_H
1170 #include <winsock2.h>
1172 #ifdef HAVE_WINSOCK_H
1173 #include <winsock.h>
1177 #ifdef HAVE_SYS_TYPES_H
1178 #include <sys/types.h>
1180 #ifdef HAVE_SYS_SOCKET_H
1181 #include <sys/socket.h>
1185 recvfrom(0, 0, 0, 0, 0, 0);
1188 AC_MSG_RESULT([yes])
1189 curl_cv_recvfrom="yes"
1192 curl_cv_recvfrom="no"
1195 if test "$curl_cv_recvfrom" = "yes"; then
1196 AC_CACHE_CHECK([types of args and return type for recvfrom],
1197 [curl_cv_func_recvfrom_args], [
1198 curl_cv_func_recvfrom_args="unknown"
1199 for recvfrom_retv in 'int' 'ssize_t'; do
1200 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1201 for recvfrom_arg2 in 'char *' 'void *'; do
1202 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1203 for recvfrom_arg4 in 'int' 'unsigned int'; do
1204 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1205 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1206 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1210 #ifdef HAVE_WINDOWS_H
1211 #ifndef WIN32_LEAN_AND_MEAN
1212 #define WIN32_LEAN_AND_MEAN
1214 #include <windows.h>
1215 #ifdef HAVE_WINSOCK2_H
1216 #include <winsock2.h>
1218 #ifdef HAVE_WINSOCK_H
1219 #include <winsock.h>
1222 #define RECVFROMCALLCONV PASCAL
1224 #ifdef HAVE_SYS_TYPES_H
1225 #include <sys/types.h>
1227 #ifdef HAVE_SYS_SOCKET_H
1228 #include <sys/socket.h>
1230 #define RECVFROMCALLCONV
1232 extern $recvfrom_retv RECVFROMCALLCONV
1233 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1234 $recvfrom_arg3, $recvfrom_arg4,
1235 $recvfrom_arg5, $recvfrom_arg6);
1238 $recvfrom_arg2 buf=0;
1239 $recvfrom_arg3 len=0;
1240 $recvfrom_arg4 flags=0;
1241 $recvfrom_arg5 addr=0;
1242 $recvfrom_arg6 addrlen=0;
1243 $recvfrom_retv res=0;
1244 res = recvfrom(s, buf, len, flags, addr, addrlen);
1247 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1258 # Nearly last minute change for this release starts here
1259 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1260 [Define to 1 if you have the recvfrom function.])
1261 ac_cv_func_recvfrom="yes"
1262 # Nearly last minute change for this release ends here
1263 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1264 AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
1266 recvfrom_prev_IFS=$IFS; IFS=','
1267 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1268 IFS=$recvfrom_prev_IFS
1271 recvfrom_ptrt_arg2=$[2]
1272 recvfrom_ptrt_arg5=$[5]
1273 recvfrom_ptrt_arg6=$[6]
1275 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1276 [Define to the type of arg 1 for recvfrom.])
1277 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1278 [Define to the type of arg 3 for recvfrom.])
1279 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1280 [Define to the type of arg 4 for recvfrom.])
1281 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1282 [Define to the function return type for recvfrom.])
1286 case $prev_sh_opts in
1294 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1295 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1296 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1298 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1299 [Define to the type pointed by arg 2 for recvfrom.])
1300 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1301 [Define to the type pointed by arg 5 for recvfrom.])
1302 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1303 [Define to the type pointed by arg 6 for recvfrom.])
1305 if test "$recvfrom_type_arg2" = "void"; then
1306 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1307 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1309 if test "$recvfrom_type_arg5" = "void"; then
1310 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1311 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1313 if test "$recvfrom_type_arg6" = "void"; then
1314 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1315 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1318 case $prev_sh_opts in
1326 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1327 [Define to 1 if you have the recvfrom function.])
1328 ac_cv_func_recvfrom="yes"
1331 AC_MSG_WARN([Unable to link function recvfrom])
1332 AC_MSG_WARN([Your system will be vulnerable to some forms of DNS cache poisoning])
1337 dnl CURL_CHECK_MSG_NOSIGNAL
1338 dnl -------------------------------------------------
1339 dnl Check for MSG_NOSIGNAL
1341 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1342 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1343 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1347 #ifdef HAVE_WINDOWS_H
1348 #ifndef WIN32_LEAN_AND_MEAN
1349 #define WIN32_LEAN_AND_MEAN
1351 #include <windows.h>
1352 #ifdef HAVE_WINSOCK2_H
1353 #include <winsock2.h>
1355 #ifdef HAVE_WINSOCK_H
1356 #include <winsock.h>
1360 #ifdef HAVE_SYS_TYPES_H
1361 #include <sys/types.h>
1363 #ifdef HAVE_SYS_SOCKET_H
1364 #include <sys/socket.h>
1368 int flag=MSG_NOSIGNAL;
1371 ac_cv_msg_nosignal="yes"
1373 ac_cv_msg_nosignal="no"
1376 case "$ac_cv_msg_nosignal" in
1378 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1379 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1385 dnl CURL_CHECK_STRUCT_TIMEVAL
1386 dnl -------------------------------------------------
1387 dnl Check for timeval struct
1389 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1390 AC_REQUIRE([AC_HEADER_TIME])dnl
1391 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1392 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1393 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1394 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1398 #ifdef HAVE_WINDOWS_H
1399 #ifndef WIN32_LEAN_AND_MEAN
1400 #define WIN32_LEAN_AND_MEAN
1402 #include <windows.h>
1403 #ifdef HAVE_WINSOCK2_H
1404 #include <winsock2.h>
1406 #ifdef HAVE_WINSOCK_H
1407 #include <winsock.h>
1411 #ifdef HAVE_SYS_TYPES_H
1412 #include <sys/types.h>
1414 #ifdef HAVE_SYS_TIME_H
1415 #include <sys/time.h>
1416 #ifdef TIME_WITH_SYS_TIME
1430 ac_cv_struct_timeval="yes"
1432 ac_cv_struct_timeval="no"
1435 case "$ac_cv_struct_timeval" in
1437 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1438 [Define to 1 if you have the timeval struct.])
1444 dnl TYPE_SIG_ATOMIC_T
1445 dnl -------------------------------------------------
1446 dnl Check if the sig_atomic_t type is available, and
1447 dnl verify if it is already defined as volatile.
1449 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1450 AC_CHECK_HEADERS(signal.h)
1451 AC_CHECK_TYPE([sig_atomic_t],[
1452 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1453 [Define to 1 if sig_atomic_t is an available typedef.])
1455 #ifdef HAVE_SIGNAL_H
1459 case "$ac_cv_type_sig_atomic_t" in
1462 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1465 #ifdef HAVE_SIGNAL_H
1469 static volatile sig_atomic_t dummy = 0;
1473 ac_cv_sig_atomic_t_volatile="no"
1475 AC_MSG_RESULT([yes])
1476 ac_cv_sig_atomic_t_volatile="yes"
1479 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1480 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1481 [Define to 1 if sig_atomic_t is already defined as volatile.])
1489 dnl -------------------------------------------------
1490 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1491 dnl and a few other things.
1493 AC_DEFUN([TYPE_IN_ADDR_T], [
1494 AC_CHECK_TYPE([in_addr_t], ,[
1495 dnl in_addr_t not available
1496 AC_CACHE_CHECK([for in_addr_t equivalent],
1497 [curl_cv_in_addr_t_equiv], [
1498 curl_cv_in_addr_t_equiv="unknown"
1499 for t in "unsigned long" int size_t unsigned long; do
1500 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1504 #ifdef HAVE_WINDOWS_H
1505 #ifndef WIN32_LEAN_AND_MEAN
1506 #define WIN32_LEAN_AND_MEAN
1508 #include <windows.h>
1509 #ifdef HAVE_WINSOCK2_H
1510 #include <winsock2.h>
1512 #ifdef HAVE_WINSOCK_H
1513 #include <winsock.h>
1517 #ifdef HAVE_SYS_TYPES_H
1518 #include <sys/types.h>
1520 #ifdef HAVE_SYS_SOCKET_H
1521 #include <sys/socket.h>
1523 #ifdef HAVE_NETINET_IN_H
1524 #include <netinet/in.h>
1526 #ifdef HAVE_ARPA_INET_H
1527 #include <arpa/inet.h>
1531 $t data = inet_addr ("1.2.3.4");
1534 curl_cv_in_addr_t_equiv="$t"
1539 case "$curl_cv_in_addr_t_equiv" in
1541 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1544 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1545 [Type to use in place of in_addr_t when system does not provide it.])
1550 #ifdef HAVE_WINDOWS_H
1551 #ifndef WIN32_LEAN_AND_MEAN
1552 #define WIN32_LEAN_AND_MEAN
1554 #include <windows.h>
1555 #ifdef HAVE_WINSOCK2_H
1556 #include <winsock2.h>
1558 #ifdef HAVE_WINSOCK_H
1559 #include <winsock.h>
1563 #ifdef HAVE_SYS_TYPES_H
1564 #include <sys/types.h>
1566 #ifdef HAVE_SYS_SOCKET_H
1567 #include <sys/socket.h>
1569 #ifdef HAVE_NETINET_IN_H
1570 #include <netinet/in.h>
1572 #ifdef HAVE_ARPA_INET_H
1573 #include <arpa/inet.h>
1580 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1581 dnl -------------------------------------------------
1582 dnl Check if monotonic clock_gettime is available.
1584 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1585 AC_REQUIRE([AC_HEADER_TIME])dnl
1586 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1587 AC_MSG_CHECKING([for monotonic clock_gettime])
1590 #ifdef HAVE_SYS_TYPES_H
1591 #include <sys/types.h>
1593 #ifdef HAVE_SYS_TIME_H
1594 #include <sys/time.h>
1595 #ifdef TIME_WITH_SYS_TIME
1605 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1608 AC_MSG_RESULT([yes])
1609 ac_cv_func_clock_gettime="yes"
1612 ac_cv_func_clock_gettime="no"
1614 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1615 dnl until library linking and run-time checks for clock_gettime succeed.
1619 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1620 dnl -------------------------------------------------
1621 dnl If monotonic clock_gettime is available then,
1622 dnl check and prepended to LIBS any needed libraries.
1624 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1625 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1627 if test "$ac_cv_func_clock_gettime" = "yes"; then
1629 AC_MSG_CHECKING([for clock_gettime in libraries])
1631 curl_cv_save_LIBS="$LIBS"
1632 curl_cv_gclk_LIBS="unknown"
1634 for x_xlibs in '' '-lrt' '-lposix4' ; do
1635 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1636 if test -z "$x_xlibs"; then
1637 LIBS="$curl_cv_save_LIBS"
1639 LIBS="$x_xlibs $curl_cv_save_LIBS"
1643 #ifdef HAVE_SYS_TYPES_H
1644 #include <sys/types.h>
1646 #ifdef HAVE_SYS_TIME_H
1647 #include <sys/time.h>
1648 #ifdef TIME_WITH_SYS_TIME
1658 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1661 curl_cv_gclk_LIBS="$x_xlibs"
1666 LIBS="$curl_cv_save_LIBS"
1668 case X-"$curl_cv_gclk_LIBS" in
1670 AC_MSG_RESULT([cannot find clock_gettime])
1671 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1672 ac_cv_func_clock_gettime="no"
1675 AC_MSG_RESULT([no additional lib required])
1676 ac_cv_func_clock_gettime="yes"
1679 if test -z "$curl_cv_save_LIBS"; then
1680 LIBS="$curl_cv_gclk_LIBS"
1682 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1684 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1685 ac_cv_func_clock_gettime="yes"
1689 dnl only do runtime verification when not cross-compiling
1690 if test "x$cross_compiling" != "xyes" &&
1691 test "$ac_cv_func_clock_gettime" = "yes"; then
1692 AC_MSG_CHECKING([if monotonic clock_gettime works])
1695 #ifdef HAVE_STDLIB_H
1698 #ifdef HAVE_SYS_TYPES_H
1699 #include <sys/types.h>
1701 #ifdef HAVE_SYS_TIME_H
1702 #include <sys/time.h>
1703 #ifdef TIME_WITH_SYS_TIME
1713 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1719 AC_MSG_RESULT([yes])
1722 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1723 ac_cv_func_clock_gettime="no"
1724 LIBS="$curl_cv_save_LIBS"
1728 case "$ac_cv_func_clock_gettime" in
1730 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1731 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1740 dnl CARES_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1741 dnl -------------------------------------------------
1742 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1743 dnl symbol that can be further used in custom template configuration
1744 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1745 dnl argument for the description. Symbol definitions done with this
1746 dnl macro are intended to be exclusively used in handcrafted *.h.in
1747 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1748 dnl prevents autoheader generation and insertion of symbol template
1749 dnl stub and definition into the first configuration header file. Do
1750 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1751 dnl one serves different functional needs.
1753 AC_DEFUN([CARES_DEFINE_UNQUOTED], [
1754 cat >>confdefs.h <<_EOF
1755 [@%:@define] $1 ifelse($#, 2, [$2], 1)
1760 dnl CARES_CONFIGURE_LONG
1761 dnl -------------------------------------------------
1762 dnl Find out the size of long as reported by sizeof() and define
1763 dnl CARES_SIZEOF_LONG as appropriate to be used in template file
1764 dnl ares_build.h.in to properly configure the library.
1765 dnl The size of long is a build time characteristic and as such
1766 dnl must be recorded in ares_build.h
1768 AC_DEFUN([CARES_CONFIGURE_LONG], [
1769 if test -z "$ac_cv_sizeof_long" ||
1770 test "$ac_cv_sizeof_long" -eq "0"; then
1771 AC_MSG_ERROR([cannot find out size of long.])
1773 CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
1777 dnl CARES_CONFIGURE_ARES_SOCKLEN_T
1778 dnl -------------------------------------------------
1779 dnl Find out suitable ares_socklen_t data type definition and size, making
1780 dnl appropriate definitions for template file ares_build.h.in
1781 dnl to properly configure and use the library.
1783 dnl The need for the ares_socklen_t definition arises mainly to properly
1784 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
1785 dnl data type which is 32 or 64-Bit wide depending on the data model being
1786 dnl used, and that on the other hand is only actually used when interfacing
1787 dnl the X/Open sockets provided in the xnet library.
1789 AC_DEFUN([CARES_CONFIGURE_ARES_SOCKLEN_T], [
1790 AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
1791 AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
1792 AC_REQUIRE([CARES_PREPROCESS_CALLCONV])dnl
1794 AC_MSG_CHECKING([for ares_socklen_t data type])
1795 cares_typeof_ares_socklen_t="unknown"
1796 for arg1 in int SOCKET; do
1797 for arg2 in 'struct sockaddr' void; do
1798 for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
1799 if test "$cares_typeof_ares_socklen_t" = "unknown"; then
1802 $cares_includes_ws2tcpip
1803 $cares_includes_sys_socket
1804 $cares_preprocess_callconv
1805 extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
1808 if(0 != getpeername(0, 0, lenptr))
1812 cares_typeof_ares_socklen_t="$t"
1818 for t in socklen_t int; do
1819 if test "$cares_typeof_ares_socklen_t" = "void"; then
1822 $cares_includes_sys_socket
1823 typedef $t ares_socklen_t;
1825 ares_socklen_t dummy;
1828 cares_typeof_ares_socklen_t="$t"
1832 AC_MSG_RESULT([$cares_typeof_ares_socklen_t])
1833 if test "$cares_typeof_ares_socklen_t" = "void" ||
1834 test "$cares_typeof_ares_socklen_t" = "unknown"; then
1835 AC_MSG_ERROR([cannot find data type for ares_socklen_t.])
1838 AC_MSG_CHECKING([size of ares_socklen_t])
1839 cares_sizeof_ares_socklen_t="unknown"
1840 cares_pull_headers_socklen_t="unknown"
1841 if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
1842 tst_pull_header_checks='none ws2tcpip'
1845 tst_pull_header_checks='none systypes syssocket'
1846 tst_size_checks='4 8 2'
1848 for tst_size in $tst_size_checks; do
1849 for tst_pull_headers in $tst_pull_header_checks; do
1850 if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
1851 case $tst_pull_headers in
1853 tmp_includes="$cares_includes_ws2tcpip"
1856 tmp_includes="$cares_includes_sys_types"
1859 tmp_includes="$cares_includes_sys_socket"
1868 typedef $cares_typeof_ares_socklen_t ares_socklen_t;
1869 typedef char dummy_arr[sizeof(ares_socklen_t) == $tst_size ? 1 : -1];
1871 ares_socklen_t dummy;
1874 cares_sizeof_ares_socklen_t="$tst_size"
1875 cares_pull_headers_socklen_t="$tst_pull_headers"
1880 AC_MSG_RESULT([$cares_sizeof_ares_socklen_t])
1881 if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
1882 AC_MSG_ERROR([cannot find out size of ares_socklen_t.])
1885 case $cares_pull_headers_socklen_t in
1887 CARES_DEFINE_UNQUOTED([CARES_PULL_WS2TCPIP_H])
1890 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
1893 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
1894 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_SOCKET_H])
1897 CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [$cares_typeof_ares_socklen_t])
1898 CARES_DEFINE_UNQUOTED([CARES_SIZEOF_ARES_SOCKLEN_T], [$cares_sizeof_ares_socklen_t])
1902 dnl This macro determines if the specified struct exists in the specified file
1904 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1906 AC_DEFUN([CARES_CHECK_STRUCT], [
1907 AC_MSG_CHECKING([for struct $2])
1908 AC_TRY_COMPILE([$1],
1910 struct $2 struct_instance;
1911 ], ac_struct="yes", ac_found="no")
1912 if test "$ac_struct" = "yes" ; then
1921 dnl This macro determines if the specified constant exists in the specified file
1923 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1925 AC_DEFUN([CARES_CHECK_CONSTANT], [
1926 AC_MSG_CHECKING([for $2])
1927 AC_EGREP_CPP(VARIABLEWASDEFINED,
1936 ], ac_constant="yes", ac_constant="no"
1938 if test "$ac_constant" = "yes" ; then