mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-21 10:41:46 +01:00
endian.h: Define uint{16,32,64}_t
The Draft Posix Issue 8 standard requires that these be defined. Define them in the usual way that lets multiple headers define them. Opted to not just use #include <stdint.h>, allowed by the draft, to be conservative. Add notes about how we comply with Issue 8, and that we've opted to define these only as macros, though the standard allows functions, macros or both. Sponsored by: Netflix
This commit is contained in:
parent
e12b7446bd
commit
1314d14c32
@ -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 <sys/_types.h>
|
||||
|
||||
#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 <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
|
||||
|
Loading…
Reference in New Issue
Block a user