From owner-freebsd-standards@freebsd.org Sun Jan 24 21:00:05 2021 Return-Path: Delivered-To: freebsd-standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 72F6A4D9EEF for ; Sun, 24 Jan 2021 21:00:05 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4DP53n2jDQz4Zkd for ; Sun, 24 Jan 2021 21:00:05 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: by mailman.nyi.freebsd.org (Postfix) id 5CC794D9DED; Sun, 24 Jan 2021 21:00:05 +0000 (UTC) Delivered-To: standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5C9024D9F0A for ; Sun, 24 Jan 2021 21:00:05 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DP53n29Txz4ZWd for ; Sun, 24 Jan 2021 21:00:05 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3D4C82097 for ; Sun, 24 Jan 2021 21:00:05 +0000 (UTC) (envelope-from bugzilla-noreply@FreeBSD.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 10OL05kZ029207 for ; Sun, 24 Jan 2021 21:00:05 GMT (envelope-from bugzilla-noreply@FreeBSD.org) Received: (from bugzilla@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 10OL05g7029206 for standards@FreeBSD.org; Sun, 24 Jan 2021 21:00:05 GMT (envelope-from bugzilla-noreply@FreeBSD.org) Message-Id: <202101242100.10OL05g7029206@kenobi.freebsd.org> X-Authentication-Warning: kenobi.freebsd.org: bugzilla set sender to bugzilla-noreply@FreeBSD.org using -f From: bugzilla-noreply@FreeBSD.org To: standards@FreeBSD.org Subject: Problem reports for standards@FreeBSD.org that need special attention Date: Sun, 24 Jan 2021 21:00:05 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jan 2021 21:00:05 -0000 To view an individual PR, use: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=(Bug Id). The following is a listing of current problems submitted by FreeBSD users, which need special attention. These represent problem reports covering all versions including experimental development code and obsolete releases. Status | Bug Id | Description ------------+-----------+--------------------------------------------------- Open | 191586 | FreeBSD doesn't validate negative edgecases in bi 1 problems total for which you should take action. From owner-freebsd-standards@freebsd.org Mon Jan 25 09:04:30 2021 Return-Path: Delivered-To: freebsd-standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A20F4EFD02 for ; Mon, 25 Jan 2021 09:04:30 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from anubis.delphij.net (anubis.delphij.net [IPv6:2001:470:1:117::25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "anubis.delphij.net", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DPP7d1g22z3LTL; Mon, 25 Jan 2021 09:04:28 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from odin.corp.delphij.net (unknown [IPv6:2601:646:8601:f4a:f47b:3e7c:223f:6703]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by anubis.delphij.net (Postfix) with ESMTPSA id 9A7142BC5B; Mon, 25 Jan 2021 01:04:26 -0800 (PST) Reply-To: d@delphij.net To: freebsd-standards@freebsd.org, Jilles Tjoelker , Ed Maste From: Xin Li Cc: Marshall Kirk McKusick Subject: _POSIX_C_SOURCE and S_IFMT macros Message-ID: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> Date: Mon, 25 Jan 2021 01:04:25 -0800 User-Agent: Thunderbird MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3HCik9fKRoooaqEco88ihSK1eM5qKyEZj" X-Rspamd-Queue-Id: 4DPP7d1g22z3LTL X-Spamd-Bar: ------ X-Spamd-Result: default: False [-6.08 / 15.00]; HAS_REPLYTO(0.00)[d@delphij.net]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:sirius.delphij.net]; HAS_ATTACHMENT(0.00)[]; DKIM_TRACE(0.00)[delphij.net:+]; DMARC_POLICY_ALLOW(-0.50)[delphij.net,reject]; NEURAL_HAM_SHORT(-0.99)[-0.987]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[2001:470:1:117::25:from]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[delphij.net:s=m7e2]; FREEFALL_USER(0.00)[delphij]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.20)[multipart/signed,multipart/mixed,text/plain]; REPLYTO_DOM_EQ_FROM_DOM(0.00)[]; SPAMHAUS_ZRD(0.00)[2001:470:1:117::25:from:127.0.2.255]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-standards] X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2021 09:04:30 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3HCik9fKRoooaqEco88ihSK1eM5qKyEZj Content-Type: multipart/mixed; boundary="91OnLhtfkkNYnIHeNGLSbk1DS1MEbU2W9"; protected-headers="v1" From: Xin Li Reply-To: d@delphij.net To: freebsd-standards@freebsd.org, Jilles Tjoelker , Ed Maste Cc: Marshall Kirk McKusick Message-ID: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> Subject: _POSIX_C_SOURCE and S_IFMT macros --91OnLhtfkkNYnIHeNGLSbk1DS1MEbU2W9 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi, I recently discovered [1] a difference between FreeBSD's handling of _POSIX_C_SOURCE and what I have observe on Linux and macOS systems, basically, if a program defines _POSIX_C_SOURCE to 200809L, but did not define _XOPEN_SOURCE, we will not define S_IFMT when sys/stat.h is includ= ed. It appears that the glibc version of sys/stat.h won't define it either, but their fcntl.h would define it by having _POSIX_C_SOURCE >=3D 200809L to define _USE_XOPEN2K8 and expose it. A quick glance on my Macbook suggests that they were defining the S_IFMT macros unconditionally. Based on my research, hiding these macros started in revision 40491 of CSRG repository ( https://svnweb.freebsd.org/csrg?view=3Drevision&revision=3D40491 ); NetBS= D chose to make the macro visible when _XOPEN_SOURCE in revision 1.34 and expanded the visibility scope to also cover _NETBSD_SOURCE. Do we need to hide these with 200809L when _XOPEN_SOURCE is not defined? If I'm reading the standards correctly, I think we are required to define these in modern POSIX revisions? [1] When building pigz (https://github.com/madler/pigz), I got: cc -O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual -c pigz.c -o pigz.= o pigz.c:3817:47: error: use of undeclared identifier 'S_IFMT' if (stat(from, &st) !=3D 0 || (st.st_mode & S_IFMT) !=3D S_IFREG) ^ [...] --91OnLhtfkkNYnIHeNGLSbk1DS1MEbU2W9-- --3HCik9fKRoooaqEco88ihSK1eM5qKyEZj Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsF5BAABCAAjFiEEceNg5NEMZIki80nQQHl/fJX0g08FAmAOiZkFAwAAAAAACgkQQHl/fJX0g0+I EhAAnzcCPtyTeC1Uj40yVGsKbgZ9Xt1xVfUPGlEREJDkOvy7md0tHrNVgjb+Apqjxoz6kbPKtTUr zf5kiJK+vpQ0ocPZoDtG8NNyMEwG0CFCipu9QEw1cBNEq3kfDEaEJb4wfiSUvmFsBDWFpBkq/YPQ Vjv0cln24ydzr9Dw0yTv7+z49EVsg0GwL+t8954SuEBMqbBIvr6Yi9g7E9ZxuL3yOdFkUttF4Yf0 eUNjB2WmAko33jGIAitHzW6zIFheo6EG+57GyHpWRX0lhQRR8Wqx3YFJSShWrJsxzDsxD7rneqAY N4n0/d6Ek0jKjHBb2TZdB2Zm15T7GTOgoeAZUcumvjHJFoFYjBJjamJGcHZOaDT28vxluVLQQdmc joFyXIwNoENqKJYtjyAtIXPrby7WdfvVxfR8mFrIitH79IpfbKTrPZSxPhG49lWCvy0x3/++VKo2 7jKAzPdoZShFgAe1hjZRqVZuY4lWXYvUrVZL7IR7CCB8J1VjmKwiIO6cgCX/A1w1KV5ECSDyeDlL Pdbtixi00IMOqjsiBb8hzfTtPLbBxbCJh6oQP5SuE+kv5f2yUV/6OIlgAiK3hy6A9N//zDUmqFOF nO5axK0R+xOruGxdYO/7pp8+0d4gwC8uYssCCErQ5ixl6KkSt7mBHwx9FTMqb3BAPn1McicEshKs R9o= =+bO/ -----END PGP SIGNATURE----- --3HCik9fKRoooaqEco88ihSK1eM5qKyEZj-- From owner-freebsd-standards@freebsd.org Mon Jan 25 09:17:55 2021 Return-Path: Delivered-To: freebsd-standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A2B64D81DE for ; Mon, 25 Jan 2021 09:17:55 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DPPR72v2Lz3Mpl; Mon, 25 Jan 2021 09:17:55 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wr1-x430.google.com with SMTP id g10so11468006wrx.1; Mon, 25 Jan 2021 01:17:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=82GWTLdZP9TjVkTQYbzxpzifiiV/sh5kwfR28YuD1SE=; b=GK4/O8yJCSPEdLJ093dxlX5e+h+Wkf79vT3L4da9u88NbxN3D1Dzkfpu1qRSHYIW0O SG2G2IitIjLnyFp52iaYmb6ValUwtpoOe9RbSgIjdCognVTCOX5G05/rWF7EWk7vr9dg nGJ9/9LEW5rDc+6FtJhkWBvwie/r311Z95nTc/qv8DPMoka0hM94n1wClaJ+8D3hv2uw /X5GW5H7cR9WTZktS2boQH3h00gZzZVx5T17IS9MDI9a6Lc4JIcnlffVfwhrejMjhCjK 9jkIw3rIDAF+rTCRtnHQnyHsyg0bLu9F2rrH4wTPDN38CqGi73xsJXTP3xaE7C92S/uy eylw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=82GWTLdZP9TjVkTQYbzxpzifiiV/sh5kwfR28YuD1SE=; b=JQU+m8lkEPPY7FERHkgEFUxQBVpPp/wzfQNIMBXdq3q0aWrFAvMnPJP54Gdq41GDwH JpEfyQeTSmX95Vru9SRIX8XrPK7UPpGF0OgpXeqKf5/kP/fMZU50lBLav6b4QO4CEYIO qzodZh+LP90oz7reuBwU4tdpkmn7UStFJqbZ/bIHzNxkNGH0tg2rsnrQGL+AASgJ0P6x 6fmENj47yufkkebblUWy7JUJSxWGlzhK6VxrbBttnq1IuO83/Cjt5uZnF/hu25w3PB8t ek+E8QZBCQsKWPNwr3YKO077XGuzImoxTvYXnR1k5h+NyzolMPMqFl0ktoTmC/pq8a5I HeWw== X-Gm-Message-State: AOAM5305ZxyEGBOXjmrgur18f3wY3Ogp9pCaRgoCd/4HouTlMdq5JdEh 9Ui5kwjM4qw96TGyYf+L2Lo4sFl4lh5MHFuMlEAX5+FUkOc= X-Google-Smtp-Source: ABdhPJzpzRwnyACd2E8tr0To4+Vjq01ydy8Xp5IcP3P1NuPyDKTesx70Zh4vj1iRq+LiAsPNLn4Y7bLRVo1KcJgF040= X-Received: by 2002:adf:e88f:: with SMTP id d15mr795137wrm.17.1611566274155; Mon, 25 Jan 2021 01:17:54 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a5d:464c:0:0:0:0:0 with HTTP; Mon, 25 Jan 2021 01:17:53 -0800 (PST) In-Reply-To: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> References: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> From: Mateusz Guzik Date: Mon, 25 Jan 2021 10:17:53 +0100 Message-ID: Subject: Re: _POSIX_C_SOURCE and S_IFMT macros To: d@delphij.net Cc: freebsd-standards@freebsd.org, Jilles Tjoelker , Ed Maste , Xin Li , Marshall Kirk McKusick Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4DPPR72v2Lz3Mpl X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2021 09:17:55 -0000 Does not matter what POSIX says. If something compiles on Linux, it should compile on FreeBSD modulo use of Linux-specific APIs. On 1/25/21, Xin Li via freebsd-standards wrote: > Hi, > > I recently discovered [1] a difference between FreeBSD's handling of > _POSIX_C_SOURCE and what I have observe on Linux and macOS systems, > basically, if a program defines _POSIX_C_SOURCE to 200809L, but did not > define _XOPEN_SOURCE, we will not define S_IFMT when sys/stat.h is > included. > > It appears that the glibc version of sys/stat.h won't define it either, > but their fcntl.h would define it by having _POSIX_C_SOURCE >= 200809L > to define _USE_XOPEN2K8 and expose it. > > A quick glance on my Macbook suggests that they were defining the S_IFMT > macros unconditionally. > > Based on my research, hiding these macros started in revision 40491 of > CSRG repository ( > https://svnweb.freebsd.org/csrg?view=revision&revision=40491 ); NetBSD > chose to make the macro visible when _XOPEN_SOURCE in revision 1.34 and > expanded the visibility scope to also cover _NETBSD_SOURCE. > > Do we need to hide these with 200809L when _XOPEN_SOURCE is not defined? > If I'm reading the standards correctly, I think we are required to > define these in modern POSIX revisions? > > > > [1] When building pigz (https://github.com/madler/pigz), I got: > > cc -O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual -c pigz.c -o pigz.o > pigz.c:3817:47: error: use of undeclared identifier 'S_IFMT' > if (stat(from, &st) != 0 || (st.st_mode & S_IFMT) != S_IFREG) > ^ > [...] > > > -- Mateusz Guzik From owner-freebsd-standards@freebsd.org Mon Jan 25 12:18:26 2021 Return-Path: Delivered-To: freebsd-standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 350BA4E02F6 for ; Mon, 25 Jan 2021 12:18:26 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DPTRP5sY1z3sJn; Mon, 25 Jan 2021 12:18:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 10PCGY9L023453 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 25 Jan 2021 14:16:37 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 10PCGY9L023453 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 10PCGXwi023452; Mon, 25 Jan 2021 14:16:33 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 25 Jan 2021 14:16:33 +0200 From: Konstantin Belousov To: d@delphij.net Cc: freebsd-standards@freebsd.org, Jilles Tjoelker , Ed Maste , Xin Li , Marshall Kirk McKusick Subject: Re: _POSIX_C_SOURCE and S_IFMT macros Message-ID: References: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4DPTRP5sY1z3sJn X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2021 12:18:26 -0000 On Mon, Jan 25, 2021 at 01:04:25AM -0800, Xin Li via freebsd-standards wrote: > Hi, > > I recently discovered [1] a difference between FreeBSD's handling of > _POSIX_C_SOURCE and what I have observe on Linux and macOS systems, > basically, if a program defines _POSIX_C_SOURCE to 200809L, but did not > define _XOPEN_SOURCE, we will not define S_IFMT when sys/stat.h is included. > > It appears that the glibc version of sys/stat.h won't define it either, > but their fcntl.h would define it by having _POSIX_C_SOURCE >= 200809L > to define _USE_XOPEN2K8 and expose it. > > A quick glance on my Macbook suggests that they were defining the S_IFMT > macros unconditionally. > > Based on my research, hiding these macros started in revision 40491 of > CSRG repository ( > https://svnweb.freebsd.org/csrg?view=revision&revision=40491 ); NetBSD > chose to make the macro visible when _XOPEN_SOURCE in revision 1.34 and > expanded the visibility scope to also cover _NETBSD_SOURCE. > > Do we need to hide these with 200809L when _XOPEN_SOURCE is not defined? > If I'm reading the standards correctly, I think we are required to > define these in modern POSIX revisions? > > > > [1] When building pigz (https://github.com/madler/pigz), I got: > > cc -O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual -c pigz.c -o pigz.o > pigz.c:3817:47: error: use of undeclared identifier 'S_IFMT' > if (stat(from, &st) != 0 || (st.st_mode & S_IFMT) != S_IFREG) > ^ > [...] In my copy of IEEE Std 1003.1™-2017 S_IFMT and related S_IF symbols are specified as provided by sys/stat.h. fcntl.h (not sys/fcntl.h, which is not specified by POSIX at all) does not require export of S_IF*. So I think S_IF symbols listed in POSIX standard should be provided by sys/stat.h under some value of POSIX_C_SOURCE, but I did not dig to see which should be the guard value. Most likely 200809 is fine. From owner-freebsd-standards@freebsd.org Mon Jan 25 19:42:31 2021 Return-Path: Delivered-To: freebsd-standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 05AA34EECF5 for ; Mon, 25 Jan 2021 19:42:31 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailrelay119.isp.belgacom.be (mailrelay119.isp.belgacom.be [195.238.20.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign RSA OV SSL CA 2018" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DPgHp2l6kz3CMZ; Mon, 25 Jan 2021 19:42:30 +0000 (UTC) (envelope-from tijl@freebsd.org) IronPort-SDR: HJxCkdaPAbk7ttScb409ZcV1l/jbZwGUkFvFhlO4cdc2gEuHCcWptxVmcVPWOg1vbV+x5teuIE Fo97Qm+Htnc6lAL/05tN2TP8ib9mLoKDAx7Fkj4Zgno2nqzU/JOuAbN1fPx17+gxEKOFXj0/Pi BH+ShxFPtvNUf0l+CuV4NeA7wgdUx5IjcatazaMaVipBllLjTi1Z/AvOse4ih2NOdIrJoadkFa EpY5pD+mSY5p3fpf7yozKZOSzAAyj5IFmXMXQtOTx7hS1wQvsVBDa3Ddu9uiIUef5txAuH1p1l LBs= X-Belgacom-Dynamic: yes IronPort-PHdr: =?us-ascii?q?9a23=3Aj1JlbBKmRipFYETafNmcpTZWNBhigK39O0sv0r?= =?us-ascii?q?FitYgXK/X7rarrMEGX3/hxlliBBdydt6sVzbCN+Pm6ASRAuc/H7CldNsQUFl?= =?us-ascii?q?cssoY/p0QYGsmLCEn2frbBThcRO4B8bmJj5GyxKkNPGczzNBX4q3y26iMOSF?= =?us-ascii?q?2kbVImbuv6FZTPgMupyuu854PcYxlShDq6fLh+MAi6oR/eu8ULhYZuMLg9xx?= =?us-ascii?q?XGrndVZeha2X5jKVaPkxrh/Mu984Nv/iZKt/4968JMVLjxcrglQ7BfEDkoKX?= =?us-ascii?q?0+6tfxtRnEQwuP538cXXsTnxFVHQXL7wz0U4novCfiueVzxCeVPcvtTbApQj?= =?us-ascii?q?ui9LtkSAXpiCgcKTE09nzch9Fqg6JapBKhoAF/w5LRbYqIOvdyYr/RcNUHTm?= =?us-ascii?q?daQM1fSzJODZ+9b4sXDuoOI+BYr5Xmp1ATqReyHBSgCP/zxjNNgHL9wK803P?= =?us-ascii?q?k7EQze0gIuH8wAvmnXotr3OqcdXvy6wqbTwDXfbf5bwyvx5JTUfhw/p/yHQL?= =?us-ascii?q?J+cdDWyUkqDw7LkFCSqYj4ND6L0eQNtHOb4PRlVe21jW4nsBx6rz+zxsctiI?= =?us-ascii?q?nJgpkYxFDe9Spn3ok4OMC2RkBhbd6jCptQuDiXOo1rScwtX29mojw1yqEauZ?= =?us-ascii?q?GlZigKzowqywLRZvKIc4aG7A7vWeKRLzp7mn5pZLKxigqw/ES8yuPxWMa53V?= =?us-ascii?q?VOoyZZltTCuG4B2gLP58aJVvZx41qt1zaO2g3V9+pKL0c0la/BJJ4gxL49jp?= =?us-ascii?q?QTsV7dESDog0r2l7KZel8j+uiy5OTrerrmpp6AN490lwHxKb4ildC4AeQ9Kg?= =?us-ascii?q?QOWHCb9vq61L3s5035R6hKjuUsnqneqpDaKsIWrbO6DQ9Nyosu6AuzAy243N?= =?us-ascii?q?kXg3ULNk9JdRCZg4TzNFzDJu3zA+2ljFS2ijhrwujLPrjmAprQMHfOiKzhfb?= =?us-ascii?q?Nh605Ezwoz0Mxf64pUCr4fJPLzXVf8tN/CAR89Mgy0xvjoCM961o8ERWKPA6?= =?us-ascii?q?2ZMKfIvVCU4eIvJPKMa5EQuDnnLfgl/OTijXgjmV8SZaWp3J0XZ26kHvl+IE?= =?us-ascii?q?iVfGDgjskOHGsUpAYyUe7nhEOYXTNcf3qyWrgz5jA/CIKoF4fDQYWtjaSd3C?= =?us-ascii?q?e6HJ1WYntLCl6WEXj2aYqLQOwMZz+ILs9miDwEWqCtS5U92hG2qA/6171nI/?= =?us-ascii?q?LR+iIEtpLjycN15+zPmhEx7jF0Ad6d3H+TQG5vhWMHWiU63KdloUxy0l2Dy7?= =?us-ascii?q?R3g+REFdxP4PNEShk1NZvGwOxhF9D9RBnMftmTSFm4XNqpGioxQc8rz98JeU?= =?us-ascii?q?Z9FM2ojgrf0CqyH78Vi7uLCYQ28qLd23jxI9hyy23d2akvlVkpXNVAOna9hq?= =?us-ascii?q?Fi7QTTAJTJk0qBnaawaascxDLN9HuEzWeWskFYShB/XrveUnAEe0TatM/55l?= =?us-ascii?q?/YQL+oFLsoKBFBxtOZKqZRZN3pl0tJS+n4N9TFfm29gWCwBQyHxuDEUI2/S2?= =?us-ascii?q?QblAHcQFYFmkgd53uLPxMyQzy9qmTSBSZiDhq7bVnh/ONlpDagUkYywwiQY1?= =?us-ascii?q?ZJ2aC49xQOibqbUfxFjZwevyJ0l9JwVH262MnbDtOGvEI1YKReZfsT+lpK/1?= =?us-ascii?q?n18QtnMcrzfOhZmlcCflEv7AvV3BJtB9AFyJByoQ=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2ACAABkHg9g/wSs8lFiGQEBAQEBAQE?= =?us-ascii?q?BAQEBAQEBAQEBARIBAQEBAQEBAQEBAQFAB4E0BAEBAQEBCwGDCxVXAUkYjGR?= =?us-ascii?q?ghj4Bghk4imWPKIF8CwEBAQEBAQEBAS4KBAEBhAZEAoF5JjQJDgIDAQEBAwI?= =?us-ascii?q?FAQEGAQEBAQEBBQQBhhg5DII4KQGDEgEFOj8QCxguVwYTgyeDCguyVYE0hEA?= =?us-ascii?q?BhRmBAgaBOAGNPUGCAIERgxk+gl0CAQEXhz8Egj6BAj0CgU8zYZwGnDKDAYk?= =?us-ascii?q?wkjAxongtnRaBepg2ghFNMAiDJBIBPRkNji0Xg06FFIVFQAMwAgE0AgYKAQE?= =?us-ascii?q?DCYwVAQE?= X-IPAS-Result: =?us-ascii?q?A2ACAABkHg9g/wSs8lFiGQEBAQEBAQEBAQEBAQEBAQEBA?= =?us-ascii?q?RIBAQEBAQEBAQEBAQFAB4E0BAEBAQEBCwGDCxVXAUkYjGRghj4Bghk4imWPK?= =?us-ascii?q?IF8CwEBAQEBAQEBAS4KBAEBhAZEAoF5JjQJDgIDAQEBAwIFAQEGAQEBAQEBB?= =?us-ascii?q?QQBhhg5DII4KQGDEgEFOj8QCxguVwYTgyeDCguyVYE0hEABhRmBAgaBOAGNP?= =?us-ascii?q?UGCAIERgxk+gl0CAQEXhz8Egj6BAj0CgU8zYZwGnDKDAYkwkjAxongtnRaBe?= =?us-ascii?q?pg2ghFNMAiDJBIBPRkNji0Xg06FFIVFQAMwAgE0AgYKAQEDCYwVAQE?= Received: from 4.172-242-81.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([81.242.172.4]) by relay.skynet.be with ESMTP; 25 Jan 2021 20:42:27 +0100 Received: from localhost (localhost [127.0.0.1]) by kalimero.tijl.coosemans.org (8.16.1/8.16.1) with ESMTP id 10PJgQO8025847; Mon, 25 Jan 2021 20:42:26 +0100 (CET) (envelope-from tijl@FreeBSD.org) Date: Mon, 25 Jan 2021 20:42:25 +0100 From: =?UTF-8?B?VMSzbA==?= Coosemans To: Xin Li via freebsd-standards Cc: d@delphij.net, Jilles Tjoelker , Ed Maste , Xin Li , Marshall Kirk McKusick Subject: Re: _POSIX_C_SOURCE and S_IFMT macros Message-ID: <20210125204225.1a9e38d3@FreeBSD.org> In-Reply-To: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> References: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4DPgHp2l6kz3CMZ X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2021 19:42:31 -0000 On Mon, 25 Jan 2021 01:04:25 -0800 Xin Li via freebsd-standards wrote: > Hi, > > I recently discovered [1] a difference between FreeBSD's handling of > _POSIX_C_SOURCE and what I have observe on Linux and macOS systems, > basically, if a program defines _POSIX_C_SOURCE to 200809L, but did not > define _XOPEN_SOURCE, we will not define S_IFMT when sys/stat.h is included. > > It appears that the glibc version of sys/stat.h won't define it either, > but their fcntl.h would define it by having _POSIX_C_SOURCE >= 200809L > to define _USE_XOPEN2K8 and expose it. > > A quick glance on my Macbook suggests that they were defining the S_IFMT > macros unconditionally. > > Based on my research, hiding these macros started in revision 40491 of > CSRG repository ( > https://svnweb.freebsd.org/csrg?view=revision&revision=40491 ); NetBSD > chose to make the macro visible when _XOPEN_SOURCE in revision 1.34 and > expanded the visibility scope to also cover _NETBSD_SOURCE. > > Do we need to hide these with 200809L when _XOPEN_SOURCE is not defined? > If I'm reading the standards correctly, I think we are required to > define these in modern POSIX revisions? > > > > [1] When building pigz (https://github.com/madler/pigz), I got: > > cc -O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual -c pigz.c -o pigz.o > pigz.c:3817:47: error: use of undeclared identifier 'S_IFMT' > if (stat(from, &st) != 0 || (st.st_mode & S_IFMT) != S_IFREG) > ^ > [...] S_IFMT is marked as an XSI extension so _XOPEN_SOURCE needs to be defined to use it. POSIX programs are supposed to use the equivalent function-like macros, so in this case S_ISREG(st.st_mode) == 0. https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html From owner-freebsd-standards@freebsd.org Mon Jan 25 21:47:10 2021 Return-Path: Delivered-To: freebsd-standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B89634F2DC8 for ; Mon, 25 Jan 2021 21:47:10 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DPk3f0bgLz3PhF; Mon, 25 Jan 2021 21:47:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 10PLkmgW059926 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 25 Jan 2021 23:46:51 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 10PLkmgW059926 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 10PLkmb7059925; Mon, 25 Jan 2021 23:46:48 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 25 Jan 2021 23:46:47 +0200 From: Konstantin Belousov To: Kirk McKusick Cc: Xin Li , d@delphij.net, freebsd-standards@freebsd.org, Jilles Tjoelker , Ed Maste Subject: Re: _POSIX_C_SOURCE and S_IFMT macros Message-ID: References: <202101252118.10PLISQI065263@chez.mckusick.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202101252118.10PLISQI065263@chez.mckusick.com> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4DPk3f0bgLz3PhF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.99 / 15.00]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2001:470:d5e7:1::1:from]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCPT_COUNT_FIVE(0.00)[6]; SPAMHAUS_ZRD(0.00)[2001:470:d5e7:1::1:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.99)[-0.992]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[freebsd-standards]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2021 21:47:10 -0000 On Mon, Jan 25, 2021 at 01:18:28PM -0800, Kirk McKusick wrote: > > Date: Mon, 25 Jan 2021 14:16:33 +0200 > > From: Konstantin Belousov > > To: d@delphij.net > > Cc: freebsd-standards@freebsd.org, Jilles Tjoelker , > > Ed Maste , Xin Li , > > Marshall Kirk McKusick > > Subject: Re: _POSIX_C_SOURCE and S_IFMT macros > > > > On Mon, Jan 25, 2021 at 01:04:25AM -0800, Xin Li via freebsd-standards wrote: > >> Hi, > >> > >> I recently discovered [1] a difference between FreeBSD's handling of > >> _POSIX_C_SOURCE and what I have observe on Linux and macOS systems, > >> basically, if a program defines _POSIX_C_SOURCE to 200809L, but did not > >> define _XOPEN_SOURCE, we will not define S_IFMT when sys/stat.h is included. > >> > >> It appears that the glibc version of sys/stat.h won't define it either, > >> but their fcntl.h would define it by having _POSIX_C_SOURCE >= 200809L > >> to define _USE_XOPEN2K8 and expose it. > >> > >> A quick glance on my Macbook suggests that they were defining the S_IFMT > >> macros unconditionally. > >> > >> Based on my research, hiding these macros started in revision 40491 of > >> CSRG repository ( > >> https://svnweb.freebsd.org/csrg?view=revision&revision=40491 ); NetBSD > >> chose to make the macro visible when _XOPEN_SOURCE in revision 1.34 and > >> expanded the visibility scope to also cover _NETBSD_SOURCE. > >> > >> Do we need to hide these with 200809L when _XOPEN_SOURCE is not defined? > >> If I'm reading the standards correctly, I think we are required to > >> define these in modern POSIX revisions? > >> > >> > >> > >> [1] When building pigz (https://github.com/madler/pigz), I got: > >> > >> cc -O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual -c pigz.c -o pigz.o > >> pigz.c:3817:47: error: use of undeclared identifier 'S_IFMT' > >> if (stat(from, &st) != 0 || (st.st_mode & S_IFMT) != S_IFREG) > >> ^ > >> [...] > > > > In my copy of IEEE Std 1003.1™-2017 S_IFMT and related S_IF symbols > > are specified as provided by sys/stat.h. fcntl.h (not sys/fcntl.h, which > > is not specified by POSIX at all) does not require export of S_IF*. > > > > So I think S_IF symbols listed in POSIX standard should be provided by > > sys/stat.h under some value of POSIX_C_SOURCE, but I did not dig to see > > which should be the guard value. > > > > Most likely 200809 is fine. > > My reading of the current POSIX standard agrees with Kostik's analysis > that S_IF symbols listed in POSIX standard should be provided by > sys/stat.h. I do not have a complete set of POSIX standards over time, > so cannot help with what the cutover date should be. There is actually a small sign 'XSI' at line 13355 of C181.pdf. This is what Jilles referenced as _XOPEN_SOURCE. From owner-freebsd-standards@freebsd.org Mon Jan 25 21:16:36 2021 Return-Path: Delivered-To: freebsd-standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 23FB64F1F93 for ; Mon, 25 Jan 2021 21:16:36 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (chez.mckusick.com [70.36.157.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DPjNM6Jgpz3MpV; Mon, 25 Jan 2021 21:16:35 +0000 (UTC) (envelope-from mckusick@mckusick.com) Received: from chez.mckusick.com (localhost [IPv6:::1]) by chez.mckusick.com (8.15.2/8.15.2) with ESMTP id 10PLISQI065263; Mon, 25 Jan 2021 13:18:28 -0800 (PST) (envelope-from mckusick@mckusick.com) Message-Id: <202101252118.10PLISQI065263@chez.mckusick.com> From: Kirk McKusick To: Xin Li Subject: Re: _POSIX_C_SOURCE and S_IFMT macros cc: d@delphij.net, freebsd-standards@freebsd.org, Jilles Tjoelker , Ed Maste , Konstantin Belousov X-URL: http://WWW.McKusick.COM/ Reply-To: Kirk McKusick In-reply-to: Comments: In-reply-to Konstantin Belousov message dated "Mon, 25 Jan 2021 14:16:33 +0200." MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <65261.1611609508.1@chez.mckusick.com> Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Jan 2021 13:18:28 -0800 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,MISSING_MID, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on chez.mckusick.com X-Rspamd-Queue-Id: 4DPjNM6Jgpz3MpV X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-Mailman-Approved-At: Tue, 26 Jan 2021 11:50:08 +0000 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2021 21:16:36 -0000 > Date: Mon, 25 Jan 2021 14:16:33 +0200 > From: Konstantin Belousov > To: d@delphij.net > Cc: freebsd-standards@freebsd.org, Jilles Tjoelker , > Ed Maste , Xin Li , > Marshall Kirk McKusick > Subject: Re: _POSIX_C_SOURCE and S_IFMT macros > = > On Mon, Jan 25, 2021 at 01:04:25AM -0800, Xin Li via freebsd-standards w= rote: >> Hi, >> = >> I recently discovered [1] a difference between FreeBSD's handling of >> _POSIX_C_SOURCE and what I have observe on Linux and macOS systems, >> basically, if a program defines _POSIX_C_SOURCE to 200809L, but did not >> define _XOPEN_SOURCE, we will not define S_IFMT when sys/stat.h is incl= uded. >> = >> It appears that the glibc version of sys/stat.h won't define it either, >> but their fcntl.h would define it by having _POSIX_C_SOURCE >=3D 200809= L >> to define _USE_XOPEN2K8 and expose it. >> = >> A quick glance on my Macbook suggests that they were defining the S_IFM= T >> macros unconditionally. >> = >> Based on my research, hiding these macros started in revision 40491 of >> CSRG repository ( >> https://svnweb.freebsd.org/csrg?view=3Drevision&revision=3D40491 ); Net= BSD >> chose to make the macro visible when _XOPEN_SOURCE in revision 1.34 and >> expanded the visibility scope to also cover _NETBSD_SOURCE. >> = >> Do we need to hide these with 200809L when _XOPEN_SOURCE is not defined= ? >> If I'm reading the standards correctly, I think we are required to >> define these in modern POSIX revisions? >> = >> = >> = >> [1] When building pigz (https://github.com/madler/pigz), I got: >> = >> cc -O3 -Wall -Wextra -Wno-unknown-pragmas -Wcast-qual -c pigz.c -o pig= z.o >> pigz.c:3817:47: error: use of undeclared identifier 'S_IFMT' >> if (stat(from, &st) !=3D 0 || (st.st_mode & S_IFMT) !=3D S_IFREG) >> ^ >> [...] > = > In my copy of IEEE Std 1003.1=E2=84=A2-2017 S_IFMT and related S_IF symbols > are specified as provided by sys/stat.h. fcntl.h (not sys/fcntl.h, whic= h > is not specified by POSIX at all) does not require export of S_IF*. > = > So I think S_IF symbols listed in POSIX standard should be provided by > sys/stat.h under some value of POSIX_C_SOURCE, but I did not dig to see > which should be the guard value. > = > Most likely 200809 is fine. My reading of the current POSIX standard agrees with Kostik's analysis that S_IF symbols listed in POSIX standard should be provided by sys/stat.h. I do not have a complete set of POSIX standards over time, so cannot help with what the cutover date should be. Kirk McKusick From owner-freebsd-standards@freebsd.org Tue Jan 26 05:13:25 2021 Return-Path: Delivered-To: freebsd-standards@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DE7D84FFAC3 for ; Tue, 26 Jan 2021 05:13:25 +0000 (UTC) (envelope-from wollman@khavrinen.csail.mit.edu) Received: from khavrinen.csail.mit.edu (khavrinen.csail.mit.edu [IPv6:2603:400a:0:7ec::801e:1c14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "khavrinen.csail.mit.edu", Issuer "Client CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DPvyY5vLyz4ky6 for ; Tue, 26 Jan 2021 05:13:25 +0000 (UTC) (envelope-from wollman@khavrinen.csail.mit.edu) Received: from khavrinen.csail.mit.edu (localhost [127.0.0.1]) by khavrinen.csail.mit.edu (8.16.1/8.16.1) with ESMTPS id 10Q5DB8H019590 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=FAIL CN=khavrinen.csail.mit.edu issuer=Client+20CA); Tue, 26 Jan 2021 00:13:11 -0500 (EST) (envelope-from wollman@khavrinen.csail.mit.edu) Received: (from wollman@localhost) by khavrinen.csail.mit.edu (8.16.1/8.16.1/Submit) id 10Q5DBpb019589; Tue, 26 Jan 2021 00:13:11 -0500 (EST) (envelope-from wollman) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <24591.42215.445286.330260@khavrinen.csail.mit.edu> Date: Tue, 26 Jan 2021 00:13:11 -0500 From: Garrett Wollman To: d@delphij.net Cc: freebsd-standards@freebsd.org Subject: _POSIX_C_SOURCE and S_IFMT macros In-Reply-To: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> References: <69977864-0a68-909d-8ecb-1d72c0ec0ef9@delphij.net> X-Mailer: VM 8.2.0b under 27.1 (amd64-portbld-freebsd12.2) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (khavrinen.csail.mit.edu [0.0.0.0]); Tue, 26 Jan 2021 00:13:11 -0500 (EST) X-Rspamd-Queue-Id: 4DPvyY5vLyz4ky6 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-Mailman-Approved-At: Tue, 26 Jan 2021 11:50:17 +0000 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2021 05:13:25 -0000 < said: > I recently discovered [1] a difference between FreeBSD's handling of > _POSIX_C_SOURCE and what I have observe on Linux and macOS systems, > basically, if a program defines _POSIX_C_SOURCE to 200809L, but did not > define _XOPEN_SOURCE, we will not define S_IFMT when sys/stat.h is included. We (try to[1]) take a "strict namespacing" policy: if an application asks for a strict POSIX environment, then we try not to define symbols other than those required by the standard to be present, even if they are permitted. In the case of the "X/Open System Interfaces" option, which we do not completely implement (and never have -- it mostly memorializes old System V mistakes that were never part of our BSD heritage), those symbols are only declared when _XOPEN_SOURCE is defined, which applications are required by the standard to define if they wish to use those interfaces. This is a different, less permissive approach than is taken by glibc, but it is intentional and it is permitted by the standard. Non-standard-conforming applications should not define a feature-test macro that requests a standard-conforming compilation environment. -GAWollman [1] I can't promise that we succeed. I know I didn't come close when I did a lot of namespace cleanliness work in the early 2000s, and I probably still have the bde-mail (RIP) to prove it.