~ubuntu-branches/ubuntu/quantal/gnutls26/quantal

« back to all changes in this revision

Viewing changes to lib/gl/time.in.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-05-20 13:07:18 UTC
  • mfrom: (12.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110520130718-db41dybbanzfvlji
Tags: 2.10.5-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Fix build failure with --no-add-needed.
  - Build for multiarch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* A more-standard <time.h>.
2
2
 
3
 
   Copyright (C) 2007-2008 Free Software Foundation, Inc.
 
3
   Copyright (C) 2007-2010 Free Software Foundation, Inc.
4
4
 
5
5
   This program is free software; you can redistribute it and/or modify
6
6
   it under the terms of the GNU Lesser General Public License as published by
37
37
 
38
38
# @INCLUDE_NEXT@ @NEXT_TIME_H@
39
39
 
40
 
# ifdef __cplusplus
41
 
extern "C" {
42
 
# endif
 
40
/* NetBSD 5.0 mis-defines NULL.  */
 
41
# include <stddef.h>
 
42
 
 
43
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
44
 
 
45
/* The definition of _GL_ARG_NONNULL is copied here.  */
 
46
 
 
47
/* The definition of _GL_WARN_ON_USE is copied here.  */
43
48
 
44
49
/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
45
50
   Or they define it with the wrong member names or define it in <sys/time.h>
46
 
   (e.g., FreeBSD circa 1997).  */
 
51
   (e.g., FreeBSD circa 1997).  Stock Mingw does not define it, but the
 
52
   pthreads-win32 library defines it in <pthread.h>.  */
47
53
# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
48
54
#  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
49
55
#   include <sys/time.h>
 
56
#  elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
 
57
#   include <pthread.h>
 
58
/* The pthreads-win32 <pthread.h> also defines a couple of broken macros.  */
 
59
#   undef asctime_r
 
60
#   undef ctime_r
 
61
#   undef gmtime_r
 
62
#   undef localtime_r
 
63
#   undef rand_r
 
64
#   undef strtok_r
50
65
#  else
 
66
 
 
67
#   ifdef __cplusplus
 
68
extern "C" {
 
69
#   endif
 
70
 
51
71
#   undef timespec
52
72
#   define timespec rpl_timespec
53
73
struct timespec
55
75
  time_t tv_sec;
56
76
  long int tv_nsec;
57
77
};
 
78
 
 
79
#   ifdef __cplusplus
 
80
}
 
81
#   endif
 
82
 
58
83
#  endif
59
84
# endif
60
85
 
61
86
/* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
62
87
   return -1 and store the remaining time into RMTP.  See
63
88
   <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
64
 
# if @REPLACE_NANOSLEEP@
65
 
#  define nanosleep rpl_nanosleep
66
 
int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
 
89
# if @GNULIB_NANOSLEEP@
 
90
#  if @REPLACE_NANOSLEEP@
 
91
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
92
#    define nanosleep rpl_nanosleep
 
93
#   endif
 
94
_GL_FUNCDECL_RPL (nanosleep, int,
 
95
                  (struct timespec const *__rqtp, struct timespec *__rmtp)
 
96
                  _GL_ARG_NONNULL ((1)));
 
97
_GL_CXXALIAS_RPL (nanosleep, int,
 
98
                  (struct timespec const *__rqtp, struct timespec *__rmtp));
 
99
#  else
 
100
#   if ! @HAVE_NANOSLEEP@
 
101
_GL_FUNCDECL_SYS (nanosleep, int,
 
102
                  (struct timespec const *__rqtp, struct timespec *__rmtp)
 
103
                  _GL_ARG_NONNULL ((1)));
 
104
#   endif
 
105
_GL_CXXALIAS_SYS (nanosleep, int,
 
106
                  (struct timespec const *__rqtp, struct timespec *__rmtp));
 
107
#  endif
 
108
_GL_CXXALIASWARN (nanosleep);
 
109
# endif
 
110
 
 
111
/* Return the 'time_t' representation of TP and normalize TP.  */
 
112
# if @GNULIB_MKTIME@
 
113
#  if @REPLACE_MKTIME@
 
114
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
115
#    define mktime rpl_mktime
 
116
#   endif
 
117
_GL_FUNCDECL_RPL (mktime, time_t, (struct tm *__tp) _GL_ARG_NONNULL ((1)));
 
118
_GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
 
119
#  else
 
120
_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
 
121
#  endif
 
122
_GL_CXXALIASWARN (mktime);
67
123
# endif
68
124
 
69
125
/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
70
126
   <http://www.opengroup.org/susv3xsh/localtime_r.html> and
71
127
   <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
72
 
# if @REPLACE_LOCALTIME_R@
73
 
#  undef localtime_r
74
 
#  define localtime_r rpl_localtime_r
75
 
#  undef gmtime_r
76
 
#  define gmtime_r rpl_gmtime_r
77
 
struct tm *localtime_r (time_t const *restrict __timer,
78
 
                        struct tm *restrict __result);
79
 
struct tm *gmtime_r (time_t const *restrict __timer,
80
 
                     struct tm *restrict __result);
 
128
# if @GNULIB_TIME_R@
 
129
#  if @REPLACE_LOCALTIME_R@
 
130
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
131
#    undef localtime_r
 
132
#    define localtime_r rpl_localtime_r
 
133
#   endif
 
134
_GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
 
135
                                             struct tm *restrict __result)
 
