1 #include "test/jemalloc_test.h"
2 
3 /*
4  * Sleep for approximately ns nanoseconds.  No lower *nor* upper bound on sleep
5  * time is guaranteed.
6  */
7 void
mq_nanosleep(unsigned ns)8 mq_nanosleep(unsigned ns)
9 {
10 
11 	assert(ns <= 1000*1000*1000);
12 
13 #ifdef _WIN32
14 	Sleep(ns / 1000);
15 #else
16 	{
17 		struct timespec timeout;
18 
19 		if (ns < 1000*1000*1000) {
20 			timeout.tv_sec = 0;
21 			timeout.tv_nsec = ns;
22 		} else {
23 			timeout.tv_sec = 1;
24 			timeout.tv_nsec = 0;
25 		}
26 		nanosleep(&timeout, NULL);
27 	}
28 #endif
29 }
30