[v2,4/4] c2y: Add function cnd_timedwait_base and mtx_timedlock_base

Message ID 20230620171731.230-5-luoyonggang@gmail.com
State RFC
Headers
Series c2y proposal add monotonicwait support for mtx and ctx |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 fail Testing failed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm fail Testing failed

Commit Message

Yonggang Luo June 20, 2023, 5:17 p.m. UTC
  For c11 threads, the mtx and cnd doesn't support for monotonic timedlock and timedwait;
So add two proposal function mtx_timedlock_base cnd_timedwait_base to do that.
The protype of these two functions is:
int mtx_timedlock_base(mtx_t *restrict m, int time_base, const struct timespec *restrict ts);
int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int time_base, const struct timespec *restrict ts);
The time_base at least can be TIME_UTC/TIME_MONOTONIC, the implementer can implement it with any provided
TIME_* base parameter provided in c2y time.h, if TIME_MONOTONIC can not natively supported, fallback to TIME_UTC
should provided, for other TIME_* base parameter, it's implementer's choice.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 conform/data/threads.h-data                  |  2 +
 htl/Versions                                 |  5 ++
 nptl/Versions                                |  5 ++
 sysdeps/pthread/Makefile                     |  2 +
 sysdeps/pthread/cnd_timedwait_base.c         | 29 +++++++++++
 sysdeps/pthread/mtx_timedlock_base.c         | 28 +++++++++++
 sysdeps/pthread/threads.h                    | 18 +++++++
 sysdeps/unix/sysv/linux/Versions             |  6 +++
 sysdeps/unix/sysv/linux/cnd_timedwait_base.c | 53 ++++++++++++++++++++
 sysdeps/unix/sysv/linux/mtx_timedlock_base.c | 50 ++++++++++++++++++
 sysdeps/unix/sysv/linux/thrd_priv.h          | 10 ++++
 11 files changed, 208 insertions(+)
 create mode 100644 sysdeps/pthread/cnd_timedwait_base.c
 create mode 100644 sysdeps/pthread/mtx_timedlock_base.c
 create mode 100644 sysdeps/unix/sysv/linux/cnd_timedwait_base.c
 create mode 100644 sysdeps/unix/sysv/linux/mtx_timedlock_base.c
  

Comments

Joseph Myers June 20, 2023, 8:41 p.m. UTC | #1
On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:

> diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h
> index d88d7a3ddd..4f61ad9236 100644
> --- a/sysdeps/pthread/threads.h
> +++ b/sysdeps/pthread/threads.h
> @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
>  #ifndef __USE_TIME_BITS64
>  extern int mtx_timedlock (mtx_t *__restrict __mutex,
>  			  const struct timespec *__restrict __time_point);
> +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int time_base,
> +                               const struct timespec *__restrict __time_point);

As noted, this should be conditional on __USE_GNU.  Since you didn't make 
it conditional, I'd expect it to have failed the conform/ namespace tests 
- both for the mtx_timedlock_base name itself if there weren't incorrect 
conform/ changes in the patch series, and for the time_base parameter 
(parameters in installed headers should always have a leading __).  How 
did you test these patches?

> +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict __mutex,
> +                                            int time_base,
> +                                            const struct timespec *__restrict
> +                                            __time_point),
> +                       __mtx_timedlock_base64);

Likewise, should be conditional on __USE_GNU and time_base should be 
__time_base.

> +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
> +                               mtx_t *__restrict __mutex, int time_base,
> +                               const struct timespec *__restrict __time_point);

> +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict __cond,
> +                                            mtx_t *__restrict __mutex,
> +                                            int time_base,
> +                                            const struct timespec *__restrict
> +                                            __time_point),

Likewise.
  
Joseph Myers June 20, 2023, 8:50 p.m. UTC | #2
In addition to my previous comments, such new user-visible features should 
be documented in the manual, when they are added to families of functions 
that are already documented there (see threads.texi), and mentioned in a 
NEWS entry.
  
develop--- via Libc-alpha June 21, 2023, 9:21 a.m. UTC | #3
On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <joseph@codesourcery.com>
wrote:
>
> On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
>
> > diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h
> > index d88d7a3ddd..4f61ad9236 100644
> > --- a/sysdeps/pthread/threads.h
> > +++ b/sysdeps/pthread/threads.h
> > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
> >  #ifndef __USE_TIME_BITS64
> >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
> >                         const struct timespec *__restrict __time_point);
> > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int
time_base,
> > +                               const struct timespec *__restrict
__time_point);
>
> As noted, this should be conditional on __USE_GNU.  Since you didn't make
> it conditional, I'd expect it to have failed the conform/ namespace tests
> - both for the mtx_timedlock_base name itself if there weren't incorrect
> conform/ changes in the patch series, and for the time_base parameter
> (parameters in installed headers should always have a leading __).  How
> did you test these patches?

I am not testing these patches yet(as a new contributor for glibc, don't
know how to do that yet),
and for this patch, I'd like to know if the prototype of these two
functions is proper first

int mtx_timedlock_base(mtx_t *restrict m, int time_base, const struct
timespec *restrict ts);

int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int time_base,
const struct timespec *restrict ts);

The function name was suggested by Jens Gustedt, and indeed I also thought
about this name in the first place(because posix has cond_clockwait and
mutex_clocklock already). And seems enh also like this

If we have minimal agreement about this proposal, I'd like to add tests for
it. But still, I don't think
__USE_GNU is a good name for it, because it's for C2y or C3x, any better
option for this, so that it's not GNU restricted, for example, suppose MSVC
also wants to implement this?


>
> > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict __mutex,
> > +                                            int time_base,
> > +                                            const struct timespec
*__restrict
> > +                                            __time_point),
> > +                       __mtx_timedlock_base64);
>
> Likewise, should be conditional on __USE_GNU and time_base should be
> __time_base.
>
> > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
> > +                               mtx_t *__restrict __mutex, int
time_base,
> > +                               const struct timespec *__restrict
__time_point);
>
> > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict __cond,
> > +                                            mtx_t *__restrict __mutex,
> > +                                            int time_base,
> > +                                            const struct timespec
*__restrict
> > +                                            __time_point),
>
> Likewise.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
  
Xi Ruoyao June 21, 2023, 9:54 a.m. UTC | #4
On Wed, 2023-06-21 at 17:21 +0800, 罗勇刚(Yonggang Luo) via Libc-alpha
wrote:
> The function name was suggested by Jens Gustedt, and indeed I also thought
> about this name in the first place(because posix has cond_clockwait and
> mutex_clocklock already). And seems enh also like this
> 
> If we have minimal agreement about this proposal, I'd like to add tests for
> it. But still, I don't think
> __USE_GNU is a good name for it, because it's for C2y or C3x, any better
> option for this, so that it's not GNU restricted, for example, suppose MSVC
> also wants to implement this?

No, __USE_GNU does not mean it's GNU restricted, but mean it's a GNU
extension.  Other implementations can implement GNU extensions as well
if they wish (and doing so does not violate LGPL unless they copy the
implementation from Glibc).

Hmm, and do you have some misunderstanding about the relationship betwen
the C standard and Glibc?  Glibc implements the standard, but it's not
the standard.  If you want to add the functions into the standard you
need to submit it to WG14 first.  Before WG14 accept it, we cannot
declare the functions standard.  I've not seen your paper at
https://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log.htm but
maybe I missed something.
  
develop--- via Libc-alpha June 21, 2023, 10:16 a.m. UTC | #5
Xi Ruoyao <xry111@xry111.site> 于 2023年6月21日周三 17:54写道:

> On Wed, 2023-06-21 at 17:21 +0800, 罗勇刚(Yonggang Luo) via Libc-alpha
> wrote:
> > The function name was suggested by Jens Gustedt, and indeed I also
> thought
> > about this name in the first place(because posix has cond_clockwait and
> > mutex_clocklock already). And seems enh also like this
> >
> > If we have minimal agreement about this proposal, I'd like to add tests
> for
> > it. But still, I don't think
> > __USE_GNU is a good name for it, because it's for C2y or C3x, any better
> > option for this, so that it's not GNU restricted, for example, suppose
> MSVC
> > also wants to implement this?
>
> No, __USE_GNU does not mean it's GNU restricted, but mean it's a GNU
> extension.  Other implementations can implement GNU extensions as well
> if they wish (and doing so does not violate LGPL unless they copy the
> implementation from Glibc).
>
> Hmm, and do you have some misunderstanding about the relationship betwen
> the C standard and Glibc?  Glibc implements the standard, but it's not
> the standard.  If you want to add the functions into the standard you
> need to submit it to WG14 first.  Before WG14 accept it, we cannot
> declare the functions standard.  I've not seen your paper at
> https://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log.htm but
> maybe I missed something.
>

its not submit to wg14 yet, because this is not a totally new feature, I
need to implement it first to see if it's possible, and this is chicken/egg
problem, so I decided implement it first to receiving feedback, and after
minimal agreement received, I would submit proposal to wg14 if am qualified.

 Another reason I sumbit implementation first because I want use this in
Mesa before standardized.


> --
> Xi Ruoyao <xry111@xry111.site>
> School of Aerospace Science and Technology, Xidian University
>
  
