diff --git a/include/endian.h b/include/endian.h index eb25cedf0bef..87ec7866c791 100644 --- a/include/endian.h +++ b/include/endian.h @@ -11,9 +11,33 @@ #ifndef _ENDIAN_H_ #define _ENDIAN_H_ +/* + * POSIX Issue 8 requires that endian.h define uint{16,32,64}_t. Although POSIX + * allows stdint.h symbols here, be conservative and only define there required + * ones. FreeBSD's sys/_endian.h doesn't need to expose those types since it + * implements all the [bl]eXtoh hto[bl]eX interfaces as macros calling builtin + * functions. POSIX allows functions, macros or both. We opt for macros only. + */ +#include + +#ifndef _UINT16_T_DECLARED +typedef __uint16_t uint16_t; +#define _UINT16_T_DECLARED +#endif + +#ifndef _UINT32_T_DECLARED +typedef __uint32_t uint32_t; +#define _UINT32_T_DECLARED +#endif + +#ifndef _UINT64_T_DECLARED +typedef __uint64_t uint64_t; +#define _UINT64_T_DECLARED +#endif + /* * FreeBSD's sys/_endian.h is very close to the interface provided on Linux by - * glibc's endian.h. + * glibc's endian.h as well as POSIX Issue 8's endian.h. */ #include diff --git a/sys/sys/_endian.h b/sys/sys/_endian.h index 8d1eb3f3f3df..d0ffd87efa11 100644 --- a/sys/sys/_endian.h +++ b/sys/sys/_endian.h @@ -69,8 +69,10 @@ /* * 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. + * traditional BSD compilation environment. PDP_ENDIAN isn't strictly in Issue + * 8, but is allowed as implementations can define any *_ENDIAN symbol. Since + * issue 8 doesn't yet have an assigned date, use strictly greater than issue + * 7's date. */ #if __BSD_VISIBLE || _POSIX_C_SOURCE > 200809 #define LITTLE_ENDIAN _LITTLE_ENDIAN