3 dnl CURL_CHECK_DEF (SYMBOL, [INCLUDES], [SILENT])
4 dnl -------------------------------------------------
5 dnl Use the C preprocessor to find out if the given object-style symbol
6 dnl is defined and get its expansion. This macro will not use default
7 dnl includes even if no INCLUDES argument is given. This macro will run
8 dnl silently when invoked with three arguments. If the expansion would
9 dnl result in a set of double-quoted strings the returned expansion will
10 dnl actually be a single double-quoted string concatenating all them.
12 AC_DEFUN([CURL_CHECK_DEF], [
13 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
14 AS_VAR_PUSHDEF([ac_Def], [curl_cv_def_$1])dnl
15 if test -z "$SED"; then
16 AC_MSG_ERROR([SED not set. Cannot continue without SED being set.])
18 if test -z "$GREP"; then
19 AC_MSG_ERROR([GREP not set. Cannot continue without GREP being set.])
21 ifelse($3,,[AC_MSG_CHECKING([for preprocessor definition of $1])])
31 tmp_exp=`eval "$ac_cpp conftest.$ac_ext" 2>/dev/null | \
32 "$GREP" CURL_DEF_TOKEN 2>/dev/null | \
33 "$SED" 's/.*CURL_DEF_TOKEN[[ ]]//' 2>/dev/null | \
34 "$SED" 's/[["]][[ ]]*[["]]//g' 2>/dev/null`
35 if test -z "$tmp_exp" || test "$tmp_exp" = "$1"; then
39 if test -z "$tmp_exp"; then
40 AS_VAR_SET(ac_HaveDef, no)
41 ifelse($3,,[AC_MSG_RESULT([no])])
43 AS_VAR_SET(ac_HaveDef, yes)
44 AS_VAR_SET(ac_Def, $tmp_exp)
45 ifelse($3,,[AC_MSG_RESULT([$tmp_exp])])
47 AS_VAR_POPDEF([ac_Def])dnl
48 AS_VAR_POPDEF([ac_HaveDef])dnl
52 dnl CURL_CHECK_DEF_CC (SYMBOL, [INCLUDES], [SILENT])
53 dnl -------------------------------------------------
54 dnl Use the C compiler to find out only if the given symbol is defined
55 dnl or not, this can not find out its expansion. This macro will not use
56 dnl default includes even if no INCLUDES argument is given. This macro
57 dnl will run silently when invoked with three arguments.
59 AC_DEFUN([CURL_CHECK_DEF_CC], [
60 AS_VAR_PUSHDEF([ac_HaveDef], [curl_cv_have_def_$1])dnl
61 ifelse($3,,[AC_MSG_CHECKING([for compiler definition of $1])])
70 force compilation error
75 tst_symbol_defined="yes"
77 tst_symbol_defined="no"
79 if test "$tst_symbol_defined" = "yes"; then
80 AS_VAR_SET(ac_HaveDef, yes)
81 ifelse($3,,[AC_MSG_RESULT([yes])])
83 AS_VAR_SET(ac_HaveDef, no)
84 ifelse($3,,[AC_MSG_RESULT([no])])
86 AS_VAR_POPDEF([ac_HaveDef])dnl
90 dnl CARES_CHECK_LIB_XNET
91 dnl -------------------------------------------------
92 dnl Verify if X/Open network library is required.
94 AC_DEFUN([CARES_CHECK_LIB_XNET], [
95 AC_MSG_CHECKING([if X/Open network library is required])
96 tst_lib_xnet_required="no"
101 #if defined(__hpux) && defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600)
103 #elif defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
106 force compilation error
111 tst_lib_xnet_required="yes"
114 AC_MSG_RESULT([$tst_lib_xnet_required])
118 dnl CARES_CHECK_AIX_ALL_SOURCE
119 dnl -------------------------------------------------
120 dnl Provides a replacement of traditional AC_AIX with
121 dnl an uniform behaviour across all autoconf versions,
122 dnl and with our own placement rules.
124 AC_DEFUN([CARES_CHECK_AIX_ALL_SOURCE], [
125 AH_VERBATIM([_ALL_SOURCE],
126 [/* Define to 1 if OS is AIX. */
130 AC_BEFORE([$0], [AC_SYS_LARGEFILE])dnl
131 AC_BEFORE([$0], [CARES_CONFIGURE_REENTRANT])dnl
132 AC_MSG_CHECKING([if OS is AIX (to define _ALL_SOURCE)])
133 AC_EGREP_CPP([yes_this_is_aix],[
139 AC_DEFINE(_ALL_SOURCE)
146 dnl CURL_CHECK_HEADER_WINDOWS
147 dnl -------------------------------------------------
148 dnl Check for compilable and valid windows.h header
150 AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
151 AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
155 #ifndef WIN32_LEAN_AND_MEAN
156 #define WIN32_LEAN_AND_MEAN
160 #if defined(__CYGWIN__) || defined(__CEGCC__)
161 HAVE_WINDOWS_H shall not be defined.
167 ac_cv_header_windows_h="yes"
169 ac_cv_header_windows_h="no"
172 case "$ac_cv_header_windows_h" in
174 AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
175 [Define to 1 if you have the windows.h header file.])
176 AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
177 [Define to avoid automatic inclusion of winsock.h])
183 dnl CURL_CHECK_NATIVE_WINDOWS
184 dnl -------------------------------------------------
185 dnl Check if building a native Windows target
187 AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [
188 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
189 AC_CACHE_CHECK([whether build target is a native Windows one], [ac_cv_native_windows], [
190 if test "$ac_cv_header_windows_h" = "no"; then
191 ac_cv_native_windows="no"
196 #if defined(__MINGW32__) || defined(__MINGW32CE__) || \
197 (defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)))
200 Not a native Windows build target.
204 ac_cv_native_windows="yes"
206 ac_cv_native_windows="no"
210 case "$ac_cv_native_windows" in
212 AC_DEFINE_UNQUOTED(NATIVE_WINDOWS, 1,
213 [Define to 1 if you are building a native Windows target.])
219 dnl CURL_CHECK_HEADER_WINSOCK
220 dnl -------------------------------------------------
221 dnl Check for compilable and valid winsock.h header
223 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
224 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
225 AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
229 #ifndef WIN32_LEAN_AND_MEAN
230 #define WIN32_LEAN_AND_MEAN
235 #if defined(__CYGWIN__) || defined(__CEGCC__)
236 HAVE_WINSOCK_H shall not be defined.
238 int dummy=WSACleanup();
242 ac_cv_header_winsock_h="yes"
244 ac_cv_header_winsock_h="no"
247 case "$ac_cv_header_winsock_h" in
249 AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
250 [Define to 1 if you have the winsock.h header file.])
256 dnl CURL_CHECK_HEADER_WINSOCK2
257 dnl -------------------------------------------------
258 dnl Check for compilable and valid winsock2.h header
260 AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
261 AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
262 AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
266 #ifndef WIN32_LEAN_AND_MEAN
267 #define WIN32_LEAN_AND_MEAN
270 #include <winsock2.h>
272 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
273 HAVE_WINSOCK2_H shall not be defined.
275 int dummy=2*IPPROTO_ESP;
279 ac_cv_header_winsock2_h="yes"
281 ac_cv_header_winsock2_h="no"
284 case "$ac_cv_header_winsock2_h" in
286 AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
287 [Define to 1 if you have the winsock2.h header file.])
293 dnl CURL_CHECK_HEADER_WS2TCPIP
294 dnl -------------------------------------------------
295 dnl Check for compilable and valid ws2tcpip.h header
297 AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
298 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
299 AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
303 #ifndef WIN32_LEAN_AND_MEAN
304 #define WIN32_LEAN_AND_MEAN
307 #include <winsock2.h>
308 #include <ws2tcpip.h>
310 #if defined(__CYGWIN__) || defined(__CEGCC__) || defined(__MINGW32CE__)
311 HAVE_WS2TCPIP_H shall not be defined.
313 int dummy=2*IP_PKTINFO;
317 ac_cv_header_ws2tcpip_h="yes"
319 ac_cv_header_ws2tcpip_h="no"
322 case "$ac_cv_header_ws2tcpip_h" in
324 AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
325 [Define to 1 if you have the ws2tcpip.h header file.])
331 dnl CURL_CHECK_HEADER_MALLOC
332 dnl -------------------------------------------------
333 dnl Check for compilable and valid malloc.h header,
334 dnl and check if it is needed even with stdlib.h
336 AC_DEFUN([CURL_CHECK_HEADER_MALLOC], [
337 AC_CACHE_CHECK([for malloc.h], [ac_cv_header_malloc_h], [
342 void *p = malloc(10);
343 void *q = calloc(10,10);
348 ac_cv_header_malloc_h="yes"
350 ac_cv_header_malloc_h="no"
353 if test "$ac_cv_header_malloc_h" = "yes"; then
354 AC_DEFINE_UNQUOTED(HAVE_MALLOC_H, 1,
355 [Define to 1 if you have the malloc.h header file.])
361 void *p = malloc(10);
362 void *q = calloc(10,10);
367 curl_cv_need_header_malloc_h="no"
369 curl_cv_need_header_malloc_h="yes"
372 case "$curl_cv_need_header_malloc_h" in
374 AC_DEFINE_UNQUOTED(NEED_MALLOC_H, 1,
375 [Define to 1 if you need the malloc.h header file even with stdlib.h])
382 dnl CURL_CHECK_HEADER_MEMORY
383 dnl -------------------------------------------------
384 dnl Check for compilable and valid memory.h header,
385 dnl and check if it is needed even with stdlib.h for
386 dnl memory related functions.
388 AC_DEFUN([CURL_CHECK_HEADER_MEMORY], [
389 AC_CACHE_CHECK([for memory.h], [ac_cv_header_memory_h], [
394 void *p = malloc(10);
395 void *q = calloc(10,10);
400 ac_cv_header_memory_h="yes"
402 ac_cv_header_memory_h="no"
405 if test "$ac_cv_header_memory_h" = "yes"; then
406 AC_DEFINE_UNQUOTED(HAVE_MEMORY_H, 1,
407 [Define to 1 if you have the memory.h header file.])
413 void *p = malloc(10);
414 void *q = calloc(10,10);
419 curl_cv_need_header_memory_h="no"
421 curl_cv_need_header_memory_h="yes"
424 case "$curl_cv_need_header_memory_h" in
426 AC_DEFINE_UNQUOTED(NEED_MEMORY_H, 1,
427 [Define to 1 if you need the memory.h header file even with stdlib.h])
434 dnl CURL_CHECK_FUNC_GETNAMEINFO
435 dnl -------------------------------------------------
436 dnl Test if the getnameinfo function is available,
437 dnl and check the types of five of its arguments.
438 dnl If the function succeeds HAVE_GETNAMEINFO will be
439 dnl defined, defining the types of the arguments in
440 dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
441 dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7,
442 dnl and also defining the type qualifier of first
443 dnl argument in GETNAMEINFO_QUAL_ARG1.
445 AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
446 AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
447 AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
449 AC_MSG_CHECKING([for getnameinfo])
451 AC_LANG_FUNC_LINK_TRY([getnameinfo])
454 curl_cv_getnameinfo="yes"
457 curl_cv_getnameinfo="no"
460 if test "$curl_cv_getnameinfo" != "yes"; then
461 AC_MSG_CHECKING([deeper for getnameinfo])
469 curl_cv_getnameinfo="yes"
471 AC_MSG_RESULT([but still no])
472 curl_cv_getnameinfo="no"
476 if test "$curl_cv_getnameinfo" != "yes"; then
477 AC_MSG_CHECKING([deeper and deeper for getnameinfo])
481 #ifdef HAVE_WINDOWS_H
482 #ifndef WIN32_LEAN_AND_MEAN
483 #define WIN32_LEAN_AND_MEAN
486 #ifdef HAVE_WINSOCK2_H
487 #include <winsock2.h>
488 #ifdef HAVE_WS2TCPIP_H
489 #include <ws2tcpip.h>
493 #ifdef HAVE_SYS_TYPES_H
494 #include <sys/types.h>
496 #ifdef HAVE_SYS_SOCKET_H
497 #include <sys/socket.h>
504 getnameinfo(0, 0, 0, 0, 0, 0, 0);
508 curl_cv_getnameinfo="yes"
510 AC_MSG_RESULT([but still no])
511 curl_cv_getnameinfo="no"
515 if test "$curl_cv_getnameinfo" = "yes"; then
516 AC_CACHE_CHECK([types of arguments for getnameinfo],
517 [curl_cv_func_getnameinfo_args], [
518 curl_cv_func_getnameinfo_args="unknown"
519 for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
520 for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
521 for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
522 for gni_arg7 in 'int' 'unsigned int'; do
523 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
527 #ifdef HAVE_WINDOWS_H
528 #ifndef WIN32_LEAN_AND_MEAN
529 #define WIN32_LEAN_AND_MEAN
531 #if (!defined(_WIN32_WINNT)) || (_WIN32_WINNT < 0x0501)
533 #define _WIN32_WINNT 0x0501
536 #ifdef HAVE_WINSOCK2_H
537 #include <winsock2.h>
538 #ifdef HAVE_WS2TCPIP_H
539 #include <ws2tcpip.h>
542 #define GNICALLCONV WSAAPI
544 #ifdef HAVE_SYS_TYPES_H
545 #include <sys/types.h>
547 #ifdef HAVE_SYS_SOCKET_H
548 #include <sys/socket.h>
555 extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
561 $gni_arg46 hostlen=0;
562 $gni_arg46 servlen=0;
564 int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
567 curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
575 if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
576 AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
577 AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
579 gni_prev_IFS=$IFS; IFS=','
580 set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
584 gni_qual_type_arg1=$[1]
586 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
587 [Define to the type of arg 2 for getnameinfo.])
588 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
589 [Define to the type of args 4 and 6 for getnameinfo.])
590 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
591 [Define to the type of arg 7 for getnameinfo.])
595 case $prev_sh_opts in
603 case "$gni_qual_type_arg1" in
606 gni_type_arg1=`echo $gni_qual_type_arg1 | sed 's/^const //'`
610 gni_type_arg1=$gni_qual_type_arg1
614 AC_DEFINE_UNQUOTED(GETNAMEINFO_QUAL_ARG1, $gni_qual_arg1,
615 [Define to the type qualifier of arg 1 for getnameinfo.])
616 AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $gni_type_arg1,
617 [Define to the type of arg 1 for getnameinfo.])
619 case $prev_sh_opts in
627 AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
628 [Define to 1 if you have the getnameinfo function.])
629 ac_cv_func_getnameinfo="yes"
635 dnl TYPE_SOCKADDR_STORAGE
636 dnl -------------------------------------------------
637 dnl Check for struct sockaddr_storage. Most IPv6-enabled
638 dnl hosts have it, but AIX 4.3 is one known exception.
640 AC_DEFUN([TYPE_SOCKADDR_STORAGE],
642 AC_CHECK_TYPE([struct sockaddr_storage],
643 AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
644 [if struct sockaddr_storage is defined]), ,
647 #ifdef HAVE_WINDOWS_H
648 #ifndef WIN32_LEAN_AND_MEAN
649 #define WIN32_LEAN_AND_MEAN
652 #ifdef HAVE_WINSOCK2_H
653 #include <winsock2.h>
656 #ifdef HAVE_SYS_TYPES_H
657 #include <sys/types.h>
659 #ifdef HAVE_SYS_SOCKET_H
660 #include <sys/socket.h>
662 #ifdef HAVE_NETINET_IN_H
663 #include <netinet/in.h>
665 #ifdef HAVE_ARPA_INET_H
666 #include <arpa/inet.h>
673 dnl CURL_CHECK_NI_WITHSCOPEID
674 dnl -------------------------------------------------
675 dnl Check for working NI_WITHSCOPEID in getnameinfo()
677 AC_DEFUN([CURL_CHECK_NI_WITHSCOPEID], [
678 AC_REQUIRE([CURL_CHECK_FUNC_GETNAMEINFO])dnl
679 AC_REQUIRE([TYPE_SOCKADDR_STORAGE])dnl
680 AC_CHECK_HEADERS(stdio.h sys/types.h sys/socket.h \
681 netdb.h netinet/in.h arpa/inet.h)
683 AC_CACHE_CHECK([for working NI_WITHSCOPEID],
684 [ac_cv_working_ni_withscopeid], [
693 #ifdef HAVE_SYS_TYPES_H
694 #include <sys/types.h>
696 #ifdef HAVE_SYS_SOCKET_H
697 #include <sys/socket.h>
702 #ifdef HAVE_NETINET_IN_H
703 #include <netinet/in.h>
705 #ifdef HAVE_ARPA_INET_H
706 #include <arpa/inet.h>
709 #if defined(NI_WITHSCOPEID) && defined(HAVE_GETNAMEINFO)
710 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE
711 struct sockaddr_storage sa;
713 unsigned char sa[256];
715 char hostbuf[NI_MAXHOST];
717 GETNAMEINFO_TYPE_ARG2 salen = (GETNAMEINFO_TYPE_ARG2)sizeof(sa);
718 GETNAMEINFO_TYPE_ARG46 hostlen = (GETNAMEINFO_TYPE_ARG46)sizeof(hostbuf);
719 GETNAMEINFO_TYPE_ARG7 flags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
720 int fd = socket(AF_INET6, SOCK_STREAM, 0);
723 return 1; /* Error creating socket */
725 rc = getsockname(fd, (GETNAMEINFO_TYPE_ARG1)&sa, &salen);
727 perror("getsockname()");
728 return 2; /* Error retrieving socket name */
730 rc = getnameinfo((GETNAMEINFO_TYPE_ARG1)&sa, salen, hostbuf, hostlen, NULL, 0, flags);
732 printf("rc = %s\n", gai_strerror(rc));
733 return 3; /* Error translating socket address */
735 return 0; /* Ok, NI_WITHSCOPEID works */
737 return 4; /* Error, NI_WITHSCOPEID not defined or no getnameinfo() */
739 ]]) # AC-LANG-PROGRAM
741 # Exit code == 0. Program worked.
742 ac_cv_working_ni_withscopeid="yes"
744 # Exit code != 0. Program failed.
745 ac_cv_working_ni_withscopeid="no"
747 # Program is not run when cross-compiling. So we assume
748 # NI_WITHSCOPEID will work if we are able to compile it.
751 #include <sys/types.h>
752 #include <sys/socket.h>
755 unsigned int dummy= NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
758 ac_cv_working_ni_withscopeid="yes"
760 ac_cv_working_ni_withscopeid="no"
761 ]) # AC-COMPILE-IFELSE
764 case "$ac_cv_working_ni_withscopeid" in
766 AC_DEFINE(HAVE_NI_WITHSCOPEID, 1,
767 [Define to 1 if NI_WITHSCOPEID exists and works.])
773 dnl CURL_CHECK_FUNC_RECV
774 dnl -------------------------------------------------
775 dnl Test if the socket recv() function is available,
776 dnl and check its return type and the types of its
777 dnl arguments. If the function succeeds HAVE_RECV
778 dnl will be defined, defining the types of the arguments
779 dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
780 dnl and RECV_TYPE_ARG4, defining the type of the function
781 dnl return value in RECV_TYPE_RETV.
783 AC_DEFUN([CURL_CHECK_FUNC_RECV], [
784 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
785 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
786 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
788 AC_MSG_CHECKING([for recv])
792 #ifdef HAVE_WINDOWS_H
793 #ifndef WIN32_LEAN_AND_MEAN
794 #define WIN32_LEAN_AND_MEAN
797 #ifdef HAVE_WINSOCK2_H
798 #include <winsock2.h>
800 #ifdef HAVE_WINSOCK_H
805 #ifdef HAVE_SYS_TYPES_H
806 #include <sys/types.h>
808 #ifdef HAVE_SYS_SOCKET_H
809 #include <sys/socket.h>
823 if test "$curl_cv_recv" = "yes"; then
824 AC_CACHE_CHECK([types of args and return type for recv],
825 [curl_cv_func_recv_args], [
826 curl_cv_func_recv_args="unknown"
827 for recv_retv in 'int' 'ssize_t'; do
828 for recv_arg1 in 'int' 'ssize_t' 'SOCKET'; do
829 for recv_arg2 in 'char *' 'void *'; do
830 for recv_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
831 for recv_arg4 in 'int' 'unsigned int'; do
832 if test "$curl_cv_func_recv_args" = "unknown"; then
836 #ifdef HAVE_WINDOWS_H
837 #ifndef WIN32_LEAN_AND_MEAN
838 #define WIN32_LEAN_AND_MEAN
841 #ifdef HAVE_WINSOCK2_H
842 #include <winsock2.h>
844 #ifdef HAVE_WINSOCK_H
848 #define RECVCALLCONV PASCAL
850 #ifdef HAVE_SYS_TYPES_H
851 #include <sys/types.h>
853 #ifdef HAVE_SYS_SOCKET_H
854 #include <sys/socket.h>
858 extern $recv_retv RECVCALLCONV
859 recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
865 $recv_retv res = recv(s, buf, len, flags);
868 curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
877 if test "$curl_cv_func_recv_args" = "unknown"; then
878 AC_MSG_ERROR([Cannot find proper types to use for recv args])
880 recv_prev_IFS=$IFS; IFS=','
881 set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
885 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
886 [Define to the type of arg 1 for recv.])
887 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
888 [Define to the type of arg 2 for recv.])
889 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
890 [Define to the type of arg 3 for recv.])
891 AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
892 [Define to the type of arg 4 for recv.])
893 AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
894 [Define to the function return type for recv.])
896 AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
897 [Define to 1 if you have the recv function.])
898 ac_cv_func_recv="yes"
901 AC_MSG_ERROR([Unable to link function recv])
906 dnl CURL_CHECK_FUNC_SEND
907 dnl -------------------------------------------------
908 dnl Test if the socket send() function is available,
909 dnl and check its return type and the types of its
910 dnl arguments. If the function succeeds HAVE_SEND
911 dnl will be defined, defining the types of the arguments
912 dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
913 dnl and SEND_TYPE_ARG4, defining the type of the function
914 dnl return value in SEND_TYPE_RETV, and also defining the
915 dnl type qualifier of second argument in SEND_QUAL_ARG2.
917 AC_DEFUN([CURL_CHECK_FUNC_SEND], [
918 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
919 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
920 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
922 AC_MSG_CHECKING([for send])
926 #ifdef HAVE_WINDOWS_H
927 #ifndef WIN32_LEAN_AND_MEAN
928 #define WIN32_LEAN_AND_MEAN
931 #ifdef HAVE_WINSOCK2_H
932 #include <winsock2.h>
934 #ifdef HAVE_WINSOCK_H
939 #ifdef HAVE_SYS_TYPES_H
940 #include <sys/types.h>
942 #ifdef HAVE_SYS_SOCKET_H
943 #include <sys/socket.h>
957 if test "$curl_cv_send" = "yes"; then
958 AC_CACHE_CHECK([types of args and return type for send],
959 [curl_cv_func_send_args], [
960 curl_cv_func_send_args="unknown"
961 for send_retv in 'int' 'ssize_t'; do
962 for send_arg1 in 'int' 'ssize_t' 'SOCKET'; do
963 for send_arg2 in 'char *' 'void *' 'const char *' 'const void *'; do
964 for send_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
965 for send_arg4 in 'int' 'unsigned int'; do
966 if test "$curl_cv_func_send_args" = "unknown"; then
970 #ifdef HAVE_WINDOWS_H
971 #ifndef WIN32_LEAN_AND_MEAN
972 #define WIN32_LEAN_AND_MEAN
975 #ifdef HAVE_WINSOCK2_H
976 #include <winsock2.h>
978 #ifdef HAVE_WINSOCK_H
982 #define SENDCALLCONV PASCAL
984 #ifdef HAVE_SYS_TYPES_H
985 #include <sys/types.h>
987 #ifdef HAVE_SYS_SOCKET_H
988 #include <sys/socket.h>
992 extern $send_retv SENDCALLCONV
993 send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
998 $send_retv res = send(s, 0, len, flags);
1001 curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
1010 if test "$curl_cv_func_send_args" = "unknown"; then
1011 AC_MSG_ERROR([Cannot find proper types to use for send args])
1013 send_prev_IFS=$IFS; IFS=','
1014 set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
1018 send_qual_type_arg2=$[2]
1020 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
1021 [Define to the type of arg 1 for send.])
1022 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
1023 [Define to the type of arg 3 for send.])
1024 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
1025 [Define to the type of arg 4 for send.])
1026 AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
1027 [Define to the function return type for send.])
1031 case $prev_sh_opts in
1039 case "$send_qual_type_arg2" in
1041 send_qual_arg2=const
1042 send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
1046 send_type_arg2=$send_qual_type_arg2
1050 AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
1051 [Define to the type qualifier of arg 2 for send.])
1052 AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
1053 [Define to the type of arg 2 for send.])
1055 case $prev_sh_opts in
1063 AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
1064 [Define to 1 if you have the send function.])
1065 ac_cv_func_send="yes"
1068 AC_MSG_ERROR([Unable to link function send])
1073 dnl CURL_CHECK_FUNC_RECVFROM
1074 dnl -------------------------------------------------
1075 dnl Test if the socket recvfrom() function is available,
1076 dnl and check its return type and the types of its
1077 dnl arguments. If the function succeeds HAVE_RECVFROM
1078 dnl will be defined, defining the types of the arguments
1079 dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
1080 dnl to RECVFROM_TYPE_ARG6, defining also the type of the
1081 dnl function return value in RECVFROM_TYPE_RETV.
1082 dnl Notice that the types returned for pointer arguments
1083 dnl will actually be the type pointed by the pointer.
1085 AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
1086 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1087 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1088 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1090 AC_MSG_CHECKING([for recvfrom])
1094 #ifdef HAVE_WINDOWS_H
1095 #ifndef WIN32_LEAN_AND_MEAN
1096 #define WIN32_LEAN_AND_MEAN
1098 #include <windows.h>
1099 #ifdef HAVE_WINSOCK2_H
1100 #include <winsock2.h>
1102 #ifdef HAVE_WINSOCK_H
1103 #include <winsock.h>
1107 #ifdef HAVE_SYS_TYPES_H
1108 #include <sys/types.h>
1110 #ifdef HAVE_SYS_SOCKET_H
1111 #include <sys/socket.h>
1115 recvfrom(0, 0, 0, 0, 0, 0);
1118 AC_MSG_RESULT([yes])
1119 curl_cv_recvfrom="yes"
1122 curl_cv_recvfrom="no"
1125 if test "$curl_cv_recvfrom" = "yes"; then
1126 AC_CACHE_CHECK([types of args and return type for recvfrom],
1127 [curl_cv_func_recvfrom_args], [
1128 curl_cv_func_recvfrom_args="unknown"
1129 for recvfrom_retv in 'int' 'ssize_t'; do
1130 for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
1131 for recvfrom_arg2 in 'char *' 'void *'; do
1132 for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
1133 for recvfrom_arg4 in 'int' 'unsigned int'; do
1134 for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
1135 for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *' 'void *'; do
1136 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1140 #ifdef HAVE_WINDOWS_H
1141 #ifndef WIN32_LEAN_AND_MEAN
1142 #define WIN32_LEAN_AND_MEAN
1144 #include <windows.h>
1145 #ifdef HAVE_WINSOCK2_H
1146 #include <winsock2.h>
1148 #ifdef HAVE_WINSOCK_H
1149 #include <winsock.h>
1152 #define RECVFROMCALLCONV PASCAL
1154 #ifdef HAVE_SYS_TYPES_H
1155 #include <sys/types.h>
1157 #ifdef HAVE_SYS_SOCKET_H
1158 #include <sys/socket.h>
1160 #define RECVFROMCALLCONV
1162 extern $recvfrom_retv RECVFROMCALLCONV
1163 recvfrom($recvfrom_arg1, $recvfrom_arg2,
1164 $recvfrom_arg3, $recvfrom_arg4,
1165 $recvfrom_arg5, $recvfrom_arg6);
1168 $recvfrom_arg2 buf=0;
1169 $recvfrom_arg3 len=0;
1170 $recvfrom_arg4 flags=0;
1171 $recvfrom_arg5 addr=0;
1172 $recvfrom_arg6 addrlen=0;
1173 $recvfrom_retv res=0;
1174 res = recvfrom(s, buf, len, flags, addr, addrlen);
1177 curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
1188 # Nearly last minute change for this release starts here
1189 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1190 [Define to 1 if you have the recvfrom function.])
1191 ac_cv_func_recvfrom="yes"
1192 # Nearly last minute change for this release ends here
1193 if test "$curl_cv_func_recvfrom_args" = "unknown"; then
1194 AC_MSG_WARN([Cannot find proper types to use for recvfrom args])
1196 recvfrom_prev_IFS=$IFS; IFS=','
1197 set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
1198 IFS=$recvfrom_prev_IFS
1201 recvfrom_ptrt_arg2=$[2]
1202 recvfrom_ptrt_arg5=$[5]
1203 recvfrom_ptrt_arg6=$[6]
1205 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
1206 [Define to the type of arg 1 for recvfrom.])
1207 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
1208 [Define to the type of arg 3 for recvfrom.])
1209 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
1210 [Define to the type of arg 4 for recvfrom.])
1211 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
1212 [Define to the function return type for recvfrom.])
1216 case $prev_sh_opts in
1224 recvfrom_type_arg2=`echo $recvfrom_ptrt_arg2 | sed 's/ \*//'`
1225 recvfrom_type_arg5=`echo $recvfrom_ptrt_arg5 | sed 's/ \*//'`
1226 recvfrom_type_arg6=`echo $recvfrom_ptrt_arg6 | sed 's/ \*//'`
1228 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $recvfrom_type_arg2,
1229 [Define to the type pointed by arg 2 for recvfrom.])
1230 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $recvfrom_type_arg5,
1231 [Define to the type pointed by arg 5 for recvfrom.])
1232 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $recvfrom_type_arg6,
1233 [Define to the type pointed by arg 6 for recvfrom.])
1235 if test "$recvfrom_type_arg2" = "void"; then
1236 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2_IS_VOID, 1,
1237 [Define to 1 if the type pointed by arg 2 for recvfrom is void.])
1239 if test "$recvfrom_type_arg5" = "void"; then
1240 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5_IS_VOID, 1,
1241 [Define to 1 if the type pointed by arg 5 for recvfrom is void.])
1243 if test "$recvfrom_type_arg6" = "void"; then
1244 AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6_IS_VOID, 1,
1245 [Define to 1 if the type pointed by arg 6 for recvfrom is void.])
1248 case $prev_sh_opts in
1256 AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
1257 [Define to 1 if you have the recvfrom function.])
1258 ac_cv_func_recvfrom="yes"
1261 AC_MSG_WARN([Unable to link function recvfrom])
1262 AC_MSG_WARN([Your system will be vulnerable to some forms of DNS cache poisoning])
1267 dnl CURL_CHECK_MSG_NOSIGNAL
1268 dnl -------------------------------------------------
1269 dnl Check for MSG_NOSIGNAL
1271 AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
1272 AC_CHECK_HEADERS(sys/types.h sys/socket.h)
1273 AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [
1277 #ifdef HAVE_WINDOWS_H
1278 #ifndef WIN32_LEAN_AND_MEAN
1279 #define WIN32_LEAN_AND_MEAN
1281 #include <windows.h>
1282 #ifdef HAVE_WINSOCK2_H
1283 #include <winsock2.h>
1285 #ifdef HAVE_WINSOCK_H
1286 #include <winsock.h>
1290 #ifdef HAVE_SYS_TYPES_H
1291 #include <sys/types.h>
1293 #ifdef HAVE_SYS_SOCKET_H
1294 #include <sys/socket.h>
1298 int flag=MSG_NOSIGNAL;
1301 ac_cv_msg_nosignal="yes"
1303 ac_cv_msg_nosignal="no"
1306 case "$ac_cv_msg_nosignal" in
1308 AC_DEFINE_UNQUOTED(HAVE_MSG_NOSIGNAL, 1,
1309 [Define to 1 if you have the MSG_NOSIGNAL flag.])
1315 dnl CURL_CHECK_STRUCT_TIMEVAL
1316 dnl -------------------------------------------------
1317 dnl Check for timeval struct
1319 AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
1320 AC_REQUIRE([AC_HEADER_TIME])dnl
1321 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
1322 AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
1323 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h sys/socket.h)
1324 AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
1328 #ifdef HAVE_WINDOWS_H
1329 #ifndef WIN32_LEAN_AND_MEAN
1330 #define WIN32_LEAN_AND_MEAN
1332 #include <windows.h>
1333 #ifdef HAVE_WINSOCK2_H
1334 #include <winsock2.h>
1336 #ifdef HAVE_WINSOCK_H
1337 #include <winsock.h>
1341 #ifdef HAVE_SYS_TYPES_H
1342 #include <sys/types.h>
1344 #ifdef HAVE_SYS_TIME_H
1345 #include <sys/time.h>
1346 #ifdef TIME_WITH_SYS_TIME
1354 #ifdef HAVE_SYS_SOCKET_H
1355 #include <sys/socket.h>
1363 ac_cv_struct_timeval="yes"
1365 ac_cv_struct_timeval="no"
1368 case "$ac_cv_struct_timeval" in
1370 AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
1371 [Define to 1 if you have the timeval struct.])
1377 dnl TYPE_SIG_ATOMIC_T
1378 dnl -------------------------------------------------
1379 dnl Check if the sig_atomic_t type is available, and
1380 dnl verify if it is already defined as volatile.
1382 AC_DEFUN([TYPE_SIG_ATOMIC_T], [
1383 AC_CHECK_HEADERS(signal.h)
1384 AC_CHECK_TYPE([sig_atomic_t],[
1385 AC_DEFINE(HAVE_SIG_ATOMIC_T, 1,
1386 [Define to 1 if sig_atomic_t is an available typedef.])
1388 #ifdef HAVE_SIGNAL_H
1392 case "$ac_cv_type_sig_atomic_t" in
1395 AC_MSG_CHECKING([if sig_atomic_t is already defined as volatile])
1398 #ifdef HAVE_SIGNAL_H
1402 static volatile sig_atomic_t dummy = 0;
1406 ac_cv_sig_atomic_t_volatile="no"
1408 AC_MSG_RESULT([yes])
1409 ac_cv_sig_atomic_t_volatile="yes"
1412 if test "$ac_cv_sig_atomic_t_volatile" = "yes"; then
1413 AC_DEFINE(HAVE_SIG_ATOMIC_T_VOLATILE, 1,
1414 [Define to 1 if sig_atomic_t is already defined as volatile.])
1422 dnl -------------------------------------------------
1423 dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
1424 dnl and a few other things.
1426 AC_DEFUN([TYPE_IN_ADDR_T], [
1427 AC_CHECK_TYPE([in_addr_t], ,[
1428 dnl in_addr_t not available
1429 AC_CACHE_CHECK([for in_addr_t equivalent],
1430 [curl_cv_in_addr_t_equiv], [
1431 curl_cv_in_addr_t_equiv="unknown"
1432 for t in "unsigned long" int size_t unsigned long; do
1433 if test "$curl_cv_in_addr_t_equiv" = "unknown"; then
1437 #ifdef HAVE_WINDOWS_H
1438 #ifndef WIN32_LEAN_AND_MEAN
1439 #define WIN32_LEAN_AND_MEAN
1441 #include <windows.h>
1442 #ifdef HAVE_WINSOCK2_H
1443 #include <winsock2.h>
1445 #ifdef HAVE_WINSOCK_H
1446 #include <winsock.h>
1450 #ifdef HAVE_SYS_TYPES_H
1451 #include <sys/types.h>
1453 #ifdef HAVE_SYS_SOCKET_H
1454 #include <sys/socket.h>
1456 #ifdef HAVE_NETINET_IN_H
1457 #include <netinet/in.h>
1459 #ifdef HAVE_ARPA_INET_H
1460 #include <arpa/inet.h>
1464 $t data = inet_addr ("1.2.3.4");
1467 curl_cv_in_addr_t_equiv="$t"
1472 case "$curl_cv_in_addr_t_equiv" in
1474 AC_MSG_ERROR([Cannot find a type to use in place of in_addr_t])
1477 AC_DEFINE_UNQUOTED(in_addr_t, $curl_cv_in_addr_t_equiv,
1478 [Type to use in place of in_addr_t when system does not provide it.])
1483 #ifdef HAVE_WINDOWS_H
1484 #ifndef WIN32_LEAN_AND_MEAN
1485 #define WIN32_LEAN_AND_MEAN
1487 #include <windows.h>
1488 #ifdef HAVE_WINSOCK2_H
1489 #include <winsock2.h>
1491 #ifdef HAVE_WINSOCK_H
1492 #include <winsock.h>
1496 #ifdef HAVE_SYS_TYPES_H
1497 #include <sys/types.h>
1499 #ifdef HAVE_SYS_SOCKET_H
1500 #include <sys/socket.h>
1502 #ifdef HAVE_NETINET_IN_H
1503 #include <netinet/in.h>
1505 #ifdef HAVE_ARPA_INET_H
1506 #include <arpa/inet.h>
1513 dnl CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC
1514 dnl -------------------------------------------------
1515 dnl Check if monotonic clock_gettime is available.
1517 AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
1518 AC_REQUIRE([AC_HEADER_TIME])dnl
1519 AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
1520 AC_MSG_CHECKING([for monotonic clock_gettime])
1523 #ifdef HAVE_SYS_TYPES_H
1524 #include <sys/types.h>
1526 #ifdef HAVE_SYS_TIME_H
1527 #include <sys/time.h>
1528 #ifdef TIME_WITH_SYS_TIME
1538 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1541 AC_MSG_RESULT([yes])
1542 ac_cv_func_clock_gettime="yes"
1545 ac_cv_func_clock_gettime="no"
1547 dnl Definition of HAVE_CLOCK_GETTIME_MONOTONIC is intentionally postponed
1548 dnl until library linking and run-time checks for clock_gettime succeed.
1552 dnl CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC
1553 dnl -------------------------------------------------
1554 dnl If monotonic clock_gettime is available then,
1555 dnl check and prepended to LIBS any needed libraries.
1557 AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
1558 AC_REQUIRE([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC])dnl
1560 if test "$ac_cv_func_clock_gettime" = "yes"; then
1562 AC_MSG_CHECKING([for clock_gettime in libraries])
1564 curl_cv_save_LIBS="$LIBS"
1565 curl_cv_gclk_LIBS="unknown"
1567 for x_xlibs in '' '-lrt' '-lposix4' ; do
1568 if test "$curl_cv_gclk_LIBS" = "unknown"; then
1569 if test -z "$x_xlibs"; then
1570 LIBS="$curl_cv_save_LIBS"
1572 LIBS="$x_xlibs $curl_cv_save_LIBS"
1576 #ifdef HAVE_SYS_TYPES_H
1577 #include <sys/types.h>
1579 #ifdef HAVE_SYS_TIME_H
1580 #include <sys/time.h>
1581 #ifdef TIME_WITH_SYS_TIME
1591 (void)clock_gettime(CLOCK_MONOTONIC, &ts);
1594 curl_cv_gclk_LIBS="$x_xlibs"
1599 LIBS="$curl_cv_save_LIBS"
1601 case X-"$curl_cv_gclk_LIBS" in
1603 AC_MSG_RESULT([cannot find clock_gettime])
1604 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1605 ac_cv_func_clock_gettime="no"
1608 AC_MSG_RESULT([no additional lib required])
1609 ac_cv_func_clock_gettime="yes"
1612 if test -z "$curl_cv_save_LIBS"; then
1613 LIBS="$curl_cv_gclk_LIBS"
1615 LIBS="$curl_cv_gclk_LIBS $curl_cv_save_LIBS"
1617 AC_MSG_RESULT([$curl_cv_gclk_LIBS])
1618 ac_cv_func_clock_gettime="yes"
1622 dnl only do runtime verification when not cross-compiling
1623 if test "x$cross_compiling" != "xyes" &&
1624 test "$ac_cv_func_clock_gettime" = "yes"; then
1625 AC_MSG_CHECKING([if monotonic clock_gettime works])
1628 #ifdef HAVE_STDLIB_H
1631 #ifdef HAVE_SYS_TYPES_H
1632 #include <sys/types.h>
1634 #ifdef HAVE_SYS_TIME_H
1635 #include <sys/time.h>
1636 #ifdef TIME_WITH_SYS_TIME
1646 if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
1652 AC_MSG_RESULT([yes])
1655 AC_MSG_WARN([HAVE_CLOCK_GETTIME_MONOTONIC will not be defined])
1656 ac_cv_func_clock_gettime="no"
1657 LIBS="$curl_cv_save_LIBS"
1661 case "$ac_cv_func_clock_gettime" in
1663 AC_DEFINE_UNQUOTED(HAVE_CLOCK_GETTIME_MONOTONIC, 1,
1664 [Define to 1 if you have the clock_gettime function and monotonic timer.])
1673 dnl CARES_DEFINE_UNQUOTED (VARIABLE, [VALUE])
1674 dnl -------------------------------------------------
1675 dnl Like AC_DEFINE_UNQUOTED this macro will define a C preprocessor
1676 dnl symbol that can be further used in custom template configuration
1677 dnl files. This macro, unlike AC_DEFINE_UNQUOTED, does not use a third
1678 dnl argument for the description. Symbol definitions done with this
1679 dnl macro are intended to be exclusively used in handcrafted *.h.in
1680 dnl template files. Contrary to what AC_DEFINE_UNQUOTED does, this one
1681 dnl prevents autoheader generation and insertion of symbol template
1682 dnl stub and definition into the first configuration header file. Do
1683 dnl not use this macro as a replacement for AC_DEFINE_UNQUOTED, each
1684 dnl one serves different functional needs.
1686 AC_DEFUN([CARES_DEFINE_UNQUOTED], [
1687 cat >>confdefs.h <<_EOF
1688 [@%:@define] $1 ifelse($#, 2, [$2], 1)
1693 dnl CARES_CONFIGURE_LONG
1694 dnl -------------------------------------------------
1695 dnl Find out the size of long as reported by sizeof() and define
1696 dnl CARES_SIZEOF_LONG as appropriate to be used in template file
1697 dnl ares_build.h.in to properly configure the library.
1698 dnl The size of long is a build time characteristic and as such
1699 dnl must be recorded in ares_build.h
1701 AC_DEFUN([CARES_CONFIGURE_LONG], [
1702 if test -z "$ac_cv_sizeof_long" ||
1703 test "$ac_cv_sizeof_long" -eq "0"; then
1704 AC_MSG_ERROR([cannot find out size of long.])
1706 CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
1710 dnl CARES_CONFIGURE_ARES_SOCKLEN_T
1711 dnl -------------------------------------------------
1712 dnl Find out suitable ares_socklen_t data type definition and size, making
1713 dnl appropriate definitions for template file ares_build.h.in
1714 dnl to properly configure and use the library.
1716 dnl The need for the ares_socklen_t definition arises mainly to properly
1717 dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
1718 dnl data type which is 32 or 64-Bit wide depending on the data model being
1719 dnl used, and that on the other hand is only actually used when interfacing
1720 dnl the X/Open sockets provided in the xnet library.
1722 AC_DEFUN([CARES_CONFIGURE_ARES_SOCKLEN_T], [
1723 AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
1724 AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
1725 AC_REQUIRE([CARES_PREPROCESS_CALLCONV])dnl
1727 AC_MSG_CHECKING([for ares_socklen_t data type])
1728 cares_typeof_ares_socklen_t="unknown"
1729 for arg1 in int SOCKET; do
1730 for arg2 in 'struct sockaddr' void; do
1731 for t in socklen_t int size_t 'unsigned int' long 'unsigned long' void; do
1732 if test "$cares_typeof_ares_socklen_t" = "unknown"; then
1735 $cares_includes_ws2tcpip
1736 $cares_includes_sys_socket
1737 $cares_preprocess_callconv
1738 extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
1741 if(0 != getpeername(0, 0, lenptr))
1745 cares_typeof_ares_socklen_t="$t"
1751 for t in socklen_t int; do
1752 if test "$cares_typeof_ares_socklen_t" = "void"; then
1755 $cares_includes_sys_socket
1756 typedef $t ares_socklen_t;
1758 ares_socklen_t dummy;
1761 cares_typeof_ares_socklen_t="$t"
1765 AC_MSG_RESULT([$cares_typeof_ares_socklen_t])
1766 if test "$cares_typeof_ares_socklen_t" = "void" ||
1767 test "$cares_typeof_ares_socklen_t" = "unknown"; then
1768 AC_MSG_ERROR([cannot find data type for ares_socklen_t.])
1771 AC_MSG_CHECKING([size of ares_socklen_t])
1772 cares_sizeof_ares_socklen_t="unknown"
1773 cares_pull_headers_socklen_t="unknown"
1774 if test "$ac_cv_header_ws2tcpip_h" = "yes"; then
1775 tst_pull_header_checks='none ws2tcpip'
1778 tst_pull_header_checks='none systypes syssocket'
1779 tst_size_checks='4 8 2'
1781 for tst_size in $tst_size_checks; do
1782 for tst_pull_headers in $tst_pull_header_checks; do
1783 if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
1784 case $tst_pull_headers in
1786 tmp_includes="$cares_includes_ws2tcpip"
1789 tmp_includes="$cares_includes_sys_types"
1792 tmp_includes="$cares_includes_sys_socket"
1801 typedef $cares_typeof_ares_socklen_t ares_socklen_t;
1802 typedef char dummy_arr[sizeof(ares_socklen_t) == $tst_size ? 1 : -1];
1804 ares_socklen_t dummy;
1807 cares_sizeof_ares_socklen_t="$tst_size"
1808 cares_pull_headers_socklen_t="$tst_pull_headers"
1813 AC_MSG_RESULT([$cares_sizeof_ares_socklen_t])
1814 if test "$cares_sizeof_ares_socklen_t" = "unknown"; then
1815 AC_MSG_ERROR([cannot find out size of ares_socklen_t.])
1818 case $cares_pull_headers_socklen_t in
1820 CARES_DEFINE_UNQUOTED([CARES_PULL_WS2TCPIP_H])
1823 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
1826 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_TYPES_H])
1827 CARES_DEFINE_UNQUOTED([CARES_PULL_SYS_SOCKET_H])
1830 CARES_DEFINE_UNQUOTED([CARES_TYPEOF_ARES_SOCKLEN_T], [$cares_typeof_ares_socklen_t])
1831 CARES_DEFINE_UNQUOTED([CARES_SIZEOF_ARES_SOCKLEN_T], [$cares_sizeof_ares_socklen_t])
1835 dnl This macro determines if the specified struct exists in the specified file
1837 dnl CARES_CHECK_STRUCT(headers, struct name, if found, [if not found])
1839 AC_DEFUN([CARES_CHECK_STRUCT], [
1840 AC_MSG_CHECKING([for struct $2])
1841 AC_TRY_COMPILE([$1],
1843 struct $2 struct_instance;
1844 ], ac_struct="yes", ac_found="no")
1845 if test "$ac_struct" = "yes" ; then
1854 dnl This macro determines if the specified constant exists in the specified file
1856 dnl CARES_CHECK_CONSTANT(headers, constant name, if found, [if not found])
1858 AC_DEFUN([CARES_CHECK_CONSTANT], [
1859 AC_MSG_CHECKING([for $2])
1860 AC_EGREP_CPP(VARIABLEWASDEFINED,
1869 ], ac_constant="yes", ac_constant="no"
1871 if test "$ac_constant" = "yes" ; then