git: 1f09e354297c - main - sys/limits.h: Add BOOL_MAX, BITINT_MAXWIDTH, and C23 feature test macro
Faraz Vahedi <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.cvs.src,gmane.os.freebsd.current.scm |
|---|---|
| Message-ID | <[email protected]> |
The branch main has been updated by kfv: URL: https://cgit.FreeBSD.org/src/commit/?id=1f09e354297ce571353210c23e50ef6fc19ce382 commit 1f09e354297ce571353210c23e50ef6fc19ce382 Author: Faraz Vahedi <[email protected]> AuthorDate: 2026-08-04 12:43:57 +0000 Commit: Faraz Vahedi <[email protected]> CommitDate: 2026-08-13 09:41:25 +0000 sys/limits.h: Add BOOL_MAX, BITINT_MAXWIDTH, and C23 feature test macro Add BOOL_MAX and BITINT_MAXWIDTH macros for C23 compliance, and define the __STDC_VERSION_LIMITS_H__ feature test macro now that the header fully conforms to C23. Reviewed by: fuz Approved by: fuz (mentor) MFC after: 1 month Pull Request: https://github.com/freebsd/freebsd-src/pull/2352 --- include/limits.h | 6 +++--- sys/sys/limits.h | 7 +++++++ sys/sys/syslimits.h | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/limits.h b/include/limits.h index 2b75b94cb513..7b316e6e905d 100644 --- a/include/limits.h +++ b/include/limits.h @@ -29,8 +29,8 @@ * SUCH DAMAGE. */ -#ifndef _LIMITS_H_ -#define _LIMITS_H_ +#ifndef __STDC_VERSION_LIMITS_H__ +#define __STDC_VERSION_LIMITS_H__ 202311L #include <sys/cdefs.h> @@ -148,4 +148,4 @@ #include <sys/syslimits.h> #endif -#endif /* !_LIMITS_H_ */ +#endif /* !__STDC_VERSION_LIMITS_H__ */ diff --git a/sys/sys/limits.h b/sys/sys/limits.h index 8044d4458639..c25257f01c5e 100644 --- a/sys/sys/limits.h +++ b/sys/sys/limits.h @@ -69,6 +69,7 @@ #endif #if __ISO_C_VISIBLE >= 2023 +#define BOOL_MAX 1 /* max value for a bool */ #define BOOL_WIDTH 1 /* number of bits in a bool */ #define CHAR_WIDTH __CHAR_BIT /* number of bits in a char */ @@ -86,6 +87,12 @@ #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 */ + +#ifdef __BITINT_MAXWIDTH__ +#define BITINT_MAXWIDTH __BITINT_MAXWIDTH__ +#else +#define BITINT_MAXWIDTH ULLONG_WIDTH +#endif #endif #if __POSIX_VISIBLE || __XSI_VISIBLE diff --git a/sys/sys/syslimits.h b/sys/sys/syslimits.h index 64be1fc9b4e2..eb1520d98c89 100644 --- a/sys/sys/syslimits.h +++ b/sys/sys/syslimits.h @@ -32,7 +32,8 @@ #ifndef _SYS_SYSLIMITS_H_ #define _SYS_SYSLIMITS_H_ -#if !defined(_STANDALONE) && !defined(_KERNEL) && !defined(_LIMITS_H_) && !defined(_SYS_PARAM_H_) +#if !defined(_STANDALONE) && !defined(_KERNEL) && \ + !defined(__STDC_VERSION_LIMITS_H__) && !defined(_SYS_PARAM_H_) #warning "No user-serviceable parts inside." #endif