1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
Description: add GNU extensions for struct tm.
This might be incomplete.
Omly localtime() and gmtime() work.
Index: libc/usr/src/head/iso/time_iso.h
===================================================================
--- libc.orig/usr/src/head/iso/time_iso.h
+++ libc/usr/src/head/iso/time_iso.h
@@ -45,7 +45,7 @@
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.18 */
-#include <sys/feature_tests.h>
+#include <features.h>
#ifdef __cplusplus
extern "C" {
@@ -94,9 +94,15 @@ struct tm { /* see ctime(3) */
int tm_wday;
int tm_yday;
int tm_isdst;
+#if defined (_BSD_SOURCE)
+ long tm_gmtoff;
+ const char *tm_zone;
+#else
+ long __tm_gmtoff;
+ const char *__tm_zone;
+#endif
};
-
#if defined(__STDC__)
extern char *asctime(const struct tm *);
@@ -105,11 +111,21 @@ extern char *ctime(const time_t *);
extern double difftime(time_t, time_t);
extern struct tm *gmtime(const time_t *);
extern struct tm *localtime(const time_t *);
-extern time_t mktime(struct tm *);
extern time_t time(time_t *);
extern size_t strftime(char *_RESTRICT_KYWD, size_t, const char *_RESTRICT_KYWD,
const struct tm *_RESTRICT_KYWD);
+#ifndef __IN_LIBC
+#ifdef __PRAGMA_REDEFINE_EXTNAME
+extern time_t mktime(struct tm *);
+#pragma redefine_extname mktime __gnu_mktime
+#else
+static time_t mktime(struct tm *___tm) {
+ return __gnu_mktime(___tm);
+}
+#endif
+#endif /* __IN_LIBC */
+
#else /* __STDC__ */
extern char *asctime();
Index: libc/usr/src/head/time.h
===================================================================
--- libc.orig/usr/src/head/time.h
+++ libc/usr/src/head/time.h
@@ -33,7 +33,7 @@
#ifndef _TIME_H
#define _TIME_H
-#include <sys/feature_tests.h>
+#include <features.h>
#include <iso/time_iso.h>
#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
(_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)
@@ -85,10 +85,27 @@ typedef int timer_t;
#if defined(__EXTENSIONS__) || \
(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
+
+#ifndef __IN_LIBC
+#ifdef __PRAGMA_REDEFINE_EXTNAME
extern struct tm *gmtime_r(const time_t *_RESTRICT_KYWD,
struct tm *_RESTRICT_KYWD);
extern struct tm *localtime_r(const time_t *_RESTRICT_KYWD,
struct tm *_RESTRICT_KYWD);
+#pragma redefine_extname gmtime_r __gnu_gmtime_r
+#pragma redefine_extname localtime_r __gnu_localtime_r
+#else /* ! __PRAGMA_REDEFINE_EXTNAME */
+static struct tm *gmtime_r(const time_t *_RESTRICT_KYWD __t,
+ struct tm *_RESTRICT_KYWD __tm) {
+ return __gnu_gmtime_r(__t, __tm);
+}
+static struct tm *localtime_r(const time_t *_RESTRICT_KYWD __t,
+ struct tm *_RESTRICT_KYWD __tm) {
+ return __gnu_localtime_r(__t, __tm);
+}
+#endif /* __PRAGMA_REDEFINE_EXTNAME */
+#endif /* __IN_LIBC */
+
#endif
#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
@@ -183,7 +200,18 @@ extern int daylight;
#if (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
defined(__EXTENSIONS__)
+
+#ifndef __IN_LIBC
+#ifdef __PRAGMA_REDEFINE_EXTNAME
extern time_t timegm(struct tm *);
+#pragma redefine_extname timegm __gnu_timegm
+#else /* ! __PRAGMA_REDEFINE_EXTNAME */
+static time_t timegm(struct tm *__tm) {
+ return __gnu_timegm(__tm);
+}
+#endif /* __PRAGMA_REDEFINE_EXTNAME */
+#endif /* __IN_LIBC */
+
extern int cftime(char *, char *, const time_t *);
extern int ascftime(char *, const char *, const struct tm *);
extern long altzone;
Index: libc/usr/src/lib/libc/port/gen/localtime.c
===================================================================
--- libc.orig/usr/src/lib/libc/port/gen/localtime.c
+++ libc/usr/src/lib/libc/port/gen/localtime.c
@@ -88,6 +88,8 @@
* Functions that are common to ctime(3C) and cftime(3C)
*/
+
+#define __IN_LIBC
#pragma weak _tzset = tzset
#undef TZDIR
@@ -488,6 +490,14 @@ gmtime_r(const time_t *timep, struct tm
return (offtime_u((time_t)*timep, 0L, p_tm));
}
+struct tm *
+__gnu_gmtime_r(const time_t *timep, struct tm *p_tm)
+{
+ p_tm->tm_gmtoff = 0;
+ p_tm->tm_zone = _tz_gmt;
+ return (offtime_u((time_t)*timep, 0L, p_tm));
+}
+
/*
* Accepts a time_t, returns a tm struct based on it, with
* no local timezone adjustment.
@@ -507,7 +517,7 @@ gmtime(const time_t *timep)
if (p_tm == NULL) /* memory allocation failure */
p_tm = &tm; /* use static buffer and hope for the best */
- return (gmtime_r(timep, p_tm));
+ return (__gnu_gmtime_r(timep, p_tm));
}
/*
@@ -649,6 +659,34 @@ localtime_r(const time_t *timep, struct
return (rt);
}
+struct tm *
+__gnu_localtime_r(const time_t *timep, struct tm *p_tm)
+{
+ long offset;
+ struct tm *rt;
+ void *unused;
+ int my_is_in_dst;
+
+ lmutex_lock(&_time_lock);
+ unused = ltzset_u(*timep);
+ if (lclzonep == NULL) {
+ lmutex_unlock(&_time_lock);
+ if (unused != NULL)
+ free(unused);
+ return (offtime_u(*timep, 0L, p_tm));
+ }
+ my_is_in_dst = is_in_dst;
+ offset = (my_is_in_dst) ? -altzone : -timezone;
+ p_tm->tm_gmtoff = offset;
+ p_tm->tm_zone = tzname[0];
+ lmutex_unlock(&_time_lock);
+ if (unused != NULL)
+ free(unused);
+ rt = offtime_u(*timep, offset, p_tm);
+ p_tm->tm_isdst = my_is_in_dst;
+ return (rt);
+}
+
/*
* Accepts a time_t, returns a tm struct based on it, correcting
* for the local timezone. Produces documented side-effects to
@@ -673,7 +711,7 @@ localtime(const time_t *timep)
if (p_tm == NULL) /* memory allocation failure */
p_tm = &tm; /* use static buffer and hope for the best */
- return (localtime_r(timep, p_tm));
+ return (__gnu_localtime_r(timep, p_tm));
}
/*
@@ -682,7 +720,7 @@ localtime(const time_t *timep)
* extern global zone state variables. (See mktime(3C)).
*/
static time_t
-mktime1(struct tm *tmptr, int usetz)
+mktime1(struct tm *tmptr, int usetz, int gnu)
{
struct tm _tm;
long long t; /* must hold more than 32-bit time_t */
@@ -823,7 +861,19 @@ mktime1(struct tm *tmptr, int usetz)
mketimerrno = EOVERFLOW;
t = -1;
} else {
- *tmptr = _tm;
+ if (gnu)
+ *tmptr = _tm;
+ else {
+ tmptr->tm_sec = _tm.tm_sec;
+ tmptr->tm_min = _tm.tm_min;
+ tmptr->tm_hour = _tm.tm_hour;
+ tmptr->tm_mday = _tm.tm_mday;
+ tmptr->tm_mon = _tm.tm_mon;
+ tmptr->tm_year = _tm.tm_year;
+ tmptr->tm_wday = _tm.tm_wday;
+ tmptr->tm_yday = _tm.tm_yday;
+ tmptr->tm_isdst = _tm.tm_isdst;
+ }
}
lmutex_unlock(&_time_lock);
@@ -837,15 +887,26 @@ mktime1(struct tm *tmptr, int usetz)
time_t
mktime(struct tm *tmptr)
{
- return (mktime1(tmptr, TRUE));
+ return (mktime1(tmptr, TRUE, 0));
}
time_t
timegm(struct tm *tmptr)
{
- return (mktime1(tmptr, FALSE));
+ return (mktime1(tmptr, FALSE, 0));
}
+time_t
+__gnu_mktime(struct tm *tmptr)
+{
+ return (mktime1(tmptr, TRUE, 1));
+}
+
+time_t
+__gnu_timegm(struct tm *tmptr)
+{
+ return (mktime1(tmptr, FALSE, 1));
+}
/*
* Sets extern global zone state variables based on the current
Index: libc/usr/src/lib/libc/port/mapfile-vers
===================================================================
--- libc.orig/usr/src/lib/libc/port/mapfile-vers
+++ libc/usr/src/lib/libc/port/mapfile-vers
@@ -120,6 +120,10 @@ SYMBOL_VERSION ILLUMOS_0.4 { # Illumos a
SYMBOL_VERSION DYSON_1 {
global:
+ __gnu_gmtime_r;
+ __gnu_localtime_r;
+ __gnu_mktime;
+ __gnu_timegm;
_so_accept4;
cfmakeraw;
error;
|