1 /* A more-standard <time.h>.
3 Copyright (C) 2007-2009 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 @PRAGMA_SYSTEM_HEADER@
23 /* Don't get in the way of glibc when it includes time.h merely to
24 declare a few standard symbols, rather than to declare all the
25 symbols. Also, Solaris 8 <time.h> eventually includes itself
26 recursively; if that is happening, just include the system <time.h>
27 without adding our own declarations. */
28 #if (defined __need_time_t || defined __need_clock_t \
29 || defined __need_timespec \
30 || defined _GL_TIME_H)
32 # @INCLUDE_NEXT@ @NEXT_TIME_H@
38 # @INCLUDE_NEXT@ @NEXT_TIME_H@
40 /* NetBSD 5.0 mis-defines NULL. */
47 /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
48 Or they define it with the wrong member names or define it in <sys/time.h>
49 (e.g., FreeBSD circa 1997). */
50 # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
51 # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
52 # include <sys/time.h>
55 # define timespec rpl_timespec
64 /* Sleep for at least RQTP seconds unless interrupted, If interrupted,
65 return -1 and store the remaining time into RMTP. See
66 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
67 # if @REPLACE_NANOSLEEP@
68 # define nanosleep rpl_nanosleep
69 int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
72 /* Return the 'time_t' representation of TP and normalize TP. */
74 # define mktime rpl_mktime
75 extern time_t mktime (struct tm *__tp);
78 /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
79 <http://www.opengroup.org/susv3xsh/localtime_r.html> and
80 <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
81 # if @REPLACE_LOCALTIME_R@
83 # define localtime_r rpl_localtime_r
85 # define gmtime_r rpl_gmtime_r
86 struct tm *localtime_r (time_t const *restrict __timer,
87 struct tm *restrict __result);
88 struct tm *gmtime_r (time_t const *restrict __timer,
89 struct tm *restrict __result);
92 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
93 the resulting broken-down time into TM. See
94 <http://www.opengroup.org/susv3xsh/strptime.html>. */
95 # if @REPLACE_STRPTIME@
97 # define strptime rpl_strptime
98 char *strptime (char const *restrict __buf, char const *restrict __format,
99 struct tm *restrict __tm);
102 /* Convert TM to a time_t value, assuming UTC. */
103 # if @REPLACE_TIMEGM@
105 # define timegm rpl_timegm
106 time_t timegm (struct tm *__tm);
109 /* Encourage applications to avoid unsafe functions that can overrun
110 buffers when given outlandish struct tm values. Portable
111 applications should use strftime (or even sprintf) instead. */
112 # if GNULIB_PORTCHECK
114 # define asctime eschew_asctime
116 # define asctime_r eschew_asctime_r
118 # define ctime eschew_ctime
120 # define ctime_r eschew_ctime_r