feat(headers): stddef/stdint/stdbool/limits/float/assert + features wiring

This commit is contained in:
2026-09-03 17:34:16 -04:00
parent ce517ad0d6
commit dec1017527
22 changed files with 2076 additions and 2 deletions
+70
View File
@@ -0,0 +1,70 @@
#ifndef VLIBC_LIMITS_H
#define VLIBC_LIMITS_H
/*
* vlibc — <limits.h>.
*
* Sizes of integer types (C23). Every value is derived from compiler
* predefined macros (__CHAR_BIT__, __SCHAR_MAX__, __SIZEOF_INT__, ...), so
* this header is fully self-contained. char is signed on x86_64; the
* __CHAR_UNSIGNED__ branch keeps the header correct if that ever changes.
*
* This header is ISO C core and is present in every profile.
*/
#include <vlibc/features.h>
/* Number of bits in the smallest addressable object. */
#define CHAR_BIT __CHAR_BIT__
/* Maximum number of bytes in a multibyte character (UTF-8 over 32-bit
* wchar_t needs at most 4). */
#define MB_LEN_MAX 4
/* Limits of the plain char types. */
#define SCHAR_MIN (-__SCHAR_MAX__ - 1)
#define SCHAR_MAX __SCHAR_MAX__
#define UCHAR_MAX (__SCHAR_MAX__ * 2 + 1)
#if defined(__CHAR_UNSIGNED__)
#define CHAR_MIN 0
#define CHAR_MAX UCHAR_MAX
#else
#define CHAR_MIN SCHAR_MIN
#define CHAR_MAX SCHAR_MAX
#endif
/* Limits of the short types. */
#define SHRT_MIN (-__SHRT_MAX__ - 1)
#define SHRT_MAX __SHRT_MAX__
#define USHRT_MAX (__SHRT_MAX__ * 2 + 1)
/* Limits of the int types. */
#define INT_MIN (-__INT_MAX__ - 1)
#define INT_MAX __INT_MAX__
#define UINT_MAX (__INT_MAX__ * 2U + 1U)
/* Limits of the long types (x86_64 LP64: 64-bit). */
#define LONG_MIN (-__LONG_MAX__ - 1L)
#define LONG_MAX __LONG_MAX__
#define ULONG_MAX (__LONG_MAX__ * 2UL + 1UL)
/* Limits of the long long types. */
#define LLONG_MIN (-__LONG_LONG_MAX__ - 1LL)
#define LLONG_MAX __LONG_LONG_MAX__
#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
/* Width of each integer type, in bits (C23). */
#define BOOL_WIDTH 1
#define CHAR_WIDTH __CHAR_BIT__
#define SCHAR_WIDTH __CHAR_BIT__
#define UCHAR_WIDTH __CHAR_BIT__
#define SHRT_WIDTH (__SIZEOF_SHORT__ * __CHAR_BIT__)
#define USHRT_WIDTH (__SIZEOF_SHORT__ * __CHAR_BIT__)
#define INT_WIDTH (__SIZEOF_INT__ * __CHAR_BIT__)
#define UINT_WIDTH (__SIZEOF_INT__ * __CHAR_BIT__)
#define LONG_WIDTH (__SIZEOF_LONG__ * __CHAR_BIT__)
#define ULONG_WIDTH (__SIZEOF_LONG__ * __CHAR_BIT__)
#define LLONG_WIDTH (__SIZEOF_LONG_LONG__ * __CHAR_BIT__)
#define ULLONG_WIDTH (__SIZEOF_LONG_LONG__ * __CHAR_BIT__)
#endif /* VLIBC_LIMITS_H */