sys_time.in.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* Provide a more complete sys/time.h.
  2. Copyright (C) 2007-2013 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. /* The include_next requires a split double-inclusion guard. */
  20. #if @HAVE_SYS_TIME_H@
  21. # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
  22. #endif
  23. #ifndef _@GUARD_PREFIX@_SYS_TIME_H
  24. #define _@GUARD_PREFIX@_SYS_TIME_H
  25. #if ! @HAVE_SYS_TIME_H@
  26. # include <time.h>
  27. #endif
  28. /* On native Windows with MSVC, get the 'struct timeval' type.
  29. Also, on native Windows with a 64-bit time_t, where we are overriding the
  30. 'struct timeval' type, get all declarations of system functions whose
  31. signature contains 'struct timeval'. */
  32. #if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
  33. # define _GL_INCLUDING_WINSOCK2_H
  34. # include <winsock2.h>
  35. # undef _GL_INCLUDING_WINSOCK2_H
  36. #endif
  37. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  38. /* The definition of _GL_ARG_NONNULL is copied here. */
  39. /* The definition of _GL_WARN_ON_USE is copied here. */
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
  44. # if @REPLACE_STRUCT_TIMEVAL@
  45. # define timeval rpl_timeval
  46. # endif
  47. # if !GNULIB_defined_struct_timeval
  48. struct timeval
  49. {
  50. time_t tv_sec;
  51. long int tv_usec;
  52. };
  53. # define GNULIB_defined_struct_timeval 1
  54. # endif
  55. #endif
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #if @GNULIB_GETTIMEOFDAY@
  60. # if @REPLACE_GETTIMEOFDAY@
  61. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  62. # undef gettimeofday
  63. # define gettimeofday rpl_gettimeofday
  64. # endif
  65. _GL_FUNCDECL_RPL (gettimeofday, int,
  66. (struct timeval *restrict, void *restrict)
  67. _GL_ARG_NONNULL ((1)));
  68. _GL_CXXALIAS_RPL (gettimeofday, int,
  69. (struct timeval *restrict, void *restrict));
  70. # else
  71. # if !@HAVE_GETTIMEOFDAY@
  72. _GL_FUNCDECL_SYS (gettimeofday, int,
  73. (struct timeval *restrict, void *restrict)
  74. _GL_ARG_NONNULL ((1)));
  75. # endif
  76. /* Need to cast, because on glibc systems, by default, the second argument is
  77. struct timezone *. */
  78. _GL_CXXALIAS_SYS_CAST (gettimeofday, int,
  79. (struct timeval *restrict, void *restrict));
  80. # endif
  81. _GL_CXXALIASWARN (gettimeofday);
  82. #elif defined GNULIB_POSIXCHECK
  83. # undef gettimeofday
  84. # if HAVE_RAW_DECL_GETTIMEOFDAY
  85. _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
  86. "use gnulib module gettimeofday for portability");
  87. # endif
  88. #endif
  89. /* Hide some function declarations from <winsock2.h>. */
  90. #if defined _MSC_VER && @HAVE_WINSOCK2_H@
  91. # if !defined _@GUARD_PREFIX@_UNISTD_H
  92. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  93. # undef close
  94. # define close close_used_without_including_unistd_h
  95. # else
  96. _GL_WARN_ON_USE (close,
  97. "close() used without including <unistd.h>");
  98. # endif
  99. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  100. # undef gethostname
  101. # define gethostname gethostname_used_without_including_unistd_h
  102. # else
  103. _GL_WARN_ON_USE (gethostname,
  104. "gethostname() used without including <unistd.h>");
  105. # endif
  106. # endif
  107. # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
  108. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  109. # undef socket
  110. # define socket socket_used_without_including_sys_socket_h
  111. # undef connect
  112. # define connect connect_used_without_including_sys_socket_h
  113. # undef accept
  114. # define accept accept_used_without_including_sys_socket_h
  115. # undef bind
  116. # define bind bind_used_without_including_sys_socket_h
  117. # undef getpeername
  118. # define getpeername getpeername_used_without_including_sys_socket_h
  119. # undef getsockname
  120. # define getsockname getsockname_used_without_including_sys_socket_h
  121. # undef getsockopt
  122. # define getsockopt getsockopt_used_without_including_sys_socket_h
  123. # undef listen
  124. # define listen listen_used_without_including_sys_socket_h
  125. # undef recv
  126. # define recv recv_used_without_including_sys_socket_h
  127. # undef send
  128. # define send send_used_without_including_sys_socket_h
  129. # undef recvfrom
  130. # define recvfrom recvfrom_used_without_including_sys_socket_h
  131. # undef sendto
  132. # define sendto sendto_used_without_including_sys_socket_h
  133. # undef setsockopt
  134. # define setsockopt setsockopt_used_without_including_sys_socket_h
  135. # undef shutdown
  136. # define shutdown shutdown_used_without_including_sys_socket_h
  137. # else
  138. _GL_WARN_ON_USE (socket,
  139. "socket() used without including <sys/socket.h>");
  140. _GL_WARN_ON_USE (connect,
  141. "connect() used without including <sys/socket.h>");
  142. _GL_WARN_ON_USE (accept,
  143. "accept() used without including <sys/socket.h>");
  144. _GL_WARN_ON_USE (bind,
  145. "bind() used without including <sys/socket.h>");
  146. _GL_WARN_ON_USE (getpeername,
  147. "getpeername() used without including <sys/socket.h>");
  148. _GL_WARN_ON_USE (getsockname,
  149. "getsockname() used without including <sys/socket.h>");
  150. _GL_WARN_ON_USE (getsockopt,
  151. "getsockopt() used without including <sys/socket.h>");
  152. _GL_WARN_ON_USE (listen,
  153. "listen() used without including <sys/socket.h>");
  154. _GL_WARN_ON_USE (recv,
  155. "recv() used without including <sys/socket.h>");
  156. _GL_WARN_ON_USE (send,
  157. "send() used without including <sys/socket.h>");
  158. _GL_WARN_ON_USE (recvfrom,
  159. "recvfrom() used without including <sys/socket.h>");
  160. _GL_WARN_ON_USE (sendto,
  161. "sendto() used without including <sys/socket.h>");
  162. _GL_WARN_ON_USE (setsockopt,
  163. "setsockopt() used without including <sys/socket.h>");
  164. _GL_WARN_ON_USE (shutdown,
  165. "shutdown() used without including <sys/socket.h>");
  166. # endif
  167. # endif
  168. # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
  169. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  170. # undef select
  171. # define select select_used_without_including_sys_select_h
  172. # else
  173. _GL_WARN_ON_USE (select,
  174. "select() used without including <sys/select.h>");
  175. # endif
  176. # endif
  177. #endif
  178. #endif /* _@GUARD_PREFIX@_SYS_TIME_H */
  179. #endif /* _@GUARD_PREFIX@_SYS_TIME_H */