git: ed52baf51bd1 - main - _endian.h: Include sys/ctypes.h for visibility macros
Date: Wed, 22 Mar 2023 02:26:21 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ed52baf51bd142b5e32701842346452a7ebe37a5 commit ed52baf51bd142b5e32701842346452a7ebe37a5 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2023-03-22 02:25:58 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2023-03-22 02:25:58 +0000 _endian.h: Include sys/ctypes.h for visibility macros BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN will be required by the forthcoming POSIX Issue 8. In addition, they are provided in the BSD compilation environments. However, depending on the order includes happend, sys/cdefs.h may or may not be included when endian.h is included. Include it here so we can safely test __BSD_VISIBLE. Add visibility when we're compiling in the future for issue 8, but since the date number for issue 8 hasn't been fixed, use strictly greater than the issue 7 date.of 200809. This had the side effect of sometimes (in the traditional BSD compliation environment) #if BYTE_ORDER == LITTLE_ENDIAN and #if BYTE_ORDER == BIG_ENDIAN both being true because none of these were defined. This fixes that. It also fixes including it after <stdio.h> but not before. PR: 269249 MFC After: 1d (build related) Reviewed by: kib, emaste Differential Revision: https://reviews.freebsd.org/D39176 Sponsored by: Netflix --- sys/sys/_endian.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/sys/_endian.h b/sys/sys/_endian.h index 7ac39386e2e1..3b4460472eb6 100644 --- a/sys/sys/_endian.h +++ b/sys/sys/_endian.h @@ -36,6 +36,8 @@ #error "sys/_endian.h should not be included directly" #endif +#include <sys/cdefs.h> /* visibility macros */ + /* BSD Compatiblity */ #define _BYTE_ORDER __BYTE_ORDER__ @@ -66,10 +68,11 @@ #endif /* - * Deprecated variants that don't have enough underscores to be useful in more - * strict namespaces. + * POSIX Issue 8 will require these for endian.h. Define them there and in the + * traditional BSD compilation environment. Since issue 8 doesn't yet have an + * assigned date, use strictly greater than issue 7's date. */ -#if __BSD_VISIBLE +#if __BSD_VISIBLE || _POSIX_C_SOURCE > 200809 #define LITTLE_ENDIAN _LITTLE_ENDIAN #define BIG_ENDIAN _BIG_ENDIAN #define PDP_ENDIAN _PDP_ENDIAN