[vlc-commits] [Git][videolan/vlc][master] 3 commits: tick: add vlc_tick_to_timespec()
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Wed Mar 30 07:29:41 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
70228951 by Rémi Denis-Courmont at 2022-03-30T07:18:29+00:00
tick: add vlc_tick_to_timespec()
This is essentially the same as timespec_to_vlc_tick() but it does not
clobber the namespace, so it can be exported.
- - - - -
cd193332 by Rémi Denis-Courmont at 2022-03-30T07:18:29+00:00
src: use vlc_tick_to_timespec()
- - - - -
b18dda38 by Rémi Denis-Courmont at 2022-03-30T07:18:29+00:00
tick: remove timespec_from_vlc_tick()
- - - - -
7 changed files:
- include/vlc_tick.h
- src/freebsd/thread.c
- src/libvlccore.sym
- src/linux/thread.c
- src/misc/mtime.c
- src/posix/thread.c
- src/posix/wait.c
Changes:
=====================================
include/vlc_tick.h
=====================================
@@ -31,6 +31,8 @@
#ifndef __VLC_MTIME_H
# define __VLC_MTIME_H 1
+struct timespec;
+
/**
* High precision date or time interval
*
@@ -186,8 +188,15 @@ typedef int64_t msftime_t;
#define vlc_tick_from_timespec(tv) \
(vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_NS( (tv)->tv_nsec ))
-struct timespec timespec_from_vlc_tick(vlc_tick_t date);
-
+/**
+ * Converts a VLC tick to a POSIX time specification.
+ *
+ * \param ts [out] storage space for the time specification
+ * \param tick VLC tick
+ * \return @c ts
+ */
+VLC_API struct timespec *vlc_tick_to_timespec(struct timespec *restrict ts,
+ vlc_tick_t tick);
/*****************************************************************************
* MSTRTIME_MAX_SIZE: maximum possible size of vlc_tick_to_str
=====================================
src/freebsd/thread.c
=====================================
@@ -84,8 +84,8 @@ void vlc_atomic_wait(void *addr, unsigned val)
int vlc_atomic_timedwait(void *addr, unsigned val, vlc_tick_t deadline)
{
- struct timespec ts = timespec_from_vlc_tick(delay);
- int ret = vlc_umtx_wait(addr, val, &ts);
+ struct timespec ts;
+ int ret = vlc_umtx_wait(addr, val, vlc_tick_to_timespec(&ts, deadline));
assert(ret == 0 || ret == ETIMEDOUT || ret == EINTR || ret == ERESTART);
return (ret != ETIMEDOUT) ? 0 : ret;
=====================================
src/libvlccore.sym
=====================================
@@ -255,6 +255,7 @@ vlc_uri_resolve
vlc_uri_fixup
vlc_tick_now
vlc_tick_to_str
+vlc_tick_to_timespec
module_config_free
module_config_get
module_find
=====================================
src/linux/thread.c
=====================================
@@ -105,9 +105,9 @@ void vlc_atomic_wait(void *addr, unsigned val)
int vlc_atomic_timedwait(void *addr, unsigned val, vlc_tick_t deadline)
{
- struct timespec ts = timespec_from_vlc_tick(deadline);
+ struct timespec ts;
- if (vlc_futex_wait(addr, 0, val, &ts) == 0)
+ if (vlc_futex_wait(addr, 0, val, vlc_tick_to_timespec(&ts, deadline)) == 0)
return 0;
switch (errno) {
=====================================
src/misc/mtime.c
=====================================
@@ -144,10 +144,12 @@ uint64_t NTPtime64(void)
return t;
}
-struct timespec timespec_from_vlc_tick (vlc_tick_t date)
+struct timespec *vlc_tick_to_timespec(struct timespec *restrict ts,
+ vlc_tick_t tick)
{
- lldiv_t d = lldiv (date, CLOCK_FREQ);
- struct timespec ts = { d.quot, NS_FROM_VLC_TICK( d.rem ) };
+ lldiv_t d = lldiv(tick, CLOCK_FREQ);
+ ts->tv_sec = d.quot;
+ ts->tv_nsec = NS_FROM_VLC_TICK(d.rem);;
return ts;
}
=====================================
src/posix/thread.c
=====================================
@@ -268,16 +268,18 @@ void vlc_tick_wait (vlc_tick_t deadline)
pthread_once(&vlc_clock_once, vlc_clock_setup_once);
deadline -= vlc_clock_prec;
- struct timespec ts = timespec_from_vlc_tick (deadline);
+ struct timespec ts;
+ vlc_tick_to_timespec(&ts, deadline);
while (clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL) == EINTR);
}
#undef vlc_tick_sleep
void vlc_tick_sleep (vlc_tick_t delay)
{
- struct timespec ts = timespec_from_vlc_tick (delay);
+ struct timespec ts;
+ vlc_tick_to_timespec(&ts, delay);
while (clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts) == EINTR);
}
=====================================
src/posix/wait.c
=====================================
@@ -129,8 +129,9 @@ static void vlc_timespec_adjust(clockid_t cid, struct timespec *restrict ts)
int vlc_atomic_timedwait(void *addr, unsigned value, vlc_tick_t deadline)
{
- struct timespec ts = timespec_from_vlc_tick(deadline);
+ struct timespec ts;
+ vlc_tick_to_timespec(&ts, deadline);
vlc_timespec_adjust(CLOCK_MONOTONIC, &ts);
return vlc_atomic_timedwait_timespec(addr, value, &ts);
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e2988d70a8c3ce61b1cdb13b983f73afc1a74c1d...b18dda38130cbc8c384ba3b202852858495461c9
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e2988d70a8c3ce61b1cdb13b983f73afc1a74c1d...b18dda38130cbc8c384ba3b202852858495461c9
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list