Date: Thu, 01 Jan 2026 22:21:36 +0000 From: Robert Clausecker <fuz@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: cbad54ba46e6 - stable/15 - sys/limits.h: add C23 _WIDTH macros Message-ID: <6956f370.eee6.5b3293bd@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=cbad54ba46e6a4ad83d87d379fc3fcedb0cd7246 commit cbad54ba46e6a4ad83d87d379fc3fcedb0cd7246 Author: Robert Clausecker <fuz@FreeBSD.org> AuthorDate: 2025-11-19 12:29:58 +0000 Commit: Robert Clausecker <fuz@FreeBSD.org> CommitDate: 2026-01-01 20:51:52 +0000 sys/limits.h: add C23 _WIDTH macros For compliance with IOS/IEC 9899:2024 ("C23"). These macros define the width in bits of the basic integer types. Another new macro, BITINT_MAXWIDTH, is not yet included as I do not understand what it should be set to. Perhaps it is compiler-specific. Approved by: markj (mentor) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D53825 (cherry picked from commit 7326bc7f9c14f86976a7769906b167ff96140809) --- sys/arm/include/_limits.h | 3 +++ sys/arm64/include/_limits.h | 3 +++ sys/powerpc/include/_limits.h | 3 +++ sys/riscv/include/_limits.h | 3 +++ sys/sys/limits.h | 20 ++++++++++++++++++++ sys/x86/include/_limits.h | 3 +++ 6 files changed, 35 insertions(+) diff --git a/sys/arm/include/_limits.h b/sys/arm/include/_limits.h index 8cd48337508e..d6bcb09bda84 100644 --- a/sys/arm/include/_limits.h +++ b/sys/arm/include/_limits.h @@ -42,6 +42,9 @@ */ #define __CHAR_BIT 8 /* number of bits in a char */ +#define __SHRT_BIT 16 /* number of bits in a short */ +#define __INT_BIT 32 /* number of bits in an int */ +#define __LLONG_BIT 64 /* number of bits in a long long */ #define __SCHAR_MAX 0x7f /* max value for a signed char */ #define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ diff --git a/sys/arm64/include/_limits.h b/sys/arm64/include/_limits.h index 08649b5c779d..aeb72dc19b09 100644 --- a/sys/arm64/include/_limits.h +++ b/sys/arm64/include/_limits.h @@ -41,6 +41,9 @@ */ #define __CHAR_BIT 8 /* number of bits in a char */ +#define __SHRT_BIT 16 /* number of bits in a short */ +#define __INT_BIT 32 /* number of bits in an int */ +#define __LLONG_BIT 64 /* number of bits in a long long */ #define __SCHAR_MAX 0x7f /* max value for a signed char */ #define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ diff --git a/sys/powerpc/include/_limits.h b/sys/powerpc/include/_limits.h index 542248e51498..cae389ef0f36 100644 --- a/sys/powerpc/include/_limits.h +++ b/sys/powerpc/include/_limits.h @@ -42,6 +42,9 @@ */ #define __CHAR_BIT 8 /* number of bits in a char */ +#define __SHRT_BIT 16 /* number of bits in an short */ +#define __INT_BIT 32 /* number of bits in an int */ +#define __LLONG_BIT 64 /* number of bits in a long long */ #define __SCHAR_MAX 0x7f /* max value for a signed char */ #define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ diff --git a/sys/riscv/include/_limits.h b/sys/riscv/include/_limits.h index 95e86c14e168..872e5b610e0c 100644 --- a/sys/riscv/include/_limits.h +++ b/sys/riscv/include/_limits.h @@ -37,6 +37,9 @@ */ #define __CHAR_BIT 8 /* number of bits in a char */ +#define __SHRT_BIT 16 /* number of bits in a short */ +#define __INT_BIT 32 /* number of bits in an int */ +#define __LLONG_BIT 64 /* number of bits in a long long */ #define __SCHAR_MAX 0x7f /* max value for a signed char */ #define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */ diff --git a/sys/sys/limits.h b/sys/sys/limits.h index 2cb0051fe86c..8044d4458639 100644 --- a/sys/sys/limits.h +++ b/sys/sys/limits.h @@ -68,6 +68,26 @@ #define LLONG_MIN __LLONG_MIN /* min for a long long */ #endif +#if __ISO_C_VISIBLE >= 2023 +#define BOOL_WIDTH 1 /* number of bits in a bool */ + +#define CHAR_WIDTH __CHAR_BIT /* number of bits in a char */ +#define SCHAR_WIDTH __CHAR_BIT /* number of bits in a signed char */ +#define UCHAR_WIDTH __CHAR_BIT /* number of bits in an unsigned char */ + +#define SHRT_WIDTH __SHRT_BIT /* number of bits in a short */ +#define USHRT_WIDTH __SHRT_BIT /* number of bits in an unsigned short */ + +#define INT_WIDTH __INT_BIT /* number of bits in an int */ +#define UINT_WIDTH __INT_BIT /* number of bits in an unsigned int */ + +#define LONG_WIDTH __LONG_BIT /* number of bits in a long */ +#define ULONG_WIDTH __LONG_BIT /* number of bits in an unsigned long */ + +#define LLONG_WIDTH __LLONG_BIT /* number of bits in a long long */ +#define ULLONG_WIDTH __LLONG_BIT /* number of bits in an unsigned long long */ +#endif + #if __POSIX_VISIBLE || __XSI_VISIBLE #define SSIZE_MAX __SSIZE_MAX /* max value for an ssize_t */ #endif diff --git a/sys/x86/include/_limits.h b/sys/x86/include/_limits.h index 422667a79bc0..fc7cfac1e70d 100644 --- a/sys/x86/include/_limits.h +++ b/sys/x86/include/_limits.h @@ -42,6 +42,9 @@ */ #define __CHAR_BIT 8 /* number of bits in a char */ +#define __SHRT_BIT 16 /* number of bits in a short */ +#define __INT_BIT 32 /* number of bits in an int */ +#define __LLONG_BIT 64 /* number of bits in a long long */ #define __SCHAR_MAX 0x7f /* max value for a signed char */ #define __SCHAR_MIN (-0x7f - 1) /* min value for a signed char */home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6956f370.eee6.5b3293bd>
