Git init
[external/curl.git] / CMake / CurlTests.c
1 #ifdef TIME_WITH_SYS_TIME
2 /* Time with sys/time test */
3
4 #include <sys/types.h>
5 #include <sys/time.h>
6 #include <time.h>
7
8 int
9 main ()
10 {
11 if ((struct tm *) 0)
12 return 0;
13   ;
14   return 0;
15 }
16
17 #endif
18
19 #ifdef HAVE_FCNTL_O_NONBLOCK
20
21 /* headers for FCNTL_O_NONBLOCK test */
22 #include <sys/types.h>
23 #include <unistd.h>
24 #include <fcntl.h>
25 /* */
26 #if defined(sun) || defined(__sun__) || \
27     defined(__SUNPRO_C) || defined(__SUNPRO_CC)
28 # if defined(__SVR4) || defined(__srv4__)
29 #  define PLATFORM_SOLARIS
30 # else
31 #  define PLATFORM_SUNOS4
32 # endif
33 #endif
34 #if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
35 # define PLATFORM_AIX_V3
36 #endif
37 /* */
38 #if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
39 #error "O_NONBLOCK does not work on this platform"
40 #endif
41
42 int
43 main ()
44 {
45       /* O_NONBLOCK source test */
46       int flags = 0;
47       if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK))
48           return 1;
49       return 0;
50 }
51 #endif
52
53 #ifdef HAVE_GETHOSTBYADDR_R_5
54 #include <sys/types.h>
55 #include <netdb.h>
56 int
57 main ()
58 {
59
60 char * address;
61 int length;
62 int type;
63 struct hostent h;
64 struct hostent_data hdata;
65 int rc;
66 #ifndef gethostbyaddr_r
67   (void)gethostbyaddr_r;
68 #endif
69 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
70   ;
71   return 0;
72 }
73 #endif
74 #ifdef HAVE_GETHOSTBYADDR_R_5_REENTRANT
75 #define _REENTRANT
76 #include <sys/types.h>
77 #include <netdb.h>
78 int
79 main ()
80 {
81
82 char * address;
83 int length;q
84 int type;
85 struct hostent h;
86 struct hostent_data hdata;
87 int rc;
88 #ifndef gethostbyaddr_r
89   (void)gethostbyaddr_r;
90 #endif
91 rc = gethostbyaddr_r(address, length, type, &h, &hdata);
92   ;
93   return 0;
94 }
95 #endif
96 #ifdef HAVE_GETHOSTBYADDR_R_7
97 #include <sys/types.h>
98 #include <netdb.h>
99 int
100 main ()
101 {
102
103 char * address;
104 int length;
105 int type;
106 struct hostent h;
107 char buffer[8192];
108 int h_errnop;
109 struct hostent * hp;
110
111 #ifndef gethostbyaddr_r
112   (void)gethostbyaddr_r;
113 #endif
114 hp = gethostbyaddr_r(address, length, type, &h,
115                      buffer, 8192, &h_errnop);
116   ;
117   return 0;
118 }
119 #endif
120 #ifdef HAVE_GETHOSTBYADDR_R_7_REENTRANT
121 #define _REENTRANT
122 #include <sys/types.h>
123 #include <netdb.h>
124 int
125 main ()
126 {
127
128 char * address;
129 int length;
130 int type;
131 struct hostent h;
132 char buffer[8192];
133 int h_errnop;
134 struct hostent * hp;
135
136 #ifndef gethostbyaddr_r
137   (void)gethostbyaddr_r;
138 #endif
139 hp = gethostbyaddr_r(address, length, type, &h,
140                      buffer, 8192, &h_errnop);
141   ;
142   return 0;
143 }
144 #endif
145 #ifdef HAVE_GETHOSTBYADDR_R_8
146 #include <sys/types.h>
147 #include <netdb.h>
148 int
149 main ()
150 {
151
152 char * address;
153 int length;
154 int type;
155 struct hostent h;
156 char buffer[8192];
157 int h_errnop;
158 struct hostent * hp;
159 int rc;
160
161 #ifndef gethostbyaddr_r
162   (void)gethostbyaddr_r;
163 #endif
164 rc = gethostbyaddr_r(address, length, type, &h,
165                      buffer, 8192, &hp, &h_errnop);
166   ;
167   return 0;
168 }
169 #endif
170 #ifdef HAVE_GETHOSTBYADDR_R_8_REENTRANT
171 #define _REENTRANT
172 #include <sys/types.h>
173 #include <netdb.h>
174 int
175 main ()
176 {
177
178 char * address;
179 int length;
180 int type;
181 struct hostent h;
182 char buffer[8192];
183 int h_errnop;
184 struct hostent * hp;
185 int rc;
186
187 #ifndef gethostbyaddr_r
188   (void)gethostbyaddr_r;
189 #endif
190 rc = gethostbyaddr_r(address, length, type, &h,
191                      buffer, 8192, &hp, &h_errnop);
192   ;
193   return 0;
194 }
195 #endif
196 #ifdef HAVE_GETHOSTBYNAME_R_3
197 #include <string.h>
198 #include <sys/types.h>
199 #include <netdb.h>
200 #undef NULL
201 #define NULL (void *)0
202
203 int
204 main ()
205 {
206
207 struct hostent_data data;
208 #ifndef gethostbyname_r
209   (void)gethostbyname_r;
210 #endif
211 gethostbyname_r(NULL, NULL, NULL);
212   ;
213   return 0;
214 }
215 #endif
216 #ifdef HAVE_GETHOSTBYNAME_R_3_REENTRANT
217 #define _REENTRANT
218 #include <string.h>
219 #include <sys/types.h>
220 #include <netdb.h>
221 #undef NULL
222 #define NULL (void *)0
223
224 int
225 main ()
226 {
227
228 struct hostent_data data;
229 #ifndef gethostbyname_r
230   (void)gethostbyname_r;
231 #endif
232 gethostbyname_r(NULL, NULL, NULL);
233   ;
234   return 0;
235 }
236 #endif
237 #ifdef HAVE_GETHOSTBYNAME_R_5
238 #include <sys/types.h>
239 #include <netinet/in.h>
240 #include <netdb.h>
241 #undef NULL
242 #define NULL (void *)0
243
244 int
245 main ()
246 {
247 #ifndef gethostbyname_r
248   (void)gethostbyname_r;
249 #endif
250 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
251   ;
252   return 0;
253 }
254 #endif
255 #ifdef HAVE_GETHOSTBYNAME_R_5_REENTRANT
256 #define _REENTRANT
257 #include <sys/types.h>
258 #include <netdb.h>
259 #undef NULL
260 #define NULL (void *)0
261
262 int
263 main ()
264 {
265
266 #ifndef gethostbyname_r
267   (void)gethostbyname_r;
268 #endif
269 gethostbyname_r(NULL, NULL, NULL, 0, NULL);
270   ;
271   return 0;
272 }
273 #endif
274 #ifdef HAVE_GETHOSTBYNAME_R_6
275 #include <sys/types.h>
276 #include <netdb.h>
277 #undef NULL
278 #define NULL (void *)0
279
280 int
281 main ()
282 {
283
284 #ifndef gethostbyname_r
285   (void)gethostbyname_r;
286 #endif
287 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
288   ;
289   return 0;
290 }
291 #endif
292 #ifdef HAVE_GETHOSTBYNAME_R_6_REENTRANT
293 #define _REENTRANT
294 #include <sys/types.h>
295 #include <netdb.h>
296 #undef NULL
297 #define NULL (void *)0
298
299 int
300 main ()
301 {
302
303 #ifndef gethostbyname_r
304   (void)gethostbyname_r;
305 #endif
306 gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL);
307   ;
308   return 0;
309 }
310 #endif
311 #ifdef HAVE_SOCKLEN_T
312 #ifdef _WIN32
313 #include <ws2tcpip.h>
314 #else
315 #include <sys/types.h>
316 #include <sys/socket.h>
317 #endif
318 int
319 main ()
320 {
321 if ((socklen_t *) 0)
322   return 0;
323 if (sizeof (socklen_t))
324   return 0;
325   ;
326   return 0;
327 }
328 #endif
329 #ifdef HAVE_IN_ADDR_T
330 #include <sys/types.h>
331 #include <sys/socket.h>
332 #include <arpa/inet.h>
333
334 int
335 main ()
336 {
337 if ((in_addr_t *) 0)
338   return 0;
339 if (sizeof (in_addr_t))
340   return 0;
341   ;
342   return 0;
343 }
344 #endif
345
346 #ifdef HAVE_BOOL_T
347 #ifdef HAVE_SYS_TYPES_H
348 #include <sys/types.h>
349 #endif
350 #ifdef HAVE_STDBOOL_H
351 #include <stdbool.h>
352 #endif
353 int
354 main ()
355 {
356 if (sizeof (bool *) )
357   return 0;
358   ;
359   return 0;
360 }
361 #endif
362
363 #ifdef STDC_HEADERS
364 #include <stdlib.h>
365 #include <stdarg.h>
366 #include <string.h>
367 #include <float.h>
368 int main() { return 0; }
369 #endif
370 #ifdef RETSIGTYPE_TEST
371 #include <sys/types.h>
372 #include <signal.h>
373 #ifdef signal
374 # undef signal
375 #endif
376 #ifdef __cplusplus
377 extern "C" void (*signal (int, void (*)(int)))(int);
378 #else
379 void (*signal ()) ();
380 #endif
381
382 int
383 main ()
384 {
385   return 0;
386 }
387 #endif
388 #ifdef HAVE_INET_NTOA_R_DECL
389 #include <arpa/inet.h>
390
391 typedef void (*func_type)();
392
393 int main()
394 {
395 #ifndef inet_ntoa_r
396   func_type func;
397   func = (func_type)inet_ntoa_r;
398 #endif
399   return 0;
400 }
401 #endif
402 #ifdef HAVE_INET_NTOA_R_DECL_REENTRANT
403 #define _REENTRANT
404 #include <arpa/inet.h>
405
406 typedef void (*func_type)();
407
408 int main()
409 {
410 #ifndef inet_ntoa_r
411   func_type func;
412   func = (func_type)&inet_ntoa_r;
413 #endif
414   return 0;
415 }
416 #endif
417 #ifdef HAVE_GETADDRINFO
418 #include <netdb.h>
419 #include <sys/types.h>
420 #include <sys/socket.h>
421
422 int main(void) {
423     struct addrinfo hints, *ai;
424     int error;
425
426     memset(&hints, 0, sizeof(hints));
427     hints.ai_family = AF_UNSPEC;
428     hints.ai_socktype = SOCK_STREAM;
429 #ifndef getaddrinfo
430     (void)getaddrinfo;
431 #endif
432     error = getaddrinfo("127.0.0.1", "8080", &hints, &ai);
433     if (error) {
434         return 1;
435     }
436     return 0;
437 }
438 #endif
439 #ifdef HAVE_FILE_OFFSET_BITS
440 #ifdef _FILE_OFFSET_BITS
441 #undef _FILE_OFFSET_BITS
442 #endif
443 #define _FILE_OFFSET_BITS 64
444 #include <sys/types.h>
445  /* Check that off_t can represent 2**63 - 1 correctly.
446     We can't simply define LARGE_OFF_T to be 9223372036854775807,
447     since some C++ compilers masquerading as C compilers
448     incorrectly reject 9223372036854775807.  */
449 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
450   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
451                        && LARGE_OFF_T % 2147483647 == 1)
452                       ? 1 : -1];
453 int main () { ; return 0; }
454 #endif
455 #ifdef HAVE_IOCTLSOCKET
456 /* includes start */
457 #ifdef HAVE_WINDOWS_H
458 #  ifndef WIN32_LEAN_AND_MEAN
459 #    define WIN32_LEAN_AND_MEAN
460 #  endif
461 #  include <windows.h>
462 #  ifdef HAVE_WINSOCK2_H
463 #    include <winsock2.h>
464 #  else
465 #    ifdef HAVE_WINSOCK_H
466 #      include <winsock.h>
467 #    endif
468 #  endif
469 #endif
470
471 int
472 main ()
473 {
474
475 /* ioctlsocket source code */
476  int socket;
477  unsigned long flags = ioctlsocket(socket, FIONBIO, &flags);
478
479   ;
480   return 0;
481 }
482
483 #endif
484 #ifdef HAVE_IOCTLSOCKET_CAMEL
485 /* includes start */
486 #ifdef HAVE_WINDOWS_H
487 #  ifndef WIN32_LEAN_AND_MEAN
488 #    define WIN32_LEAN_AND_MEAN
489 #  endif
490 #  include <windows.h>
491 #  ifdef HAVE_WINSOCK2_H
492 #    include <winsock2.h>
493 #  else
494 #    ifdef HAVE_WINSOCK_H
495 #      include <winsock.h>
496 #    endif
497 #  endif
498 #endif
499
500 int
501 main ()
502 {
503
504 /* IoctlSocket source code */
505     if(0 != IoctlSocket(0, 0, 0))
506       return 1;
507   ;
508   return 0;
509 }
510 #endif
511 #ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO
512 /* includes start */
513 #ifdef HAVE_WINDOWS_H
514 #  ifndef WIN32_LEAN_AND_MEAN
515 #    define WIN32_LEAN_AND_MEAN
516 #  endif
517 #  include <windows.h>
518 #  ifdef HAVE_WINSOCK2_H
519 #    include <winsock2.h>
520 #  else
521 #    ifdef HAVE_WINSOCK_H
522 #      include <winsock.h>
523 #    endif
524 #  endif
525 #endif
526
527 int
528 main ()
529 {
530
531 /* IoctlSocket source code */
532         long flags = 0;
533         if(0 != ioctlsocket(0, FIONBIO, &flags))
534           return 1;
535   ;
536   return 0;
537 }
538 #endif
539 #ifdef HAVE_IOCTLSOCKET_FIONBIO
540 /* includes start */
541 #ifdef HAVE_WINDOWS_H
542 #  ifndef WIN32_LEAN_AND_MEAN
543 #    define WIN32_LEAN_AND_MEAN
544 #  endif
545 #  include <windows.h>
546 #  ifdef HAVE_WINSOCK2_H
547 #    include <winsock2.h>
548 #  else
549 #    ifdef HAVE_WINSOCK_H
550 #      include <winsock.h>
551 #    endif
552 #  endif
553 #endif
554
555 int
556 main ()
557 {
558
559         int flags = 0;
560         if(0 != ioctlsocket(0, FIONBIO, &flags))
561           return 1;
562
563   ;
564   return 0;
565 }
566 #endif
567 #ifdef HAVE_IOCTL_FIONBIO
568 /* headers for FIONBIO test */
569 /* includes start */
570 #ifdef HAVE_SYS_TYPES_H
571 #  include <sys/types.h>
572 #endif
573 #ifdef HAVE_UNISTD_H
574 #  include <unistd.h>
575 #endif
576 #ifdef HAVE_SYS_SOCKET_H
577 #  include <sys/socket.h>
578 #endif
579 #ifdef HAVE_SYS_IOCTL_H
580 #  include <sys/ioctl.h>
581 #endif
582 #ifdef HAVE_STROPTS_H
583 #  include <stropts.h>
584 #endif
585
586 int
587 main ()
588 {
589
590         int flags = 0;
591         if(0 != ioctl(0, FIONBIO, &flags))
592           return 1;
593
594   ;
595   return 0;
596 }
597 #endif
598 #ifdef HAVE_IOCTL_SIOCGIFADDR
599 /* headers for FIONBIO test */
600 /* includes start */
601 #ifdef HAVE_SYS_TYPES_H
602 #  include <sys/types.h>
603 #endif
604 #ifdef HAVE_UNISTD_H
605 #  include <unistd.h>
606 #endif
607 #ifdef HAVE_SYS_SOCKET_H
608 #  include <sys/socket.h>
609 #endif
610 #ifdef HAVE_SYS_IOCTL_H
611 #  include <sys/ioctl.h>
612 #endif
613 #ifdef HAVE_STROPTS_H
614 #  include <stropts.h>
615 #endif
616 #include <net/if.h>
617
618 int
619 main ()
620 {
621         struct ifreq ifr;
622         if(0 != ioctl(0, SIOCGIFADDR, &ifr))
623           return 1;
624
625   ;
626   return 0;
627 }
628 #endif
629 #ifdef HAVE_SETSOCKOPT_SO_NONBLOCK
630 /* includes start */
631 #ifdef HAVE_WINDOWS_H
632 #  ifndef WIN32_LEAN_AND_MEAN
633 #    define WIN32_LEAN_AND_MEAN
634 #  endif
635 #  include <windows.h>
636 #  ifdef HAVE_WINSOCK2_H
637 #    include <winsock2.h>
638 #  else
639 #    ifdef HAVE_WINSOCK_H
640 #      include <winsock.h>
641 #    endif
642 #  endif
643 #endif
644 /* includes start */
645 #ifdef HAVE_SYS_TYPES_H
646 #  include <sys/types.h>
647 #endif
648 #ifdef HAVE_SYS_SOCKET_H
649 #  include <sys/socket.h>
650 #endif
651 /* includes end */
652
653 int
654 main ()
655 {
656         if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0))
657           return 1;
658   ;
659   return 0;
660 }
661 #endif
662 #ifdef HAVE_GLIBC_STRERROR_R
663 #include <string.h>
664 #include <errno.h>
665 int
666 main () {
667   char buffer[1024]; /* big enough to play with */
668   char *string =
669     strerror_r(EACCES, buffer, sizeof(buffer));
670     /* this should've returned a string */
671     if(!string || !string[0])
672       return 99;
673     return 0;
674 }
675 #endif
676 #ifdef HAVE_POSIX_STRERROR_R
677 #include <string.h>
678 #include <errno.h>
679 int
680 main () {
681   char buffer[1024]; /* big enough to play with */
682   int error =
683     strerror_r(EACCES, buffer, sizeof(buffer));
684     /* This should've returned zero, and written an error string in the
685        buffer.*/
686     if(!buffer[0] || error)
687       return 99;
688     return 0;
689 }
690 #endif