Xi Ruoyao June 21, 2023, 10:25 a.m. UTC | #6
On Wed, 2023-06-21 at 18:16 +0800, 罗勇刚(Yonggang Luo) wrote:
> its not submit to wg14 yet, because this is not a totally new feature,
> I need to implement it first to see if it's possible, and this is
> chicken/egg problem, so I decided implement it first to receiving
> feedback, and after minimal agreement received, I would submit
> proposal to wg14 if am qualified.

Then they are GNU extensions, for now.  When they are published by WG14
we can move from __USE_GNU to __USE_ISOC??.


> Another reason I sumbit implementation first because I want use this
> in Mesa before standardized.

Mesa uses -D_GNU_SOURCE in CFLAGS anyway, so __USE_GNU won't prevent you
from using it.
  
Florian Weimer June 21, 2023, 10:40 a.m. UTC | #7
* 罗勇刚(Yonggang Luo):

> its not submit to wg14 yet, because this is not a totally new feature,
> I need to implement it first to see if it's possible, and this is
> chicken/egg problem, so I decided implement it first to receiving
> feedback, and after minimal agreement received, I would submit
> proposal to wg14 if am qualified.

You need to take this up with WG14.  This is not the right list for
that.

There is no reason to duplicate existing POSIX functionality or
extensions in glibc just because they might be included in a future
version of the C standard.  Usually, WG14 does not adopt actually
deployed interfaces, but makes up new ones (despite the “no invention,
without exception“ still in the charter).  In that case, we end up with
three incompatible interfaces, the POSIX one, our C prototype, and the
actual C interface.

Thanks,
Florian
  
Joseph Myers June 21, 2023, 12:09 p.m. UTC | #8
On Wed, 21 Jun 2023, 罗勇刚(Yonggang Luo) via Libc-alpha wrote:

> I am not testing these patches yet(as a new contributor for glibc, don't
> know how to do that yet),

Please don't post untested patches without marking them very clearly as 
untested (and a good reason for them being untested).  If you have 
difficulty following the documentation on how to test glibc, please seek 
help on the libc-help mailing list.

> If we have minimal agreement about this proposal, I'd like to add tests for
> it. But still, I don't think
> __USE_GNU is a good name for it, because it's for C2y or C3x, any better
> option for this, so that it's not GNU restricted, for example, suppose MSVC
> also wants to implement this?

It would be a GNU extension unless and until it's adopted into some 
standard.

For example, exp10 was a GNU extension, conditional on __USE_GNU, until it 
was added to TS 18661-4; it was then conditioned on __GLIBC_USE 
(IEC_60559_FUNCS_EXT) in glibc (commit 
412cb261b0d66ef5251d7d1c8276b5c522d943b7), and, when parts of TS 18661-4 
were added to C2x, the conditionals in glibc were updated to make exp10 
visible for C2x (commit c3ce62cc0bd6e8a33629e2aabb7783a322e9189c).

A similar principle applies to any function added to glibc that's not in a 
standard but might be added to one in future: it should be conditional on 
__USE_GNU (rarely __USE_MISC in cases of extensions also present in other 
Unix-like libcs) and the conditional is changed in future if added to a 
standard.

This generally applies even if the interface name matches a pattern 
reserved in ISO C (for example, strdup - added to ISO C in C2x - is only 
conditionally declared, even though C90 reserves all str* names).
  
Jₑₙₛ Gustedt June 21, 2023, 1:23 p.m. UTC | #9
Hello Florian,

On Wed, 21 Jun 2023 12:40:45 +0200, Florian Weimer wrote:

> There is no reason to duplicate existing POSIX functionality or
> extensions in glibc just because they might be included in a future
> version of the C standard.  Usually, WG14 does not adopt actually
> deployed interfaces, but makes up new ones (despite the “no invention,
> without exception“ still in the charter).

You are exagerating a bit. C23 will integrate a bunch of POSIX
functions, verbatim. There is no "usually" here, it is discussed for
every individual function that we look at. And that is a tedious
case-by-case analysis.

Interfaces for time are a bit special because they were modeled along
POSIX but then changed names and specification of clocks / time bases.

> In that case, we end up with three incompatible interfaces, the
> POSIX one, our C prototype, and the actual C interface.

Yes, that would indeed be not good. The way forward here would be to
propose an integration of the POSIX feature into C2y that would most
probably need a new name and ABI for the reasons I mentioned. Such a
proposal can't happen before mid/end of 2024. If in the meantime one
would want to add a `mtx_…_np` (non-portable) function to a given C
library is certainly debadable. Where this could make sense is for
non-POSIX implementations.

For all of this to make sense, we first need solid implementations of
the three new optional time bases for the existing time interfaces, in
particular for non-POSIX implementations. This would then only make it
interesting for the committees to have new functions in C2y that
depend on these time base and which then, in turn, would make the
whole subset of functions more attractive to our users.


Thanks
Jₑₙₛ

PS: where I am fine to participate in this particular discussion with
glibc on time bases, please remove my name from other tagential
discussions about code identation or stuff like that. Please everybody
be a bit more careful, thanks.
  
enh June 21, 2023, 2:30 p.m. UTC | #10
On Wed, Jun 21, 2023 at 2:21 AM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
wrote:

>
>
> On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <joseph@codesourcery.com>
> wrote:
> >
> > On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
> >
> > > diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h
> > > index d88d7a3ddd..4f61ad9236 100644
> > > --- a/sysdeps/pthread/threads.h
> > > +++ b/sysdeps/pthread/threads.h
> > > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
> > >  #ifndef __USE_TIME_BITS64
> > >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
> > >                         const struct timespec *__restrict
> __time_point);
> > > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int
> time_base,
> > > +                               const struct timespec *__restrict
> __time_point);
> >
> > As noted, this should be conditional on __USE_GNU.  Since you didn't make
> > it conditional, I'd expect it to have failed the conform/ namespace tests
> > - both for the mtx_timedlock_base name itself if there weren't incorrect
> > conform/ changes in the patch series, and for the time_base parameter
> > (parameters in installed headers should always have a leading __).  How
> > did you test these patches?
>
> I am not testing these patches yet(as a new contributor for glibc, don't
> know how to do that yet),
> and for this patch, I'd like to know if the prototype of these two
> functions is proper first
>
> int mtx_timedlock_base(mtx_t *restrict m, int time_base, const struct
> timespec *restrict ts);
>
> int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
> time_base, const struct timespec *restrict ts);
>
> The function name was suggested by Jens Gustedt, and indeed I also thought
> about this name in the first place(because posix has cond_clockwait and
> mutex_clocklock already). And seems enh also like this
>

well, to the extent that i think "pthreads that's also available on
Windows" is useful to some, sure, i'll continue to add the trivial inline
functions to bionic so that this is actually portable (
https://android.googlesource.com/platform/bionic/+/master/libc/include/bits/threads_inlines.h).
but for Android host tools themselves, i think we'll continue to use
std::thread or pthreads via mingw.

but my real feedback earlier was the same as what you're seeing here:
"since this is a WG14-driven thing, it should come as a proposal from there
first". anyone using bionic or glibc already has perfectly good pthread
apis, so no real need for this stuff until/unless it's in Windows. (and
last time i looked, Windows hadn't actually implemented the existing
<threads.h> stuff yet?)


> If we have minimal agreement about this proposal, I'd like to add tests
> for it. But still, I don't think
> __USE_GNU is a good name for it, because it's for C2y or C3x, any better
> option for this, so that it's not GNU restricted, for example, suppose MSVC
> also wants to implement this?
>
>
> >
> > > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict __mutex,
> > > +                                            int time_base,
> > > +                                            const struct timespec
> *__restrict
> > > +                                            __time_point),
> > > +                       __mtx_timedlock_base64);
> >
> > Likewise, should be conditional on __USE_GNU and time_base should be
> > __time_base.
> >
> > > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
> > > +                               mtx_t *__restrict __mutex, int
> time_base,
> > > +                               const struct timespec *__restrict
> __time_point);
> >
> > > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict __cond,
> > > +                                            mtx_t *__restrict __mutex,
> > > +                                            int time_base,
> > > +                                            const struct timespec
> *__restrict
> > > +                                            __time_point),
> >
> > Likewise.
> >
> > --
> > Joseph S. Myers
> > joseph@codesourcery.com
>
>
>
> --
>          此致
> 礼
> 罗勇刚
> Yours
>     sincerely,
> Yonggang Luo
>
  
Joseph Myers June 21, 2023, 3:08 p.m. UTC | #11
On Wed, 21 Jun 2023, enh via Libc-alpha wrote:

> but my real feedback earlier was the same as what you're seeing here:
> "since this is a WG14-driven thing, it should come as a proposal from there
> first". anyone using bionic or glibc already has perfectly good pthread

And, since there is one bit that *is* already in C2x (three new time 
bases), that bit should be submitted on its own (with the fixes already 
identified), since that bit unambiguously makes sense as adding support 
for a C2x feature - independent of whether any further functions in this 
area, or time bases, ever get added to the C standard, or to other 
implementations that make them useful to add to glibc.
  
