[vlc-devel] [PATCH 4/4] threads: remove vlc_atomic_timedwait_daytime()
RĂ©mi Denis-Courmont
remi at remlab.net
Thu Aug 27 18:43:24 CEST 2020
---
include/vlc_threads.h | 2 --
src/linux/thread.c | 29 ++++-------------------------
src/posix/wait.c | 8 --------
src/win32/thread.c | 25 -------------------------
4 files changed, 4 insertions(+), 60 deletions(-)
diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 0c5ef8d19c..bc30f53bde 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -705,8 +705,6 @@ void vlc_atomic_wait(void *addr, unsigned val);
*/
int vlc_atomic_timedwait(void *addr, unsigned val, vlc_tick_t deadline);
-int vlc_atomic_timedwait_daytime(void *addr, unsigned val, time_t deadline);
-
/**
* Wakes up one thread on an address.
*
diff --git a/src/linux/thread.c b/src/linux/thread.c
index bd2596bade..3242de061e 100644
--- a/src/linux/thread.c
+++ b/src/linux/thread.c
@@ -60,10 +60,9 @@ static int vlc_futex_wake(void *addr, int nr)
return sys_futex(addr, FUTEX_WAKE_PRIVATE, nr, NULL, NULL, 0);
}
-static int vlc_futex_wait(void *addr, unsigned flags,
- unsigned val, const struct timespec *to)
+static int vlc_futex_wait(void *addr, unsigned val, const struct timespec *to)
{
- return sys_futex(addr, FUTEX_WAIT_BITSET_PRIVATE | flags, val, to, NULL,
+ return sys_futex(addr, FUTEX_WAIT_BITSET_PRIVATE, val, to, NULL,
FUTEX_BITSET_MATCH_ANY);
}
@@ -79,34 +78,14 @@ void vlc_atomic_notify_all(void *addr)
void vlc_atomic_wait(void *addr, unsigned val)
{
- vlc_futex_wait(addr, 0, val, NULL);
+ vlc_futex_wait(addr, val, NULL);
}
int vlc_atomic_timedwait(void *addr, unsigned val, vlc_tick_t deadline)
{
struct timespec ts = timespec_from_vlc_tick(deadline);
- if (vlc_futex_wait(addr, 0, val, &ts) == 0)
- return 0;
-
- switch (errno) {
- case EINTR:
- case EAGAIN:
- return 0;
- case EFAULT:
- case EINVAL:
- vlc_assert_unreachable(); /* BUG! */
- default:
- break;
- }
- return errno;
-}
-
-int vlc_atomic_timedwait_daytime(void *addr, unsigned val, time_t deadline)
-{
- struct timespec ts = { .tv_sec = deadline, .tv_nsec = 0 };
-
- if (vlc_futex_wait(addr, FUTEX_CLOCK_REALTIME, val, &ts) == 0)
+ if (vlc_futex_wait(addr, val, &ts) == 0)
return 0;
switch (errno) {
diff --git a/src/posix/wait.c b/src/posix/wait.c
index 3fa6890193..87b8ef7b75 100644
--- a/src/posix/wait.c
+++ b/src/posix/wait.c
@@ -133,14 +133,6 @@ int vlc_atomic_timedwait(void *addr, unsigned value, vlc_tick_t deadline)
return vlc_atomic_timedwait_timespec(addr, value, &ts);
}
-int vlc_atomic_timedwait_daytime(void *addr, unsigned value, time_t deadline)
-{
- struct timespec ts = { .tv_sec = deadline, .tv_nsec = 0 };
-
- vlc_timespec_adjust(CLOCK_REALTIME, &ts);
- return vlc_atomic_timedwait_timespec(addr, value, &ts);
-}
-
void vlc_atomic_notify_one(void *addr)
{
vlc_atomic_notify_all(addr);
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 255946913c..330ddd9988 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -303,31 +303,6 @@ int vlc_atomic_timedwait(void *addr, unsigned val, vlc_tick_t deadline)
return ETIMEDOUT;
}
-int vlc_atomic_timedwait_daytime(void *addr, unsigned val, time_t deadline)
-{
- long delay;
-
- do
- {
- long ms;
-
- delay = deadline - time(NULL);
-
- if (delay < 0)
- break; // deadline passed
- if (delay >= (LONG_MAX / 1000))
- ms = LONG_MAX;
- else
- ms = delay * 1000;
-
- if (WaitOnAddress(addr, &val, sizeof (val), ms))
- return 0;
- }
- while (delay > 0);
-
- return ETIMEDOUT;
-}
-
void vlc_atomic_notify_one(void *addr)
{
WakeByAddressSingle(addr);
--
2.28.0
More information about the vlc-devel
mailing list