vlc | branch: master | Steve Lhomme <[email protected]> | Wed Jul 4 11:20:49 2018 +0200| [62dce674cff264e101d0524c37d6968ea720a2d5] | committer: Steve Lhomme
core: factorize mtime_to_ts() in mtime.c > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=62dce674cff264e101d0524c37d6968ea720a2d5 --- include/vlc_tick.h | 2 ++ src/darwin/thread.c | 8 -------- src/linux/thread.c | 8 -------- src/misc/mtime.c | 9 +++++++++ src/posix/thread.c | 8 -------- 5 files changed, 11 insertions(+), 24 deletions(-) diff --git a/include/vlc_tick.h b/include/vlc_tick.h index 7de78ec402..25d070e3ea 100644 --- a/include/vlc_tick.h +++ b/include/vlc_tick.h @@ -165,6 +165,8 @@ static inline vlc_tick_t vlc_tick_from_timeval(const struct timeval *tv) return vlc_tick_from_sec( tv->tv_sec ) + VLC_TICK_FROM_US( tv->tv_usec ); } +struct timespec mtime_to_ts (vlc_tick_t date); + /***************************************************************************** * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime diff --git a/src/darwin/thread.c b/src/darwin/thread.c index d5f935464b..b6ac92af77 100644 --- a/src/darwin/thread.c +++ b/src/darwin/thread.c @@ -55,14 +55,6 @@ static pthread_once_t vlc_clock_once = PTHREAD_ONCE_INIT; #define vlc_clock_setup() \ pthread_once(&vlc_clock_once, vlc_clock_setup_once) -static struct timespec mtime_to_ts (vlc_tick_t date) -{ - lldiv_t d = lldiv (date, CLOCK_FREQ); - struct timespec ts = { d.quot, NS_FROM_VLC_TICK( d.rem ) }; - - return ts; -} - /* Print a backtrace to the standard error for debugging purpose. */ void vlc_trace (const char *fn, const char *file, unsigned line) { diff --git a/src/linux/thread.c b/src/linux/thread.c index 15e8a08439..f535602658 100644 --- a/src/linux/thread.c +++ b/src/linux/thread.c @@ -78,14 +78,6 @@ void vlc_addr_wait(void *addr, unsigned val) vlc_futex_wait(addr, val, NULL); } -static struct timespec mtime_to_ts (vlc_tick_t date) -{ - 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); diff --git a/src/misc/mtime.c b/src/misc/mtime.c index ac852541c6..5e428c4ad9 100644 --- a/src/misc/mtime.c +++ b/src/misc/mtime.c @@ -37,6 +37,7 @@ #include <assert.h> #include <time.h> +#include <stdlib.h> /** * Convert seconds to a time in the format h:mm:ss. @@ -154,3 +155,11 @@ uint64_t NTPtime64(void) t |= ((UINT64_C(70) * 365 + 17) * 24 * 60 * 60 + ts.tv_sec) << 32; return t; } + +struct timespec mtime_to_ts (vlc_tick_t date) +{ + lldiv_t d = lldiv (date, CLOCK_FREQ); + struct timespec ts = { d.quot, NS_FROM_VLC_TICK( d.rem ) }; + + return ts; +} diff --git a/src/posix/thread.c b/src/posix/thread.c index 14220bb47a..74f7d36c3b 100644 --- a/src/posix/thread.c +++ b/src/posix/thread.c @@ -61,14 +61,6 @@ static void vlc_clock_setup_once (void) vlc_clock_prec = (res.tv_nsec + 500) / 1000; } -static struct timespec mtime_to_ts (vlc_tick_t date) -{ - lldiv_t d = lldiv (date, CLOCK_FREQ); - struct timespec ts = { d.quot, NS_FROM_VLC_TICK( d.rem ) }; - - return ts; -} - /** * Print a backtrace to the standard error for debugging purpose. */ _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
