1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 /* Provide a more complete sys/time.h. 3 4 Copyright (C) 2007-2014 Free Software Foundation, Inc. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 3, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 18 19 /* Written by Paul Eggert. */ 20 21 #ifndef _GL_SYS_TIME_H 22 23 #if __GNUC__ >= 3 24 #pragma GCC system_header 25 #endif 26 27 28 /* On Cygwin and on many BSDish systems, <sys/time.h> includes itself 29 recursively via <sys/select.h>. 30 Simply delegate to the system's header in this case; it is a no-op. 31 Without this extra ifdef, the C++ gettimeofday declaration below 32 would be a forward declaration in gnulib's nested <sys/time.h>. */ 33 #if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_ 34 # include_next <sys/time.h> 35 #else 36 37 /* The include_next requires a split double-inclusion guard. */ 38 #if 1 39 # include_next <sys/time.h> 40 #endif 41 42 #ifndef _GL_SYS_TIME_H 43 #define _GL_SYS_TIME_H 44 45 #if ! 1 46 # include <time.h> 47 #endif 48 49 /* On native Windows with MSVC, get the 'struct timeval' type. 50 Also, on native Windows with a 64-bit time_t, where we are overriding the 51 'struct timeval' type, get all declarations of system functions whose 52 signature contains 'struct timeval'. */ 53 #if (defined _MSC_VER || 0) && 0 && !defined _GL_INCLUDING_WINSOCK2_H 54 # define _GL_INCLUDING_WINSOCK2_H 55 # include <winsock2.h> 56 # undef _GL_INCLUDING_WINSOCK2_H 57 #endif 58 59 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 60 #ifndef _GL_CXXDEFS_H 61 #define _GL_CXXDEFS_H 62 63 /* The three most frequent use cases of these macros are: 64 65 * For providing a substitute for a function that is missing on some 66 platforms, but is declared and works fine on the platforms on which 67 it exists: 68 69 #if @GNULIB_FOO@ 70 # if !@HAVE_FOO@ 71 _GL_FUNCDECL_SYS (foo, ...); 72 # endif 73 _GL_CXXALIAS_SYS (foo, ...); 74 _GL_CXXALIASWARN (foo); 75 #elif defined GNULIB_POSIXCHECK 76 ... 77 #endif 78 79 * For providing a replacement for a function that exists on all platforms, 80 but is broken/insufficient and needs to be replaced on some platforms: 81 82 #if @GNULIB_FOO@ 83 # if @REPLACE_FOO@ 84 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 85 # undef foo 86 # define foo rpl_foo 87 # endif 88 _GL_FUNCDECL_RPL (foo, ...); 89 _GL_CXXALIAS_RPL (foo, ...); 90 # else 91 _GL_CXXALIAS_SYS (foo, ...); 92 # endif 93 _GL_CXXALIASWARN (foo); 94 #elif defined GNULIB_POSIXCHECK 95 ... 96 #endif 97 98 * For providing a replacement for a function that exists on some platforms 99 but is broken/insufficient and needs to be replaced on some of them and 100 is additionally either missing or undeclared on some other platforms: 101 102 #if @GNULIB_FOO@ 103 # if @REPLACE_FOO@ 104 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 105 # undef foo 106 # define foo rpl_foo 107 # endif 108 _GL_FUNCDECL_RPL (foo, ...); 109 _GL_CXXALIAS_RPL (foo, ...); 110 # else 111 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 112 _GL_FUNCDECL_SYS (foo, ...); 113 # endif 114 _GL_CXXALIAS_SYS (foo, ...); 115 # endif 116 _GL_CXXALIASWARN (foo); 117 #elif defined GNULIB_POSIXCHECK 118 ... 119 #endif 120 */ 121 122 /* _GL_EXTERN_C declaration; 123 performs the declaration with C linkage. */ 124 #if defined __cplusplus 125 # define _GL_EXTERN_C extern "C" 126 #else 127 # define _GL_EXTERN_C extern 128 #endif 129 130 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 131 declares a replacement function, named rpl_func, with the given prototype, 132 consisting of return type, parameters, and attributes. 133 Example: 134 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 135 _GL_ARG_NONNULL ((1))); 136 */ 137 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 138 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 139 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 140 _GL_EXTERN_C rettype rpl_func parameters_and_attributes 141 142 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 143 declares the system function, named func, with the given prototype, 144 consisting of return type, parameters, and attributes. 145 Example: 146 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 147 _GL_ARG_NONNULL ((1))); 148 */ 149 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 150 _GL_EXTERN_C rettype func parameters_and_attributes 151 152 /* _GL_CXXALIAS_RPL (func, rettype, parameters); 153 declares a C++ alias called GNULIB_NAMESPACE::func 154 that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 155 Example: 156 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 157 */ 158 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 159 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 160 #if defined __cplusplus && defined GNULIB_NAMESPACE 161 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 162 namespace GNULIB_NAMESPACE \ 163 { \ 164 rettype (*const func) parameters = ::rpl_func; \ 165 } \ 166 _GL_EXTERN_C int _gl_cxxalias_dummy 167 #else 168 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 169 _GL_EXTERN_C int _gl_cxxalias_dummy 170 #endif 171 172 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 173 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 174 except that the C function rpl_func may have a slightly different 175 declaration. A cast is used to silence the "invalid conversion" error 176 that would otherwise occur. */ 177 #if defined __cplusplus && defined GNULIB_NAMESPACE 178 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 179 namespace GNULIB_NAMESPACE \ 180 { \ 181 rettype (*const func) parameters = \ 182 reinterpret_cast<rettype(*)parameters>(::rpl_func); \ 183 } \ 184 _GL_EXTERN_C int _gl_cxxalias_dummy 185 #else 186 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 187 _GL_EXTERN_C int _gl_cxxalias_dummy 188 #endif 189 190 /* _GL_CXXALIAS_SYS (func, rettype, parameters); 191 declares a C++ alias called GNULIB_NAMESPACE::func 192 that redirects to the system provided function func, if GNULIB_NAMESPACE 193 is defined. 194 Example: 195 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 196 */ 197 #if defined __cplusplus && defined GNULIB_NAMESPACE 198 /* If we were to write 199 rettype (*const func) parameters = ::func; 200 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls 201 better (remove an indirection through a 'static' pointer variable), 202 but then the _GL_CXXALIASWARN macro below would cause a warning not only 203 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ 204 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 205 namespace GNULIB_NAMESPACE \ 206 { \ 207 static rettype (*func) parameters = ::func; \ 208 } \ 209 _GL_EXTERN_C int _gl_cxxalias_dummy 210 #else 211 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 212 _GL_EXTERN_C int _gl_cxxalias_dummy 213 #endif 214 215 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 216 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 217 except that the C function func may have a slightly different declaration. 218 A cast is used to silence the "invalid conversion" error that would 219 otherwise occur. */ 220 #if defined __cplusplus && defined GNULIB_NAMESPACE 221 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 222 namespace GNULIB_NAMESPACE \ 223 { \ 224 static rettype (*func) parameters = \ 225 reinterpret_cast<rettype(*)parameters>(::func); \ 226 } \ 227 _GL_EXTERN_C int _gl_cxxalias_dummy 228 #else 229 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 230 _GL_EXTERN_C int _gl_cxxalias_dummy 231 #endif 232 233 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 234 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 235 except that the C function is picked among a set of overloaded functions, 236 namely the one with rettype2 and parameters2. Two consecutive casts 237 are used to silence the "cannot find a match" and "invalid conversion" 238 errors that would otherwise occur. */ 239 #if defined __cplusplus && defined GNULIB_NAMESPACE 240 /* The outer cast must be a reinterpret_cast. 241 The inner cast: When the function is defined as a set of overloaded 242 functions, it works as a static_cast<>, choosing the designated variant. 243 When the function is defined as a single variant, it works as a 244 reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 245 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 246 namespace GNULIB_NAMESPACE \ 247 { \ 248 static rettype (*func) parameters = \ 249 reinterpret_cast<rettype(*)parameters>( \ 250 (rettype2(*)parameters2)(::func)); \ 251 } \ 252 _GL_EXTERN_C int _gl_cxxalias_dummy 253 #else 254 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 255 _GL_EXTERN_C int _gl_cxxalias_dummy 256 #endif 257 258 /* _GL_CXXALIASWARN (func); 259 causes a warning to be emitted when ::func is used but not when 260 GNULIB_NAMESPACE::func is used. func must be defined without overloaded 261 variants. */ 262 #if defined __cplusplus && defined GNULIB_NAMESPACE 263 # define _GL_CXXALIASWARN(func) \ 264 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 265 # define _GL_CXXALIASWARN_1(func,namespace) \ 266 _GL_CXXALIASWARN_2 (func, namespace) 267 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 268 we enable the warning only when not optimizing. */ 269 # if !__OPTIMIZE__ 270 # define _GL_CXXALIASWARN_2(func,namespace) \ 271 _GL_WARN_ON_USE (func, \ 272 "The symbol ::" #func " refers to the system function. " \ 273 "Use " #namespace "::" #func " instead.") 274 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 275 # define _GL_CXXALIASWARN_2(func,namespace) \ 276 extern __typeof__ (func) func 277 # else 278 # define _GL_CXXALIASWARN_2(func,namespace) \ 279 _GL_EXTERN_C int _gl_cxxalias_dummy 280 # endif 281 #else 282 # define _GL_CXXALIASWARN(func) \ 283 _GL_EXTERN_C int _gl_cxxalias_dummy 284 #endif 285 286 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 287 causes a warning to be emitted when the given overloaded variant of ::func 288 is used but not when GNULIB_NAMESPACE::func is used. */ 289 #if defined __cplusplus && defined GNULIB_NAMESPACE 290 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 291 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 292 GNULIB_NAMESPACE) 293 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 294 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 295 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 296 we enable the warning only when not optimizing. */ 297 # if !__OPTIMIZE__ 298 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 299 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 300 "The symbol ::" #func " refers to the system function. " \ 301 "Use " #namespace "::" #func " instead.") 302 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 303 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 304 extern __typeof__ (func) func 305 # else 306 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 307 _GL_EXTERN_C int _gl_cxxalias_dummy 308 # endif 309 #else 310 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 311 _GL_EXTERN_C int _gl_cxxalias_dummy 312 #endif 313 314 #endif /* _GL_CXXDEFS_H */ 315 316 /* The definition of _GL_ARG_NONNULL is copied here. */ 317 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 318 that the values passed as arguments n, ..., m must be non-NULL pointers. 319 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 320 #ifndef _GL_ARG_NONNULL 321 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 322 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 323 # else 324 # define _GL_ARG_NONNULL(params) 325 # endif 326 #endif 327 328 /* The definition of _GL_WARN_ON_USE is copied here. */ 329 #ifndef _GL_WARN_ON_USE 330 331 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 332 /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 333 # define _GL_WARN_ON_USE(function, message) \ 334 extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 335 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 336 /* Verify the existence of the function. */ 337 # define _GL_WARN_ON_USE(function, message) \ 338 extern __typeof__ (function) function 339 # else /* Unsupported. */ 340 # define _GL_WARN_ON_USE(function, message) \ 341 _GL_WARN_EXTERN_C int _gl_warn_on_use 342 # endif 343 #endif 344 345 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 346 is like _GL_WARN_ON_USE (function, "string"), except that the function is 347 declared with the given prototype, consisting of return type, parameters, 348 and attributes. 349 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 350 not work in this case. */ 351 #ifndef _GL_WARN_ON_USE_CXX 352 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 353 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 354 extern rettype function parameters_and_attributes \ 355 __attribute__ ((__warning__ (msg))) 356 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 357 /* Verify the existence of the function. */ 358 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 359 extern rettype function parameters_and_attributes 360 # else /* Unsupported. */ 361 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 362 _GL_WARN_EXTERN_C int _gl_warn_on_use 363 # endif 364 #endif 365 366 /* _GL_WARN_EXTERN_C declaration; 367 performs the declaration with C linkage. */ 368 #ifndef _GL_WARN_EXTERN_C 369 # if defined __cplusplus 370 # define _GL_WARN_EXTERN_C extern "C" 371 # else 372 # define _GL_WARN_EXTERN_C extern 373 # endif 374 #endif 375 376 #ifdef __cplusplus 377 extern "C" { 378 #endif 379 380 #if !1 || 0 381 382 # if 0 383 # define timeval rpl_timeval 384 # endif 385 386 # if !GNULIB_defined_struct_timeval 387 struct timeval 388 { 389 time_t tv_sec; 390 long int tv_usec; 391 }; 392 # define GNULIB_defined_struct_timeval 1 393 # endif 394 395 #endif 396 397 #ifdef __cplusplus 398 } 399 #endif 400 401 #if 1 402 # if 0 403 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 404 # undef gettimeofday 405 # define gettimeofday rpl_gettimeofday 406 # endif 407 _GL_FUNCDECL_RPL (gettimeofday, int, 408 (struct timeval *restrict, void *restrict) 409 _GL_ARG_NONNULL ((1))); 410 _GL_CXXALIAS_RPL (gettimeofday, int, 411 (struct timeval *restrict, void *restrict)); 412 # else 413 # if !1 414 _GL_FUNCDECL_SYS (gettimeofday, int, 415 (struct timeval *restrict, void *restrict) 416 _GL_ARG_NONNULL ((1))); 417 # endif 418 /* Need to cast, because on glibc systems, by default, the second argument is 419 struct timezone *. */ 420 _GL_CXXALIAS_SYS_CAST (gettimeofday, int, 421 (struct timeval *restrict, void *restrict)); 422 # endif 423 _GL_CXXALIASWARN (gettimeofday); 424 #elif defined GNULIB_POSIXCHECK 425 # undef gettimeofday 426 # if HAVE_RAW_DECL_GETTIMEOFDAY 427 _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " 428 "use gnulib module gettimeofday for portability"); 429 # endif 430 #endif 431 432 /* Hide some function declarations from <winsock2.h>. */ 433 434 #if defined _MSC_VER && 0 435 # if !defined _GL_UNISTD_H 436 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 437 # undef close 438 # define close close_used_without_including_unistd_h 439 # else 440 _GL_WARN_ON_USE (close, 441 "close() used without including <unistd.h>"); 442 # endif 443 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 444 # undef gethostname 445 # define gethostname gethostname_used_without_including_unistd_h 446 # else 447 _GL_WARN_ON_USE (gethostname, 448 "gethostname() used without including <unistd.h>"); 449 # endif 450 # endif 451 # if !defined _GL_SYS_SOCKET_H 452 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 453 # undef socket 454 # define socket socket_used_without_including_sys_socket_h 455 # undef connect 456 # define connect connect_used_without_including_sys_socket_h 457 # undef accept 458 # define accept accept_used_without_including_sys_socket_h 459 # undef bind 460 # define bind bind_used_without_including_sys_socket_h 461 # undef getpeername 462 # define getpeername getpeername_used_without_including_sys_socket_h 463 # undef getsockname 464 # define getsockname getsockname_used_without_including_sys_socket_h 465 # undef getsockopt 466 # define getsockopt getsockopt_used_without_including_sys_socket_h 467 # undef listen 468 # define listen listen_used_without_including_sys_socket_h 469 # undef recv 470 # define recv recv_used_without_including_sys_socket_h 471 # undef send 472 # define send send_used_without_including_sys_socket_h 473 # undef recvfrom 474 # define recvfrom recvfrom_used_without_including_sys_socket_h 475 # undef sendto 476 # define sendto sendto_used_without_including_sys_socket_h 477 # undef setsockopt 478 # define setsockopt setsockopt_used_without_including_sys_socket_h 479 # undef shutdown 480 # define shutdown shutdown_used_without_including_sys_socket_h 481 # else 482 _GL_WARN_ON_USE (socket, 483 "socket() used without including <sys/socket.h>"); 484 _GL_WARN_ON_USE (connect, 485 "connect() used without including <sys/socket.h>"); 486 _GL_WARN_ON_USE (accept, 487 "accept() used without including <sys/socket.h>"); 488 _GL_WARN_ON_USE (bind, 489 "bind() used without including <sys/socket.h>"); 490 _GL_WARN_ON_USE (getpeername, 491 "getpeername() used without including <sys/socket.h>"); 492 _GL_WARN_ON_USE (getsockname, 493 "getsockname() used without including <sys/socket.h>"); 494 _GL_WARN_ON_USE (getsockopt, 495 "getsockopt() used without including <sys/socket.h>"); 496 _GL_WARN_ON_USE (listen, 497 "listen() used without including <sys/socket.h>"); 498 _GL_WARN_ON_USE (recv, 499 "recv() used without including <sys/socket.h>"); 500 _GL_WARN_ON_USE (send, 501 "send() used without including <sys/socket.h>"); 502 _GL_WARN_ON_USE (recvfrom, 503 "recvfrom() used without including <sys/socket.h>"); 504 _GL_WARN_ON_USE (sendto, 505 "sendto() used without including <sys/socket.h>"); 506 _GL_WARN_ON_USE (setsockopt, 507 "setsockopt() used without including <sys/socket.h>"); 508 _GL_WARN_ON_USE (shutdown, 509 "shutdown() used without including <sys/socket.h>"); 510 # endif 511 # endif 512 # if !defined _GL_SYS_SELECT_H 513 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 514 # undef select 515 # define select select_used_without_including_sys_select_h 516 # else 517 _GL_WARN_ON_USE (select, 518 "select() used without including <sys/select.h>"); 519 # endif 520 # endif 521 #endif 522 523 #endif /* _GL_SYS_TIME_H */ 524 #endif /* _CYGWIN_SYS_TIME_H */ 525 #endif /* _GL_SYS_TIME_H */ 526