136
                                            _GL_ARG_NONNULL ((1, 2)));
 
137
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
 
138
                                             struct tm *restrict __result));
 
139
#  else
 
140
#   if ! @HAVE_LOCALTIME_R@
 
141
_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
 
142
                                             struct tm *restrict __result)
 
143
                                            _GL_ARG_NONNULL ((1, 2)));
 
144
#   endif
 
145
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
 
146
                                             struct tm *restrict __result));
 
147
#  endif
 
148
_GL_CXXALIASWARN (localtime_r);
 
149
#  if @REPLACE_LOCALTIME_R@
 
150
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
151
#    undef gmtime_r
 
152
#    define gmtime_r rpl_gmtime_r
 
153
#   endif
 
154
_GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
 
155
                                          struct tm *restrict __result)
 
156
                                         _GL_ARG_NONNULL ((1, 2)));
 
157
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
 
158
                                          struct tm *restrict __result));
 
159
#  else
 
160
#   if ! @HAVE_LOCALTIME_R@
 
161
_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
 
162
                                          struct tm *restrict __result)
 
163
                                         _GL_ARG_NONNULL ((1, 2)));
 
164
#   endif
 
165
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
 
166
                                          struct tm *restrict __result));
 
167
#  endif
 
168
_GL_CXXALIASWARN (gmtime_r);
81
169
# endif
82
170
 
83
171
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
84
172
   the resulting broken-down time into TM.  See
85
173
   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
86
 
# if @REPLACE_STRPTIME@
87
 
#  undef strptime
88
 
#  define strptime rpl_strptime
89
 
char *strptime (char const *restrict __buf, char const *restrict __format,
90
 
                struct tm *restrict __tm);
 
174
# if @GNULIB_STRPTIME@
 
175
#  if ! @HAVE_STRPTIME@
 
176
_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
 
177
                                     char const *restrict __format,
 
178
                                     struct tm *restrict __tm)
 
179
                                    _GL_ARG_NONNULL ((1, 2, 3)));
 
180
#  endif
 
181
_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
 
182
                                     char const *restrict __format,
 
183
                                     struct tm *restrict __tm));
 
184
_GL_CXXALIASWARN (strptime);
91
185
# endif
92
186
 
93
187
/* Convert TM to a time_t value, assuming UTC.  */
94
 
# if @REPLACE_TIMEGM@
95
 
#  undef timegm
96
 
#  define timegm rpl_timegm
97
 
time_t timegm (struct tm *__tm);
 
188
# if @GNULIB_TIMEGM@
 
189
#  if @REPLACE_TIMEGM@
 
190
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
191
#    undef timegm
 
192
#    define timegm rpl_timegm
 
193
#   endif
 
194
_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
 
195
_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
 
196
#  else
 
197
#   if ! @HAVE_TIMEGM@
 
198
_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
 
199
#   endif
 
200
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
 
201
#  endif
 
202
_GL_CXXALIASWARN (timegm);
98
203
# endif
99
204
 
100
205
/* Encourage applications to avoid unsafe functions that can overrun
101
206
   buffers when given outlandish struct tm values.  Portable
102
207
   applications should use strftime (or even sprintf) instead.  */
103
 
# if GNULIB_PORTCHECK
 
208
# if defined GNULIB_POSIXCHECK
104
209
#  undef asctime
105
 
#  define asctime eschew_asctime
 
210
_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
 
211
                 "better use strftime (or even sprintf) instead");
 
212
# endif
 
213
# if defined GNULIB_POSIXCHECK
106
214
#  undef asctime_r
107
 
#  define asctime_r eschew_asctime_r
 
215
_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - "
 
216
                 "better use strftime (or even sprintf) instead");
 
217
# endif
 
218
# if defined GNULIB_POSIXCHECK
108
219
#  undef ctime
109
 
#  define ctime eschew_ctime
 
220
_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - "
 
221
                 "better use strftime (or even sprintf) instead");
 
222
# endif
 
223
# if defined GNULIB_POSIXCHECK
110
224
#  undef ctime_r
111
 
#  define ctime_r eschew_ctime_r
112
 
# endif
113
 
 
114
 
# ifdef __cplusplus
115
 
}
 
225
_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - "
 
226
                 "better use strftime (or even sprintf) instead");
116
227
# endif
117
228
 
118
229
#endif