develop--- via Libc-alpha June 21, 2023, 6:39 p.m. UTC | #12
On Wed, Jun 21, 2023 at 10:31 PM enh <enh@google.com> wrote:
>
>
>
> On Wed, Jun 21, 2023 at 2:21 AM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
wrote:
>>
>>
>>
>> On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <joseph@codesourcery.com>
wrote:
>> >
>> > On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
>> >
>> > > diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h
>> > > index d88d7a3ddd..4f61ad9236 100644
>> > > --- a/sysdeps/pthread/threads.h
>> > > +++ b/sysdeps/pthread/threads.h
>> > > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
>> > >  #ifndef __USE_TIME_BITS64
>> > >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
>> > >                         const struct timespec *__restrict
__time_point);
>> > > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int
time_base,
>> > > +                               const struct timespec *__restrict
__time_point);
>> >
>> > As noted, this should be conditional on __USE_GNU.  Since you didn't
make
>> > it conditional, I'd expect it to have failed the conform/ namespace
tests
>> > - both for the mtx_timedlock_base name itself if there weren't
incorrect
>> > conform/ changes in the patch series, and for the time_base parameter
>> > (parameters in installed headers should always have a leading __).  How
>> > did you test these patches?
>>
>> I am not testing these patches yet(as a new contributor for glibc, don't
know how to do that yet),
>> and for this patch, I'd like to know if the prototype of these two
functions is proper first
>>
>> int mtx_timedlock_base(mtx_t *restrict m, int time_base, const struct
timespec *restrict ts);
>>
>> int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
time_base, const struct timespec *restrict ts);
>>
>> The function name was suggested by Jens Gustedt, and indeed I also
thought about this name in the first place(because posix has cond_clockwait
and mutex_clocklock already). And seems enh also like this
>
>
> well, to the extent that i think "pthreads that's also available on
Windows" is useful to some, sure, i'll continue to add the trivial inline
functions to bionic so that this is actually portable (
https://android.googlesource.com/platform/bionic/+/master/libc/include/bits/threads_inlines.h).
but for Android host tools themselves, i think we'll continue to use
std::thread or pthreads via mingw.
>
> but my real feedback earlier was the same as what you're seeing here:
"since this is a WG14-driven thing, it should come as a proposal from there
first". anyone using bionic or glibc already has perfectly good pthread
apis, so no real need for this stuff until/unless it's in Windows. (and
last time i looked, Windows hadn't actually implemented the existing
<threads.h> stuff yet?)

Yeah, you are correct, windows msvc doesn't have either pthread or c11
threads, and pthreads is so huge, so there is multiple third-party c11
threads implementation for MSVC, that's why I wanna c2y threads comes with
monotonic mtx_timedlock cnd_timedwait support, so that the third-party c11
threads implementation have a consistence API to implement.

So my question, anyone in this threads have suggestion about the newly
proposed API:

 int mtx_timedlock_base (mtx_t*, int, const struct timespec*);
 int cnd_timedwait_base (cnd_t*, mtx_t*, int, const struct timespec*);

>
>>
>> If we have minimal agreement about this proposal, I'd like to add tests
for it. But still, I don't think
>> __USE_GNU is a good name for it, because it's for C2y or C3x, any better
option for this, so that it's not GNU restricted, for example, suppose MSVC
also wants to implement this?
>>
>>
>> >
>> > > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict
__mutex,
>> > > +                                            int time_base,
>> > > +                                            const struct timespec
*__restrict
>> > > +                                            __time_point),
>> > > +                       __mtx_timedlock_base64);
>> >
>> > Likewise, should be conditional on __USE_GNU and time_base should be
>> > __time_base.
>> >
>> > > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
>> > > +                               mtx_t *__restrict __mutex, int
time_base,
>> > > +                               const struct timespec *__restrict
__time_point);
>> >
>> > > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict
__cond,
>> > > +                                            mtx_t *__restrict
__mutex,
>> > > +                                            int time_base,
>> > > +                                            const struct timespec
*__restrict
>> > > +                                            __time_point),
>> >
>> > Likewise.
>> >
>> > --
>> > Joseph S. Myers
>> > joseph@codesourcery.com
>>
>>
>>
>> --
>>          此致
>> 礼
>> 罗勇刚
>> Yours
>>     sincerely,
>> Yonggang Luo



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
  
enh June 21, 2023, 7:04 p.m. UTC | #13
On Wed, Jun 21, 2023 at 11:39 AM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
wrote:

>
>
> On Wed, Jun 21, 2023 at 10:31 PM enh <enh@google.com> wrote:
> >
> >
> >
> > On Wed, Jun 21, 2023 at 2:21 AM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
> wrote:
> >>
> >>
> >>
> >> On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <joseph@codesourcery.com>
> wrote:
> >> >
> >> > On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
> >> >
> >> > > diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h
> >> > > index d88d7a3ddd..4f61ad9236 100644
> >> > > --- a/sysdeps/pthread/threads.h
> >> > > +++ b/sysdeps/pthread/threads.h
> >> > > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
> >> > >  #ifndef __USE_TIME_BITS64
> >> > >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
> >> > >                         const struct timespec *__restrict
> __time_point);
> >> > > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int
> time_base,
> >> > > +                               const struct timespec *__restrict
> __time_point);
> >> >
> >> > As noted, this should be conditional on __USE_GNU.  Since you didn't
> make
> >> > it conditional, I'd expect it to have failed the conform/ namespace
> tests
> >> > - both for the mtx_timedlock_base name itself if there weren't
> incorrect
> >> > conform/ changes in the patch series, and for the time_base parameter
> >> > (parameters in installed headers should always have a leading __).
> How
> >> > did you test these patches?
> >>
> >> I am not testing these patches yet(as a new contributor for glibc,
> don't know how to do that yet),
> >> and for this patch, I'd like to know if the prototype of these two
> functions is proper first
> >>
> >> int mtx_timedlock_base(mtx_t *restrict m, int time_base, const struct
> timespec *restrict ts);
> >>
> >> int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
> time_base, const struct timespec *restrict ts);
> >>
> >> The function name was suggested by Jens Gustedt, and indeed I also
> thought about this name in the first place(because posix has cond_clockwait
> and mutex_clocklock already). And seems enh also like this
> >
> >
> > well, to the extent that i think "pthreads that's also available on
> Windows" is useful to some, sure, i'll continue to add the trivial inline
> functions to bionic so that this is actually portable (
> https://android.googlesource.com/platform/bionic/+/master/libc/include/bits/threads_inlines.h).
> but for Android host tools themselves, i think we'll continue to use
> std::thread or pthreads via mingw.
> >
> > but my real feedback earlier was the same as what you're seeing here:
> "since this is a WG14-driven thing, it should come as a proposal from there
> first". anyone using bionic or glibc already has perfectly good pthread
> apis, so no real need for this stuff until/unless it's in Windows. (and
> last time i looked, Windows hadn't actually implemented the existing
> <threads.h> stuff yet?)
>
> Yeah, you are correct, windows msvc doesn't have either pthread or c11
> threads, and pthreads is so huge, so there is multiple third-party c11
> threads implementation for MSVC, that's why I wanna c2y threads comes with
> monotonic mtx_timedlock cnd_timedwait support, so that the third-party c11
> threads implementation have a consistence API to implement.
>

if MS didn't bother to implement the C11 functions, why do you think they'd
implement any future additions?


> So my question, anyone in this threads have suggestion about the newly
> proposed API:
>
>  int mtx_timedlock_base (mtx_t*, int, const struct timespec*);
>  int cnd_timedwait_base (cnd_t*, mtx_t*, int, const struct timespec*);
>

don't existing functions put the `int __base` last? sounds like a question
for WG14 rather than c library implementors though --- as long as this
isn't supported on the platform that doesn't have pthreads, it's not
filling any obvious need.


> >
> >>
> >> If we have minimal agreement about this proposal, I'd like to add tests
> for it. But still, I don't think
> >> __USE_GNU is a good name for it, because it's for C2y or C3x, any
> better option for this, so that it's not GNU restricted, for example,
> suppose MSVC also wants to implement this?
> >>
> >>
> >> >
> >> > > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict
> __mutex,
> >> > > +                                            int time_base,
> >> > > +                                            const struct timespec
> *__restrict
> >> > > +                                            __time_point),
> >> > > +                       __mtx_timedlock_base64);
> >> >
> >> > Likewise, should be conditional on __USE_GNU and time_base should be
> >> > __time_base.
> >> >
> >> > > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
> >> > > +                               mtx_t *__restrict __mutex, int
> time_base,
> >> > > +                               const struct timespec *__restrict
> __time_point);
> >> >
> >> > > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict
> __cond,
> >> > > +                                            mtx_t *__restrict
> __mutex,
> >> > > +                                            int time_base,
> >> > > +                                            const struct timespec
> *__restrict
> >> > > +                                            __time_point),
> >> >
> >> > Likewise.
> >> >
> >> > --
> >> > Joseph S. Myers
> >> > joseph@codesourcery.com
> >>
> >>
> >>
> >> --
> >>          此致
> >> 礼
> >> 罗勇刚
> >> Yours
> >>     sincerely,
> >> Yonggang Luo
>
>
>
> --
>          此致
> 礼
> 罗勇刚
> Yours
>     sincerely,
> Yonggang Luo
>
  
