Overview
Context
Changes
Modified src/OFDate.m
from [08b8759c25]
to [ede0d16dc4].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
+
-
+
-
+
|
# import "OFThread.h"
static OFMutex *mutex;
#endif
#ifdef HAVE_GMTIME_R
# define GMTIME_RET(field) \
time_t sec_ = sec; \
time_t sec_ = (time_t)sec; \
struct tm tm; \
\
if (sec != sec_) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
if (gmtime_r(&sec_, &tm) == NULL) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
return tm.field;
# define LOCALTIME_RET(field) \
time_t sec_ = sec; \
time_t sec_ = (time_t)sec; \
struct tm tm; \
\
if (sec != sec_) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
if (localtime_r(&sec_, &tm) == NULL) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
return tm.field;
#else
# ifdef OF_THREADS
# define GMTIME_RET(field) \
time_t sec_ = sec; \
time_t sec_ = (time_t)sec; \
struct tm *tm; \
\
if (sec != sec_) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
[mutex lock]; \
\
@try { \
if ((tm = gmtime(&sec_)) == NULL) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
return tm->field; \
} @finally { \
[mutex unlock]; \
}
# define LOCALTIME_RET(field) \
time_t sec_ = sec; \
time_t sec_ = (time_t)sec; \
struct tm *tm; \
\
if (sec != sec_) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
[mutex lock]; \
\
@try { \
if ((tm = localtime(&sec_)) == NULL) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
return tm->field; \
} @finally { \
[mutex unlock]; \
}
# else
# define GMTIME_RET(field) \
time_t sec_ = sec; \
time_t sec_ = (time_t)sec; \
struct tm *tm; \
\
if (sec != sec_) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
if ((tm = gmtime(&sec_)) == NULL) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
return tm->field;
# define LOCALTIME_RET(field) \
time_t sec_ = sec; \
time_t sec_ = (time_t)sec; \
struct tm *tm; \
\
if (sec != sec_) \
@throw [OFOutOfRangeException newWithClass: isa]; \
\
if ((tm = localtime(&sec_)) == NULL) \
@throw [OFOutOfRangeException newWithClass: isa]; \
|
︙ | | |
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
-
+
|
if (gettimeofday(&t, NULL)) {
Class c = isa;
[self release];
@throw [OFInitializationFailedException newWithClass: c];
}
return [self initWithTimeIntervalSince1970: t.tv_sec
microseconds: t.tv_usec];
microseconds: (uint32_t)t.tv_usec];
}
- initWithTimeIntervalSince1970: (int64_t)sec_
{
return [self initWithTimeIntervalSince1970: sec_
microseconds: 0];
}
|
︙ | | |
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
-
+
|
{
LOCALTIME_RET(tm_yday + 1)
}
- (OFString*)dateStringWithFormat: (OFString*)fmt
{
OFString *ret;
time_t sec_ = sec;
time_t sec_ = (time_t)sec;
struct tm tm;
char *buf;
if (sec != sec_)
@throw [OFOutOfRangeException newWithClass: isa];
#ifdef HAVE_GMTIME_R
|
︙ | | |
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
|
-
+
|
return ret;
}
- (OFString*)localDateStringWithFormat: (OFString*)fmt
{
OFString *ret;
time_t sec_ = sec;
time_t sec_ = (time_t)sec;
struct tm tm;
char *buf;
if (sec != sec_)
@throw [OFOutOfRangeException newWithClass: isa];
#ifdef HAVE_LOCALTIME_R
|
︙ | | |
Modified src/objc_sync.m
from [609aa012a7]
to [4107e88ea3].
︙ | | |
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
|
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
|
-
+
-
+
|
size_t recursion;
of_thread_t thread;
of_mutex_t mutex;
};
static of_mutex_t mutex;
static struct locks_s *locks = NULL;
static size_t num_locks = 0;
static ssize_t num_locks = 0;
#define SYNC_ERR(f) \
{ \
fprintf(stderr, "WARNING: %s failed in line %d!\n" \
"WARNING: This might result in a race " \
"condition!\n", f, __LINE__); \
return 1; \
}
BOOL
objc_sync_init()
{
return (of_mutex_new(&mutex) ? YES : NO);
}
int
objc_sync_enter(id obj)
{
int i;
ssize_t i;
if (obj == nil)
return 0;
if (!of_mutex_lock(&mutex))
SYNC_ERR("of_mutex_lock(&mutex)");
|
︙ | | |
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
-
+
|
return 0;
}
int
objc_sync_exit(id obj)
{
int i;
ssize_t i;
if (obj == nil)
return 0;
if (!of_mutex_lock(&mutex))
SYNC_ERR("of_mutex_lock(&mutex)");
|
︙ | | |