[libc-commits] [libc] [libc] Define `MB_LEN_MAX` in `limits.h` (PR #102246)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue Aug 6 16:03:45 PDT 2024
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/102246
Summary:
This is supposed to define the maximum bytes required to store a char in
any locale. There's some question about what this should be set to. I
believe because the proposed solution for `locale.h` is to only support
the default locale, we should do what `musl` does and set it to `4`
which covers up to UTF-32.
Fixes https://github.com/llvm/llvm-project/issues/79358
>From 89923daef7c24ff8d3e8840f0dbae76312ffc852 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Tue, 6 Aug 2024 17:43:19 -0500
Subject: [PATCH] [libc] Define `MB_LEN_MAX` in `limits.h`
Summary:
This is supposed to define the maximum bytes required to store a char in
any locale. There's some question about what this should be set to. I
believe because the proposed solution for `locale.h` is to only support
the default locale, we should do what `musl` does and set it to `4`
which covers up to UTF-32.
Fixes https://github.com/llvm/llvm-project/issues/79358
---
libc/include/llvm-libc-macros/limits-macros.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/libc/include/llvm-libc-macros/limits-macros.h b/libc/include/llvm-libc-macros/limits-macros.h
index 456487e603b25..066896c73119f 100644
--- a/libc/include/llvm-libc-macros/limits-macros.h
+++ b/libc/include/llvm-libc-macros/limits-macros.h
@@ -19,12 +19,9 @@
#endif // __CHAR_BIT__
#endif // CHAR_BIT
-// TODO: https://github.com/llvm/llvm-project/issues/79358
-// Define MB_LEN_MAX if missing.
-// clang: MB_LEN_MAX = 1 -
-// https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/limits.h#L64
-// glibc: MB_LEN_MAX = 16 -
-// https://github.com/bminor/glibc/blob/master/include/limits.h#L32
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 4
+#endif // MB_LEN_MAX
// *_WIDTH macros
More information about the libc-commits
mailing list