sys_time.in.h 6.9 KB

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