public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Do not declare asctime_r and ctime_r for C2X
@ 2021-05-13 22:39 Joseph Myers
  2021-05-14  6:42 ` Paul Eggert
  2021-05-18 18:38 ` Adhemerval Zanella
  0 siblings, 2 replies; 3+ messages in thread
From: Joseph Myers @ 2021-05-13 22:39 UTC (permalink / raw)
  To: libc-alpha

ISO C2X added the asctime_r, ctime_r, gmtime_r and localtime_r
functions from POSIX.  It's now removed asctime_r and ctime_r again,
reflecting that they are marked obsolescent in POSIX; update glibc's
time.h accordingly.

The same change that removed those two functions from C2X also marked
asctime and ctime as deprecated (reflecting how POSIX shows them as
obsolescent), i.e. using the [[deprecated]] attribute in the
prototypes shown in C2X.  It's less clear if we should explicitly
deprecate those functions like that in the glibc headers; this patch
does nothing regarding such a deprecation (there's no normative
requirement from C2X showing the functions as deprecated).

Tested for x86_64 and x86.

diff --git a/time/time.h b/time/time.h
index 3bf206be0b..dcc2d595e8 100644
--- a/time/time.h
+++ b/time/time.h
@@ -141,7 +141,7 @@ extern char *asctime (const struct tm *__tp) __THROW;
 /* Equivalent to `asctime (localtime (timer))'.  */
 extern char *ctime (const time_t *__timer) __THROW;
 
-#if defined __USE_POSIX || __GLIBC_USE (ISOC2X)
+#ifdef __USE_POSIX
 /* Reentrant versions of the above functions.  */
 
 /* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n"
@@ -152,7 +152,7 @@ extern char *asctime_r (const struct tm *__restrict __tp,
 /* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'.  */
 extern char *ctime_r (const time_t *__restrict __timer,
 		      char *__restrict __buf) __THROW;
-#endif	/* POSIX || C2X */
+#endif	/* POSIX */
 
 
 /* Defined in localtime.c.  */

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Do not declare asctime_r and ctime_r for C2X
  2021-05-13 22:39 Do not declare asctime_r and ctime_r for C2X Joseph Myers
@ 2021-05-14  6:42 ` Paul Eggert
  2021-05-18 18:38 ` Adhemerval Zanella
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2021-05-14  6:42 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

On 5/13/21 5:39 PM, Joseph Myers wrote:
> The same change that removed those two functions from C2X also marked
> asctime and ctime as deprecated (reflecting how POSIX shows them as
> obsolescent), i.e. using the [[deprecated]] attribute in the
> prototypes shown in C2X.  It's less clear if we should explicitly
> deprecate those functions like that in the glibc headers

Sounds like that's just a quality-of-implementation issue. My vote would 
be to deprecate them in the glibc headers, as they're asking for trouble 
(buffer overrun etc.) with 64-bit time_t.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Do not declare asctime_r and ctime_r for C2X
  2021-05-13 22:39 Do not declare asctime_r and ctime_r for C2X Joseph Myers
  2021-05-14  6:42 ` Paul Eggert
@ 2021-05-18 18:38 ` Adhemerval Zanella
  1 sibling, 0 replies; 3+ messages in thread
From: Adhemerval Zanella @ 2021-05-18 18:38 UTC (permalink / raw)
  To: libc-alpha, Joseph Myers



On 13/05/2021 19:39, Joseph Myers wrote:
> ISO C2X added the asctime_r, ctime_r, gmtime_r and localtime_r
> functions from POSIX.  It's now removed asctime_r and ctime_r again,
> reflecting that they are marked obsolescent in POSIX; update glibc's
> time.h accordingly.
> 
> The same change that removed those two functions from C2X also marked
> asctime and ctime as deprecated (reflecting how POSIX shows them as
> obsolescent), i.e. using the [[deprecated]] attribute in the
> prototypes shown in C2X.  It's less clear if we should explicitly
> deprecate those functions like that in the glibc headers; this patch
> does nothing regarding such a deprecation (there's no normative
> requirement from C2X showing the functions as deprecated).
> 
> Tested for x86_64 and x86.

LGTM, I think we can make the function deprecated on a subsequent patch.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 
> diff --git a/time/time.h b/time/time.h
> index 3bf206be0b..dcc2d595e8 100644
> --- a/time/time.h
> +++ b/time/time.h
> @@ -141,7 +141,7 @@ extern char *asctime (const struct tm *__tp) __THROW;
>  /* Equivalent to `asctime (localtime (timer))'.  */
>  extern char *ctime (const time_t *__timer) __THROW;
>  
> -#if defined __USE_POSIX || __GLIBC_USE (ISOC2X)
> +#ifdef __USE_POSIX
>  /* Reentrant versions of the above functions.  */
>  
>  /* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n"
> @@ -152,7 +152,7 @@ extern char *asctime_r (const struct tm *__restrict __tp,
>  /* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'.  */
>  extern char *ctime_r (const time_t *__restrict __timer,
>  		      char *__restrict __buf) __THROW;
> -#endif	/* POSIX || C2X */
> +#endif	/* POSIX */
>  
>  
>  /* Defined in localtime.c.  */
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-18 18:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 22:39 Do not declare asctime_r and ctime_r for C2X Joseph Myers
2021-05-14  6:42 ` Paul Eggert
2021-05-18 18:38 ` Adhemerval Zanella

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).