From c8c9324c94dfd4eeecbcfe4a1d3daa047420d3e5 Mon Sep 17 00:00:00 2001 From: Robert Clausecker Date: Sun, 19 Apr 2026 14:36:34 +0200 Subject: [PATCH] include/stdbit.h: declare size_t, (u)int*_t, and (u)int_least*_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are required by ISO/IEC 9899:2024 § 7.18.1 ¶ 1 but were forgotten in my initial work. The current approach leaks intptr_t, uintptr_t, intmax_t, and uintmax_t through . This could be avoided using a more complicated approach if desired. PR: 294131 Fixes: 6296500a85c8474e3ff3fe2f8e4a9d56dd0acd64 Reported by: Collin Funk Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56515 --- include/stdbit.h | 22 +++++++++++++++++++++- sys/sys/stdint.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/stdbit.h b/include/stdbit.h index a529676bed4..6b9ea02971b 100644 --- a/include/stdbit.h +++ b/include/stdbit.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2025 Robert Clausecker + * Copyright (c) 2025-2026 Robert Clausecker * * SPDX-License-Identifier: BSD-2-Clause */ @@ -8,6 +8,26 @@ #define __STDC_VERSION_STDBIT_H__ 202311L #include +#include +#include + +#ifndef _SIZE_T_DECLARED +typedef __size_t size_t; +#define _SIZE_T_DECLARED +#endif + +#ifndef _INT_LEAST_T_DECLARED +typedef __int_least8_t int_least8_t; +typedef __int_least16_t int_least16_t; +typedef __int_least32_t int_least32_t; +typedef __int_least64_t int_least64_t; + +typedef __uint_least8_t uint_least8_t; +typedef __uint_least16_t uint_least16_t; +typedef __uint_least32_t uint_least32_t; +typedef __uint_least64_t uint_least64_t; +#define _INT_LEAST_T_DECLARED +#endif /* byte order */ #define __STDC_ENDIAN_LITTLE__ __ORDER_LITTLE_ENDIAN__ diff --git a/sys/sys/stdint.h b/sys/sys/stdint.h index 77f469f3c2a..dccc5a8e6a6 100644 --- a/sys/sys/stdint.h +++ b/sys/sys/stdint.h @@ -35,6 +35,7 @@ #include #include +#ifndef _INT_LEAST_T_DECLARED typedef __int_least8_t int_least8_t; typedef __int_least16_t int_least16_t; typedef __int_least32_t int_least32_t; @@ -44,6 +45,8 @@ typedef __uint_least8_t uint_least8_t; typedef __uint_least16_t uint_least16_t; typedef __uint_least32_t uint_least32_t; typedef __uint_least64_t uint_least64_t; +#define _INT_LEAST_T_DECLARED +#endif typedef __int_fast8_t int_fast8_t; typedef __int_fast16_t int_fast16_t;