From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 70D1D3838211; Thu, 26 May 2022 17:22:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70D1D3838211 From: "adhemerval.zanella at linaro dot org" To: glibc-bugs@sourceware.org Subject: [Bug libc/29147] getconf: Wrong values for symbolic constants defined in limits.h Date: Thu, 26 May 2022 17:22:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.34 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: adhemerval.zanella at linaro dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2022 17:22:39 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29147 --- Comment #7 from Adhemerval Zanella --- (In reply to cquike from comment #5) > > POSIX standard also defines that for getconf each configuration variabl= e=20 > > shall be determined as if it were obtained by calling the function from > > which it is defined to be available (either fpathconf, sysconf, or conf= str) > > [1]. > >=20 > > And for fpathconf, POSIX only defines a handfull of symbolic constants = an=20 > > implementation should support (which _POSIX_PIPE_BUF is not listed). A= lso=20 > > for _POSIX_PIPE_BUF, it means the 'Maximum number of bytes that is > > guaranteed=20 > > to be atomic when writing to a pipe'. > >=20 >=20 > 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 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]). Another issue is POSIX is not clear how the 'Maximum' and 'Minimum' values should be obtained, but getting the POSIX defined values seems rational. >=20 > In fact, consider the output of this small program: >=20 > #include > #include >=20 > int main() > { > printf("_POSIX_PIPE_BUF: %d\n", _POSIX_PIPE_BUF); > } >=20 > $ ./a.out > _POSIX_PIPE_BUF: 512 >=20 > and the output of getconf: >=20 > $ getconf _POSIX_PIPE_BUF / > 4096 >=20 > 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=C2=B4t be needed to provide a path, since it is a symbolic consta= nt. >=20 >=20 > > for the users perspective what really matters is the=20 > > implementation-defined >=20 > 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 _strictl= y_ > conformant applications ([4]) should not rely on the implementation > supporting a limit larger than _POSIX_PIPE_BUF. It is for those applicati= ons > where this constant might be useful. Right, it seems that other system do return the limits.h value (Solaris 11,= AIX 7.2, and MacOSX) so it seems that it would be good to have the same behavior. >=20 > > And I don't think this will make getconf more POSIX compliant, since PO= SIX > > does not state POSIXLY_CORRECT as an affecting environment variable.=20 >=20 > Yes, you are right. >=20 > [1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/getconf.ht= ml > [2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.= html > [3] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.ht= ml > [4] > https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap02. > html#tag_02_02_01 --=20 You are receiving this mail because: You are on the CC list for the bug.=