develop--- via Libc-alpha June 21, 2023, 7:07 p.m. UTC | #14
On Thu, Jun 22, 2023 at 3:05 AM enh <enh@google.com> wrote:
>
>
>
> On Wed, Jun 21, 2023 at 11:39 AM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
wrote:
>>
>>
>>
>> On Wed, Jun 21, 2023 at 10:31 PM enh <enh@google.com> wrote:
>> >
>> >
>> >
>> > On Wed, Jun 21, 2023 at 2:21 AM 罗勇刚(Yonggang Luo) <
luoyonggang@gmail.com> wrote:
>> >>
>> >>
>> >>
>> >> On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <joseph@codesourcery.com>
wrote:
>> >> >
>> >> > On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
>> >> >
>> >> > > diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h
>> >> > > index d88d7a3ddd..4f61ad9236 100644
>> >> > > --- a/sysdeps/pthread/threads.h
>> >> > > +++ b/sysdeps/pthread/threads.h
>> >> > > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
>> >> > >  #ifndef __USE_TIME_BITS64
>> >> > >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
>> >> > >                         const struct timespec *__restrict
__time_point);
>> >> > > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int
time_base,
>> >> > > +                               const struct timespec *__restrict
__time_point);
>> >> >
>> >> > As noted, this should be conditional on __USE_GNU.  Since you
didn't make
>> >> > it conditional, I'd expect it to have failed the conform/ namespace
tests
>> >> > - both for the mtx_timedlock_base name itself if there weren't
incorrect
>> >> > conform/ changes in the patch series, and for the time_base
parameter
>> >> > (parameters in installed headers should always have a leading __).
How
>> >> > did you test these patches?
>> >>
>> >> I am not testing these patches yet(as a new contributor for glibc,
don't know how to do that yet),
>> >> and for this patch, I'd like to know if the prototype of these two
functions is proper first
>> >>
>> >> int mtx_timedlock_base(mtx_t *restrict m, int time_base, const struct
timespec *restrict ts);
>> >>
>> >> int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
time_base, const struct timespec *restrict ts);
>> >>
>> >> The function name was suggested by Jens Gustedt, and indeed I also
thought about this name in the first place(because posix has cond_clockwait
and mutex_clocklock already). And seems enh also like this
>> >
>> >
>> > well, to the extent that i think "pthreads that's also available on
Windows" is useful to some, sure, i'll continue to add the trivial inline
functions to bionic so that this is actually portable (
https://android.googlesource.com/platform/bionic/+/master/libc/include/bits/threads_inlines.h).
but for Android host tools themselves, i think we'll continue to use
std::thread or pthreads via mingw.
>> >
>> > but my real feedback earlier was the same as what you're seeing here:
"since this is a WG14-driven thing, it should come as a proposal from there
first". anyone using bionic or glibc already has perfectly good pthread
apis, so no real need for this stuff until/unless it's in Windows. (and
last time i looked, Windows hadn't actually implemented the existing
<threads.h> stuff yet?)
>>
>> Yeah, you are correct, windows msvc doesn't have either pthread or c11
threads, and pthreads is so huge, so there is multiple third-party c11
threads implementation for MSVC, that's why I wanna c2y threads comes with
monotonic mtx_timedlock cnd_timedwait support, so that the third-party c11
threads implementation have a consistence API to implement.
>
>
> if MS didn't bother to implement the C11 functions, why do you think
they'd implement any future additions?

I don't bother MS if they will implement the C11 functions, I just want a
set of cross-platform threads api(c11 threads) to use (non-posix
non-pthreads), we can always polyfill that API when the native libc doesn't
support that.
The API is more important than who would implement it

>
>>
>> So my question, anyone in this threads have suggestion about the newly
proposed API:
>>
>>  int mtx_timedlock_base (mtx_t*, int, const struct timespec*);
>>  int cnd_timedwait_base (cnd_t*, mtx_t*, int, const struct timespec*);
>
>
> don't existing functions put the `int __base` last? sounds like a
question for WG14 rather than c library implementors though --- as long as
this isn't supported on the platform that doesn't have pthreads, it's not
filling any obvious need.
>
>>
>> >
>> >>
>> >> If we have minimal agreement about this proposal, I'd like to add
tests for it. But still, I don't think
>> >> __USE_GNU is a good name for it, because it's for C2y or C3x, any
better option for this, so that it's not GNU restricted, for example,
suppose MSVC also wants to implement this?
>> >>
>> >>
>> >> >
>> >> > > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict
__mutex,
>> >> > > +                                            int time_base,
>> >> > > +                                            const struct
timespec *__restrict
>> >> > > +                                            __time_point),
>> >> > > +                       __mtx_timedlock_base64);
>> >> >
>> >> > Likewise, should be conditional on __USE_GNU and time_base should be
>> >> > __time_base.
>> >> >
>> >> > > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
>> >> > > +                               mtx_t *__restrict __mutex, int
time_base,
>> >> > > +                               const struct timespec *__restrict
__time_point);
>> >> >
>> >> > > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict
__cond,
>> >> > > +                                            mtx_t *__restrict
__mutex,
>> >> > > +                                            int time_base,
>> >> > > +                                            const struct
timespec *__restrict
>> >> > > +                                            __time_point),
>> >> >
>> >> > Likewise.
>> >> >
>> >> > --
>> >> > Joseph S. Myers
>> >> > joseph@codesourcery.com
>> >>
>> >>
>> >>
>> >> --
>> >>          此致
>> >> 礼
>> >> 罗勇刚
>> >> Yours
>> >>     sincerely,
>> >> Yonggang Luo
>>
>>
>>
>> --
>>          此致
>> 礼
>> 罗勇刚
>> Yours
>>     sincerely,
>> Yonggang Luo



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
  
enh June 21, 2023, 7:18 p.m. UTC | #15
On Wed, Jun 21, 2023 at 12:08 PM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
wrote:

>
>
> On Thu, Jun 22, 2023 at 3:05 AM enh <enh@google.com> wrote:
> >
> >
> >
> > On Wed, Jun 21, 2023 at 11:39 AM 罗勇刚(Yonggang Luo) <
> luoyonggang@gmail.com> wrote:
> >>
> >>
> >>
> >> On Wed, Jun 21, 2023 at 10:31 PM enh <enh@google.com> wrote:
> >> >
> >> >
> >> >
> >> > On Wed, Jun 21, 2023 at 2:21 AM 罗勇刚(Yonggang Luo) <
> luoyonggang@gmail.com> wrote:
> >> >>
> >> >>
> >> >>
> >> >> On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <
> joseph@codesourcery.com> wrote:
> >> >> >
> >> >> > On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
> >> >> >
> >> >> > > diff --git a/sysdeps/pthread/threads.h
> b/sysdeps/pthread/threads.h
> >> >> > > index d88d7a3ddd..4f61ad9236 100644
> >> >> > > --- a/sysdeps/pthread/threads.h
> >> >> > > +++ b/sysdeps/pthread/threads.h
> >> >> > > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
> >> >> > >  #ifndef __USE_TIME_BITS64
> >> >> > >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
> >> >> > >                         const struct timespec *__restrict
> __time_point);
> >> >> > > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int
> time_base,
> >> >> > > +                               const struct timespec
> *__restrict __time_point);
> >> >> >
> >> >> > As noted, this should be conditional on __USE_GNU.  Since you
> didn't make
> >> >> > it conditional, I'd expect it to have failed the conform/
> namespace tests
> >> >> > - both for the mtx_timedlock_base name itself if there weren't
> incorrect
> >> >> > conform/ changes in the patch series, and for the time_base
> parameter
> >> >> > (parameters in installed headers should always have a leading
> __).  How
> >> >> > did you test these patches?
> >> >>
> >> >> I am not testing these patches yet(as a new contributor for glibc,
> don't know how to do that yet),
> >> >> and for this patch, I'd like to know if the prototype of these two
> functions is proper first
> >> >>
> >> >> int mtx_timedlock_base(mtx_t *restrict m, int time_base, const
> struct timespec *restrict ts);
> >> >>
> >> >> int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
> time_base, const struct timespec *restrict ts);
> >> >>
> >> >> The function name was suggested by Jens Gustedt, and indeed I also
> thought about this name in the first place(because posix has cond_clockwait
> and mutex_clocklock already). And seems enh also like this
> >> >
> >> >
> >> > well, to the extent that i think "pthreads that's also available on
> Windows" is useful to some, sure, i'll continue to add the trivial inline
> functions to bionic so that this is actually portable (
> https://android.googlesource.com/platform/bionic/+/master/libc/include/bits/threads_inlines.h).
> but for Android host tools themselves, i think we'll continue to use
> std::thread or pthreads via mingw.
> >> >
> >> > but my real feedback earlier was the same as what you're seeing here:
> "since this is a WG14-driven thing, it should come as a proposal from there
> first". anyone using bionic or glibc already has perfectly good pthread
> apis, so no real need for this stuff until/unless it's in Windows. (and
> last time i looked, Windows hadn't actually implemented the existing
> <threads.h> stuff yet?)
> >>
> >> Yeah, you are correct, windows msvc doesn't have either pthread or c11
> threads, and pthreads is so huge, so there is multiple third-party c11
> threads implementation for MSVC, that's why I wanna c2y threads comes with
> monotonic mtx_timedlock cnd_timedwait support, so that the third-party c11
> threads implementation have a consistence API to implement.
> >
> >
> > if MS didn't bother to implement the C11 functions, why do you think
> they'd implement any future additions?
>
> I don't bother MS if they will implement the C11 functions, I just want a
> set of cross-platform threads api(c11 threads) to use (non-posix
> non-pthreads), we can always polyfill that API when the native libc doesn't
> support that.
> The API is more important than who would implement it
>

if you're the only person implementing it _and_ the only person using it
... it doesn't really matter what you call it? just put _something_ in your
code, and worry about changing the name/signature if/when WG14 adds
something equivalent.


