This commit is contained in:
Alexei Svitkine 2017-08-08 23:38:41 -04:00
commit bc7cd78467
2 changed files with 19 additions and 19 deletions

View File

@ -185,10 +185,10 @@ typedef char * caddr_t;
#endif #endif
/* Time data type for Time Manager emulation */ /* Time data type for Time Manager emulation */
#ifdef HAVE_CLOCK_GETTIME #if defined(__MACH__)
typedef struct timespec tm_time_t;
#elif defined(__MACH__)
typedef mach_timespec_t tm_time_t; typedef mach_timespec_t tm_time_t;
#elif defined(HAVE_CLOCK_GETTIME)
typedef struct timespec tm_time_t;
#else #else
typedef struct timeval tm_time_t; typedef struct timeval tm_time_t;
#endif #endif
@ -266,7 +266,7 @@ static inline int testandset(volatile int *p)
__asm__ __volatile__("0: cs %0,%1,0(%2)\n" __asm__ __volatile__("0: cs %0,%1,0(%2)\n"
" jl 0b" " jl 0b"
: "=&d" (ret) : "=&d" (ret)
: "r" (1), "a" (p), "0" (*p) : "r" (1), "a" (p), "0" (*p)
: "cc", "memory" ); : "cc", "memory" );
return ret; return ret;
} }
@ -315,7 +315,7 @@ static inline int testandset(volatile int *p)
__asm__ __volatile__("swp %0, %1, [%2]" __asm__ __volatile__("swp %0, %1, [%2]"
: "=r"(ret) : "=r"(ret)
: "0"(1), "r"(p)); : "0"(1), "r"(p));
return ret; return ret;
} }
#endif #endif

View File

@ -44,7 +44,7 @@ static inline void mach_current_time(tm_time_t &t) {
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &host_clock); host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &host_clock);
host_clock_inited = true; host_clock_inited = true;
} }
clock_get_time(host_clock, &t); clock_get_time(host_clock, &t);
} }
#endif #endif
@ -57,14 +57,14 @@ static inline void mach_current_time(tm_time_t &t) {
void Microseconds(uint32 &hi, uint32 &lo) void Microseconds(uint32 &hi, uint32 &lo)
{ {
D(bug("Microseconds\n")); D(bug("Microseconds\n"));
#if defined(HAVE_CLOCK_GETTIME) #if defined(__MACH__)
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
uint64 tl = (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000;
#elif defined(__MACH__)
tm_time_t t; tm_time_t t;
mach_current_time(t); mach_current_time(t);
uint64 tl = (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; uint64 tl = (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000;
#elif defined(HAVE_CLOCK_GETTIME)
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
uint64 tl = (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000;
#else #else
struct timeval t; struct timeval t;
gettimeofday(&t, NULL); gettimeofday(&t, NULL);
@ -91,10 +91,10 @@ uint32 TimerDateTime(void)
void timer_current_time(tm_time_t &t) void timer_current_time(tm_time_t &t)
{ {
#ifdef HAVE_CLOCK_GETTIME #if defined(__MACH__)
clock_gettime(CLOCK_REALTIME, &t);
#elif defined(__MACH__)
mach_current_time(t); mach_current_time(t);
#elif defined(HAVE_CLOCK_GETTIME)
clock_gettime(CLOCK_REALTIME, &t);
#else #else
gettimeofday(&t, NULL); gettimeofday(&t, NULL);
#endif #endif
@ -229,14 +229,14 @@ int32 timer_host2mac_time(tm_time_t hosttime)
uint64 GetTicks_usec(void) uint64 GetTicks_usec(void)
{ {
#ifdef HAVE_CLOCK_GETTIME #if defined(__MACH__)
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
return (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000;
#elif defined(__MACH__)
tm_time_t t; tm_time_t t;
mach_current_time(t); mach_current_time(t);
return (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; return (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000;
#elif defined(HAVE_CLOCK_GETTIME)
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
return (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000;
#else #else
struct timeval t; struct timeval t;
gettimeofday(&t, NULL); gettimeofday(&t, NULL);