| 1 |
/*************************************************************************** |
| 2 |
* _ _ ____ _ |
| 3 |
* Project ___| | | | _ \| | |
| 4 |
* / __| | | | |_) | | |
| 5 |
* | (__| |_| | _ <| |___ |
| 6 |
* \___|\___/|_| \_\_____| |
| 7 |
* |
| 8 |
* Copyright (C) 1998 - 2019, Daniel Stenberg, <[email protected]>, et al. |
| 9 |
* |
| 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. |
| 13 |
* |
| 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. |
| 17 |
* |
| 18 |
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 |
* KIND, either express or implied. |
| 20 |
* |
| 21 |
***************************************************************************/ |
| 22 |
#ifdef TIME_WITH_SYS_TIME |
| 23 |
/* Time with sys/time test */ |
| 24 |
|
| 25 |
#include <sys/types.h> |
| 26 |
#include <sys/time.h> |
| 27 |
#include <time.h> |
| 28 |
|
| 29 |
int |
| 30 |
main () |
| 31 |
{ |
| 32 |
if ((struct tm *) 0) |
| 33 |
return 0; |
| 34 |
; |
| 35 |
return 0; |
| 36 |
} |
| 37 |
|
| 38 |
#endif |
| 39 |
|
| 40 |
#ifdef HAVE_FCNTL_O_NONBLOCK |
| 41 |
|
| 42 |
/* headers for FCNTL_O_NONBLOCK test */ |
| 43 |
#include <sys/types.h> |
| 44 |
#include <unistd.h> |
| 45 |
#include <fcntl.h> |
| 46 |
/* */ |
| 47 |
#if defined(sun) || defined(__sun__) || \ |
| 48 |
defined(__SUNPRO_C) || defined(__SUNPRO_CC) |
| 49 |
# if defined(__SVR4) || defined(__srv4__) |
| 50 |
# define PLATFORM_SOLARIS |
| 51 |
# else |
| 52 |
# define PLATFORM_SUNOS4 |
| 53 |
# endif |
| 54 |
#endif |
| 55 |
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41) |
| 56 |
# define PLATFORM_AIX_V3 |
| 57 |
#endif |
| 58 |
/* */ |
| 59 |
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__) |
| 60 |
#error "O_NONBLOCK does not work on this platform" |
| 61 |
#endif |
| 62 |
|
| 63 |
int |
| 64 |
main () |
| 65 |
{ |
| 66 |
/* O_NONBLOCK source test */ |
| 67 |
int flags = 0; |
| 68 |
if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK)) |
| 69 |
return 1; |
| 70 |
return 0; |
| 71 |
} |
| 72 |
#endif |
| 73 |
|
| 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) |
| 81 |
# define _REENTRANT |
| 82 |
/* no idea whether _REENTRANT is always set, just invent a new flag */ |
| 83 |
# define TEST_GETHOSTBYFOO_REENTRANT |
| 84 |
#endif |
| 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> |
| 93 |
#include <netdb.h> |
| 94 |
int main(void) |
| 95 |
{ |
| 96 |
char *address = "example.com"; |
| 97 |
int length = 0; |
| 98 |
int type = 0; |
| 99 |
struct hostent h; |
| 100 |
int rc = 0; |
| 101 |
#if defined(HAVE_GETHOSTBYADDR_R_5) || \ |
| 102 |
defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) || \ |
| 103 |
\ |
| 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) || \ |
| 111 |
\ |
| 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) |
| 116 |
char buffer[8192]; |
| 117 |
int h_errnop; |
| 118 |
struct hostent *hp; |
| 119 |
#endif |
| 120 |
|
| 121 |
#ifndef gethostbyaddr_r |
| 122 |
(void)gethostbyaddr_r; |
| 123 |
#endif |
| 124 |
|
| 125 |
#if defined(HAVE_GETHOSTBYADDR_R_5) || \ |
| 126 |
defined(HAVE_GETHOSTBYADDR_R_5_REENTRANT) |
| 127 |
rc = gethostbyaddr_r(address, length, type, &h, &hdata); |
| 128 |
(void)rc; |
| 129 |
#elif defined(HAVE_GETHOSTBYADDR_R_7) || \ |
| 130 |
defined(HAVE_GETHOSTBYADDR_R_7_REENTRANT) |
| 131 |
hp = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &h_errnop); |
| 132 |
(void)hp; |
| 133 |
#elif defined(HAVE_GETHOSTBYADDR_R_8) || \ |
| 134 |
defined(HAVE_GETHOSTBYADDR_R_8_REENTRANT) |
| 135 |
rc = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &hp, &h_errnop); |
| 136 |
(void)rc; |
| 137 |
#endif |
| 138 |
|
| 139 |
#if defined(HAVE_GETHOSTBYNAME_R_3) || \ |
| 140 |
defined(HAVE_GETHOSTBYNAME_R_3_REENTRANT) |
| 141 |
rc = gethostbyname_r(address, &h, &hdata); |
| 142 |
#elif defined(HAVE_GETHOSTBYNAME_R_5) || \ |
| 143 |
defined(HAVE_GETHOSTBYNAME_R_5_REENTRANT) |
| 144 |
rc = gethostbyname_r(address, &h, buffer, 8192, &h_errnop); |
| 145 |
(void)hp; /* not used for test */ |
| 146 |
#elif defined(HAVE_GETHOSTBYNAME_R_6) || \ |
| 147 |
defined(HAVE_GETHOSTBYNAME_R_6_REENTRANT) |
| 148 |
rc = gethostbyname_r(address, &h, buffer, 8192, &hp, &h_errnop); |
| 149 |
#endif |
| 150 |
|
| 151 |
(void)length; |
| 152 |
(void)type; |
| 153 |
(void)rc; |
| 154 |
return 0; |
| 155 |
} |
| 156 |
#endif |
| 157 |
|
| 158 |
#ifdef HAVE_SOCKLEN_T |
| 159 |
#ifdef _WIN32 |
| 160 |
#include <ws2tcpip.h> |
| 161 |
#else |
| 162 |
#include <sys/types.h> |
| 163 |
#include <sys/socket.h> |
| 164 |
#endif |
| 165 |
int |
| 166 |
main () |
| 167 |
{ |
| 168 |
if ((socklen_t *) 0) |
| 169 |
return 0; |
| 170 |
if (sizeof (socklen_t)) |
| 171 |
return 0; |
| 172 |
; |
| 173 |
return 0; |
| 174 |
} |
| 175 |
#endif |
| 176 |
#ifdef HAVE_IN_ADDR_T |
| 177 |
#include <sys/types.h> |
| 178 |
#include <sys/socket.h> |
| 179 |
#include <arpa/inet.h> |
| 180 |
|
| 181 |
int |
| 182 |
main () |
| 183 |
{ |
| 184 |
if ((in_addr_t *) 0) |
| 185 |
return 0; |
| 186 |
if (sizeof (in_addr_t)) |
| 187 |
return 0; |
| 188 |
; |
| 189 |
return 0; |
| 190 |
} |
| 191 |
#endif |
| 192 |
|
| 193 |
#ifdef HAVE_BOOL_T |
| 194 |
#ifdef HAVE_SYS_TYPES_H |
| 195 |
#include <sys/types.h> |
| 196 |
#endif |
| 197 |
#ifdef HAVE_STDBOOL_H |
| 198 |
#include <stdbool.h> |
| 199 |
#endif |
| 200 |
int |
| 201 |
main () |
| 202 |
{ |
| 203 |
if (sizeof (bool *) ) |
| 204 |
return 0; |
| 205 |
; |
| 206 |
return 0; |
| 207 |
} |
| 208 |
#endif |
| 209 |
|
| 210 |
#ifdef STDC_HEADERS |
| 211 |
#include <stdlib.h> |
| 212 |
#include <stdarg.h> |
| 213 |
#include <string.h> |
| 214 |
#include <float.h> |
| 215 |
int main() { return 0; } |
| 216 |
#endif |
| 217 |
#ifdef RETSIGTYPE_TEST |
| 218 |
#include <sys/types.h> |
| 219 |
#include <signal.h> |
| 220 |
#ifdef signal |
| 221 |
# undef signal |
| 222 |
#endif |
| 223 |
#ifdef __cplusplus |
| 224 |
extern "C" void (*signal (int, void (*)(int)))(int); |
| 225 |
#else |
| 226 |
void (*signal ()) (); |
| 227 |
#endif |
| 228 |
|
| 229 |
int |
| 230 |
main () |
| 231 |
{ |
| 232 |
return 0; |
| 233 |
} |
| 234 |
#endif |
| 235 |
#ifdef HAVE_INET_NTOA_R_DECL |
| 236 |
#include <arpa/inet.h> |
| 237 |
|
| 238 |
typedef void (*func_type)(); |
| 239 |
|
| 240 |
int main() |
| 241 |
{ |
| 242 |
#ifndef inet_ntoa_r |
| 243 |
func_type func; |
| 244 |
func = (func_type)inet_ntoa_r; |
| 245 |
(void)func; |
| 246 |
#endif |
| 247 |
return 0; |
| 248 |
} |
| 249 |
#endif |
| 250 |
#ifdef HAVE_INET_NTOA_R_DECL_REENTRANT |
| 251 |
#define _REENTRANT |
| 252 |
#include <arpa/inet.h> |
| 253 |
|
| 254 |
typedef void (*func_type)(); |
| 255 |
|
| 256 |
int main() |
| 257 |
{ |
| 258 |
#ifndef inet_ntoa_r |
| 259 |
func_type func; |
| 260 |
func = (func_type)&inet_ntoa_r; |
| 261 |
(void)func; |
| 262 |
#endif |
| 263 |
return 0; |
| 264 |
} |
| 265 |
#endif |
| 266 |
#ifdef HAVE_GETADDRINFO |
| 267 |
#include <netdb.h> |
| 268 |
#include <sys/types.h> |
| 269 |
#include <sys/socket.h> |
| 270 |
|
| 271 |
int main(void) { |
| 272 |
struct addrinfo hints, *ai; |
| 273 |
int error; |
| 274 |
|
| 275 |
memset(&hints, 0, sizeof(hints)); |
| 276 |
hints.ai_family = AF_UNSPEC; |
| 277 |
hints.ai_socktype = SOCK_STREAM; |
| 278 |
#ifndef getaddrinfo |
| 279 |
(void)getaddrinfo; |
| 280 |
#endif |
| 281 |
error = getaddrinfo("127.0.0.1", "8080", &hints, &ai); |
| 282 |
if (error) { |
| 283 |
return 1; |
| 284 |
} |
| 285 |
return 0; |
| 286 |
} |
| 287 |
#endif |
| 288 |
#ifdef HAVE_FILE_OFFSET_BITS |
| 289 |
#ifdef _FILE_OFFSET_BITS |
| 290 |
#undef _FILE_OFFSET_BITS |
| 291 |
#endif |
| 292 |
#define _FILE_OFFSET_BITS 64 |
| 293 |
#include <sys/types.h> |
| 294 |
/* Check that off_t can represent 2**63 - 1 correctly. |
| 295 |
We can't simply define LARGE_OFF_T to be 9223372036854775807, |
| 296 |
since some C++ compilers masquerading as C compilers |
| 297 |
incorrectly reject 9223372036854775807. */ |
| 298 |
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) |
| 299 |
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 |
| 300 |
&& LARGE_OFF_T % 2147483647 == 1) |
| 301 |
? 1 : -1]; |
| 302 |
int main () { ; return 0; } |
| 303 |
#endif |
| 304 |
#ifdef HAVE_IOCTLSOCKET |
| 305 |
/* includes start */ |
| 306 |
#ifdef HAVE_WINDOWS_H |
| 307 |
# ifndef WIN32_LEAN_AND_MEAN |
| 308 |
# define WIN32_LEAN_AND_MEAN |
| 309 |
# endif |
| 310 |
# include <windows.h> |
| 311 |
# ifdef HAVE_WINSOCK2_H |
| 312 |
# include <winsock2.h> |
| 313 |
# else |
| 314 |
# ifdef HAVE_WINSOCK_H |
| 315 |
# include <winsock.h> |
| 316 |
# endif |
| 317 |
# endif |
| 318 |
#endif |
| 319 |
|
| 320 |
int |
| 321 |
main () |
| 322 |
{ |
| 323 |
|
| 324 |
/* ioctlsocket source code */ |
| 325 |
int socket; |
| 326 |
unsigned long flags = ioctlsocket(socket, FIONBIO, &flags); |
| 327 |
|
| 328 |
; |
| 329 |
return 0; |
| 330 |
} |
| 331 |
|
| 332 |
#endif |
| 333 |
#ifdef HAVE_IOCTLSOCKET_CAMEL |
| 334 |
/* includes start */ |
| 335 |
#ifdef HAVE_WINDOWS_H |
| 336 |
# ifndef WIN32_LEAN_AND_MEAN |
| 337 |
# define WIN32_LEAN_AND_MEAN |
| 338 |
# endif |
| 339 |
# include <windows.h> |
| 340 |
# ifdef HAVE_WINSOCK2_H |
| 341 |
# include <winsock2.h> |
| 342 |
# else |
| 343 |
# ifdef HAVE_WINSOCK_H |
| 344 |
# include <winsock.h> |
| 345 |
# endif |
| 346 |
# endif |
| 347 |
#endif |
| 348 |
|
| 349 |
int |
| 350 |
main () |
| 351 |
{ |
| 352 |
|
| 353 |
/* IoctlSocket source code */ |
| 354 |
if(0 != IoctlSocket(0, 0, 0)) |
| 355 |
return 1; |
| 356 |
; |
| 357 |
return 0; |
| 358 |
} |
| 359 |
#endif |
| 360 |
#ifdef HAVE_IOCTLSOCKET_CAMEL_FIONBIO |
| 361 |
/* includes start */ |
| 362 |
#ifdef HAVE_WINDOWS_H |
| 363 |
# ifndef WIN32_LEAN_AND_MEAN |
| 364 |
# define WIN32_LEAN_AND_MEAN |
| 365 |
# endif |
| 366 |
# include <windows.h> |
| 367 |
# ifdef HAVE_WINSOCK2_H |
| 368 |
# include <winsock2.h> |
| 369 |
# else |
| 370 |
# ifdef HAVE_WINSOCK_H |
| 371 |
# include <winsock.h> |
| 372 |
# endif |
| 373 |
# endif |
| 374 |
#endif |
| 375 |
|
| 376 |
int |
| 377 |
main () |
| 378 |
{ |
| 379 |
|
| 380 |
/* IoctlSocket source code */ |
| 381 |
long flags = 0; |
| 382 |
if(0 != ioctlsocket(0, FIONBIO, &flags)) |
| 383 |
return 1; |
| 384 |
; |
| 385 |
return 0; |
| 386 |
} |
| 387 |
#endif |
| 388 |
#ifdef HAVE_IOCTLSOCKET_FIONBIO |
| 389 |
/* includes start */ |
| 390 |
#ifdef HAVE_WINDOWS_H |
| 391 |
# ifndef WIN32_LEAN_AND_MEAN |
| 392 |
# define WIN32_LEAN_AND_MEAN |
| 393 |
# endif |
| 394 |
# include <windows.h> |
| 395 |
# ifdef HAVE_WINSOCK2_H |
| 396 |
# include <winsock2.h> |
| 397 |
# else |
| 398 |
# ifdef HAVE_WINSOCK_H |
| 399 |
# include <winsock.h> |
| 400 |
# endif |
| 401 |
# endif |
| 402 |
#endif |
| 403 |
|
| 404 |
int |
| 405 |
main () |
| 406 |
{ |
| 407 |
|
| 408 |
int flags = 0; |
| 409 |
if(0 != ioctlsocket(0, FIONBIO, &flags)) |
| 410 |
return 1; |
| 411 |
|
| 412 |
; |
| 413 |
return 0; |
| 414 |
} |
| 415 |
#endif |
| 416 |
#ifdef HAVE_IOCTL_FIONBIO |
| 417 |
/* headers for FIONBIO test */ |
| 418 |
/* includes start */ |
| 419 |
#ifdef HAVE_SYS_TYPES_H |
| 420 |
# include <sys/types.h> |
| 421 |
#endif |
| 422 |
#ifdef HAVE_UNISTD_H |
| 423 |
# include <unistd.h> |
| 424 |
#endif |
| 425 |
#ifdef HAVE_SYS_SOCKET_H |
| 426 |
# include <sys/socket.h> |
| 427 |
#endif |
| 428 |
#ifdef HAVE_SYS_IOCTL_H |
| 429 |
# include <sys/ioctl.h> |
| 430 |
#endif |
| 431 |
#ifdef HAVE_STROPTS_H |
| 432 |
# include <stropts.h> |
| 433 |
#endif |
| 434 |
|
| 435 |
int |
| 436 |
main () |
| 437 |
{ |
| 438 |
|
| 439 |
int flags = 0; |
| 440 |
if(0 != ioctl(0, FIONBIO, &flags)) |
| 441 |
return 1; |
| 442 |
|
| 443 |
; |
| 444 |
return 0; |
| 445 |
} |
| 446 |
#endif |
| 447 |
#ifdef HAVE_IOCTL_SIOCGIFADDR |
| 448 |
/* headers for FIONBIO test */ |
| 449 |
/* includes start */ |
| 450 |
#ifdef HAVE_SYS_TYPES_H |
| 451 |
# include <sys/types.h> |
| 452 |
#endif |
| 453 |
#ifdef HAVE_UNISTD_H |
| 454 |
# include <unistd.h> |
| 455 |
#endif |
| 456 |
#ifdef HAVE_SYS_SOCKET_H |
| 457 |
# include <sys/socket.h> |
| 458 |
#endif |
| 459 |
#ifdef HAVE_SYS_IOCTL_H |
| 460 |
# include <sys/ioctl.h> |
| 461 |
#endif |
| 462 |
#ifdef HAVE_STROPTS_H |
| 463 |
# include <stropts.h> |
| 464 |
#endif |
| 465 |
#include <net/if.h> |
| 466 |
|
| 467 |
int |
| 468 |
main () |
| 469 |
{ |
| 470 |
struct ifreq ifr; |
| 471 |
if(0 != ioctl(0, SIOCGIFADDR, &ifr)) |
| 472 |
return 1; |
| 473 |
|
| 474 |
; |
| 475 |
return 0; |
| 476 |
} |
| 477 |
#endif |
| 478 |
#ifdef HAVE_SETSOCKOPT_SO_NONBLOCK |
| 479 |
/* includes start */ |
| 480 |
#ifdef HAVE_WINDOWS_H |
| 481 |
# ifndef WIN32_LEAN_AND_MEAN |
| 482 |
# define WIN32_LEAN_AND_MEAN |
| 483 |
# endif |
| 484 |
# include <windows.h> |
| 485 |
# ifdef HAVE_WINSOCK2_H |
| 486 |
# include <winsock2.h> |
| 487 |
# else |
| 488 |
# ifdef HAVE_WINSOCK_H |
| 489 |
# include <winsock.h> |
| 490 |
# endif |
| 491 |
# endif |
| 492 |
#endif |
| 493 |
/* includes start */ |
| 494 |
#ifdef HAVE_SYS_TYPES_H |
| 495 |
# include <sys/types.h> |
| 496 |
#endif |
| 497 |
#ifdef HAVE_SYS_SOCKET_H |
| 498 |
# include <sys/socket.h> |
| 499 |
#endif |
| 500 |
/* includes end */ |
| 501 |
|
| 502 |
int |
| 503 |
main () |
| 504 |
{ |
| 505 |
if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0)) |
| 506 |
return 1; |
| 507 |
; |
| 508 |
return 0; |
| 509 |
} |
| 510 |
#endif |
| 511 |
#ifdef HAVE_GLIBC_STRERROR_R |
| 512 |
#include <string.h> |
| 513 |
#include <errno.h> |
| 514 |
|
| 515 |
void check(char c) {} |
| 516 |
|
| 517 |
int |
| 518 |
main () { |
| 519 |
char buffer[1024]; |
| 520 |
/* This will not compile if strerror_r does not return a char* */ |
| 521 |
check(strerror_r(EACCES, buffer, sizeof(buffer))[0]); |
| 522 |
return 0; |
| 523 |
} |
| 524 |
#endif |
| 525 |
#ifdef HAVE_POSIX_STRERROR_R |
| 526 |
#include <string.h> |
| 527 |
#include <errno.h> |
| 528 |
|
| 529 |
/* float, because a pointer can't be implicitly cast to float */ |
| 530 |
void check(float f) {} |
| 531 |
|
| 532 |
int |
| 533 |
main () { |
| 534 |
char buffer[1024]; |
| 535 |
/* This will not compile if strerror_r does not return an int */ |
| 536 |
check(strerror_r(EACCES, buffer, sizeof(buffer))); |
| 537 |
return 0; |
| 538 |
} |
| 539 |
#endif |
| 540 |
#ifdef HAVE_FSETXATTR_6 |
| 541 |
#include <sys/xattr.h> /* header from libc, not from libattr */ |
| 542 |
int |
| 543 |
main() { |
| 544 |
fsetxattr(0, 0, 0, 0, 0, 0); |
| 545 |
return 0; |
| 546 |
} |
| 547 |
#endif |
| 548 |
#ifdef HAVE_FSETXATTR_5 |
| 549 |
#include <sys/xattr.h> /* header from libc, not from libattr */ |
| 550 |
int |
| 551 |
main() { |
| 552 |
fsetxattr(0, 0, 0, 0, 0); |
| 553 |
return 0; |
| 554 |
} |
| 555 |
#endif |
| 556 |
#ifdef HAVE_CLOCK_GETTIME_MONOTONIC |
| 557 |
#include <time.h> |
| 558 |
int |
| 559 |
main() { |
| 560 |
struct timespec ts = {0, 0}; |
| 561 |
clock_gettime(CLOCK_MONOTONIC, &ts); |
| 562 |
return 0; |
| 563 |
} |
| 564 |
#endif |
| 565 |
#ifdef HAVE_BUILTIN_AVAILABLE |
| 566 |
int |
| 567 |
main() { |
| 568 |
if(__builtin_available(macOS 10.12, *)) {} |
| 569 |
return 0; |
| 570 |
} |
| 571 |
#endif |
| 572 |
#ifdef HAVE_VARIADIC_MACROS_C99 |
| 573 |
#define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__) |
| 574 |
#define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__) |
| 575 |
|
| 576 |
int fun3(int arg1, int arg2, int arg3); |
| 577 |
int fun2(int arg1, int arg2); |
| 578 |
|
| 579 |
int fun3(int arg1, int arg2, int arg3) { |
| 580 |
return arg1 + arg2 + arg3; |
| 581 |
} |
| 582 |
int fun2(int arg1, int arg2) { |
| 583 |
return arg1 + arg2; |
| 584 |
} |
| 585 |
|
| 586 |
int |
| 587 |
main() { |
| 588 |
int res3 = c99_vmacro3(1, 2, 3); |
| 589 |
int res2 = c99_vmacro2(1, 2); |
| 590 |
(void)res3; |
| 591 |
(void)res2; |
| 592 |
return 0; |
| 593 |
} |
| 594 |
#endif |
| 595 |
#ifdef HAVE_VARIADIC_MACROS_GCC |
| 596 |
#define gcc_vmacro3(first, args...) fun3(first, args) |
| 597 |
#define gcc_vmacro2(first, args...) fun2(first, args) |
| 598 |
|
| 599 |
int fun3(int arg1, int arg2, int arg3); |
| 600 |
int fun2(int arg1, int arg2); |
| 601 |
|
| 602 |
int fun3(int arg1, int arg2, int arg3) { |
| 603 |
return arg1 + arg2 + arg3; |
| 604 |
} |
| 605 |
int fun2(int arg1, int arg2) { |
| 606 |
return arg1 + arg2; |
| 607 |
} |
| 608 |
|
| 609 |
int |
| 610 |
main() { |
| 611 |
int res3 = gcc_vmacro3(1, 2, 3); |
| 612 |
int res2 = gcc_vmacro2(1, 2); |
| 613 |
(void)res3; |
| 614 |
(void)res2; |
| 615 |
return 0; |
| 616 |
} |
| 617 |
#endif |