> >
> >>
> >> So my question, anyone in this threads have suggestion about the newly
> proposed API:
> >>
> >>  int mtx_timedlock_base (mtx_t*, int, const struct timespec*);
> >>  int cnd_timedwait_base (cnd_t*, mtx_t*, int, const struct timespec*);
> >
> >
> > don't existing functions put the `int __base` last? sounds like a
> question for WG14 rather than c library implementors though --- as long as
> this isn't supported on the platform that doesn't have pthreads, it's not
> filling any obvious need.
> >
> >>
> >> >
> >> >>
> >> >> If we have minimal agreement about this proposal, I'd like to add
> tests for it. But still, I don't think
> >> >> __USE_GNU is a good name for it, because it's for C2y or C3x, any
> better option for this, so that it's not GNU restricted, for example,
> suppose MSVC also wants to implement this?
> >> >>
> >> >>
> >> >> >
> >> >> > > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict
> __mutex,
> >> >> > > +                                            int time_base,
> >> >> > > +                                            const struct
> timespec *__restrict
> >> >> > > +                                            __time_point),
> >> >> > > +                       __mtx_timedlock_base64);
> >> >> >
> >> >> > Likewise, should be conditional on __USE_GNU and time_base should
> be
> >> >> > __time_base.
> >> >> >
> >> >> > > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
> >> >> > > +                               mtx_t *__restrict __mutex, int
> time_base,
> >> >> > > +                               const struct timespec
> *__restrict __time_point);
> >> >> >
> >> >> > > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict
> __cond,
> >> >> > > +                                            mtx_t *__restrict
> __mutex,
> >> >> > > +                                            int time_base,
> >> >> > > +                                            const struct
> timespec *__restrict
> >> >> > > +                                            __time_point),
> >> >> >
> >> >> > Likewise.
> >> >> >
> >> >> > --
> >> >> > Joseph S. Myers
> >> >> > joseph@codesourcery.com
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >>          此致
> >> >> 礼
> >> >> 罗勇刚
> >> >> Yours
> >> >>     sincerely,
> >> >> Yonggang Luo
> >>
> >>
> >>
> >> --
> >>          此致
> >> 礼
> >> 罗勇刚
> >> Yours
> >>     sincerely,
> >> Yonggang Luo
>
>
>
> --
>          此致
> 礼
> 罗勇刚
> Yours
>     sincerely,
> Yonggang Luo
>
  
develop--- via Libc-alpha June 21, 2023, 7:38 p.m. UTC | #16
On Thu, Jun 22, 2023 at 3:18 AM enh <enh@google.com> wrote:
>
>
>
> On Wed, Jun 21, 2023 at 12:08 PM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
wrote:
>>
>>
>>
>> On Thu, Jun 22, 2023 at 3:05 AM enh <enh@google.com> wrote:
>> >
>> >
>> >
>> > On Wed, Jun 21, 2023 at 11:39 AM 罗勇刚(Yonggang Luo) <
luoyonggang@gmail.com> wrote:
>> >>
>> >>
>> >>
>> >> On Wed, Jun 21, 2023 at 10:31 PM enh <enh@google.com> wrote:
>> >> >
>> >> >
>> >> >
>> >> > On Wed, Jun 21, 2023 at 2:21 AM 罗勇刚(Yonggang Luo) <
luoyonggang@gmail.com> wrote:
>> >> >>
>> >> >>
>> >> >>
>> >> >> On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <
joseph@codesourcery.com> wrote:
>> >> >> >
>> >> >> > On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
>> >> >> >
>> >> >> > > diff --git a/sysdeps/pthread/threads.h
b/sysdeps/pthread/threads.h
>> >> >> > > index d88d7a3ddd..4f61ad9236 100644
>> >> >> > > --- a/sysdeps/pthread/threads.h
>> >> >> > > +++ b/sysdeps/pthread/threads.h
>> >> >> > > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
>> >> >> > >  #ifndef __USE_TIME_BITS64
>> >> >> > >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
>> >> >> > >                         const struct timespec *__restrict
__time_point);
>> >> >> > > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int
time_base,
>> >> >> > > +                               const struct timespec
*__restrict __time_point);
>> >> >> >
>> >> >> > As noted, this should be conditional on __USE_GNU.  Since you
didn't make
>> >> >> > it conditional, I'd expect it to have failed the conform/
namespace tests
>> >> >> > - both for the mtx_timedlock_base name itself if there weren't
incorrect
>> >> >> > conform/ changes in the patch series, and for the time_base
parameter
>> >> >> > (parameters in installed headers should always have a leading
__).  How
>> >> >> > did you test these patches?
>> >> >>
>> >> >> I am not testing these patches yet(as a new contributor for glibc,
don't know how to do that yet),
>> >> >> and for this patch, I'd like to know if the prototype of these two
functions is proper first
>> >> >>
>> >> >> int mtx_timedlock_base(mtx_t *restrict m, int time_base, const
struct timespec *restrict ts);
>> >> >>
>> >> >> int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
time_base, const struct timespec *restrict ts);
>> >> >>
>> >> >> The function name was suggested by Jens Gustedt, and indeed I also
thought about this name in the first place(because posix has cond_clockwait
and mutex_clocklock already). And seems enh also like this
>> >> >
>> >> >
>> >> > well, to the extent that i think "pthreads that's also available on
Windows" is useful to some, sure, i'll continue to add the trivial inline
functions to bionic so that this is actually portable (
https://android.googlesource.com/platform/bionic/+/master/libc/include/bits/threads_inlines.h).
but for Android host tools themselves, i think we'll continue to use
std::thread or pthreads via mingw.
>> >> >
>> >> > but my real feedback earlier was the same as what you're seeing
here: "since this is a WG14-driven thing, it should come as a proposal from
there first". anyone using bionic or glibc already has perfectly good
pthread apis, so no real need for this stuff until/unless it's in Windows.
(and last time i looked, Windows hadn't actually implemented the existing
<threads.h> stuff yet?)
>> >>
>> >> Yeah, you are correct, windows msvc doesn't have either pthread or
c11 threads, and pthreads is so huge, so there is multiple third-party c11
threads implementation for MSVC, that's why I wanna c2y threads comes with
monotonic mtx_timedlock cnd_timedwait support, so that the third-party c11
threads implementation have a consistence API to implement.
>> >
>> >
>> > if MS didn't bother to implement the C11 functions, why do you think
they'd implement any future additions?
>>
>> I don't bother MS if they will implement the C11 functions, I just want
a set of cross-platform threads api(c11 threads) to use (non-posix
non-pthreads), we can always polyfill that API when the native libc doesn't
support that.
>> The API is more important than who would implement it
>
>
> if you're the only person implementing it _and_ the only person using it
... it doesn't really matter what you call it? just put _something_ in your
code, and worry about changing the name/signature if/when WG14 adds
something equivalent.

I am not the only person implementing it _and_ the only person using it
obviously, I am just the only person that want to improve the c11 threads
api currently

>
>>
>> >
>> >>
>> >> So my question, anyone in this threads have suggestion about the
newly proposed API:
>> >>
>> >>  int mtx_timedlock_base (mtx_t*, int, const struct timespec*);
>> >>  int cnd_timedwait_base (cnd_t*, mtx_t*, int, const struct timespec*);
>> >
>> >
>> > don't existing functions put the `int __base` last? sounds like a
question for WG14 rather than c library implementors though --- as long as
this isn't supported on the platform that doesn't have pthreads, it's not
filling any obvious need.
>> >
>> >>
>> >> >
>> >> >>
>> >> >> If we have minimal agreement about this proposal, I'd like to add
tests for it. But still, I don't think
>> >> >> __USE_GNU is a good name for it, because it's for C2y or C3x, any
better option for this, so that it's not GNU restricted, for example,
suppose MSVC also wants to implement this?
>> >> >>
>> >> >>
>> >> >> >
>> >> >> > > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict
__mutex,
>> >> >> > > +                                            int time_base,
>> >> >> > > +                                            const struct
timespec *__restrict
>> >> >> > > +                                            __time_point),
>> >> >> > > +                       __mtx_timedlock_base64);
>> >> >> >
>> >> >> > Likewise, should be conditional on __USE_GNU and time_base
should be
>> >> >> > __time_base.
>> >> >> >
>> >> >> > > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
>> >> >> > > +                               mtx_t *__restrict __mutex, int
time_base,
>> >> >> > > +                               const struct timespec
*__restrict __time_point);
>> >> >> >
>> >> >> > > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict
__cond,
>> >> >> > > +                                            mtx_t *__restrict
__mutex,
>> >> >> > > +                                            int time_base,
>> >> >> > > +                                            const struct
timespec *__restrict
>> >> >> > > +                                            __time_point),
>> >> >> >
>> >> >> > Likewise.
>> >> >> >
>> >> >> > --
>> >> >> > Joseph S. Myers
>> >> >> > joseph@codesourcery.com
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >>          此致
>> >> >> 礼
>> >> >> 罗勇刚
>> >> >> Yours
>> >> >>     sincerely,
>> >> >> Yonggang Luo
>> >>
>> >>
>> >>
>> >> --
>> >>          此致
>> >> 礼
>> >> 罗勇刚
>> >> Yours
>> >>     sincerely,
>> >> Yonggang Luo
>>
>>
>>
>> --
>>          此致
>> 礼
>> 罗勇刚
>> Yours
>>     sincerely,
>> Yonggang Luo



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
  
