aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/system/Clock.cxx8
2 files changed, 5 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index e7a80b964..9cd558070 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
ver 0.18.23 (not yet released)
* despotify: remove defunct plugin
+* fix clock integer overflow on OS X
* fix gcc 5.0 warnings
ver 0.18.22 (2014/01/14)
diff --git a/src/system/Clock.cxx b/src/system/Clock.cxx
index 347997a44..916bda56c 100644
--- a/src/system/Clock.cxx
+++ b/src/system/Clock.cxx
@@ -40,8 +40,8 @@ MonotonicClockMS(void)
if (base.denom == 0)
(void)mach_timebase_info(&base);
- return (unsigned)((mach_absolute_time() * base.numer)
- / (1000000 * base.denom));
+ return (unsigned)(((double)mach_absolute_time() * base.numer)
+ / base.denom / 1000000);
#elif defined(CLOCK_MONOTONIC)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -82,8 +82,8 @@ MonotonicClockUS(void)
if (base.denom == 0)
(void)mach_timebase_info(&base);
- return ((uint64_t)mach_absolute_time() * (uint64_t)base.numer)
- / (1000 * (uint64_t)base.denom);
+ return (uint64_t)(((double)mach_absolute_time() * base.numer)
+ / base.denom / 1000);
#elif defined(CLOCK_MONOTONIC)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);