sys_time.in.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /* Provide a more complete sys/time.h.
  2. Copyright (C) 2007-2017 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>. */
  13. /* Written by Paul Eggert. */
  14. #ifndef _@GUARD_PREFIX@_SYS_TIME_H
  15. #if __GNUC__ >= 3
  16. @PRAGMA_SYSTEM_HEADER@
  17. #endif
  18. @PRAGMA_COLUMNS@
  19. /* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
  20. recursively via <sys/select.h>.
  21. Simply delegate to the system's header in this case; it is a no-op.
  22. Without this extra ifdef, the C++ gettimeofday declaration below
  23. would be a forward declaration in gnulib's nested <sys/time.h>. */
  24. #if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
  25. # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
  26. #else
  27. /* The include_next requires a split double-inclusion guard. */
  28. #if @HAVE_SYS_TIME_H@
  29. # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
  30. #endif
  31. #ifndef _@GUARD_PREFIX@_SYS_TIME_H
  32. #define _@GUARD_PREFIX@_SYS_TIME_H
  33. #if ! @HAVE_SYS_TIME_H@
  34. # include <time.h>
  35. #endif
  36. /* On native Windows with MSVC, get the 'struct timeval' type.
  37. Also, on native Windows with a 64-bit time_t, where we are overriding the
  38. 'struct timeval' type, get all declarations of system functions whose
  39. signature contains 'struct timeval'. */
  40. #if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
  41. # define _GL_INCLUDING_WINSOCK2_H
  42. # include <winsock2.h>
  43. # undef _GL_INCLUDING_WINSOCK2_H
  44. #endif
  45. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  46. /* The definition of _GL_ARG_NONNULL is copied here. */
  47. /* The definition of _GL_WARN_ON_USE is copied here. */
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51. #if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
  52. # if @REPLACE_STRUCT_TIMEVAL@
  53. # define timeval rpl_timeval
  54. # endif
  55. # if !GNULIB_defined_struct_timeval
  56. struct timeval
  57. {
  58. time_t tv_sec;
  59. long int tv_usec;
  60. };
  61. # define GNULIB_defined_struct_timeval 1
  62. # endif
  63. #endif
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #if @GNULIB_GETTIMEOFDAY@
  68. # if @REPLACE_GETTIMEOFDAY@
  69. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  70. # undef gettimeofday
  71. # define gettimeofday rpl_gettimeofday
  72. # endif
  73. _GL_FUNCDECL_RPL (gettimeofday, int,
  74. (struct timeval *restrict, void *restrict)
  75. _GL_ARG_NONNULL ((1)));
  76. _GL_CXXALIAS_RPL (gettimeofday, int,
  77. (struct timeval *restrict, void *restrict));
  78. # else
  79. # if !@HAVE_GETTIMEOFDAY@
  80. _GL_FUNCDECL_SYS (gettimeofday, int,
  81. (struct timeval *restrict, void *restrict)
  82. _GL_ARG_NONNULL ((1)));
  83. # endif
  84. /* Need to cast, because on glibc systems, by default, the second argument is
  85. struct timezone *. */
  86. _GL_CXXALIAS_SYS_CAST (gettimeofday, int,
  87. (struct timeval *restrict, void *restrict));
  88. # endif
  89. _GL_CXXALIASWARN (gettimeofday);
  90. # if defined __cplusplus && defined GNULIB_NAMESPACE
  91. namespace GNULIB_NAMESPACE {
  92. typedef ::timeval
  93. #undef timeval
  94. timeval;
  95. }
  96. # endif
  97. #elif defined GNULIB_POSIXCHECK
  98. # undef gettimeofday
  99. # if HAVE_RAW_DECL_GETTIMEOFDAY
  100. _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
  101. "use gnulib module gettimeofday for portability");
  102. # endif
  103. #endif
  104. /* Hide some function declarations from <winsock2.h>. */
  105. #if defined _MSC_VER && @HAVE_WINSOCK2_H@
  106. # if !defined _@GUARD_PREFIX@_UNISTD_H
  107. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  108. # undef close
  109. # define close close_used_without_including_unistd_h
  110. # else
  111. _GL_WARN_ON_USE (close,
  112. "close() used without including <unistd.h>");
  113. # endif
  114. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  115. # undef gethostname
  116. # define gethostname gethostname_used_without_including_unistd_h
  117. # else
  118. _GL_WARN_ON_USE (gethostname,
  119. "gethostname() used without including <unistd.h>");
  120. # endif
  121. # endif
  122. # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
  123. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  124. # undef socket
  125. # define socket socket_used_without_including_sys_socket_h
  126. # undef connect
  127. # define connect connect_used_without_including_sys_socket_h
  128. # undef accept
  129. # define accept accept_used_without_including_sys_socket_h
  130. # undef bind
  131. # define bind bind_used_without_including_sys_socket_h
  132. # undef getpeername
  133. # define getpeername getpeername_used_without_including_sys_socket_h
  134. # undef getsockname
  135. # define getsockname getsockname_used_without_including_sys_socket_h
  136. # undef getsockopt
  137. # define getsockopt getsockopt_used_without_including_sys_socket_h
  138. # undef listen
  139. # define listen listen_used_without_including_sys_socket_h
  140. # undef recv
  141. # define recv recv_used_without_including_sys_socket_h
  142. # undef send
  143. # define send send_used_without_including_sys_socket_h
  144. # undef recvfrom
  145. # define recvfrom recvfrom_used_without_including_sys_socket_h
  146. # undef sendto
  147. # define sendto sendto_used_without_including_sys_socket_h
  148. # undef setsockopt
  149. # define setsockopt setsockopt_used_without_including_sys_socket_h
  150. # undef shutdown
  151. # define shutdown shutdown_used_without_including_sys_socket_h
  152. # else
  153. _GL_WARN_ON_USE (socket,
  154. "socket() used without including <sys/socket.h>");
  155. _GL_WARN_ON_USE (connect,
  156. "connect() used without including <sys/socket.h>");
  157. _GL_WARN_ON_USE (accept,
  158. "accept() used without including <sys/socket.h>");
  159. _GL_WARN_ON_USE (bind,
  160. "bind() used without including <sys/socket.h>");
  161. _GL_WARN_ON_USE (getpeername,
  162. "getpeername() used without including <sys/socket.h>");
  163. _GL_WARN_ON_USE (getsockname,
  164. "getsockname() used without including <sys/socket.h>");
  165. _GL_WARN_ON_USE (getsockopt,
  166. "getsockopt() used without including <sys/socket.h>");
  167. _GL_WARN_ON_USE (listen,
  168. "listen() used without including <sys/socket.h>");
  169. _GL_WARN_ON_USE (recv,
  170. "recv() used without including <sys/socket.h>");
  171. _GL_WARN_ON_USE (send,
  172. "send() used without including <sys/socket.h>");
  173. _GL_WARN_ON_USE (recvfrom,
  174. "recvfrom() used without including <sys/socket.h>");
  175. _GL_WARN_ON_USE (sendto,
  176. "sendto() used without including <sys/socket.h>");
  177. _GL_WARN_ON_USE (setsockopt,
  178. "setsockopt() used without including <sys/socket.h>");
  179. _GL_WARN_ON_USE (shutdown,
  180. "shutdown() used without including <sys/socket.h>");
  181. # endif
  182. # endif
  183. # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
  184. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  185. # undef select
  186. # define select select_used_without_including_sys_select_h
  187. # else
  188. _GL_WARN_ON_USE (select,
  189. "select() used without including <sys/select.h>");
  190. # endif
  191. # endif
  192. #endif
  193. #endif /* _@GUARD_PREFIX@_SYS_TIME_H */
  194. #endif /* _CYGWIN_SYS_TIME_H */
  195. #endif /* _@GUARD_PREFIX@_SYS_TIME_H */