diff options
| author | Ahmad Khalifa <vexeduxr@FreeBSD.org> | 2026-02-24 20:11:12 +0000 |
|---|---|---|
| committer | Ahmad Khalifa <vexeduxr@FreeBSD.org> | 2026-02-24 20:42:21 +0000 |
| commit | 0c075db78a98de8e3a255597d045bcd24ba27be7 (patch) | |
| tree | d448535996b7d6afb4f0566b489c974a97860f84 | |
| parent | 591127bd4839d00fc218d74096ca07088ad30703 (diff) | |
tools/build/stddef.h: fix stock clang/gcc headers
Both clang and gcc's stddef.h are designed to be included multiple times
with different combinations of __need_* macros defined (e.g
__need_size_t). Remove the #pragma once to accommodate this, ptraddr_t
is guarded by _PTRADDR_T_DECLARED anyways.
Also use __SIZE_TYPE__ instead of size_t since it's not guaranteed to be
defined.
Reviewed by: brooks, imp, kib
Differential Revision: https://reviews.freebsd.org/D55453
| -rw-r--r-- | tools/build/stddef.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/build/stddef.h b/tools/build/stddef.h index 77348dd57149..ca6d481a9d29 100644 --- a/tools/build/stddef.h +++ b/tools/build/stddef.h @@ -36,14 +36,24 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#pragma once + +/* + * The header guard is left out on purpose here. Both clang and gcc's + * stddef.h are designed to be included multiple times with different + * combinations of __need_* macros defined (e.g __need_size_t). + */ + #include_next <stddef.h> #ifndef _PTRADDR_T_DECLARED #ifdef __PTRADDR_TYPE__ typedef __PTRADDR_TYPE__ ptraddr_t; #else -typedef size_t ptraddr_t; +/* + * If anything other than __need_size_t is defined (see above), we won't + * have size_t. Use __SIZE_TYPE__ instead. + */ +typedef __SIZE_TYPE__ ptraddr_t; #endif #define _PTRADDR_T_DECLARED #endif |
