PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/external/bison/lib/time.in.h

https://gitlab.com/brian0218/rk3188_rk3066_r-box_android4.4.2_sdk
C Header | 248 lines | 176 code | 23 blank | 49 comment | 38 complexity | 0ba9c6fa0f390e97de1ea85b4f6f4a32 MD5 | raw file
  1. /* A more-standard <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 General Public License as published by
  5. the Free Software Foundation; either version 3, 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 General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>. */
  13. #if __GNUC__ >= 3
  14. @PRAGMA_SYSTEM_HEADER@
  15. #endif
  16. @PRAGMA_COLUMNS@
  17. /* Don't get in the way of glibc when it includes time.h merely to
  18. declare a few standard symbols, rather than to declare all the
  19. symbols. Also, Solaris 8 <time.h> eventually includes itself
  20. recursively; if that is happening, just include the system <time.h>
  21. without adding our own declarations. */
  22. #if (defined __need_time_t || defined __need_clock_t \
  23. || defined __need_timespec \
  24. || defined _@GUARD_PREFIX@_TIME_H)
  25. # @INCLUDE_NEXT@ @NEXT_TIME_H@
  26. #else
  27. # define _@GUARD_PREFIX@_TIME_H
  28. # @INCLUDE_NEXT@ @NEXT_TIME_H@
  29. /* NetBSD 5.0 mis-defines NULL. */
  30. # include <stddef.h>
  31. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  32. /* The definition of _GL_ARG_NONNULL is copied here. */
  33. /* The definition of _GL_WARN_ON_USE is copied here. */
  34. /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
  35. Or they define it with the wrong member names or define it in <sys/time.h>
  36. (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the
  37. pthreads-win32 library defines it in <pthread.h>. */
  38. # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
  39. # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
  40. # include <sys/time.h>
  41. # elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
  42. # include <pthread.h>
  43. /* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */
  44. # undef asctime_r
  45. # undef ctime_r
  46. # undef gmtime_r
  47. # undef localtime_r
  48. # undef rand_r
  49. # undef strtok_r
  50. # else
  51. # ifdef __cplusplus
  52. extern "C" {
  53. # endif
  54. # if !GNULIB_defined_struct_timespec
  55. # undef timespec
  56. # define timespec rpl_timespec
  57. struct timespec
  58. {
  59. time_t tv_sec;
  60. long int tv_nsec;
  61. };
  62. # define GNULIB_defined_struct_timespec 1
  63. # endif
  64. # ifdef __cplusplus
  65. }
  66. # endif
  67. # endif
  68. # endif
  69. # if !GNULIB_defined_struct_time_t_must_be_integral
  70. /* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
  71. time_t to be an integer type, even though C99 permits floating
  72. point. We don't know of any implementation that uses floating
  73. point, and it is much easier to write code that doesn't have to
  74. worry about that corner case, so we force the issue. */
  75. struct __time_t_must_be_integral {
  76. unsigned int __floating_time_t_unsupported : (time_t) 1;
  77. };
  78. # define GNULIB_defined_struct_time_t_must_be_integral 1
  79. # endif
  80. /* Sleep for at least RQTP seconds unless interrupted, If interrupted,
  81. return -1 and store the remaining time into RMTP. See
  82. <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
  83. # if @GNULIB_NANOSLEEP@
  84. # if @REPLACE_NANOSLEEP@
  85. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  86. # define nanosleep rpl_nanosleep
  87. # endif
  88. _GL_FUNCDECL_RPL (nanosleep, int,
  89. (struct timespec const *__rqtp, struct timespec *__rmtp)
  90. _GL_ARG_NONNULL ((1)));
  91. _GL_CXXALIAS_RPL (nanosleep, int,
  92. (struct timespec const *__rqtp, struct timespec *__rmtp));
  93. # else
  94. # if ! @HAVE_NANOSLEEP@
  95. _GL_FUNCDECL_SYS (nanosleep, int,
  96. (struct timespec const *__rqtp, struct timespec *__rmtp)
  97. _GL_ARG_NONNULL ((1)));
  98. # endif
  99. _GL_CXXALIAS_SYS (nanosleep, int,
  100. (struct timespec const *__rqtp, struct timespec *__rmtp));
  101. # endif
  102. _GL_CXXALIASWARN (nanosleep);
  103. # endif
  104. /* Return the 'time_t' representation of TP and normalize TP. */
  105. # if @GNULIB_MKTIME@
  106. # if @REPLACE_MKTIME@
  107. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  108. # define mktime rpl_mktime
  109. # endif
  110. _GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
  111. _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
  112. # else
  113. _GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
  114. # endif
  115. _GL_CXXALIASWARN (mktime);
  116. # endif
  117. /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
  118. <http://www.opengroup.org/susv3xsh/localtime_r.html> and
  119. <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
  120. # if @GNULIB_TIME_R@
  121. # if @REPLACE_LOCALTIME_R@
  122. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  123. # undef localtime_r
  124. # define localtime_r rpl_localtime_r
  125. # endif
  126. _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
  127. struct tm *restrict __result)
  128. _GL_ARG_NONNULL ((1, 2)));
  129. _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
  130. struct tm *restrict __result));
  131. # else
  132. # if ! @HAVE_DECL_LOCALTIME_R@
  133. _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
  134. struct tm *restrict __result)
  135. _GL_ARG_NONNULL ((1, 2)));
  136. # endif
  137. _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
  138. struct tm *restrict __result));
  139. # endif
  140. # if @HAVE_DECL_LOCALTIME_R@
  141. _GL_CXXALIASWARN (localtime_r);
  142. # endif
  143. # if @REPLACE_LOCALTIME_R@
  144. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  145. # undef gmtime_r
  146. # define gmtime_r rpl_gmtime_r
  147. # endif
  148. _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
  149. struct tm *restrict __result)
  150. _GL_ARG_NONNULL ((1, 2)));
  151. _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
  152. struct tm *restrict __result));
  153. # else
  154. # if ! @HAVE_DECL_LOCALTIME_R@
  155. _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
  156. struct tm *restrict __result)
  157. _GL_ARG_NONNULL ((1, 2)));
  158. # endif
  159. _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
  160. struct tm *restrict __result));
  161. # endif
  162. # if @HAVE_DECL_LOCALTIME_R@
  163. _GL_CXXALIASWARN (gmtime_r);
  164. # endif
  165. # endif
  166. /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
  167. the resulting broken-down time into TM. See
  168. <http://www.opengroup.org/susv3xsh/strptime.html>. */
  169. # if @GNULIB_STRPTIME@
  170. # if ! @HAVE_STRPTIME@
  171. _GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
  172. char const *restrict __format,
  173. struct tm *restrict __tm)
  174. _GL_ARG_NONNULL ((1, 2, 3)));
  175. # endif
  176. _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
  177. char const *restrict __format,
  178. struct tm *restrict __tm));
  179. _GL_CXXALIASWARN (strptime);
  180. # endif
  181. /* Convert TM to a time_t value, assuming UTC. */
  182. # if @GNULIB_TIMEGM@
  183. # if @REPLACE_TIMEGM@
  184. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  185. # undef timegm
  186. # define timegm rpl_timegm
  187. # endif
  188. _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
  189. _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
  190. # else
  191. # if ! @HAVE_TIMEGM@
  192. _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
  193. # endif
  194. _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
  195. # endif
  196. _GL_CXXALIASWARN (timegm);
  197. # endif
  198. /* Encourage applications to avoid unsafe functions that can overrun
  199. buffers when given outlandish struct tm values. Portable
  200. applications should use strftime (or even sprintf) instead. */
  201. # if defined GNULIB_POSIXCHECK
  202. # undef asctime
  203. _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
  204. "better use strftime (or even sprintf) instead");
  205. # endif
  206. # if defined GNULIB_POSIXCHECK
  207. # undef asctime_r
  208. _GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
  209. "better use strftime (or even sprintf) instead");
  210. # endif
  211. # if defined GNULIB_POSIXCHECK
  212. # undef ctime
  213. _GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
  214. "better use strftime (or even sprintf) instead");
  215. # endif
  216. # if defined GNULIB_POSIXCHECK
  217. # undef ctime_r
  218. _GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
  219. "better use strftime (or even sprintf) instead");
  220. # endif
  221. #endif