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