All of lore.kernel.org
 help / color / mirror / Atom feed
From: Emanuele Torre <torreemanuele6@gmail.com>
To: Alejandro Colomar <alx@kernel.org>
Cc: linux-man@vger.kernel.org, libc-alpha@sourceware.org
Subject: Re: [PATCH] grantpt.3: explicitly mention  #define _XOPEN_SOURCE requirement
Date: Sun, 26 May 2024 16:19:30 +0200	[thread overview]
Message-ID: <ZlNE8ooomjnaKWXX@t420> (raw)
In-Reply-To: <nx4yzt26bte57ak7vnc7tkl7ofs6fmqxkaexhvx2ixx7jst4yb@xui6m6mjxoz6>

On Sun, May 26, 2024 at 12:39:07PM +0200, Alejandro Colomar wrote:
> Hi Emanuele,
> 
> On Sun, May 26, 2024 at 08:42:18AM GMT, Emanuele Torre wrote:
> > Like the unlockpt(3) function, grantpt(3) requires _XOPEN_SOURCE to be
> > defined before including stdlib.h.
> > 
> > unlockpt.3 explicitly shows this requirement in its SYNOPSIS:
> > 
> >     SYNOPSIS
> >            #define _XOPEN_SOURCE
> >            #include <stdlib.h>
> > 
> >            int unlockpt(int fd);
> > 
> > But grantpt.3 did not:
> > 
> >     SYNOPSIS
> >            #include <stdlib.h>
> > 
> >            int grantpt(int fd);
> > 
> > o/
> >  emanuele6
> 
> Patch applied; thanks.

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.

Even if _XOPEN_SOURCE is defined, #include <stdlib.h> does not include
the prototype of ptsname(3).  It seems to only be included when
_GNU_SOURCE is defined.

This may be a glibc bug because ptsname(3) is supposed to be a POSIX XSI
function like grantpt(3) and unlockpt(3).  Only ptsname_r(3) is an
extension.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/ptsname.html

    $ gcc -fsyntax-only -D_XOPEN_SOURCE -includestdlib.h -x c - <<< 'int main(){ptsname(0);}'
    <stdin>: In function ‘main’:
    <stdin>:1:12: error: implicit declaration of function ‘ptsname’ [-Wimplicit-function-declaration]

    $ gcc -fsyntax-only -D_GNU_SOURCE -includestdlib.h -x c - <<< 'int main(){ptsname(0);}'

I am using the version of glibc packaged by ArchLinux
(package version 2.39+r52+gf8e4623421-1).

I added libc-alpha@sourceware.org to CC in case it is actually a bug.

> 
> Have a lovely day!

You too!  :-)

> Alex

o/
 emanuele6

  reply	other threads:[~2024-05-26 14:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-26  6:42 [PATCH] grantpt.3: explicitly mention #define _XOPEN_SOURCE requirement Emanuele Torre
2024-05-26 10:39 ` Alejandro Colomar
2024-05-26 14:19   ` Emanuele Torre [this message]
2024-05-26 14:54     ` Alejandro Colomar
2024-05-26 15:11       ` Emanuele Torre
2024-05-26 16:38         ` Alejandro Colomar
2024-05-26 16:58           ` Emanuele Torre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZlNE8ooomjnaKWXX@t420 \
    --to=torreemanuele6@gmail.com \
    --cc=alx@kernel.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.