Re: [PATCH] grantpt.3: explicitly mention #define _XOPEN_SOURCE requirement

Alejandro Colomar
2024-05-26T16:38:38Z

[-- Attachment #1: Type: text/plain, Size: 2362 bytes --]

Hi Emanuele,

On Sun, May 26, 2024 at 05:11:58PM GMT, Emanuele Torre wrote:
> > On Sun, May 26, 2024 at 04:19:30PM GMT, Emanuele Torre wrote:
> > > I've just noticed that ptsname.3 is also missing #define _XOPEN_SOURCE
> > > in its synopsis; however #define _XOPEN_SOURCE does not seem to work.
> > Did you define it to 500, or an empty value?
>
> empty value.

Hmm.

> > You need to define it to an appropriate value. (The synopsis is a bit
> > misleading, and we could/should specify the minimum value.)
>
> I did notice the
>
> ptsname():
> Since glibc 2.24:
> _XOPEN_SOURCE >= 500
> glibc 2.23 and earlier:
> _XOPEN_SOURCE
>
> But that is the same text that appears in grantpt.3 and unlockpt.3, and
> they get included with just _XOPEN_SOURCE.
>
> I also noticed it this morning when I sent my patch for grantpt.3, but I
> ignored it assuming I probably misunderstood its meaning since it worked
> with just _XOPEN_SOURCE.

I also noticed and ignored it, since I saw the same text in the other
pages.

> Does this mean that my grantpt.3 patch is wrong?
>
> And that #define _XOPEN_SOURCE in the synopsys of unlockpt.3 is also
> wrong?

Regardless of it being correct or not, I think using the definition
used by newer glibc versions is better, so we could update the SYNOPSIS
of all pages to show the requirements of the latest glibc.

> I should not use just #define _XOPEN_SOURCE without a value in my
> programs if I want to use ptsname(3), grantpt(3), unlockpt(3)?

TBH, I don't know. AFAICS, _XOPEN_SOURCE without specifying a value
means POSIX.1‐1990 (maybe? not sure). That is so obsolete these days
that I don't know what it means. Does it provide ptsname(3)? I don't
know. But yeah, I'd say just don't use it.

These days, POSIX.1-2001 is granted everywhere (except maybe some dying
proprietary systems), and even POSIX.1-2008 if you restrict yourself to
Linux and the BSDs. I suggest using the flags that enable one of these
more recent standards.

Maybe glibc people can say why there's a difference between the
functions, though, which I can't explain.

If you want to send a patch for fixing the SYNOPSIS, please go ahead.

Have a lovely day!
Alex

>
> o/
> emanuele6

--
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]