-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathposix_time.h
42 lines (33 loc) · 1.03 KB
/
posix_time.h
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
#ifndef _TIME_SPEC_H_
#define _TIME_SPEC_H_
/* Windows lacks the nanosleep() function. The following code was stuffed
together from GNUlib (http://www.gnu.org/software/gnulib/), which is
licensed under the GPLv3. */
#include <time.h>
#include <errno.h>
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* Windows platforms. */
# ifdef __cplusplus
extern "C" {
# endif
struct timespec
{
time_t tv_sec;
long int tv_nsec;
};
# ifdef __cplusplus
}
# endif
enum { BILLION = 1000 * 1000 * 1000 };
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* The Win32 function Sleep() has a resolution of about 15 ms and takes
at least 5 ms to execute. We use this function for longer time periods.
Additionally, we use busy-looping over short time periods, to get a
resolution of about 0.01 ms. In order to measure such short timespans,
we use the QueryPerformanceCounter() function. */
int
nanosleep (const struct timespec *requested_delay,
struct timespec *remaining_delay);
#endif
#endif