time.in.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* A more-standard <time.h>.
  2. Copyright (C) 2007-2008 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, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. #if __GNUC__ >= 3
  15. @PRAGMA_SYSTEM_HEADER@
  16. #endif
  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 _GL_TIME_H)
  25. # @INCLUDE_NEXT@ @NEXT_TIME_H@
  26. #else
  27. # define _GL_TIME_H
  28. # @INCLUDE_NEXT@ @NEXT_TIME_H@
  29. # ifdef __cplusplus
  30. extern "C" {
  31. # endif
  32. /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
  33. Or they define it with the wrong member names or define it in <sys/time.h>
  34. (e.g., FreeBSD circa 1997). */
  35. # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
  36. # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
  37. # include <sys/time.h>
  38. # else
  39. # undef timespec
  40. # define timespec rpl_timespec
  41. struct timespec
  42. {
  43. time_t tv_sec;
  44. long int tv_nsec;
  45. };
  46. # endif
  47. # endif
  48. /* Sleep for at least RQTP seconds unless interrupted, If interrupted,
  49. return -1 and store the remaining time into RMTP. See
  50. <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
  51. # if @REPLACE_NANOSLEEP@
  52. # define nanosleep rpl_nanosleep
  53. int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
  54. # endif
  55. /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
  56. <http://www.opengroup.org/susv3xsh/localtime_r.html> and
  57. <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
  58. # if @REPLACE_LOCALTIME_R@
  59. # undef localtime_r
  60. # define localtime_r rpl_localtime_r
  61. # undef gmtime_r
  62. # define gmtime_r rpl_gmtime_r
  63. struct tm *localtime_r (time_t const *restrict __timer,
  64. struct tm *restrict __result);
  65. struct tm *gmtime_r (time_t const *restrict __timer,
  66. struct tm *restrict __result);
  67. # endif
  68. /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
  69. the resulting broken-down time into TM. See
  70. <http://www.opengroup.org/susv3xsh/strptime.html>. */
  71. # if @REPLACE_STRPTIME@
  72. # undef strptime
  73. # define strptime rpl_strptime
  74. char *strptime (char const *restrict __buf, char const *restrict __format,
  75. struct tm *restrict __tm);
  76. # endif
  77. /* Convert TM to a time_t value, assuming UTC. */
  78. # if @REPLACE_TIMEGM@
  79. # undef timegm
  80. # define timegm rpl_timegm
  81. time_t timegm (struct tm *__tm);
  82. # endif
  83. /* Encourage applications to avoid unsafe functions that can overrun
  84. buffers when given outlandish struct tm values. Portable
  85. applications should use strftime (or even sprintf) instead. */
  86. # if GNULIB_PORTCHECK
  87. # undef asctime
  88. # define asctime eschew_asctime
  89. # undef asctime_r
  90. # define asctime_r eschew_asctime_r
  91. # undef ctime
  92. # define ctime eschew_ctime
  93. # undef ctime_r
  94. # define ctime_r eschew_ctime_r
  95. # endif
  96. # ifdef __cplusplus
  97. }
  98. # endif
  99. #endif