* [PATCH 1/2] libc/include/time.h: Add C23 timespec_getres()
@ 2026-04-16 22:06 Joel Sherrill
2026-04-16 22:06 ` [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23 Joel Sherrill
0 siblings, 1 reply; 4+ messages in thread
From: Joel Sherrill @ 2026-04-16 22:06 UTC (permalink / raw)
To: newlib; +Cc: Joel Sherrill
---
newlib/libc/include/time.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h
index 58c5066ed..e972bd416 100644
--- a/newlib/libc/include/time.h
+++ b/newlib/libc/include/time.h
@@ -62,6 +62,9 @@ time_t time (time_t *_timer);
int timespec_get(struct timespec *ts, int base);
#endif
+#if (__ISO_C_VISIBLE >= 2023)
+int timespec_getres(struct timespec *ts, int base);
+#endif
#ifndef _REENT_ONLY
char *asctime (const struct tm *_tblock);
char *ctime (const time_t *_time);
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23
2026-04-16 22:06 [PATCH 1/2] libc/include/time.h: Add C23 timespec_getres() Joel Sherrill
@ 2026-04-16 22:06 ` Joel Sherrill
2026-04-16 23:24 ` Howland, Craig D. - US
0 siblings, 1 reply; 4+ messages in thread
From: Joel Sherrill @ 2026-04-16 22:06 UTC (permalink / raw)
To: newlib; +Cc: Joel Sherrill
---
newlib/libc/include/time.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h
index e972bd416..429dd8bd9 100644
--- a/newlib/libc/include/time.h
+++ b/newlib/libc/include/time.h
@@ -63,6 +63,9 @@ time_t time (time_t *_timer);
int timespec_get(struct timespec *ts, int base);
#endif
#if (__ISO_C_VISIBLE >= 2023)
+#define TIME_MONOTONIC 2
+#endif
+#if (__ISO_C_VISIBLE >= 2023)
int timespec_getres(struct timespec *ts, int base);
#endif
#ifndef _REENT_ONLY
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23
2026-04-16 22:06 ` [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23 Joel Sherrill
@ 2026-04-16 23:24 ` Howland, Craig D. - US
2026-04-19 9:13 ` Corinna Vinschen
0 siblings, 1 reply; 4+ messages in thread
From: Howland, Craig D. - US @ 2026-04-16 23:24 UTC (permalink / raw)
To: Joel Sherrill, newlib
[-- Attachment #1: Type: text/plain, Size: 2305 bytes --]
> From: Joel Sherrill <joel@rtems.org>
> Sent: Thursday, April 16, 2026 6:06 PM
> To: newlib@sourceware.org <newlib@sourceware.org>
> Cc: Joel Sherrill <joel@rtems.org>
> Subject: [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23
> ---
> newlib/libc/include/time.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h
> index e972bd416..429dd8bd9 100644
> --- a/newlib/libc/include/time.h
> +++ b/newlib/libc/include/time.h
> @@ -63,6 +63,9 @@ time_t time (time_t *_timer);
> int timespec_get(struct timespec *ts, int base);
> #endif
> #if (__ISO_C_VISIBLE >= 2023)
> +#define TIME_MONOTONIC 2
> +#endif
> +#if (__ISO_C_VISIBLE >= 2023)
> int timespec_getres(struct timespec *ts, int base);
> #endif
> #ifndef _REENT_ONLY
Any particular reason for two of the same #if? I can't think of one, merge them.
Additionally, this also could be grouped within the preceding #if (__ISO_C_VISIBLE >= 2011 || __POSIX_VISIBLE >= 202405), which would make it read a little more cleanly.
Speaking of cleanly, this diff appears to be based on a corrupted file version, fails to apply. (It is lacking #define TIME_UTC, e.g.)
Snippet from present time.h:
#if (__ISO_C_VISIBLE >= 2011 || __POSIX_VISIBLE >= 202405)
#define TIME_UTC 1
int timespec_get(struct timespec *ts, int base);
#endif
Suggested end result:
#if (__ISO_C_VISIBLE >= 2011 || __POSIX_VISIBLE >= 202405)
#define TIME_UTC 1
int timespec_get(struct timespec *ts, int base);
#if (__ISO_C_VISIBLE >= 2023)
#define TIME_MONOTONIC 2
int timespec_getres(struct timespec *ts, int base);
#endif
#endif
Craig
________________________________
This electronic message contains information from CACI International Inc or subsidiary companies, which may be company sensitive, proprietary, privileged or otherwise protected from disclosure. The information is intended to be used solely by the recipient(s) named above. If you are not an intended recipient, be aware that any review, disclosure, copying, distribution or use of this transmission or its contents is prohibited. If you have received this transmission in error, please notify the sender immediately.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23
2026-04-16 23:24 ` Howland, Craig D. - US
@ 2026-04-19 9:13 ` Corinna Vinschen
0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2026-04-19 9:13 UTC (permalink / raw)
To: newlib
On Apr 16 23:24, Howland, Craig D. - US via Newlib wrote:
> > From: Joel Sherrill <joel@rtems.org>
> > Sent: Thursday, April 16, 2026 6:06 PM
> > To: newlib@sourceware.org <newlib@sourceware.org>
> > Cc: Joel Sherrill <joel@rtems.org>
> > Subject: [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23
> > ---
> > newlib/libc/include/time.h | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h
> > index e972bd416..429dd8bd9 100644
> > --- a/newlib/libc/include/time.h
> > +++ b/newlib/libc/include/time.h
> > @@ -63,6 +63,9 @@ time_t time (time_t *_timer);
> > int timespec_get(struct timespec *ts, int base);
> > #endif
> > #if (__ISO_C_VISIBLE >= 2023)
> > +#define TIME_MONOTONIC 2
> > +#endif
> > +#if (__ISO_C_VISIBLE >= 2023)
> > int timespec_getres(struct timespec *ts, int base);
> > #endif
> > #ifndef _REENT_ONLY
>
> Any particular reason for two of the same #if? I can't think of one, merge them.
> Additionally, this also could be grouped within the preceding #if (__ISO_C_VISIBLE >= 2011 || __POSIX_VISIBLE >= 202405), which would make it read a little more cleanly.
> Speaking of cleanly, this diff appears to be based on a corrupted file version, fails to apply. (It is lacking #define TIME_UTC, e.g.)
>
> Snippet from present time.h:
>
> #if (__ISO_C_VISIBLE >= 2011 || __POSIX_VISIBLE >= 202405)
> #define TIME_UTC 1
>
> int timespec_get(struct timespec *ts, int base);
> #endif
>
> Suggested end result:
> #if (__ISO_C_VISIBLE >= 2011 || __POSIX_VISIBLE >= 202405)
> #define TIME_UTC 1
> int timespec_get(struct timespec *ts, int base);
> #if (__ISO_C_VISIBLE >= 2023)
> #define TIME_MONOTONIC 2
> int timespec_getres(struct timespec *ts, int base);
> #endif
> #endif
Actually, the definitions TIME_UTC and TIME_MONOTONIC should
be adjacent to each other. And if TIME_MONOTONIC gets defined,
TIME_ACTIVE and TIME_THREAD_ACTIVE should be defined as well,
me thinks:
#if (__ISO_C_VISIBLE >= 2011 || __POSIX_VISIBLE >= 202405)
#define TIME_UTC 1
#endif
#if (__ISO_C_VISIBLE >= 2023)
#define TIME_MONOTONIC 2
#define TIME_ACTIVE 3
#define TIME_THREAD_ACTIVE 4
#endif
and only after that the related functions should be defined. It might
be a good idea, to separate out the above macros as well as the
functions timespec_get and timespec_getres into it's own block in
time.h, too.
Corinna
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-19 9:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-16 22:06 [PATCH 1/2] libc/include/time.h: Add C23 timespec_getres() Joel Sherrill
2026-04-16 22:06 ` [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23 Joel Sherrill
2026-04-16 23:24 ` Howland, Craig D. - US
2026-04-19 9:13 ` Corinna Vinschen
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).