public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "罗勇刚(Yonggang Luo)" <luoyonggang@gmail.com>
To: enh <enh@google.com>
Cc: Joseph Myers <joseph@codesourcery.com>,
	Jens Gustedt <jens.gustedt@inria.fr>,
	 libc-alpha@sourceware.org, Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH v2 4/4] c2y: Add function cnd_timedwait_base and mtx_timedlock_base
Date: Thu, 22 Jun 2023 03:07:48 +0800	[thread overview]
Message-ID: <CAE2XoE_kFDVjLO95R7U0UH+F0PJgPu3d67-ZZLxk1_TC2KFKEQ@mail.gmail.com> (raw)
In-Reply-To: <CAJgzZooH_NM8+YYh630864sX=_BpN=4YAcE=mOaeyiqx0_vvjg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 6347 bytes --]

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

  reply	other threads:[~2023-06-21 19:08 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20 17:17 [PATCH v2 0/4] c2y proposal add monotonicwait support for mtx and ctx Yonggang Luo
2023-06-20 17:17 ` [PATCH v2 1/4] clang-format: should format with 2 space and do not usage tab Yonggang Luo
2023-06-20 17:45   ` Zack Weinberg
2023-06-21  6:31     ` 罗勇刚(Yonggang Luo)
2023-06-21  6:47       ` Xi Ruoyao
2023-06-21  6:55         ` 罗勇刚(Yonggang Luo)
2023-06-21  7:13           ` Xi Ruoyao
2023-06-21  7:36             ` 罗勇刚(Yonggang Luo)
2023-06-21 14:26       ` Zack Weinberg
2023-06-21  7:17     ` Xi Ruoyao
2023-06-21 16:19     ` Carlos O'Donell
2023-06-21 17:35       ` Joseph Myers
2023-06-21 17:41         ` 罗勇刚(Yonggang Luo)
2023-06-21 17:49           ` Andrew Pinski
2023-06-21 17:59             ` 罗勇刚(Yonggang Luo)
2023-06-21 18:31               ` Arsen Arsenović
2023-06-21 18:42                 ` 罗勇刚(Yonggang Luo)
2023-06-21 19:36           ` Zack Weinberg
2023-06-21 21:26         ` Paul Eggert
2023-06-22 21:43           ` Joseph Myers
2023-06-22 21:48             ` Paul Eggert
2023-06-20 17:17 ` [PATCH v2 2/4] time: Implement c23 timespec_get base Yonggang Luo
2023-06-20 20:37   ` Joseph Myers
2023-06-21  6:42     ` 罗勇刚(Yonggang Luo)
2023-06-20 17:17 ` [PATCH v2 3/4] c11: Switch to use pthread_mutex_clocklock and pthread_cond_clockwait to implement cnd and mtx lock and wait Yonggang Luo
2023-06-20 17:17 ` [PATCH v2 4/4] c2y: Add function cnd_timedwait_base and mtx_timedlock_base Yonggang Luo
2023-06-20 20:41   ` Joseph Myers
2023-06-21  9:21     ` 罗勇刚(Yonggang Luo)
2023-06-21  9:54       ` Xi Ruoyao
2023-06-21 10:16         ` 罗勇刚(Yonggang Luo)
2023-06-21 10:25           ` Xi Ruoyao
2023-06-21 10:40           ` Florian Weimer
2023-06-21 13:23             ` Jₑₙₛ Gustedt
2023-06-21 12:09       ` Joseph Myers
2023-06-21 14:30       ` enh
2023-06-21 15:08         ` Joseph Myers
2023-06-21 18:39         ` 罗勇刚(Yonggang Luo)
2023-06-21 19:04           ` enh
2023-06-21 19:07             ` 罗勇刚(Yonggang Luo) [this message]
2023-06-21 19:18               ` enh
2023-06-21 19:38                 ` 罗勇刚(Yonggang Luo)
2023-06-21 19:41                   ` enh
2023-06-21 20:14                     ` 罗勇刚(Yonggang Luo)
2023-06-21 19:43                 ` 罗勇刚(Yonggang Luo)
2023-06-20 20:50   ` Joseph Myers
2023-06-20 20:45 ` [PATCH v2 0/4] c2y proposal add monotonicwait support for mtx and ctx Joseph Myers
2023-06-21  6:52   ` 罗勇刚(Yonggang Luo)
2023-06-21  7:14     ` Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE2XoE_kFDVjLO95R7U0UH+F0PJgPu3d67-ZZLxk1_TC2KFKEQ@mail.gmail.com \
    --to=luoyonggang@gmail.com \
    --cc=enh@google.com \
    --cc=fweimer@redhat.com \
    --cc=jens.gustedt@inria.fr \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).