From ed52baf51bd142b5e32701842346452a7ebe37a5 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 21 Mar 2023 20:25:58 -0600 Subject: [PATCH] _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 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 7ac39386e2e..3b4460472eb 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 /* 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 -- 2.45.0