From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21598 invoked from network); 20 Jun 2023 07:54:09 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 20 Jun 2023 07:54:09 -0000 Received: (qmail 1540 invoked by uid 550); 20 Jun 2023 07:54:06 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 1504 invoked from network); 20 Jun 2023 07:54:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687247634; x=1689839634; h=to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gDP1cx1FxjmbfCIRr7yLoTuE7hI/H4AOIc9tepMjor4=; b=AfAkMfiZjzidUgnpoH2p093HpIaKXrQ/vKTdULr1NMZRhxcPam9rWYTvtBVzu5OUl9 2/zv4JhjgYEG3A95QDZHAUcYxi2sW/8g+VTePpCbynLWglE9kFFzkCFGgeaGGmfGPzM3 aFBUME+iS6nI/fMiTi1X1/C6c4PGBtZUJwx1gYSKkLYwuAafERVvafsLIUZvH/EnRUGv NZWzv+jeMftk3jzweTQReuA9vcAcHXpAPZwYhE1gp8LFYtGRYCJMdySOKQ+juyk63gbF HPRQ5tVPsxKoB1u27mh9QmZHImNcurGO+diRHTuAoOQv/f1mbPU0ZbDDC3r6GNNOt5Eq GuJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247634; x=1689839634; h=to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gDP1cx1FxjmbfCIRr7yLoTuE7hI/H4AOIc9tepMjor4=; b=ediTePtvyC55p8CcCOngtmOjxXcH6MLShrbpTDW4j/qLX3Z7leOA8uPQJ/QKjKRtdY 7yv+sDGuk0WUeKDYbnL3pgA2UTSY10ZcXSJyi29RkjQOA8NhlbKqhYzy/WzE2c5ZZHt6 YlHYRzGwcj8+P2JU779jYwvCH743Yw1d5riKjX3KyBeUQUx3JxhvXtVfiH+aHOioYRZD CvbkY6RziQy8v8uovw06pDYohXEz5GzJlf+9F/crBcg1SO1i5z4SNGDF0ZoY5Galr+7N H4nuqatmw35bjVXEBDyiq5tjbiIzzgrUI6KhMKXyAH8x1rWuKK0/2NKlVylgGW1DEMc/ RV6g== X-Gm-Message-State: AC+VfDwgcMuPwPOLCGBfLK5wpb7D4hHWn7siIMRuy6nQ+E25V611LpP8 4NdF37/QN8VS1mMTWBjjHIP1KqrfH/ocJcGJ+WOtIP6Uw7ki0A== X-Google-Smtp-Source: ACHHUZ7in2KPQMY6Nce6SnETyWCQAHwGf3y2xb2dsATBRolelQO2mHMIMAjGmqifewXrlFI6XAXQB4H5BegMhfBry5E= X-Received: by 2002:a17:907:7da7:b0:989:2a82:fb0a with SMTP id oz39-20020a1709077da700b009892a82fb0amr909520ejc.71.1687247633543; Tue, 20 Jun 2023 00:53:53 -0700 (PDT) MIME-Version: 1.0 References: <20230620002507.796-1-luoyonggang@gmail.com> <20230620002507.796-5-luoyonggang@gmail.com> In-Reply-To: <20230620002507.796-5-luoyonggang@gmail.com> From: =?UTF-8?B?572X5YuH5YiaKFlvbmdnYW5nIEx1byk=?= Date: Tue, 20 Jun 2023 15:53:42 +0800 Message-ID: To: Jens Gustedt , musl@lists.openwall.com Content-Type: multipart/alternative; boundary="000000000000d8758b05fe8af346" Subject: [musl] Re: [PATCH 4/4] c2y: Add monotonic timed wait support for threads mtx cnd --000000000000d8758b05fe8af346 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I'd like to receive some feedback of the function names mtx_timedlock_monotonic cnd_timedwait_monotonic is properly as a proposal for c2y(the next standard after c23). If that's acceptable by anyone, I'd like to use these names in the mesa code base. Currently if I want to use monotonic timedlock and timedwait in mesa code base, I needs implement complicated https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21291/diffs?commi= t_id=3Db240090ceb3ccdfb12fa0a3a258328e7df09803d So I'd like to introduce these two functions in c2y, and indeed mesa is not a sole user that face this issue, On Tue, Jun 20, 2023 at 8:25=E2=80=AFAM Yonggang Luo wrote: > > Add two monotonic functions: > mtx_timedlock_monotonic > cnd_timedwait_monotonic > > to achieve that > > Signed-off-by: Yonggang Luo > --- > .../time32/cnd_timedwait_monotonic_time32.c | 9 ++++++ > .../time32/mtx_timedlock_monotonic_time32.c | 9 ++++++ > compat/time32/time32.h | 2 ++ > include/threads.h | 4 +++ > src/thread/cnd_timedwait.c | 2 +- > ..._timedwait.c =3D> cnd_timedwait_monotonic.c} | 28 +++++++++---------- > src/thread/mtx_timedlock.c | 2 +- > ..._timedlock.c =3D> mtx_timedlock_monotonic.c} | 26 ++++++++--------- > 8 files changed, 53 insertions(+), 29 deletions(-) > create mode 100644 compat/time32/cnd_timedwait_monotonic_time32.c > create mode 100644 compat/time32/mtx_timedlock_monotonic_time32.c > copy src/thread/{cnd_timedwait.c =3D> cnd_timedwait_monotonic.c} (52%) > copy src/thread/{mtx_timedlock.c =3D> mtx_timedlock_monotonic.c} (74%) > > diff --git a/compat/time32/cnd_timedwait_monotonic_time32.c b/compat/time32/cnd_timedwait_monotonic_time32.c > new file mode 100644 > index 00000000..a61cc944 > --- /dev/null > +++ b/compat/time32/cnd_timedwait_monotonic_time32.c > @@ -0,0 +1,9 @@ > +#include "time32.h" > +#include > +#include > + > +int __cnd_timedwait_monotonic_time32(cnd_t *restrict c, mtx_t *restrict m, const struct timespec32 *restrict ts32) > +{ > + return cnd_timedwait_monotonic(c, m, ts32 ? (&(struct timespec){ > + .tv_sec =3D ts32->tv_sec, .tv_nsec =3D ts32->tv_nsec}) : = 0); > +} > diff --git a/compat/time32/mtx_timedlock_monotonic_time32.c b/compat/time32/mtx_timedlock_monotonic_time32.c > new file mode 100644 > index 00000000..fb610ab8 > --- /dev/null > +++ b/compat/time32/mtx_timedlock_monotonic_time32.c > @@ -0,0 +1,9 @@ > +#include "time32.h" > +#include > +#include > + > +int __mtx_timedlock_monotonic_time32(mtx_t *restrict m, const struct timespec32 *restrict ts32) > +{ > + return mtx_timedlock_monotonic(m, !ts32 ? 0 : (&(struct timespec)= { > + .tv_sec =3D ts32->tv_sec, .tv_nsec =3D ts32->tv_nsec})); > +} > diff --git a/compat/time32/time32.h b/compat/time32/time32.h > index e0af9bff..c98c4a64 100644 > --- a/compat/time32/time32.h > +++ b/compat/time32/time32.h > @@ -34,6 +34,7 @@ int __clock_gettime32() __asm__("clock_gettime"); > int __clock_nanosleep_time32() __asm__("clock_nanosleep"); > int __clock_settime32() __asm__("clock_settime"); > int __cnd_timedwait_time32() __asm__("cnd_timedwait"); > +int __cnd_timedwait_monotonic_time32() __asm__("cnd_timedwait_monotonic"); > char *__ctime32() __asm__("ctime"); > char *__ctime32_r() __asm__("ctime_r"); > double __difftime32() __asm__("difftime"); > @@ -56,6 +57,7 @@ time32_t __mktime32() __asm__("mktime"); > ssize_t __mq_timedreceive_time32() __asm__("mq_timedreceive"); > int __mq_timedsend_time32() __asm__("mq_timedsend"); > int __mtx_timedlock_time32() __asm__("mtx_timedlock"); > +int __mtx_timedlock_monotonic_time32() __asm__("mtx_timedlock_monotonic"); > int __nanosleep_time32() __asm__("nanosleep"); > int __ppoll_time32() __asm__("ppoll"); > int __pselect_time32() __asm__("pselect"); > diff --git a/include/threads.h b/include/threads.h > index 52ec3100..9439d530 100644 > --- a/include/threads.h > +++ b/include/threads.h > @@ -62,6 +62,7 @@ void mtx_destroy(mtx_t *); > > int mtx_lock(mtx_t *); > int mtx_timedlock(mtx_t *__restrict, const struct timespec *__restrict); > +int mtx_timedlock_monotonic(mtx_t *__restrict, const struct timespec *__restrict); > int mtx_trylock(mtx_t *); > int mtx_unlock(mtx_t *); > > @@ -72,6 +73,7 @@ int cnd_broadcast(cnd_t *); > int cnd_signal(cnd_t *); > > int cnd_timedwait(cnd_t *__restrict, mtx_t *__restrict, const struct timespec *__restrict); > +int cnd_timedwait_monotonic(cnd_t *__restrict, mtx_t *__restrict, const struct timespec *__restrict); > int cnd_wait(cnd_t *, mtx_t *); > > int tss_create(tss_t *, tss_dtor_t); > @@ -83,7 +85,9 @@ void *tss_get(tss_t); > #if _REDIR_TIME64 > __REDIR(thrd_sleep, __thrd_sleep_time64); > __REDIR(mtx_timedlock, __mtx_timedlock_time64); > +__REDIR(mtx_timedlock_monotonic, __mtx_timedlock_monotonic_time64); > __REDIR(cnd_timedwait, __cnd_timedwait_time64); > +__REDIR(cnd_timedwait_monotonic, __cnd_timedwait_monotonic_time64); > #endif > > #ifdef __cplusplus > diff --git a/src/thread/cnd_timedwait.c b/src/thread/cnd_timedwait.c > index 2802af52..8c951e0f 100644 > --- a/src/thread/cnd_timedwait.c > +++ b/src/thread/cnd_timedwait.c > @@ -4,7 +4,7 @@ > > int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts) > { > - int ret =3D __pthread_cond_timedwait((pthread_cond_t *)c, (pthread_mutex_t *)m, ts); > + int ret =3D pthread_cond_clockdwait((pthread_cond_t *)c, (pthread_mutex_t *)m, CLOCK_REALTIME, ts); > switch (ret) { > /* May also return EINVAL or EPERM. */ > default: return thrd_error; > diff --git a/src/thread/cnd_timedwait.c b/src/thread/cnd_timedwait_monotonic.c > similarity index 52% > copy from src/thread/cnd_timedwait.c > copy to src/thread/cnd_timedwait_monotonic.c > index 2802af52..a7fe2fd6 100644 > --- a/src/thread/cnd_timedwait.c > +++ b/src/thread/cnd_timedwait_monotonic.c > @@ -1,14 +1,14 @@ > -#include > -#include > -#include > - > -int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts) > -{ > - int ret =3D __pthread_cond_timedwait((pthread_cond_t *)c, (pthread_mutex_t *)m, ts); > - switch (ret) { > - /* May also return EINVAL or EPERM. */ > - default: return thrd_error; > - case 0: return thrd_success; > - case ETIMEDOUT: return thrd_timedout; > - } > -} > +#include > +#include > +#include > + > +int cnd_timedwait_monotonic(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts) > +{ > + int ret =3D pthread_cond_clockdwait((pthread_cond_t *)c, (pthread_mutex_t *)m, CLOCK_MONOTONIC, ts); > + switch (ret) { > + /* May also return EINVAL or EPERM. */ > + default: return thrd_error; > + case 0: return thrd_success; > + case ETIMEDOUT: return thrd_timedout; > + } > +} > diff --git a/src/thread/mtx_timedlock.c b/src/thread/mtx_timedlock.c > index d22c8cf4..30dba40e 100644 > --- a/src/thread/mtx_timedlock.c > +++ b/src/thread/mtx_timedlock.c > @@ -4,7 +4,7 @@ > > int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts) > { > - int ret =3D __pthread_mutex_timedlock((pthread_mutex_t *)m, ts); > + int ret =3D pthread_mutex_clocklock((pthread_mutex_t *)m, CLOCK_REALTIME, ts); > switch (ret) { > default: return thrd_error; > case 0: return thrd_success; > diff --git a/src/thread/mtx_timedlock.c b/src/thread/mtx_timedlock_monotonic.c > similarity index 74% > copy from src/thread/mtx_timedlock.c > copy to src/thread/mtx_timedlock_monotonic.c > index d22c8cf4..a788e877 100644 > --- a/src/thread/mtx_timedlock.c > +++ b/src/thread/mtx_timedlock_monotonic.c > @@ -1,13 +1,13 @@ > -#include > -#include > -#include > - > -int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts) > -{ > - int ret =3D __pthread_mutex_timedlock((pthread_mutex_t *)m, ts); > - switch (ret) { > - default: return thrd_error; > - case 0: return thrd_success; > - case ETIMEDOUT: return thrd_timedout; > - } > -} > +#include > +#include > +#include > + > +int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts) > +{ > + int ret =3D pthread_mutex_clocklock((pthread_mutex_t *)m, CLOCK_MONOTONIC, ts); > + switch (ret) { > + default: return thrd_error; > + case 0: return thrd_success; > + case ETIMEDOUT: return thrd_timedout; > + } > +} > -- > 2.39.0.windows.1 > -- =E6=AD=A4=E8=87=B4 =E7=A4=BC =E7=BD=97=E5=8B=87=E5=88=9A Yours sincerely, Yonggang Luo --000000000000d8758b05fe8af346 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'd like to receive some feedback of the function name= s
mtx_timedlock_monotonic
cnd_timedwait_monotonic

