[PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23
Howland, Craig D. - US
craig.howland@caci.com
Thu Apr 16 23:24:11 GMT 2026
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/newlib/attachments/20260416/dd9ab0bc/attachment-0001.htm>
More information about the Newlib
mailing list