[vlc-commits] linux:thread: separate the code for mtime_to_ts()

Steve Lhomme git at videolan.org
Wed Jul 4 11:38:39 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jul  4 11:15:47 2018 +0200| [d418aafd8f7fe2b04053fbd58e4c368c43952db5] | committer: Steve Lhomme

linux:thread: separate the code for mtime_to_ts()

This function is defined multiple times. That may be something we want to share
throughout the code.

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

 src/linux/thread.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/linux/thread.c b/src/linux/thread.c
index 1d176b54f5..15e8a08439 100644
--- a/src/linux/thread.c
+++ b/src/linux/thread.c
@@ -78,10 +78,17 @@ void vlc_addr_wait(void *addr, unsigned val)
     vlc_futex_wait(addr, val, NULL);
 }
 
-bool vlc_addr_timedwait(void *addr, unsigned val, vlc_tick_t delay)
+static struct timespec mtime_to_ts (vlc_tick_t date)
 {
-    lldiv_t d = lldiv(delay, CLOCK_FREQ);
+    lldiv_t d = lldiv (date, CLOCK_FREQ);
     struct timespec ts = { d.quot, NS_FROM_VLC_TICK( d.rem ) };
 
+    return ts;
+}
+
+bool vlc_addr_timedwait(void *addr, unsigned val, vlc_tick_t delay)
+{
+    struct timespec ts = mtime_to_ts(delay);
+
     return (vlc_futex_wait(addr, val, &ts) == 0 || errno != ETIMEDOUT);
 }



More information about the vlc-commits mailing list