1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2014, 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 https://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 /* tests for gethostbyaddr_r or gethostbyname_r */
75 #if defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \
76 defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) || \
77 defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) || \
78 defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) || \
79 defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \
80 defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
82 /* no idea whether _REENTRANT is always set, just invent a new flag */
83 # define TEST_GETHOSTBYFOO_REENTRANT
85 #if defined(HAVE_GETHOSTBYADDR_R_5) || \
86 defined(HAVE_GETHOSTBYADDR_R_7) || \
87 defined(HAVE_GETHOSTBYADDR_R_8) || \
88 defined(HAVE_GETHOSTBYNAME_R_3) || \
89 defined(HAVE_GETHOSTBYNAME_R_5) || \
90 defined(HAVE_GETHOSTBYNAME_R_6) || \
91 defined(TEST_GETHOSTBYFOO_REENTRANT)
92 #include <sys/types.h>
96 char *address = "example.com";
101 #if defined(HAVE_GETHOSTBYADDR_R_5) || \
102 defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \
104 defined(HAVE_GETHOSTBYNAME_R_3) || \
105 defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT)
106 struct hostent_data hdata;
107 #elif defined(HAVE_GETHOSTBYADDR_R_7) || \
108 defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) || \
109 defined(HAVE_GETHOSTBYADDR_R_8) || \
110 defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) || \
112 defined(HAVE_GETHOSTBYNAME_R_5) || \
113 defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) || \
114 defined(HAVE_GETHOSTBYNAME_R_6) || \
115 defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
121 #ifndef gethostbyaddr_r
122 (void)gethostbyaddr_r;
125 #if defined(HAVE_GETHOSTBYADDR_R_5) || \
126 defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT)
127 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
128 #elif defined(HAVE_GETHOSTBYADDR_R_7) || \
129 defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT)
130 hp = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &h_errnop);
132 #elif defined(HAVE_GETHOSTBYADDR_R_8) || \
133 defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT)
134 rc = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &hp, &h_errnop);
137 #if defined(HAVE_GETHOSTBYNAME_R_3) || \
138 defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT)
139 rc = gethostbyname_r(address, &h, &hdata);
140 #elif defined(HAVE_GETHOSTBYNAME_R_5) || \
141 defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT)
142 rc = gethostbyname_r(address, &h, buffer, 8192, &h_errnop);
143 (void)hp; /* not used for test */
144 #elif defined(HAVE_GETHOSTBYNAME_R_6) || \
145 defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT)
146 rc = gethostbyname_r(address, &h, buffer, 8192, &hp, &h_errnop);
156 #ifdef HAVE_SOCKLEN_T
158 #include <ws2tcpip.h>
160 #include <sys/types.h>
161 #include <sys/socket.h>
168 if (sizeof (socklen_t))
174 #ifdef HAVE_IN_ADDR_T
175 #include <sys/types.h>
176 #include <sys/socket.h>
177 #include <arpa/inet.h>
184 if (sizeof (in_addr_t))
192 #ifdef HAVE_SYS_TYPES_H
193 #include <sys/types.h>
195 #ifdef HAVE_STDBOOL_H
201 if (sizeof (bool *) )
213 int main() { return 0; }
215 #ifdef RETSIGTYPE_TEST
216 #include <sys/types.h>
222 extern "C" void (*signal (int, void (*)(int)))(int);
224 void (*signal ()) ();
233 #ifdef HAVE_INET_NTOA_R_DECL
234 #include <arpa/inet.h>
236 typedef void (*func_type)();
242 func = (func_type)inet_ntoa_r;
247 #ifdef HAVE_INET_NTOA_R_DECL_REENTRANT
249 #include <arpa/inet.h>
251 typedef void (*func_type)();
257 func = (func_type)&inet_ntoa_r;
262 #ifdef HAVE_GETADDRINFO
264 #include <sys/types.h>
265 #include <sys/socket.h>
268 struct addrinfo hints, *ai;
271 memset(&hints, 0, sizeof(hints));
272 hints.ai_family = AF_UNSPEC;
273 hints.ai_socktype = SOCK_STREAM;
277 error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
284 #ifdef HAVE_FILE_OFFSET_BITS
285 #ifdef _FILE_OFFSET_BITS
286 #undef _FILE_OFFSET_BITS
288 #define _FILE_OFFSET_BITS 64
289 #include <sys/types.h>
290 /* Check that off_t can represent 2**63 - 1 correctly.
291 We can't simply define LARGE_OFF_T to be 9223372036854775807,
292 since some C++ compilers masquerading as C compilers
293 incorrectly reject 9223372036854775807. */
294 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
295 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
296 && LARGE_OFF_T % 2147483647 == 1)
298 int main () { ; return 0; }
300 #ifdef HAVE_IOCTLSOCKET
302 #ifdef HAVE_WINDOWS_H
303 # ifndef WIN32_LEAN_AND_MEAN
304 # define WIN32_LEAN_AND_MEAN
306 # include <windows.h>
307 # ifdef HAVE_WINSOCK2_H
308 # include <winsock2.h>
310 # ifdef HAVE_WINSOCK_H
311 # include <winsock.h>
320 /* ioctlsocket source code */
322 unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
329 #ifdef HAVE_IOCTLSOCKET_CAMEL
331 #ifdef HAVE_WINDOWS_H
332 # ifndef WIN32_LEAN_AND_MEAN
333 # define WIN32_LEAN_AND_MEAN
335 # include <windows.h>
336 # ifdef HAVE_WINSOCK2_H
337 # include <winsock2.h>
339 # ifdef HAVE_WINSOCK_H
340 # include <winsock.h>
349 /* IoctlSocket source code */
350 if(0 != IoctlSocket(0, 0, 0))
356 #ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO
358 #ifdef HAVE_WINDOWS_H
359 # ifndef WIN32_LEAN_AND_MEAN
360 # define WIN32_LEAN_AND_MEAN
362 # include <windows.h>
363 # ifdef HAVE_WINSOCK2_H
364 # include <winsock2.h>
366 # ifdef HAVE_WINSOCK_H
367 # include <winsock.h>
376 /* IoctlSocket source code */
378 if(0 != ioctlsocket(0, FIONBIO, &flags))
384 #ifdef HAVE_IOCTLSOCKET_FIONBIO
386 #ifdef HAVE_WINDOWS_H
387 # ifndef WIN32_LEAN_AND_MEAN
388 # define WIN32_LEAN_AND_MEAN
390 # include <windows.h>
391 # ifdef HAVE_WINSOCK2_H
392 # include <winsock2.h>
394 # ifdef HAVE_WINSOCK_H
395 # include <winsock.h>
405 if(0 != ioctlsocket(0, FIONBIO, &flags))
412 #ifdef HAVE_IOCTL_FIONBIO
413 /* headers for FIONBIO test */
415 #ifdef HAVE_SYS_TYPES_H
416 # include <sys/types.h>
421 #ifdef HAVE_SYS_SOCKET_H
422 # include <sys/socket.h>
424 #ifdef HAVE_SYS_IOCTL_H
425 # include <sys/ioctl.h>
427 #ifdef HAVE_STROPTS_H
428 # include <stropts.h>
436 if(0 != ioctl(0, FIONBIO, &flags))
443 #ifdef HAVE_IOCTL_SIOCGIFADDR
444 /* headers for FIONBIO test */
446 #ifdef HAVE_SYS_TYPES_H
447 # include <sys/types.h>
452 #ifdef HAVE_SYS_SOCKET_H
453 # include <sys/socket.h>
455 #ifdef HAVE_SYS_IOCTL_H
456 # include <sys/ioctl.h>
458 #ifdef HAVE_STROPTS_H
459 # include <stropts.h>
467 if(0 != ioctl(0, SIOCGIFADDR, &ifr))
474 #ifdef HAVE_SETSOCKOPT_SO_NONBLOCK
476 #ifdef HAVE_WINDOWS_H
477 # ifndef WIN32_LEAN_AND_MEAN
478 # define WIN32_LEAN_AND_MEAN
480 # include <windows.h>
481 # ifdef HAVE_WINSOCK2_H
482 # include <winsock2.h>
484 # ifdef HAVE_WINSOCK_H
485 # include <winsock.h>
490 #ifdef HAVE_SYS_TYPES_H
491 # include <sys/types.h>
493 #ifdef HAVE_SYS_SOCKET_H
494 # include <sys/socket.h>
501 if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
507 #ifdef HAVE_GLIBC_STRERROR_R
512 char buffer[1024]; /* big enough to play with */
514 strerror_r(EACCES, buffer, sizeof(buffer));
515 /* this should've returned a string */
516 if(!string || !string[0])
521 #ifdef HAVE_POSIX_STRERROR_R
526 char buffer[1024]; /* big enough to play with */
528 strerror_r(EACCES, buffer, sizeof(buffer));
529 /* This should've returned zero, and written an error string in the
531 if(!buffer[0] || error)