ObjFW  Check-in [06255a6aa8]

Overview
Comment:Don't use nanosleep() on Nintendo 3DS

It exists, but it just crashes.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 06255a6aa839b9b0849ab8f61bb49bd44a59c6236cdd005e723472cd46fae061
User & Date: js on 2018-08-19 01:13:36
Other Links: manifest | tags
Context
2018-08-19
02:12
Several path handling improvements and more tests check-in: 9e8164519c user: js tags: trunk
01:13
Don't use nanosleep() on Nintendo 3DS check-in: 06255a6aa8 user: js tags: trunk
01:04
Do not use lstat() on Nintendo 3DS check-in: c162213e4a user: js tags: trunk
Changes

Modified src/OFThread.m from [b00f8ab9a5] to [3b2a0f4201].

253
254
255
256
257
258
259





260
261
262
263
264
265
266
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271







+
+
+
+
+







		return;

#if defined(OF_WINDOWS)
	if (timeInterval * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	Sleep((unsigned int)(timeInterval * 1000));
#elif defined(OF_NINTENDO_3DS)
	if (timeInterval * 1000000000 > INT64_MAX)
		@throw [OFOutOfRangeException exception];

	svcSleepThread((int64_t)(timeInterval * 1000000000));
#elif defined(HAVE_NANOSLEEP)
	struct timespec rqtp;

	rqtp.tv_sec = (time_t)timeInterval;
	rqtp.tv_nsec = lrint((timeInterval - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != trunc(timeInterval))
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
282
283
284
285
286
287
288





289
290
291
292
293
294
295







-
-
-
-
-








	if (timeInterval > UINT64_MAX / 60)
		@throw [OFOutOfRangeException exception];

	counter = timeInterval * 60;
	while (counter--)
		swiWaitForVBlank();
#elif defined(OF_NINTENDO_3DS)
	if (timeInterval * 1000000000 > INT64_MAX)
		@throw [OFOutOfRangeException exception];

	svcSleepThread((int64_t)(timeInterval * 1000000000));
#else
	if (timeInterval > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	sleep((unsigned int)timeInterval);
	usleep((unsigned int)lrint(
	    (timeInterval - trunc(timeInterval)) * 1000000));