Don't use a static mtid
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
12
mud.c
12
mud.c
@@ -161,6 +161,9 @@ struct mud {
|
|||||||
uint64_t window;
|
uint64_t window;
|
||||||
uint64_t window_time;
|
uint64_t window_time;
|
||||||
uint64_t base_time;
|
uint64_t base_time;
|
||||||
|
#if defined __APPLE__
|
||||||
|
mach_timebase_info_data_t mtid;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -306,11 +309,8 @@ static uint64_t
|
|||||||
mud_now(struct mud *mud)
|
mud_now(struct mud *mud)
|
||||||
{
|
{
|
||||||
#if defined __APPLE__
|
#if defined __APPLE__
|
||||||
static mach_timebase_info_data_t mtid;
|
|
||||||
if (!mtid.denom)
|
|
||||||
mach_timebase_info(&mtid);
|
|
||||||
return MUD_TIME_MASK(mud->base_time
|
return MUD_TIME_MASK(mud->base_time
|
||||||
+ (mach_absolute_time() * mtid.numer / mtid.denom)
|
+ (mach_absolute_time() * mud->mtid.numer / mud->mtid.denom)
|
||||||
/ 1000ULL);
|
/ 1000ULL);
|
||||||
#elif defined CLOCK_MONOTONIC
|
#elif defined CLOCK_MONOTONIC
|
||||||
struct timespec tv;
|
struct timespec tv;
|
||||||
@@ -938,6 +938,10 @@ mud_create(struct sockaddr *addr)
|
|||||||
|
|
||||||
memcpy(&mud->addr, addr, addrlen);
|
memcpy(&mud->addr, addr, addrlen);
|
||||||
|
|
||||||
|
#if defined __APPLE__
|
||||||
|
mach_timebase_info(&mud->mtid);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint64_t now = mud_now(mud);
|
uint64_t now = mud_now(mud);
|
||||||
uint64_t base_time = mud_time();
|
uint64_t base_time = mud_time();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user