enh June 21, 2023, 7:41 p.m. UTC | #17
On Wed, Jun 21, 2023 at 12:38 PM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
wrote:

>
>
> On Thu, Jun 22, 2023 at 3:18 AM enh <enh@google.com> wrote:
> >
> >
> >
> > On Wed, Jun 21, 2023 at 12:08 PM 罗勇刚(Yonggang Luo) <
> luoyonggang@gmail.com> wrote:
> >>
> >>
> >>
> >> On Thu, Jun 22, 2023 at 3:05 AM enh <enh@google.com> wrote:
> >> >
> >> >
> >> >
> >> > On Wed, Jun 21, 2023 at 11:39 AM 罗勇刚(Yonggang Luo) <
> luoyonggang@gmail.com> wrote:
> >> >>
> >> >>
> >> >>
> >> >> On Wed, Jun 21, 2023 at 10:31 PM enh <enh@google.com> wrote:
> >> >> >
> >> >> >
> >> >> >
> >> >> > On Wed, Jun 21, 2023 at 2:21 AM 罗勇刚(Yonggang Luo) <
> luoyonggang@gmail.com> wrote:
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <
> joseph@codesourcery.com> wrote:
> >> >> >> >
> >> >> >> > On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
> >> >> >> >
> >> >> >> > > diff --git a/sysdeps/pthread/threads.h
> b/sysdeps/pthread/threads.h
> >> >> >> > > index d88d7a3ddd..4f61ad9236 100644
> >> >> >> > > --- a/sysdeps/pthread/threads.h
> >> >> >> > > +++ b/sysdeps/pthread/threads.h
> >> >> >> > > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
> >> >> >> > >  #ifndef __USE_TIME_BITS64
> >> >> >> > >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
> >> >> >> > >                         const struct timespec *__restrict
> __time_point);
> >> >> >> > > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex,
> int time_base,
> >> >> >> > > +                               const struct timespec
> *__restrict __time_point);
> >> >> >> >
> >> >> >> > As noted, this should be conditional on __USE_GNU.  Since you
> didn't make
> >> >> >> > it conditional, I'd expect it to have failed the conform/
> namespace tests
> >> >> >> > - both for the mtx_timedlock_base name itself if there weren't
> incorrect
> >> >> >> > conform/ changes in the patch series, and for the time_base
> parameter
> >> >> >> > (parameters in installed headers should always have a leading
> __).  How
> >> >> >> > did you test these patches?
> >> >> >>
> >> >> >> I am not testing these patches yet(as a new contributor for
> glibc, don't know how to do that yet),
> >> >> >> and for this patch, I'd like to know if the prototype of these
> two functions is proper first
> >> >> >>
> >> >> >> int mtx_timedlock_base(mtx_t *restrict m, int time_base, const
> struct timespec *restrict ts);
> >> >> >>
> >> >> >> int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
> time_base, const struct timespec *restrict ts);
> >> >> >>
> >> >> >> The function name was suggested by Jens Gustedt, and indeed I
> also thought about this name in the first place(because posix has
> cond_clockwait and mutex_clocklock already). And seems enh also like this
> >> >> >
> >> >> >
> >> >> > well, to the extent that i think "pthreads that's also available
> on Windows" is useful to some, sure, i'll continue to add the trivial
> inline functions to bionic so that this is actually portable (
> https://android.googlesource.com/platform/bionic/+/master/libc/include/bits/threads_inlines.h).
> but for Android host tools themselves, i think we'll continue to use
> std::thread or pthreads via mingw.
> >> >> >
> >> >> > but my real feedback earlier was the same as what you're seeing
> here: "since this is a WG14-driven thing, it should come as a proposal from
> there first". anyone using bionic or glibc already has perfectly good
> pthread apis, so no real need for this stuff until/unless it's in Windows.
> (and last time i looked, Windows hadn't actually implemented the existing
> <threads.h> stuff yet?)
> >> >>
> >> >> Yeah, you are correct, windows msvc doesn't have either pthread or
> c11 threads, and pthreads is so huge, so there is multiple third-party c11
> threads implementation for MSVC, that's why I wanna c2y threads comes with
> monotonic mtx_timedlock cnd_timedwait support, so that the third-party c11
> threads implementation have a consistence API to implement.
> >> >
> >> >
> >> > if MS didn't bother to implement the C11 functions, why do you think
> they'd implement any future additions?
> >>
> >> I don't bother MS if they will implement the C11 functions, I just want
> a set of cross-platform threads api(c11 threads) to use (non-posix
> non-pthreads), we can always polyfill that API when the native libc doesn't
> support that.
> >> The API is more important than who would implement it
> >
> >
> > if you're the only person implementing it _and_ the only person using it
> ... it doesn't really matter what you call it? just put _something_ in your
> code, and worry about changing the name/signature if/when WG14 adds
> something equivalent.
>
> I am not the only person implementing it _and_ the only person using it
> obviously, I am just the only person that want to improve the c11 threads
> api currently
>

i thought you said you wanted this for mesa?


> >
> >>
> >> >
> >> >>
> >> >> So my question, anyone in this threads have suggestion about the
> newly proposed API:
> >> >>
> >> >>  int mtx_timedlock_base (mtx_t*, int, const struct timespec*);
> >> >>  int cnd_timedwait_base (cnd_t*, mtx_t*, int, const struct
> timespec*);
> >> >
> >> >
> >> > don't existing functions put the `int __base` last? sounds like a
> question for WG14 rather than c library implementors though --- as long as
> this isn't supported on the platform that doesn't have pthreads, it's not
> filling any obvious need.
> >> >
> >> >>
> >> >> >
> >> >> >>
> >> >> >> If we have minimal agreement about this proposal, I'd like to add
> tests for it. But still, I don't think
> >> >> >> __USE_GNU is a good name for it, because it's for C2y or C3x, any
> better option for this, so that it's not GNU restricted, for example,
> suppose MSVC also wants to implement this?
> >> >> >>
> >> >> >>
> >> >> >> >
> >> >> >> > > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t
> *__restrict __mutex,
> >> >> >> > > +                                            int time_base,
> >> >> >> > > +                                            const struct
> timespec *__restrict
> >> >> >> > > +                                            __time_point),
> >> >> >> > > +                       __mtx_timedlock_base64);
> >> >> >> >
> >> >> >> > Likewise, should be conditional on __USE_GNU and time_base
> should be
> >> >> >> > __time_base.
> >> >> >> >
> >> >> >> > > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
> >> >> >> > > +                               mtx_t *__restrict __mutex,
> int time_base,
> >> >> >> > > +                               const struct timespec
> *__restrict __time_point);
> >> >> >> >
> >> >> >> > > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t
> *__restrict __cond,
> >> >> >> > > +                                            mtx_t
> *__restrict __mutex,
> >> >> >> > > +                                            int time_base,
> >> >> >> > > +                                            const struct
> timespec *__restrict
> >> >> >> > > +                                            __time_point),
> >> >> >> >
> >> >> >> > Likewise.
> >> >> >> >
> >> >> >> > --
> >> >> >> > Joseph S. Myers
> >> >> >> > joseph@codesourcery.com
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> --
> >> >> >>          此致
> >> >> >> 礼
> >> >> >> 罗勇刚
> >> >> >> Yours
> >> >> >>     sincerely,
> >> >> >> Yonggang Luo
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >>          此致
> >> >> 礼
> >> >> 罗勇刚
> >> >> Yours
> >> >>     sincerely,
> >> >> Yonggang Luo
> >>
> >>
> >>
> >> --
> >>          此致
> >> 礼
> >> 罗勇刚
> >> Yours
> >>     sincerely,
> >> Yonggang Luo
>
>
>
> --
>          此致
> 礼
> 罗勇刚
> Yours
>     sincerely,
> Yonggang Luo
>
  
