public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cquike at arcor dot de" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/29147] getconf: Wrong values for symbolic constants defined in limits.h
Date: Tue, 24 May 2022 00:57:55 +0000	[thread overview]
Message-ID: <bug-29147-131-VYJtEydFCs@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29147-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=29147

--- Comment #5 from cquike at arcor dot de ---

> POSIX standard also defines that for getconf each configuration variable 
> shall be determined as if it were obtained by calling the function from
> which it is defined to be available (either fpathconf, sysconf, or confstr)
> [1].
> 
> And for fpathconf, POSIX only defines a handfull of symbolic constants an 
> implementation should support (which _POSIX_PIPE_BUF is not listed).  Also 
> for _POSIX_PIPE_BUF, it means the 'Maximum number of bytes that is
> guaranteed 
> to be atomic when writing to a pipe'.
> 

Maybe I am interpreting it wrongly, but I see that getconf provides variables
that are defined via fpathconf, sysconf, confstr _or_ limits.h. The third
bullet under "system_var" says literally "The names of the symbolic constants
listed under the headings ``Maximum Values'' and ``Minimum Values'' in the
description of the <limits.h> header" ([1]). And indeed _POSIX_PIPE_BUF is
listed under "Minimum values" in the description of limits.h ([3]) and not
under fpathconf, as you correctly mention ([2]).

In fact, consider the output of this small program:

#include <limits.h>
#include <stdio.h>

int main()
{
  printf("_POSIX_PIPE_BUF: %d\n", _POSIX_PIPE_BUF);
}

$ ./a.out
_POSIX_PIPE_BUF: 512

and the output of getconf:

$ getconf _POSIX_PIPE_BUF /
4096

which are, in my opinion, in contradiction. By the way, it also highlights yet
another problem with the current implementation: for _POSIX_PIPE_BUF it
shouldn´t be needed to provide a path, since it is a symbolic constant.


> for the users perspective what really matters is the 
> implementation-defined

For most applications I agree with you. That means that POSIX conformant
applications applications are most interested on querying fpathconf(fd,
_PC_PIPE_BUF) or the equivalent getconf PIPE_BUF /path . However _strictly_
conformant applications ([4]) should not rely on the implementation supporting
a limit larger than _POSIX_PIPE_BUF. It is for those applications where this
constant might be useful.

> And I don't think this will make getconf more POSIX compliant, since POSIX
> does not state POSIXLY_CORRECT as an affecting environment variable. 

Yes, you are right.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.html
[2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html
[3] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
[4]
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02.html#tag_02_02_01

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-05-24  0:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-14 23:05 [Bug libc/29147] New: " cquike at arcor dot de
2022-05-14 23:05 ` [Bug libc/29147] getconf: " cquike at arcor dot de
2022-05-14 23:12 ` cquike at arcor dot de
2022-05-18 19:47 ` adhemerval.zanella at linaro dot org
2022-05-23 20:02 ` cquike at arcor dot de
2022-05-23 20:47 ` adhemerval.zanella at linaro dot org
2022-05-24  0:57 ` cquike at arcor dot de [this message]
2022-05-24  7:49 ` schwab@linux-m68k.org
2022-05-26 17:22 ` adhemerval.zanella at linaro dot org
2022-05-27 14:31 ` adhemerval.zanella at linaro dot org
2022-07-29 22:10 ` cquike at arcor dot de

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=bug-29147-131-VYJtEydFCs@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.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 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).