diff mbox series

<time.h>: Make strptime available by default

Message ID 87lenvrzey.fsf@oldenburg.str.redhat.com
State New
Headers show
Series <time.h>: Make strptime available by default | expand

Commit Message

Florian Weimer Nov. 28, 2022, 1:17 p.m. UTC
This matches what FreeBSD does.

---
 time/time.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: f704192911c6c7b65a54beab3ab369fca7609a5d

Comments

Andreas Schwab Nov. 28, 2022, 1:55 p.m. UTC | #1
On Nov 28 2022, Florian Weimer via Libc-alpha wrote:

> This matches what FreeBSD does.

Does it?  What I see is that the strptime declaration is conditional on
__XSI_VISIBLE, which is their equivalent of __USE_XOPEN, I think.

> diff --git a/time/time.h b/time/time.h
> index d18089116e..f507b44228 100644
> --- a/time/time.h
> +++ b/time/time.h
> @@ -101,7 +101,7 @@ extern size_t strftime (char *__restrict __s, size_t __maxsize,
>  			const char *__restrict __format,
>  			const struct tm *__restrict __tp) __THROW;
>  
> -#ifdef __USE_XOPEN
> +#if (defined __USE_XOPEN || defined __USE_MISC)

No need for parens.
Florian Weimer Nov. 28, 2022, 2:52 p.m. UTC | #2
* Andreas Schwab:

> On Nov 28 2022, Florian Weimer via Libc-alpha wrote:
>
>> This matches what FreeBSD does.
>
> Does it?  What I see is that the strptime declaration is conditional on
> __XSI_VISIBLE, which is their equivalent of __USE_XOPEN, I think.

Clang without any special flags defines __XSI_VISBLE to 700 on FreeBSD
13.1 at least, which is why the declaration is visible by default.

I'm not sure why we don't default to __USE_XOPEN.  Maybe it has
something to do with our diverging definitions of strerror_r and
basename?

Thanks,
Florian
Andreas Schwab Nov. 28, 2022, 3:37 p.m. UTC | #3
On Nov 28 2022, Florian Weimer wrote:

> * Andreas Schwab:
>
>> On Nov 28 2022, Florian Weimer via Libc-alpha wrote:
>>
>>> This matches what FreeBSD does.
>>
>> Does it?  What I see is that the strptime declaration is conditional on
>> __XSI_VISIBLE, which is their equivalent of __USE_XOPEN, I think.
>
> Clang without any special flags defines __XSI_VISBLE to 700 on FreeBSD
> 13.1 at least, which is why the declaration is visible by default.

<sys/cdefs.h> defines this by default:

#else				/* Default environment: show everything. */
#define	__POSIX_VISIBLE		200809
#define	__XSI_VISIBLE		700
#define	__BSD_VISIBLE		1
#define	__ISO_C_VISIBLE		2011
#define	__EXT1_VISIBLE		1
#endif
diff mbox series

Patch

diff --git a/time/time.h b/time/time.h
index d18089116e..f507b44228 100644
--- a/time/time.h
+++ b/time/time.h
@@ -101,7 +101,7 @@  extern size_t strftime (char *__restrict __s, size_t __maxsize,
 			const char *__restrict __format,
 			const struct tm *__restrict __tp) __THROW;
 
-#ifdef __USE_XOPEN
+#if (defined __USE_XOPEN || defined __USE_MISC)
 /* Parse S according to FORMAT and store binary time information in TP.
    The return value is a pointer to the first unparsed character in S.  */
 extern char *strptime (const char *__restrict __s,