diff options
-rw-r--r-- | toxcore/network.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/toxcore/network.c b/toxcore/network.c index 0505091d..2ffe067f 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -33,6 +33,12 @@ | |||
33 | #include <errno.h> | 33 | #include <errno.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #ifdef __APPLE__ | ||
37 | #include <mach/clock.h> | ||
38 | #include <mach/mach.h> | ||
39 | #endif | ||
40 | |||
41 | #include <sodium.h> | ||
36 | #include "network.h" | 42 | #include "network.h" |
37 | #include "util.h" | 43 | #include "util.h" |
38 | 44 | ||
@@ -229,6 +235,16 @@ uint64_t current_time_monotonic(void) | |||
229 | struct timespec monotime; | 235 | struct timespec monotime; |
230 | #if defined(__linux__) | 236 | #if defined(__linux__) |
231 | clock_gettime(CLOCK_MONOTONIC_RAW, &monotime); | 237 | clock_gettime(CLOCK_MONOTONIC_RAW, &monotime); |
238 | #elif defined(__APPLE__) | ||
239 | clock_serv_t muhclock; | ||
240 | mach_timespec_t machtime; | ||
241 | |||
242 | host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &muhclock); | ||
243 | clock_get_time(muhclock, &machtime); | ||
244 | mach_port_deallocate(mach_task_self(), muhclock); | ||
245 | |||
246 | monotime.tv_sec = machtime.tv_sec; | ||
247 | monotime.tv_nsec = machtime.tv_nsec; | ||
232 | #else | 248 | #else |
233 | clock_gettime(CLOCK_MONOTONIC, &monotime); | 249 | clock_gettime(CLOCK_MONOTONIC, &monotime); |
234 | #endif | 250 | #endif |