[vlc-commits] threads: convert nanoseconds to ticks using VLC_TICK_FROM_NS()

Steve Lhomme git at videolan.org
Tue Jul 3 15:30:53 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jul  3 15:21:05 2018 +0200| [9bfe0cb651bec20edbcc29846f94c97f71324b80] | committer: Steve Lhomme

threads: convert nanoseconds to ticks using VLC_TICK_FROM_NS()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9bfe0cb651bec20edbcc29846f94c97f71324b80
---

 src/android/thread.c | 2 +-
 src/misc/threads.c   | 2 +-
 src/posix/thread.c   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/android/thread.c b/src/android/thread.c
index bdd97af3d7..eed3c0eab9 100644
--- a/src/android/thread.c
+++ b/src/android/thread.c
@@ -417,7 +417,7 @@ vlc_tick_t vlc_tick_now (void)
         abort ();
 
     static_assert(INT64_C(1000000) == CLOCK_FREQ, "CLOCK_FREQ mismatch");
-    return vlc_tick_from_sec( ts.tv_sec ) + (ts.tv_nsec / 1000);
+    return vlc_tick_from_sec( ts.tv_sec ) + VLC_TICK_FROM_NS( ts.tv_nsec );
 }
 
 /* cpu */
diff --git a/src/misc/threads.c b/src/misc/threads.c
index de648d51b6..b34d28add5 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -219,7 +219,7 @@ int vlc_cond_timedwait_daytime(vlc_cond_t *cond, vlc_mutex_t *mutex,
 
     timespec_get(&ts, TIME_UTC);
     deadline -= vlc_tick_from_sec( ts.tv_sec );
-    deadline -= ts.tv_nsec / (1000000000 / CLOCK_FREQ);
+    deadline -= VLC_TICK_FROM_NS( ts.tv_nsec );
 
     return vlc_cond_wait_delay(cond, mutex, deadline);
 }
diff --git a/src/posix/thread.c b/src/posix/thread.c
index a33ee412db..425bd32b69 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -586,7 +586,7 @@ vlc_tick_t vlc_tick_now (void)
         abort ();
 
     static_assert(INT64_C(1000000) == CLOCK_FREQ, "CLOCK_FREQ mismatch");
-    return vlc_tick_from_sec( ts.tv_sec ) + (ts.tv_nsec / 1000);
+    return vlc_tick_from_sec( ts.tv_sec ) + VLC_TICK_FROM_NS( ts.tv_nsec );
 }
 
 #undef vlc_tick_wait



More information about the vlc-commits mailing list