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
+64
View File
@@ -0,0 +1,64 @@
#ifndef VLIBC_UCHAR_H
#define VLIBC_UCHAR_H
/*
* vlibc — <uchar.h>.
*
* Unicode character types and the multibyte conversion declarations (C11,
* gated at level 1 per the plan's header inventory). In C23 char16_t and
* char32_t are keywords, so the typedefs below only fire in C17 (and
* older); the C17 types are the compiler's __CHAR16_TYPE__/__CHAR32_TYPE__,
* which is what the C23 keywords name as well.
*
* The mbrtoc16/mbrtoc32/c16rtomb/c32rtomb functions are DECLARED here but
* implemented by the multibyte todo (#50): user code compiles against this
* header today and linking resolves once #50 lands.
*/
#include <vlibc/features.h>
#include <stddef.h>
#if VLIBC_HAS_HEADER_UCHAR_H
/*
* char16_t/char32_t remain typedefs in C23 (unlike bool/alignas/... they were
* NOT promoted to keywords), so they are defined in every C mode from the
* compiler's __CHAR16_TYPE__/__CHAR32_TYPE__; in C++ they are keywords and
* no typedef fires.
*/
#ifndef __cplusplus
typedef __CHAR16_TYPE__ char16_t;
typedef __CHAR32_TYPE__ char32_t;
#endif
/*
* Conversion state for multibyte conversions. Two opaque words; the real
* layout is owned by the multibyte todo (#50), which may extend this
* definition when it lands (see the learnings note).
*/
typedef struct
{
unsigned int state[2];
} mbstate_t;
/*
* Multibyte <-> UTF-16/UTF-32 conversions (implemented in #50).
*
* mbrtoc16: convert at most n bytes of the multibyte string s to a char16_t
* stored through pc16, consuming the corresponding number of bytes.
* c16rtomb: convert char16_t c16 to at most MB_CUR_MAX bytes at s.
* The char32_t forms are the same for UTF-32.
*/
size_t
mbrtoc16(char16_t *restrict pc16, const char *restrict s, size_t n, mbstate_t *restrict ps);
size_t
c16rtomb(char *restrict s, char16_t c16, mbstate_t *restrict ps);
size_t
mbrtoc32(char32_t *restrict pc32, const char *restrict s, size_t n, mbstate_t *restrict ps);
size_t
c32rtomb(char *restrict s, char32_t c32, mbstate_t *restrict ps);
#endif /* VLIBC_HAS_HEADER_UCHAR_H */
#endif /* VLIBC_UCHAR_H */