Re: [PATCH 2/2] libc/include/time.h: Add TIME_MONOTONIC for C23

"Howland, Craig D. - US via Newlib" <[email protected]> Thu, 16 Apr 2026 23:24:11 +0000
Newsgroups gmane.comp.lib.newlib
Message-ID <PH1P110MB1540F09FB8455CDC713B849F9A23A@PH1P110MB1540.NAMP110.PROD.OUTLOOK.COM>
> From: Joel Sherrill <[email protected]>
> Sent: Thursday, April 16, 2026 6:06 PM
> To: [email protected] <[email protected]>
> Cc: Joel Sherrill <[email protected]>
> 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.