is properly= as a proposal for c2y(the next standard after c23).
If that'= s acceptable by anyone, I'd like to use these names in the mesa code ba= se.
Currently if I want to use monotonic timedlock and timedwait = in mesa code base, I needs implement complicated
So I'd like to introduce these two func= tions in c2y, and indeed mesa is not a sole user that face this issue,


On Tue, Jun 20, 2023 at 8:25=E2=80=AFAM Yonggang Luo <luoyonggang@gmail.com> wrote:>
> Add two monotonic functions:
> mtx_timedlock_monotonic=
> cnd_timedwait_monotonic
>
> to achieve that
>> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
> =C2=A0.../time32/cnd_= timedwait_monotonic_time32.c =C2=A0 | =C2=A09 ++++++
> =C2=A0.../time= 32/mtx_timedlock_monotonic_time32.c =C2=A0 | =C2=A09 ++++++
> =C2=A0c= ompat/time32/time32.h =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A02 ++
> =C2=A0include/threads.h= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A04 +++
> =C2=A0src/thread/cnd_timedwa= it.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A02 +-
> =C2=A0..._timedwait.c =3D> cnd_timedwait_monotonic.c= } | 28 +++++++++----------
> =C2=A0src/thread/mtx_timedlock.c =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A02 +-<= br>> =C2=A0..._timedlock.c =3D> mtx_timedlock_monotonic.c} | 26 +++++= +++---------
> =C2=A08 files changed, 53 insertions(+), 29 deletions(= -)
> =C2=A0create mode 100644 compat/time32/cnd_timedwait_monotonic_t= ime32.c
> =C2=A0create mode 100644 compat/time32/mtx_timedlock_monoto= nic_time32.c
> =C2=A0copy src/thread/{cnd_timedwait.c =3D> cnd_tim= edwait_monotonic.c} (52%)
> =C2=A0copy src/thread/{mtx_timedlock.c = =3D> mtx_timedlock_monotonic.c} (74%)
>
> diff --git a/compa= t/time32/cnd_timedwait_monotonic_time32.c b/compat/time32/cnd_timedwait_mon= otonic_time32.c
> new file mode 100644
> index 00000000..a61cc9= 44
> --- /dev/null
> +++ b/compat/time32/cnd_timedwait_monotoni= c_time32.c
> @@ -0,0 +1,9 @@
> +#include "time32.h"> +#include <time.h>
> +#include <threads.h>
>= +
> +int __cnd_timedwait_monotonic_time32(cnd_t *restrict c, mtx_t *= restrict m, const struct timespec32 *restrict ts32)
> +{
> + = =C2=A0 =C2=A0 =C2=A0 return cnd_timedwait_monotonic(c, m, ts32 ? (&(str= uct timespec){
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .= tv_sec =3D ts32->tv_sec, .tv_nsec =3D ts32->tv_nsec}) : 0);
> += }
> diff --git a/compat/time32/mtx_timedlock_monotonic_time32.c b/com= pat/time32/mtx_timedlock_monotonic_time32.c
> new file mode 100644> index 00000000..fb610ab8
> --- /dev/null
> +++ b/compat/t= ime32/mtx_timedlock_monotonic_time32.c
> @@ -0,0 +1,9 @@
> +#in= clude "time32.h"
> +#include <time.h>
> +#inclu= de <threads.h>
> +
> +int __mtx_timedlock_monotonic_time3= 2(mtx_t *restrict m, const struct timespec32 *restrict ts32)
> +{
= > + =C2=A0 =C2=A0 =C2=A0 return mtx_timedlock_monotonic(m, !ts32 ? 0 : (= &(struct timespec){
> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 .tv_sec =3D ts32->tv_sec, .tv_nsec =3D ts32->tv_nsec}));
&= gt; +}
> diff --git a/compat/time32/time32.h b/compat/time32/time32.h=
> index e0af9bff..c98c4a64 100644
> --- a/compat/time32/time32= .h
> +++ b/compat/time32/time32.h
> @@ -34,6 +34,7 @@ int __clo= ck_gettime32() __asm__("clock_gettime");
> =C2=A0int __cloc= k_nanosleep_time32() __asm__("clock_nanosleep");
> =C2=A0in= t __clock_settime32() __asm__("clock_settime");
> =C2=A0int= __cnd_timedwait_time32() __asm__("cnd_timedwait");
> +int = __cnd_timedwait_monotonic_time32() __asm__("cnd_timedwait_monotonic&qu= ot;);
> =C2=A0char *__ctime32() __asm__("ctime");
> = =C2=A0char *__ctime32_r() __asm__("ctime_r");
> =C2=A0doubl= e __difftime32() __asm__("difftime");
> @@ -56,6 +57,7 @@ t= ime32_t __mktime32() __asm__("mktime");
> =C2=A0ssize_t __m= q_timedreceive_time32() __asm__("mq_timedreceive");
> =C2= =A0int __mq_timedsend_time32() __asm__("mq_timedsend");
> = =C2=A0int __mtx_timedlock_time32() __asm__("mtx_timedlock");
&= gt; +int __mtx_timedlock_monotonic_time32() __asm__("mtx_timedlock_mon= otonic");
> =C2=A0int __nanosleep_time32() __asm__("nanosle= ep");
> =C2=A0int __ppoll_time32() __asm__("ppoll");> =C2=A0int __pselect_time32() __asm__("pselect");
> d= iff --git a/include/threads.h b/include/threads.h
> index 52ec3100..9= 439d530 100644
> --- a/include/threads.h
> +++ b/include/thread= s.h
> @@ -62,6 +62,7 @@ void mtx_destroy(mtx_t *);
>
> = =C2=A0int mtx_lock(mtx_t *);
> =C2=A0int mtx_timedlock(mtx_t *__restr= ict, const struct timespec *__restrict);
> +int mtx_timedlock_monoton= ic(mtx_t *__restrict, const struct timespec *__restrict);
> =C2=A0int= mtx_trylock(mtx_t *);
> =C2=A0int mtx_unlock(mtx_t *);
>
&g= t; @@ -72,6 +73,7 @@ int cnd_broadcast(cnd_t *);
> =C2=A0int cnd_sign= al(cnd_t *);
>
> =C2=A0int cnd_timedwait(cnd_t *__restrict, mtx= _t *__restrict, const struct timespec *__restrict);
> +int cnd_timedw= ait_monotonic(cnd_t *__restrict, mtx_t *__restrict, const struct timespec *= __restrict);
> =C2=A0int cnd_wait(cnd_t *, mtx_t *);
>
> = =C2=A0int tss_create(tss_t *, tss_dtor_t);
> @@ -83,7 +85,9 @@ void *= tss_get(tss_t);
> =C2=A0#if _REDIR_TIME64
> =C2=A0__REDIR(thrd_= sleep, __thrd_sleep_time64);
> =C2=A0__REDIR(mtx_timedlock, __mtx_tim= edlock_time64);
> +__REDIR(mtx_timedlock_monotonic, __mtx_timedlock_m= onotonic_time64);
> =C2=A0__REDIR(cnd_timedwait, __cnd_timedwait_time= 64);
> +__REDIR(cnd_timedwait_monotonic, __cnd_timedwait_monotonic_ti= me64);
> =C2=A0#endif
>
> =C2=A0#ifdef __cplusplus
>= ; diff --git a/src/thread/cnd_timedwait.c b/src/thread/cnd_timedwait.c
&= gt; index 2802af52..8c951e0f 100644
> --- a/src/thread/cnd_timedwait.= c
> +++ b/src/thread/cnd_timedwait.c
> @@ -4,7 +4,7 @@
><= br>> =C2=A0int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const= struct timespec *restrict ts)
> =C2=A0{
> - =C2=A0 =C2=A0 =C2= =A0 int ret =3D __pthread_cond_timedwait((pthread_cond_t *)c, (pthread_mute= x_t *)m, ts);
> + =C2=A0 =C2=A0 =C2=A0 int ret =3D pthread_cond_clock= dwait((pthread_cond_t *)c, (pthread_mutex_t *)m, CLOCK_REALTIME, ts);
&g= t; =C2=A0 =C2=A0 =C2=A0 =C2=A0 switch (ret) {
> =C2=A0 =C2=A0 =C2=A0 = =C2=A0 /* May also return EINVAL or EPERM. */
> =C2=A0 =C2=A0 =C2=A0 = =C2=A0 default: =C2=A0 =C2=A0 =C2=A0 =C2=A0return thrd_error;
> diff = --git a/src/thread/cnd_timedwait.c b/src/thread/cnd_timedwait_monotonic.c> similarity index 52%
> copy from src/thread/cnd_timedwait.c> copy to src/thread/cnd_timedwait_monotonic.c
> index 2802af52..= a7fe2fd6 100644
> --- a/src/thread/cnd_timedwait.c
> +++ b/src/= thread/cnd_timedwait_monotonic.c
> @@ -1,14 +1,14 @@
> -#includ= e <threads.h>
> -#include <pthread.h>
> -#include &= lt;errno.h>
> -
> -int cnd_timedwait(cnd_t *restrict c, mtx_= t *restrict m, const struct timespec *restrict ts)
> -{
> - =C2= =A0 =C2=A0 =C2=A0 int ret =3D __pthread_cond_timedwait((pthread_cond_t *)c,= (pthread_mutex_t *)m, ts);
> - =C2=A0 =C2=A0 =C2=A0 switch (ret) {> - =C2=A0 =C2=A0 =C2=A0 /* May also return EINVAL or EPERM. */
>= ; - =C2=A0 =C2=A0 =C2=A0 default: =C2=A0 =C2=A0 =C2=A0 =C2=A0return thrd_er= ror;
> - =C2=A0 =C2=A0 =C2=A0 case 0: =C2=A0 =C2=A0 =C2=A0 =C2=A0 ret= urn thrd_success;
> - =C2=A0 =C2=A0 =C2=A0 case ETIMEDOUT: return thr= d_timedout;
> - =C2=A0 =C2=A0 =C2=A0 }
> -}
> +#include &= lt;threads.h>
> +#include <pthread.h>
> +#include <= errno.h>
> +
> +int cnd_timedwait_monotonic(cnd_t *restrict = c, mtx_t *restrict m, const struct timespec *restrict ts)
> +{
>= ; + =C2=A0 =C2=A0 =C2=A0 int ret =3D pthread_cond_clockdwait((pthread_cond_= t *)c, (pthread_mutex_t *)m, CLOCK_MONOTONIC, ts);
> + =C2=A0 =C2=A0 = =C2=A0 switch (ret) {
> + =C2=A0 =C2=A0 =C2=A0 /* May also return EIN= VAL or EPERM. */
> + =C2=A0 =C2=A0 =C2=A0 default: =C2=A0 =C2=A0 =C2= =A0 =C2=A0return thrd_error;
> + =C2=A0 =C2=A0 =C2=A0 case 0: =C2=A0 = =C2=A0 =C2=A0 =C2=A0 return thrd_success;
> + =C2=A0 =C2=A0 =C2=A0 ca= se ETIMEDOUT: return thrd_timedout;
> + =C2=A0 =C2=A0 =C2=A0 }
>= ; +}
> diff --git a/src/thread/mtx_timedlock.c b/src/thread/mtx_timed= lock.c
> index d22c8cf4..30dba40e 100644
> --- a/src/thread/mtx= _timedlock.c
> +++ b/src/thread/mtx_timedlock.c
> @@ -4,7 +4,7 = @@
>
> =C2=A0int mtx_timedlock(mtx_t *restrict m, const struct = timespec *restrict ts)
> =C2=A0{
> - =C2=A0 =C2=A0 =C2=A0 int r= et =3D __pthread_mutex_timedlock((pthread_mutex_t *)m, ts);
> + =C2= =A0 =C2=A0 =C2=A0 int ret =3D pthread_mutex_clocklock((pthread_mutex_t *)m,= CLOCK_REALTIME, ts);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 switch (ret) {> =C2=A0 =C2=A0 =C2=A0 =C2=A0 default: =C2=A0 =C2=A0 =C2=A0 =C2=A0retur= n thrd_error;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 case 0: =C2=A0 =C2=A0 =C2= =A0 =C2=A0 return thrd_success;
> diff --git a/src/thread/mtx_timedlo= ck.c b/src/thread/mtx_timedlock_monotonic.c
> similarity index 74%> copy from src/thread/mtx_timedlock.c
> copy to src/thread/mtx_t= imedlock_monotonic.c
> index d22c8cf4..a788e877 100644
> --- a/= src/thread/mtx_timedlock.c
> +++ b/src/thread/mtx_timedlock_monotonic= .c
> @@ -1,13 +1,13 @@
> -#include <threads.h>
> -#= include <pthread.h>
> -#include <errno.h>
> -
&g= t; -int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts= )
> -{
> - =C2=A0 =C2=A0 =C2=A0 int ret =3D __pthread_mutex_tim= edlock((pthread_mutex_t *)m, ts);
> - =C2=A0 =C2=A0 =C2=A0 switch (re= t) {
> - =C2=A0 =C2=A0 =C2=A0 default: =C2=A0 =C2=A0 =C2=A0 =C2=A0ret= urn thrd_error;
> - =C2=A0 =C2=A0 =C2=A0 case 0: =C2=A0 =C2=A0 =C2=A0= =C2=A0 return thrd_success;
> - =C2=A0 =C2=A0 =C2=A0 case ETIMEDOUT:= return thrd_timedout;
> - =C2=A0 =C2=A0 =C2=A0 }
> -}
> = +#include <threads.h>
> +#include <pthread.h>
> +#i= nclude <errno.h>
> +
> +int mtx_timedlock(mtx_t *restrict= m, const struct timespec *restrict ts)
> +{
> + =C2=A0 =C2=A0 = =C2=A0 int ret =3D pthread_mutex_clocklock((pthread_mutex_t *)m, CLOCK_MONO= TONIC, ts);
> + =C2=A0 =C2=A0 =C2=A0 switch (ret) {
> + =C2=A0 = =C2=A0 =C2=A0 default: =C2=A0 =C2=A0 =C2=A0 =C2=A0return thrd_error;
>= ; + =C2=A0 =C2=A0 =C2=A0 case 0: =C2=A0 =C2=A0 =C2=A0 =C2=A0 return thrd_su= ccess;
> + =C2=A0 =C2=A0 =C2=A0 case ETIMEDOUT: return thrd_timedout;=
> + =C2=A0 =C2=A0 =C2=A0 }
> +}
> --
> 2.39.0.wind= ows.1
>


--
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=E6=AD=A4= =E8=87=B4
=E7=A4=BC
=E7=BD=97=E5=8B=87=E5=88=9A
Yours
=C2=A0 = =C2=A0 sincerely,
Yonggang Luo
--000000000000d8758b05fe8af346--