[vlc-devel] [PATCH] core: fix vlc_tick_now on darwin platform
Zhao Zhili
quinkblack at foxmail.com
Thu Sep 27 05:42:28 CEST 2018
---
src/darwin/thread.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/src/darwin/thread.c b/src/darwin/thread.c
index f5eb4f2..0dd1e3c 100644
--- a/src/darwin/thread.c
+++ b/src/darwin/thread.c
@@ -516,14 +516,10 @@ vlc_tick_t vlc_tick_now (void)
vlc_clock_setup();
uint64_t date = mach_absolute_time();
- /* denom is uint32_t, switch to 64 bits to prevent overflow. */
- uint64_t denom = vlc_clock_conversion_factor.denom;
-
- /* Switch to microsecs */
- denom *= UINT64_C(1000);
-
/* Split the division to prevent overflow */
- return vlc_tick_from_frac( date * vlc_clock_conversion_factor.numer, denom );
+ lldiv_t d = lldiv (vlc_clock_conversion_factor.numer, vlc_clock_conversion_factor.denom);
+ date = (d.quot * date) + ((d.rem * date) / vlc_clock_conversion_factor.denom);
+ return VLC_TICK_FROM_NS(date);
}
#undef vlc_tick_wait
--
2.9.5
More information about the vlc-devel
mailing list