Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Dec 2021 15:55:26 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 773538247007 - stable/12 - headers: Implement _ISOC11_SOURCES macro when __POSIX_C_SOURCE defined
Message-ID:  <202112061555.1B6FtQFa032938@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=77353824700794eac987ae11e82d3ec5e4a99228

commit 77353824700794eac987ae11e82d3ec5e4a99228
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-05-06 22:20:19 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-12-06 15:54:11 +0000

    headers: Implement _ISOC11_SOURCES macro when __POSIX_C_SOURCE defined
    
    When _ISOC11_SOURCES is defined for glibc at the same time
    __POSIX_C_SOURCE is defined, it extends the __POSIX_C_SOURCE definition
    by exaclty what C11 adds to the spec for each system header.  We follow
    both OpenBSD's and glibc's convention by also C11 or higher compliation
    mode is selected.
    
    The Open Group is working on issuing a new version of the POSIX standard
    that will realign the standard from C99 to a newer version of C. This
    commit is a stop-gap measure for greater compatibility until that
    environment has been standardized.
    
    Reviewed by:            brooks@, arichards@, Olivier Certne
                            (comments tweaked before commit)
    PR:                     255290
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D29902
    
    (cherry picked from commit a709a4f0d4e0303eb40ea1b39b4bb35837800805)
---
 sys/sys/cdefs.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index edb491d80b86..e884875c69d4 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -720,6 +720,17 @@
 #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.
+ */
+#if _ISOC11_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
+#undef __ISO_C_VISIBLE
+#define __ISO_C_VISIBLE		2011
+#endif
 #else
 /*-
  * Deal with _ANSI_SOURCE:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112061555.1B6FtQFa032938>