develop--- via Libc-alpha June 21, 2023, 7:43 p.m. UTC | #18
On Thu, Jun 22, 2023 at 3:18 AM enh <enh@google.com> wrote:
>
>
>
> On Wed, Jun 21, 2023 at 12:08 PM 罗勇刚(Yonggang Luo) <luoyonggang@gmail.com>
wrote:
>>
>>
>>
>> On Thu, Jun 22, 2023 at 3:05 AM enh <enh@google.com> wrote:
>> >
>> >
>> >
>> > On Wed, Jun 21, 2023 at 11:39 AM 罗勇刚(Yonggang Luo) <
luoyonggang@gmail.com> wrote:
>> >>
>> >>
>> >>
>> >> On Wed, Jun 21, 2023 at 10:31 PM enh <enh@google.com> wrote:
>> >> >
>> >> >
>> >> >
>> >> > On Wed, Jun 21, 2023 at 2:21 AM 罗勇刚(Yonggang Luo) <
luoyonggang@gmail.com> wrote:
>> >> >>
>> >> >>
>> >> >>
>> >> >> On Wed, Jun 21, 2023 at 4:41 AM Joseph Myers <
joseph@codesourcery.com> wrote:
>> >> >> >
>> >> >> > On Wed, 21 Jun 2023, Yonggang Luo via Libc-alpha wrote:
>> >> >> >
>> >> >> > > diff --git a/sysdeps/pthread/threads.h
b/sysdeps/pthread/threads.h
>> >> >> > > index d88d7a3ddd..4f61ad9236 100644
>> >> >> > > --- a/sysdeps/pthread/threads.h
>> >> >> > > +++ b/sysdeps/pthread/threads.h
>> >> >> > > @@ -146,14 +146,22 @@ extern int mtx_lock (mtx_t *__mutex);
>> >> >> > >  #ifndef __USE_TIME_BITS64
>> >> >> > >  extern int mtx_timedlock (mtx_t *__restrict __mutex,
>> >> >> > >                         const struct timespec *__restrict
__time_point);
>> >> >> > > +extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int
time_base,
>> >> >> > > +                               const struct timespec
*__restrict __time_point);
>> >> >> >
>> >> >> > As noted, this should be conditional on __USE_GNU.  Since you
didn't make
>> >> >> > it conditional, I'd expect it to have failed the conform/
namespace tests
>> >> >> > - both for the mtx_timedlock_base name itself if there weren't
incorrect
>> >> >> > conform/ changes in the patch series, and for the time_base
parameter
>> >> >> > (parameters in installed headers should always have a leading
__).  How
>> >> >> > did you test these patches?
>> >> >>
>> >> >> I am not testing these patches yet(as a new contributor for glibc,
don't know how to do that yet),
>> >> >> and for this patch, I'd like to know if the prototype of these two
functions is proper first
>> >> >>
>> >> >> int mtx_timedlock_base(mtx_t *restrict m, int time_base, const
struct timespec *restrict ts);
>> >> >>
>> >> >> int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
time_base, const struct timespec *restrict ts);
>> >> >>
>> >> >> The function name was suggested by Jens Gustedt, and indeed I also
thought about this name in the first place(because posix has cond_clockwait
and mutex_clocklock already). And seems enh also like this
>> >> >
>> >> >
>> >> > well, to the extent that i think "pthreads that's also available on
Windows" is useful to some, sure, i'll continue to add the trivial inline
functions to bionic so that this is actually portable (
https://android.googlesource.com/platform/bionic/+/master/libc/include/bits/threads_inlines.h).
but for Android host tools themselves, i think we'll continue to use
std::thread or pthreads via mingw.
>> >> >
>> >> > but my real feedback earlier was the same as what you're seeing
here: "since this is a WG14-driven thing, it should come as a proposal from
there first". anyone using bionic or glibc already has perfectly good
pthread apis, so no real need for this stuff until/unless it's in Windows.
(and last time i looked, Windows hadn't actually implemented the existing
<threads.h> stuff yet?)
>> >>
>> >> Yeah, you are correct, windows msvc doesn't have either pthread or
c11 threads, and pthreads is so huge, so there is multiple third-party c11
threads implementation for MSVC, that's why I wanna c2y threads comes with
monotonic mtx_timedlock cnd_timedwait support, so that the third-party c11
threads implementation have a consistence API to implement.
>> >
>> >
>> > if MS didn't bother to implement the C11 functions, why do you think
they'd implement any future additions?
>>
>> I don't bother MS if they will implement the C11 functions, I just want
a set of cross-platform threads api(c11 threads) to use (non-posix
non-pthreads), we can always polyfill that API when the native libc doesn't
support that.
>> The API is more important than who would implement it
>
>
> if you're the only person implementing it _and_ the only person using it
... it doesn't really matter what you call it? just put _something_ in your
code, and worry about changing the name/signature if/when WG14 adds
something equivalent.
>
Think about a condition, support I want to use monotonic c11 threads
timedwait timedlock,
And I implemented it locally, then for glibc/bionic, I have to give it's
native implemented c11 threads, because those API doesn't support
monotonic timedwait timedlock, for platforms doesn't support c11 threads
anybody can implement a polyfill, that's not an issue, That's the reason
why I proposal this.

>>
>> >
>> >>
>> >> So my question, anyone in this threads have suggestion about the
newly proposed API:
>> >>
>> >>  int mtx_timedlock_base (mtx_t*, int, const struct timespec*);
>> >>  int cnd_timedwait_base (cnd_t*, mtx_t*, int, const struct timespec*);
>> >
>> >
>> > don't existing functions put the `int __base` last? sounds like a
question for WG14 rather than c library implementors though --- as long as
this isn't supported on the platform that doesn't have pthreads, it's not
filling any obvious need.
>> >
>> >>
>> >> >
>> >> >>
>> >> >> If we have minimal agreement about this proposal, I'd like to add
tests for it. But still, I don't think
>> >> >> __USE_GNU is a good name for it, because it's for C2y or C3x, any
better option for this, so that it's not GNU restricted, for example,
suppose MSVC also wants to implement this?
>> >> >>
>> >> >>
>> >> >> >
>> >> >> > > +extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict
__mutex,
>> >> >> > > +                                            int time_base,
>> >> >> > > +                                            const struct
timespec *__restrict
>> >> >> > > +                                            __time_point),
>> >> >> > > +                       __mtx_timedlock_base64);
>> >> >> >
>> >> >> > Likewise, should be conditional on __USE_GNU and time_base
should be
>> >> >> > __time_base.
>> >> >> >
>> >> >> > > +extern int cnd_timedwait_base (cnd_t *__restrict __cond,
>> >> >> > > +                               mtx_t *__restrict __mutex, int
time_base,
>> >> >> > > +                               const struct timespec
*__restrict __time_point);
>> >> >> >
>> >> >> > > +extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict
__cond,
>> >> >> > > +                                            mtx_t *__restrict
__mutex,
>> >> >> > > +                                            int time_base,
>> >> >> > > +                                            const struct
timespec *__restrict
>> >> >> > > +                                            __time_point),
>> >> >> >
>> >> >> > Likewise.
>> >> >> >
>> >> >> > --
>> >> >> > Joseph S. Myers
>> >> >> > joseph@codesourcery.com
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >>          此致
>> >> >> 礼
>> >> >> 罗勇刚
>> >> >> Yours
>> >> >>     sincerely,
>> >> >> Yonggang Luo
>> >>
>> >>
>> >>
>> >> --
>> >>          此致
>> >> 礼
>> >> 罗勇刚
>> >> Yours
>> >>     sincerely,
>> >> Yonggang Luo
>>
>>
>>
>> --
>>          此致
>> 礼
>> 罗勇刚
>> Yours
>>     sincerely,
>> Yonggang Luo



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
  
develop--- via Libc-alpha June 21, 2023, 8:14 p.m. UTC | #19
> i thought you said you wanted this for mesa?

yeap, mesa is one of those,
for example https://github.com/tinycthread/tinycthread have 800 star, those
people using
timedwait timedlock with TIME_UTC is because the c11 threads only have this
API, not because they do not want the monotonic timedwait/timedlock

In most case monotonic won't affect by system time change(that's more
stable).

--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
  

Patch

diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
index 406e497726..e938e0512c 100644
--- a/conform/data/threads.h-data
+++ b/conform/data/threads.h-data
@@ -34,6 +34,7 @@  function void thrd_yield (void)
 function int mtx_init (mtx_t*, int)
 function int mtx_lock (mtx_t*)
 function int mtx_timedlock (mtx_t*, const struct timespec*)
+function int mtx_timedlock_base (mtx_t*, int, const struct timespec*)
 function int mtx_trylock (mtx_t*)
 function int mtx_unlock (mtx_t*)
 function void mtx_destroy (mtx_t*)
@@ -45,6 +46,7 @@  function int cnd_signal (cnd_t*)
 function int cnd_broadcast (cnd_t*)
 function int cnd_wait (cnd_t*, mtx_t*)
 function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*)
+function int cnd_timedwait_base (cnd_t*, mtx_t*, int, const struct timespec*)
 function void cnd_destroy (cnd_t*)
 
 function int tss_create (tss_t*, tss_dtor_t)
diff --git a/htl/Versions b/htl/Versions
index 70fa44631a..804005bfb9 100644
--- a/htl/Versions
+++ b/htl/Versions
@@ -170,6 +170,11 @@  libpthread {
     sem_clockwait;
   }
 
