ObjFW  Check-in [45b499fb11]

Overview
Comment:Use rint() instead of nearbyint().

nearbyint() is missing on some systems, even though it is part of C99
and POSIX.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 45b499fb11f79f534c1e618b6ca94476698f88ebf927668623e53ac9e6a2f0f6
User & Date: js on 2011-09-22 02:20:18
Other Links: manifest | tags
Context
2011-09-22
02:23
D'oh, stupid typo. check-in: 08700d08a6 user: js tags: trunk
02:20
Use rint() instead of nearbyint(). check-in: 45b499fb11 user: js tags: trunk
01:11
Add support for kqueue. check-in: 4f6270da38 user: js tags: trunk
Changes

Modified src/OFDate.m from [715fe07d58] to [a20bfc7333].

371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
	[element autorelease];

	return element;
}

- (uint32_t)microsecond
{
	return (uint32_t)nearbyint((seconds - floor(seconds)) * 1000000);
}

- (uint8_t)second
{
	GMTIME_RET(tm_sec)
}








|







371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
	[element autorelease];

	return element;
}

- (uint32_t)microsecond
{
	return (uint32_t)rint((seconds - floor(seconds)) * 1000000);
}

- (uint8_t)second
{
	GMTIME_RET(tm_sec)
}

Modified src/OFThread.m from [9734ed9f86] to [a10047f5e7].

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
		@throw [OFOutOfRangeException newWithClass: self];

#ifndef _WIN32
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	sleep((unsigned int)seconds);
	usleep((useconds_t)nearbyint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	Sleep((unsigned int)(seconds * 1000));
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	double seconds = [date timeIntervalSinceNow];

#ifndef _WIN32
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	sleep((unsigned int)seconds);
	usleep((useconds_t)nearbyint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	Sleep((unsigned int)(seconds * 1000));
#endif
}







|

















|







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
		@throw [OFOutOfRangeException newWithClass: self];

#ifndef _WIN32
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	sleep((unsigned int)seconds);
	usleep((useconds_t)rint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	Sleep((unsigned int)(seconds * 1000));
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	double seconds = [date timeIntervalSinceNow];

#ifndef _WIN32
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	sleep((unsigned int)seconds);
	usleep((useconds_t)rint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	Sleep((unsigned int)(seconds * 1000));
#endif
}