From nobody Fri Nov 15 02:02:08 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XqKyn1wB3z5dRKH; Fri, 15 Nov 2024 02:02:09 +0000 (UTC) (envelope-from git@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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XqKyn0gknz4dDF; Fri, 15 Nov 2024 02:02:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731636129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tc/pVhVRk6J+ZpEt8hHsG2T7s70zRzrPI2FRdybVNWo=; b=eCAvWPfuPyDxip+OQzBX6GXESJ62Asqg3Fc3b9RpOJa4XRWPP7fgBDBQtlx0gAF3gTV/VS +iWBGDbN59jj+iAKgigXocl7Jxv8jLswJpNsh4hP27kfn8txvWPzTIsCJxdR9Slg1hIFrJ WiUrivbESXHIUkkCt3j5nPV7lylAsspyMGW6VlJYv0bw+sdHtVZ29K+6wdgIMTmsgSQfUq aT9rdAnlF+YHyfaPZi2ZvH/Zkb9umOz0cHWqGJtkBKfMCG3cyfINydXL1t10t9T0oC4f0i PMBc8soEnuG5WS6rel0nOWzW3tzM431NV5R9RgVj+EdaIXGm7LLH2q5kOUDSUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731636129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tc/pVhVRk6J+ZpEt8hHsG2T7s70zRzrPI2FRdybVNWo=; b=GTNyIxbW7YBds++ynG4hPuwnG3oCQNAzxW20zRDhOnmN8HxAPwsSlzfNljiNOfMdbQTyw8 pV/OVTeDbM7AYOsJL785LXyrOKxZdJfpA41OnnEiO45xS0RfykuIaUdCJnllaguTHGZwNc bG4/AaD0Phhe7/L9eLELkzrpygkfdSiquca/q951QWE8CoTGBP4F91PBuGmFSSKaufy5Z8 2VVBPk+uCTRC9aGdasTuQzsQxINXXlHrBTXAB30BlRjSRM/v0mduI5tnKnun6lSBQT19/K S23fWmXEhTH9opPvXW4vZTez01wOHXkxDIFwd1CbByqTlQFj13Dytvuu0wmtGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731636129; a=rsa-sha256; cv=none; b=eik6XzCSgafUfnuLuI81nlzvcLnvzwsk/DDDZAaTt282Iji0S+W4Wg7yEVhMFtQzVd3OK6 Q33XpBA7p3F/dn5Y6YxTen5KZn317WVskNS9BRFVskAgm4zJfAK/lWSikcFneTa3Ib320U Hs8G4/qvM4NJ7Hc5hCAVZDnJtwc1nL8Mthjvz9ld0McIYDw9yzk6Ln8/6ScM1zbwLEpzi3 uOgwwjUajxI9Eutd97I6m1DpH9wNBtGqLz4yIvPzJgO1ba8vAGTaor2BUcmgpzNzLBZ75g iOQDJL3NwF7bO9S95YAYj2OdrmfX4ApqT+/pa5b0buOPhnKOH9JZDcGVHoYZHA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4XqKyn01Q0z13G5; Fri, 15 Nov 2024 02:02:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AF228ER047813; Fri, 15 Nov 2024 02:02:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AF228AN047810; Fri, 15 Nov 2024 02:02:08 GMT (envelope-from git) Date: Fri, 15 Nov 2024 02:02:08 GMT Message-Id: <202411150202.4AF228AN047810@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 4afcb821938f - main - cdefs: Support _ISOC23_SOURCE and --std=c23 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4afcb821938f5e8cb50e3a781f0276c4f5357b1a Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4afcb821938f5e8cb50e3a781f0276c4f5357b1a commit 4afcb821938f5e8cb50e3a781f0276c4f5357b1a Author: Warner Losh AuthorDate: 2024-11-14 23:52:35 +0000 Commit: Warner Losh CommitDate: 2024-11-15 01:58:17 +0000 cdefs: Support _ISOC23_SOURCE and --std=c23 If either _ISOC23_SOURCE is defined or --std=c23 (or higher) is specified, then default to the making the ISO C visibility to 2023. This mirrors what glibc does, so update the comment for this change to _ISOCxx_SOURCE values. We currently implement xx = 11 or 23. C17 added no new defines or symbols, so we follow glibc's lead and ommit it. However, we don't implement the C95, C99 or C2y versions. These are non-standard and the first two don't seem to be relevant, and the latter is also experimental. Sponsored by: Netflix Reviewed by: brooks Differential Revision: https://reviews.freebsd.org/D47576 --- sys/sys/cdefs.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 25248bd235b2..1a1705129fa6 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -567,14 +567,21 @@ #define __POSIX_VISIBLE 198808 #define __ISO_C_VISIBLE 0 #endif /* _POSIX_C_SOURCE */ + /* - * Both glibc and OpenBSD enable c11 features when _ISOC11_SOURCE is defined, or - * when compiling with -stdc=c11. A strict reading of the standard would suggest - * doing it only for the former. However, a strict reading also requires C99 - * mode only, so building with C11 is already undefined. Follow glibc's and - * OpenBSD's lead for this non-standard configuration for maximum compatibility. + * When we've explicitly asked for a newer C version, make the C variable + * visible by default. Also honor the glibc _ISOC{11,23}_SOURCE macros + * extensions. Both glibc and OpenBSD do this, even when a more strict + * _POSIX_C_SOURCE has been requested, and it makes good sense (especially for + * pre POSIX 2024, since C11 is much nicer than the old C99 base). Continue the + * practice with C23, though don't do older standards. Also, GLIBC doesn't have + * a _ISOC17_SOURCE, so it's not implemented here. glibc has earlier ISOCxx defines, + * but we don't implement those as they are not relevant enough. */ -#if _ISOC11_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) +#if _ISOC23_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +#undef __ISO_C_VISIBLE +#define __ISO_C_VISIBLE 2023 +#elif _ISOC11_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) #undef __ISO_C_VISIBLE #define __ISO_C_VISIBLE 2011 #endif