+  GLIBC_2.38 {
+    cnd_timedwait_base;
+    mtx_timedlock_base;
+  }
+
   GLIBC_PRIVATE {
     __pthread_initialize_minimal;
 
diff --git a/nptl/Versions b/nptl/Versions
index 3221de89d1..d44ab2b12d 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -525,6 +525,11 @@  libpthread {
   GLIBC_2.31 {
     __libpthread_version_placeholder;
   }
+
+  GLIBC_2.38 {
+    cnd_timedwait_base;
+    mtx_timedlock_base;
+  }
 }
 
 ld {
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index 32cf4eb119..a4a9d1b2cc 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -40,11 +40,13 @@  $(libpthread-routines-var) += \
   cnd_init \
   cnd_signal \
   cnd_timedwait \
+  cnd_timedwait_base \
   cnd_wait \
   mtx_destroy \
   mtx_init \
   mtx_lock \
   mtx_timedlock \
+  mtx_timedlock_base \
   mtx_trylock \
   mtx_unlock \
   pthread_atfork_compat \
diff --git a/sysdeps/pthread/cnd_timedwait_base.c b/sysdeps/pthread/cnd_timedwait_base.c
new file mode 100644
index 0000000000..e9be66ca0e
--- /dev/null
+++ b/sysdeps/pthread/cnd_timedwait_base.c
@@ -0,0 +1,29 @@ 
+/* C11 threads conditional timed wait implementation.
+   Copyright (C) 2018-2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+int
+cnd_timedwait_base (cnd_t *restrict cond, mtx_t *restrict mutex, int time_base,
+                    const struct timespec *restrict time_point)
+{
+  int err_code = __pthread_cond_clockwait ((pthread_cond_t *) cond,
+                                           (pthread_mutex_t *) mutex,
+                                           time_base, time_point);
+  return thrd_err_map (err_code);
+}
diff --git a/sysdeps/pthread/mtx_timedlock_base.c b/sysdeps/pthread/mtx_timedlock_base.c
new file mode 100644
index 0000000000..9aecf84440
--- /dev/null
+++ b/sysdeps/pthread/mtx_timedlock_base.c
@@ -0,0 +1,28 @@ 
+/* C11 threads mutex timed lock implementation.
+   Copyright (C) 2018-2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+int
+mtx_timedlock_base (mtx_t *restrict mutex, int time_base,
+                    const struct timespec *restrict time_point)
+{
+  int err_code = __pthread_mutex_clocklock ((pthread_mutex_t *) mutex,
+                                            time_base, time_point);
+  return thrd_err_map (err_code);
+}
diff --git a/sysdeps/pthread/threads.h b/sysdeps/pthread/threads.h
index d88d7a3ddd..4f61ad9236 100644
--- a/sysdeps/pthread/threads.h
+++ b/sysdeps/pthread/threads.h
@@ -146,14 +146,22 @@  extern int mtx_lock (mtx_t *__mutex);
 #ifndef __USE_TIME_BITS64
 extern int mtx_timedlock (mtx_t *__restrict __mutex,
 			  const struct timespec *__restrict __time_point);
+extern int mtx_timedlock_base (mtx_t *__restrict __mutex, int time_base,
+                               const struct timespec *__restrict __time_point);
 #else
 # ifdef __REDIRECT
 extern int __REDIRECT (mtx_timedlock, (mtx_t *__restrict __mutex,
                                        const struct timespec *__restrict
                                        __time_point),
                        __mtx_timedlock64);
+extern int __REDIRECT (mtx_timedlock_base, (mtx_t *__restrict __mutex,
+                                            int time_base,
+                                            const struct timespec *__restrict
+                                            __time_point),
+                       __mtx_timedlock_base64);
 # else
 #  define mtx_timedlock __mtx_timedlock64
+#  define mtx_timedlock_base __mtx_timedlock_base64
 # endif
 #endif
 
@@ -198,6 +206,9 @@  extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex);
 extern int cnd_timedwait (cnd_t *__restrict __cond,
 			  mtx_t *__restrict __mutex,
 			  const struct timespec *__restrict __time_point);
+extern int cnd_timedwait_base (cnd_t *__restrict __cond,
+                               mtx_t *__restrict __mutex, int time_base,
+                               const struct timespec *__restrict __time_point);
 #else
 # ifdef __REDIRECT
 extern int __REDIRECT (cnd_timedwait, (cnd_t *__restrict __cond,
@@ -205,8 +216,15 @@  extern int __REDIRECT (cnd_timedwait, (cnd_t *__restrict __cond,
                                        const struct timespec *__restrict
                                        __time_point),
                        __cnd_timedwait64);
+extern int __REDIRECT (cnd_timedwait_base, (cnd_t *__restrict __cond,
+                                            mtx_t *__restrict __mutex,
+                                            int time_base,
+                                            const struct timespec *__restrict
+                                            __time_point),
+                       __cnd_timedwait_base64);
 # else
 #  define cnd_timedwait __cnd_timedwait64
+#  define cnd_timedwait_base __cnd_timedwait_base64
 # endif
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index bc59bce42f..73ce24bea6 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -319,6 +319,12 @@  libc {
   GLIBC_2.37 {
 %ifdef TIME64_NON_DEFAULT
     __ppoll64_chk;
+%endif
+  }
+  GLIBC_2.38 {
+%ifdef TIME64_NON_DEFAULT
+    __cnd_timedwait_base64;
+    __mtx_timedlock_base64;
 %endif
   }
   GLIBC_PRIVATE {
diff --git a/sysdeps/unix/sysv/linux/cnd_timedwait_base.c b/sysdeps/unix/sysv/linux/cnd_timedwait_base.c
new file mode 100644
index 0000000000..2e851a7aec
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/cnd_timedwait_base.c
@@ -0,0 +1,53 @@ 
+/* C11 threads conditional timed wait implementation - Linux variant.
+   Copyright (C) 2020-2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <time.h>
+#include <shlib-compat.h>
+#include "thrd_priv.h"
+
+int
+__cnd_timedwait_base64 (cnd_t *restrict cond, mtx_t *restrict mutex,
+                        int time_base,
+                        const struct __timespec64 *restrict time_point)
+{
+  int err_code = __pthread_cond_clockwait64 ((pthread_cond_t *) cond,
+                                             (pthread_mutex_t *) mutex,
+                                             time_base, time_point);
+  return thrd_err_map (err_code);
+}
+
+#if __TIMESIZE == 64
+strong_alias (__cnd_timedwait_base64, ___cnd_timedwait_base)
+#else
+libc_hidden_def (__cnd_timedwait_base64)
+
+int
+___cnd_timedwait_base (cnd_t *restrict cond, mtx_t *restrict mutex,
+                       int time_base,
+                       const struct timespec *restrict time_point)
+{
+  struct __timespec64 ts64 = valid_timespec_to_timespec64 (*time_point);
+
+  return __cnd_timedwait_base64 (cond, mutex, time_base, &ts64);
+}
+#endif /* __TIMESIZE == 64 */
+versioned_symbol (libc, ___cnd_timedwait_base, cnd_timedwait_base, GLIBC_2_34);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_28, GLIBC_2_34)
+compat_symbol (libpthread, ___cnd_timedwait_base, cnd_timedwait_base, GLIBC_2_28);
+#endif
diff --git a/sysdeps/unix/sysv/linux/mtx_timedlock_base.c b/sysdeps/unix/sysv/linux/mtx_timedlock_base.c
new file mode 100644
index 0000000000..046fb86091
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mtx_timedlock_base.c
@@ -0,0 +1,50 @@ 
+/* C11 threads mutex timed lock implementation - Linux variant.
+   Copyright (C) 2020-2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <time.h>
+#include <shlib-compat.h>
+#include "thrd_priv.h"
+
+int
+__mtx_timedlock_base64 (mtx_t *restrict mutex, int time_base,
+                        const struct __timespec64 *restrict time_point)
+{
+  int err_code = __pthread_mutex_clocklock64 ((pthread_mutex_t *) mutex,
+                                              time_base, time_point);
+  return thrd_err_map (err_code);
+}
+
+#if __TIMESIZE == 64
+strong_alias (__mtx_timedlock_base64, ___mtx_timedlock_base)
+#else
+libc_hidden_def (__mtx_timedlock_base64)
+
+int
+___mtx_timedlock_base (mtx_t *restrict mutex, int time_base,
+                       const struct timespec *restrict time_point)
+{
+  struct __timespec64 ts64 = valid_timespec_to_timespec64 (*time_point);
+
+  return __mtx_timedlock_base64 (mutex, time_base, &ts64);
+}
+#endif /* __TIMESIZE == 64 */
+versioned_symbol (libc, ___mtx_timedlock_base, mtx_timedlock_base, GLIBC_2_34);
+
+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_28, GLIBC_2_34)
+compat_symbol (libpthread, ___mtx_timedlock_base, mtx_timedlock_base, GLIBC_2_28);
+#endif
diff --git a/sysdeps/unix/sysv/linux/thrd_priv.h b/sysdeps/unix/sysv/linux/thrd_priv.h
index af23a10a07..8ea9ced507 100644
--- a/sysdeps/unix/sysv/linux/thrd_priv.h
+++ b/sysdeps/unix/sysv/linux/thrd_priv.h
@@ -20,15 +20,25 @@ 
 
 #if __TIMESIZE == 64
 # define __cnd_timedwait64 __cnd_timedwait
+# define __cnd_timedwait_base64 __cnd_timedwait_base
 # define __mtx_timedlock64 __mtx_timedlock
+# define __mtx_timedlock_base64 __mtx_timedlock_base
 # define __thrd_sleep64 __thrd_sleep
 #else
 extern int __cnd_timedwait64 (cnd_t *restrict cond, mtx_t *restrict mutex,
                               const struct __timespec64 *restrict time_point);
 libc_hidden_proto (__cnd_timedwait64)
+extern int __cnd_timedwait_base64 (cnd_t *restrict cond, mtx_t *restrict mutex,
+                                   int time_base,
+                                   const struct __timespec64 *restrict time_point);
+libc_hidden_proto (__cnd_timedwait_base64)
 extern int __mtx_timedlock64 (mtx_t *restrict mutex,
                               const struct __timespec64 *restrict time_point);
 libc_hidden_proto (__mtx_timedlock64)
+extern int __mtx_timedlock_base64 (mtx_t *restrict mutex, int time_base,
+                                   const struct __timespec64 *restrict
+                                   time_point);
+libc_hidden_proto (__mtx_timedlock_base64)
 extern int __thrd_sleep64 (const struct __timespec64 *time_point,
                            struct __timespec64 *remaining);
 libc_hidden_proto (__thrd_sleep64)