1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #ifdef TIME_WITH_SYS_TIME
23 /* Time with sys/time test */
25 #include <sys/types.h>
40 #ifdef HAVE_FCNTL_O_NONBLOCK
42 /* headers for FCNTL_O_NONBLOCK test */
43 #include <sys/types.h>
47 #if defined(sun) || defined(__sun__) || \
48 defined(__SUNPRO_C) || defined(__SUNPRO_CC)
49 # if defined(__SVR4) || defined(__srv4__)
50 # define PLATFORM_SOLARIS
52 # define PLATFORM_SUNOS4
55 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
56 # define PLATFORM_AIX_V3
59 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
60 #error "O_NONBLOCK does not work on this platform"
66 /* O_NONBLOCK source test */
68 if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
74 #ifdef HAVE_GETHOSTBYADDR_R_5
75 #include <sys/types.h>
85 struct hostent_data hdata;
87 #ifndef gethostbyaddr_r
88 (void)gethostbyaddr_r;
90 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
95 #ifdef HAVE_GETHOSTBYADDR_R_5_REENTRANT
97 #include <sys/types.h>
107 struct hostent_data hdata;
109 #ifndef gethostbyaddr_r
110 (void)gethostbyaddr_r;
112 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
117 #ifdef HAVE_GETHOSTBYADDR_R_7
118 #include <sys/types.h>
132 #ifndef gethostbyaddr_r
133 (void)gethostbyaddr_r;
135 hp = gethostbyaddr_r(address, length, type, &h,
136 buffer, 8192, &h_errnop);
141 #ifdef HAVE_GETHOSTBYADDR_R_7_REENTRANT
143 #include <sys/types.h>
157 #ifndef gethostbyaddr_r
158 (void)gethostbyaddr_r;
160 hp = gethostbyaddr_r(address, length, type, &h,
161 buffer, 8192, &h_errnop);
166 #ifdef HAVE_GETHOSTBYADDR_R_8
167 #include <sys/types.h>
182 #ifndef gethostbyaddr_r
183 (void)gethostbyaddr_r;
185 rc = gethostbyaddr_r(address, length, type, &h,
186 buffer, 8192, &hp, &h_errnop);
191 #ifdef HAVE_GETHOSTBYADDR_R_8_REENTRANT
193 #include <sys/types.h>
208 #ifndef gethostbyaddr_r
209 (void)gethostbyaddr_r;
211 rc = gethostbyaddr_r(address, length, type, &h,
212 buffer, 8192, &hp, &h_errnop);
217 #ifdef HAVE_GETHOSTBYNAME_R_3
219 #include <sys/types.h>
222 #define NULL (void *)0
228 struct hostent_data data;
229 #ifndef gethostbyname_r
230 (void)gethostbyname_r;
232 gethostbyname_r(NULL, NULL, NULL);
237 #ifdef HAVE_GETHOSTBYNAME_R_3_REENTRANT
240 #include <sys/types.h>
243 #define NULL (void *)0
249 struct hostent_data data;
250 #ifndef gethostbyname_r
251 (void)gethostbyname_r;
253 gethostbyname_r(NULL, NULL, NULL);
258 #ifdef HAVE_GETHOSTBYNAME_R_5
259 #include <sys/types.h>
260 #include <netinet/in.h>
263 #define NULL (void *)0
268 #ifndef gethostbyname_r
269 (void)gethostbyname_r;
271 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
276 #ifdef HAVE_GETHOSTBYNAME_R_5_REENTRANT
278 #include <sys/types.h>
281 #define NULL (void *)0
287 #ifndef gethostbyname_r
288 (void)gethostbyname_r;
290 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
295 #ifdef HAVE_GETHOSTBYNAME_R_6
296 #include <sys/types.h>
299 #define NULL (void *)0
305 #ifndef gethostbyname_r
306 (void)gethostbyname_r;
308 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
313 #ifdef HAVE_GETHOSTBYNAME_R_6_REENTRANT
315 #include <sys/types.h>
318 #define NULL (void *)0
324 #ifndef gethostbyname_r
325 (void)gethostbyname_r;
327 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
332 #ifdef HAVE_SOCKLEN_T
334 #include <ws2tcpip.h>
336 #include <sys/types.h>
337 #include <sys/socket.h>
344 if (sizeof (socklen_t))
350 #ifdef HAVE_IN_ADDR_T
351 #include <sys/types.h>
352 #include <sys/socket.h>
353 #include <arpa/inet.h>
360 if (sizeof (in_addr_t))
368 #ifdef HAVE_SYS_TYPES_H
369 #include <sys/types.h>
371 #ifdef HAVE_STDBOOL_H
377 if (sizeof (bool *) )
389 int main() { return 0; }
391 #ifdef RETSIGTYPE_TEST
392 #include <sys/types.h>
398 extern "C" void (*signal (int, void (*)(int)))(int);
400 void (*signal ()) ();
409 #ifdef HAVE_INET_NTOA_R_DECL
410 #include <arpa/inet.h>
412 typedef void (*func_type)();
418 func = (func_type)inet_ntoa_r;
423 #ifdef HAVE_INET_NTOA_R_DECL_REENTRANT
425 #include <arpa/inet.h>
427 typedef void (*func_type)();
433 func = (func_type)&inet_ntoa_r;
438 #ifdef HAVE_GETADDRINFO
440 #include <sys/types.h>
441 #include <sys/socket.h>
444 struct addrinfo hints, *ai;
447 memset(&hints, 0, sizeof(hints));
448 hints.ai_family = AF_UNSPEC;
449 hints.ai_socktype = SOCK_STREAM;
453 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
460 #ifdef HAVE_FILE_OFFSET_BITS
461 #ifdef _FILE_OFFSET_BITS
462 #undef _FILE_OFFSET_BITS
464 #define _FILE_OFFSET_BITS 64
465 #include <sys/types.h>
466 /* Check that off_t can represent 2**63 - 1 correctly.
467 We can't simply define LARGE_OFF_T to be 9223372036854775807,
468 since some C++ compilers masquerading as C compilers
469 incorrectly reject 9223372036854775807. */
470 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
471 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
472 && LARGE_OFF_T % 2147483647 == 1)
474 int main () { ; return 0; }
476 #ifdef HAVE_IOCTLSOCKET
478 #ifdef HAVE_WINDOWS_H
479 # ifndef WIN32_LEAN_AND_MEAN
480 # define WIN32_LEAN_AND_MEAN
482 # include <windows.h>
483 # ifdef HAVE_WINSOCK2_H
484 # include <winsock2.h>
486 # ifdef HAVE_WINSOCK_H
487 # include <winsock.h>
496 /* ioctlsocket source code */
498 unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
505 #ifdef HAVE_IOCTLSOCKET_CAMEL
507 #ifdef HAVE_WINDOWS_H
508 # ifndef WIN32_LEAN_AND_MEAN
509 # define WIN32_LEAN_AND_MEAN
511 # include <windows.h>
512 # ifdef HAVE_WINSOCK2_H
513 # include <winsock2.h>
515 # ifdef HAVE_WINSOCK_H
516 # include <winsock.h>
525 /* IoctlSocket source code */
526 if(0 != IoctlSocket(0, 0, 0))
532 #ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO
534 #ifdef HAVE_WINDOWS_H
535 # ifndef WIN32_LEAN_AND_MEAN
536 # define WIN32_LEAN_AND_MEAN
538 # include <windows.h>
539 # ifdef HAVE_WINSOCK2_H
540 # include <winsock2.h>
542 # ifdef HAVE_WINSOCK_H
543 # include <winsock.h>
552 /* IoctlSocket source code */
554 if(0 != ioctlsocket(0, FIONBIO, &flags))
560 #ifdef HAVE_IOCTLSOCKET_FIONBIO
562 #ifdef HAVE_WINDOWS_H
563 # ifndef WIN32_LEAN_AND_MEAN
564 # define WIN32_LEAN_AND_MEAN
566 # include <windows.h>
567 # ifdef HAVE_WINSOCK2_H
568 # include <winsock2.h>
570 # ifdef HAVE_WINSOCK_H
571 # include <winsock.h>
581 if(0 != ioctlsocket(0, FIONBIO, &flags))
588 #ifdef HAVE_IOCTL_FIONBIO
589 /* headers for FIONBIO test */
591 #ifdef HAVE_SYS_TYPES_H
592 # include <sys/types.h>
597 #ifdef HAVE_SYS_SOCKET_H
598 # include <sys/socket.h>
600 #ifdef HAVE_SYS_IOCTL_H
601 # include <sys/ioctl.h>
603 #ifdef HAVE_STROPTS_H
604 # include <stropts.h>
612 if(0 != ioctl(0, FIONBIO, &flags))
619 #ifdef HAVE_IOCTL_SIOCGIFADDR
620 /* headers for FIONBIO test */
622 #ifdef HAVE_SYS_TYPES_H
623 # include <sys/types.h>
628 #ifdef HAVE_SYS_SOCKET_H
629 # include <sys/socket.h>
631 #ifdef HAVE_SYS_IOCTL_H
632 # include <sys/ioctl.h>
634 #ifdef HAVE_STROPTS_H
635 # include <stropts.h>
643 if(0 != ioctl(0, SIOCGIFADDR, &ifr))
650 #ifdef HAVE_SETSOCKOPT_SO_NONBLOCK
652 #ifdef HAVE_WINDOWS_H
653 # ifndef WIN32_LEAN_AND_MEAN
654 # define WIN32_LEAN_AND_MEAN
656 # include <windows.h>
657 # ifdef HAVE_WINSOCK2_H
658 # include <winsock2.h>
660 # ifdef HAVE_WINSOCK_H
661 # include <winsock.h>
666 #ifdef HAVE_SYS_TYPES_H
667 # include <sys/types.h>
669 #ifdef HAVE_SYS_SOCKET_H
670 # include <sys/socket.h>
677 if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
683 #ifdef HAVE_GLIBC_STRERROR_R
688 char buffer[1024]; /* big enough to play with */
690 strerror_r(EACCES, buffer, sizeof(buffer));
691 /* this should've returned a string */
692 if(!string || !string[0])
697 #ifdef HAVE_POSIX_STRERROR_R
702 char buffer[1024]; /* big enough to play with */
704 strerror_r(EACCES, buffer, sizeof(buffer));
705 /* This should've returned zero, and written an error string in the
707 if(!buffer[0] || error)