Use Gnulib's `getaddrinfo' module.
[bpt/guile.git] / lib / time.in.h
CommitLineData
e65fc94b
LC
1/* A more-standard <time.h>.
2
61cd9dc9 3 Copyright (C) 2007-2010 Free Software Foundation, Inc.
e65fc94b
LC
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser 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. */
18
aa7a939c 19#if __GNUC__ >= 3
e65fc94b 20@PRAGMA_SYSTEM_HEADER@
aa7a939c 21#endif
e65fc94b
LC
22
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)
31
32# @INCLUDE_NEXT@ @NEXT_TIME_H@
33
34#else
35
36# define _GL_TIME_H
37
38# @INCLUDE_NEXT@ @NEXT_TIME_H@
39
8912421c
LC
40/* NetBSD 5.0 mis-defines NULL. */
41#include <stddef.h>
42
1cd4fffc
LC
43/* The definition of _GL_ARG_NONNULL is copied here. */
44
e65fc94b
LC
45# ifdef __cplusplus
46extern "C" {
47# endif
48
49/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
50 Or they define it with the wrong member names or define it in <sys/time.h>
51 (e.g., FreeBSD circa 1997). */
52# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
53# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
54# include <sys/time.h>
55# else
56# undef timespec
57# define timespec rpl_timespec
58struct timespec
59{
60 time_t tv_sec;
61 long int tv_nsec;
62};
63# endif
64# endif
65
66/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
67 return -1 and store the remaining time into RMTP. See
68 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
69# if @REPLACE_NANOSLEEP@
70# define nanosleep rpl_nanosleep
1cd4fffc
LC
71extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp)
72 _GL_ARG_NONNULL ((1));
e65fc94b
LC
73# endif
74
25361e4b
LC
75/* Return the 'time_t' representation of TP and normalize TP. */
76# if @REPLACE_MKTIME@
77# define mktime rpl_mktime
1cd4fffc 78extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1));
25361e4b
LC
79# endif
80
e65fc94b
LC
81/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
82 <http://www.opengroup.org/susv3xsh/localtime_r.html> and
83 <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */
84# if @REPLACE_LOCALTIME_R@
85# undef localtime_r
86# define localtime_r rpl_localtime_r
87# undef gmtime_r
88# define gmtime_r rpl_gmtime_r
1cd4fffc
LC
89extern struct tm *localtime_r (time_t const *restrict __timer,
90 struct tm *restrict __result)
91 _GL_ARG_NONNULL ((1, 2));
92extern struct tm *gmtime_r (time_t const *restrict __timer,
93 struct tm *restrict __result)
94 _GL_ARG_NONNULL ((1, 2));
e65fc94b
LC
95# endif
96
97/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
98 the resulting broken-down time into TM. See
99 <http://www.opengroup.org/susv3xsh/strptime.html>. */
100# if @REPLACE_STRPTIME@
101# undef strptime
102# define strptime rpl_strptime
1cd4fffc
LC
103extern char *strptime (char const *restrict __buf,
104 char const *restrict __format,
105 struct tm *restrict __tm)
106 _GL_ARG_NONNULL ((1, 2, 3));
e65fc94b
LC
107# endif
108
109/* Convert TM to a time_t value, assuming UTC. */
110# if @REPLACE_TIMEGM@
111# undef timegm
112# define timegm rpl_timegm
1cd4fffc 113extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1));
e65fc94b
LC
114# endif
115
116/* Encourage applications to avoid unsafe functions that can overrun
117 buffers when given outlandish struct tm values. Portable
118 applications should use strftime (or even sprintf) instead. */
119# if GNULIB_PORTCHECK
120# undef asctime
121# define asctime eschew_asctime
122# undef asctime_r
123# define asctime_r eschew_asctime_r
124# undef ctime
125# define ctime eschew_ctime
126# undef ctime_r
127# define ctime_r eschew_ctime_r
128# endif
129
130# ifdef __cplusplus
131}
132# endif
133
134#endif