Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230620002507.796-1-luoyonggang@gmail.com>
Date: Tue, 20 Jun 2023 08:25:03 +0800
From: Yonggang Luo <luoyonggang@...il.com>
To: Jens Gustedt <jens.gustedt@...ia.fr>,
	musl@...ts.openwall.com
Cc: Yonggang Luo <luoyonggang@...il.com>
Subject: [PATCH 0/4] Add posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait c2y/mtx_timedlock_monotonic c2y/cnd_timedwait_monotonic

Currently, musl doesn't have pthread_mutex_clocklock pthread_cond_clockdwait, but
glibc, android bionic, qnx libc already have these two functions, so implement them in
musl.

And for c11 threads, the mtx and cnd doesn't support for monotonic timedlock and timedwait,
so add a proposaled function mtx_timedlock_monotonic cnd_timedwait_monotonic to do that.

And indeed mtx_timedlock_monotonic and cnd_timedwait_monotonic can be implemented ontop of
posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait, so I implemented posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait
first in musl.

I think mtx_timedlock_monotonic cnd_timedwait_monotonic is reasonable because it's newly added
function and won't affect existing c11 threads functions.
And it's can be implementd with glibc/qnx libc/android bionic without burden.
For OS X it's can be implemented with pthread_cond_timedwait_relative_np
For Windows it's can be implemented with SleepConditionVariableCS
For platform have none of these, it's still can fallback to TIME_UTC

When these

Yonggang Luo (4):
  trim spaces of pthread_cond_timedwait.c and pthread_mutex_timedlock.c
  add pthread_mutex_clocklock and pthread_cond_clockdwait
  c23: Implement newly base for timespec_get
  c2y: Add monotonic timed wait support for threads mtx cnd

 .../time32/cnd_timedwait_monotonic_time32.c   |  9 ++++
 .../time32/mtx_timedlock_monotonic_time32.c   |  9 ++++
 compat/time32/pthread_cond_clockwait_time32.c |  9 ++++
 .../time32/pthread_mutex_clocklock_time32.c   |  9 ++++
 compat/time32/time32.h                        |  4 ++
 include/pthread.h                             |  4 ++
 include/threads.h                             |  4 ++
 include/time.h                                | 13 +++++-
 src/include/pthread.h                         |  2 +
 src/thread/cnd_timedwait.c                    |  2 +-
 ..._timedwait.c => cnd_timedwait_monotonic.c} | 28 ++++++------
 src/thread/mtx_timedlock.c                    |  2 +-
 ..._timedlock.c => mtx_timedlock_monotonic.c} | 26 +++++------
 src/thread/pthread_cond_clockwait.c           |  3 ++
 src/thread/pthread_cond_timedwait.c           | 18 +++++---
 src/thread/pthread_mutex_clocklock.c          |  3 ++
 src/thread/pthread_mutex_timedlock.c          | 15 ++++---
 src/time/timespec_get.c                       | 44 ++++++++++++++++++-
 18 files changed, 161 insertions(+), 43 deletions(-)
 create mode 100644 compat/time32/cnd_timedwait_monotonic_time32.c
 create mode 100644 compat/time32/mtx_timedlock_monotonic_time32.c
 create mode 100644 compat/time32/pthread_cond_clockwait_time32.c
 create mode 100644 compat/time32/pthread_mutex_clocklock_time32.c
 copy src/thread/{cnd_timedwait.c => cnd_timedwait_monotonic.c} (52%)
 copy src/thread/{mtx_timedlock.c => mtx_timedlock_monotonic.c} (74%)
 create mode 100644 src/thread/pthread_cond_clockwait.c
 create mode 100644 src/thread/pthread_mutex_clocklock.c

-- 
2.39.0.windows.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.