diff options
author | 3gg <3gg@shellblade.net> | 2023-02-04 18:17:39 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-02-04 18:17:39 -0800 |
commit | 75abeca4a9d606bee89a41475f2f451187fec127 (patch) | |
tree | 348c29304d2500f87ebce81b5ce843793d53ee68 /timer | |
parent | 90183beeb914590a2ea4eff0242b813562d2d641 (diff) |
More compliance with C11.
Diffstat (limited to 'timer')
-rw-r--r-- | timer/include/timer.h | 4 | ||||
-rw-r--r-- | timer/src/timer.c | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/timer/include/timer.h b/timer/include/timer.h index a8a3f8b..b65f8d4 100644 --- a/timer/include/timer.h +++ b/timer/include/timer.h | |||
@@ -6,6 +6,10 @@ | |||
6 | #ifdef _WIN32 | 6 | #ifdef _WIN32 |
7 | typedef uint64_t time_point; | 7 | typedef uint64_t time_point; |
8 | #else | 8 | #else |
9 | // Need to macro to make CLOCK_REALTIME available when compiling with ISO C11. | ||
10 | // The constant is only needed in the source file, but the header file needs to | ||
11 | // include time.h too. | ||
12 | #define __USE_POSIX199309 | ||
9 | #include <time.h> | 13 | #include <time.h> |
10 | typedef struct timespec time_point; | 14 | typedef struct timespec time_point; |
11 | #endif | 15 | #endif |
diff --git a/timer/src/timer.c b/timer/src/timer.c index 0c33e51..da3485b 100644 --- a/timer/src/timer.c +++ b/timer/src/timer.c | |||
@@ -1,16 +1,15 @@ | |||
1 | #include "timer.h" | 1 | #include "timer.h" |
2 | 2 | ||
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | |||
5 | #ifdef _WIN32 | 4 | #ifdef _WIN32 |
6 | static const int64_t microseconds = 1000000; | 5 | #define WIN32_LEAN_AND_MEAN |
6 | #include <Windows.h> | ||
7 | #endif | 7 | #endif |
8 | static const int64_t nanoseconds = 1000000000; | ||
9 | 8 | ||
10 | #ifdef _WIN32 | 9 | #ifdef _WIN32 |
11 | #define WIN32_LEAN_AND_MEAN | 10 | static const int64_t microseconds = 1000000; |
12 | #include <Windows.h> | ||
13 | #endif | 11 | #endif |
12 | static const int64_t nanoseconds = 1000000000; | ||
14 | 13 | ||
15 | #ifdef _WIN32 | 14 | #ifdef _WIN32 |
16 | static double seconds_per_count; | 15 | static double seconds_per_count; |