mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fix current_time_monotonic on OS X.
clock_gettime doesn't exist there, so throw in some equivalent mach stuff.
This commit is contained in:
parent
77d2ad373a
commit
28c5665a08
|
@ -33,6 +33,12 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <mach/clock.h>
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sodium.h>
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -229,6 +235,16 @@ uint64_t current_time_monotonic(void)
|
||||||
struct timespec monotime;
|
struct timespec monotime;
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
clock_gettime(CLOCK_MONOTONIC_RAW, &monotime);
|
clock_gettime(CLOCK_MONOTONIC_RAW, &monotime);
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
clock_serv_t muhclock;
|
||||||
|
mach_timespec_t machtime;
|
||||||
|
|
||||||
|
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &muhclock);
|
||||||
|
clock_get_time(muhclock, &machtime);
|
||||||
|
mach_port_deallocate(mach_task_self(), muhclock);
|
||||||
|
|
||||||
|
monotime.tv_sec = machtime.tv_sec;
|
||||||
|
monotime.tv_nsec = machtime.tv_nsec;
|
||||||
#else
|
#else
|
||||||
clock_gettime(CLOCK_MONOTONIC, &monotime);
|
clock_gettime(CLOCK_MONOTONIC, &monotime);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user