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.