[libc-commits] [libc] [libc] Add limits.h header. (PR #78887)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Sun Jan 21 12:50:19 PST 2024


================
@@ -0,0 +1,229 @@
+//===-- Definition of macros from limits.h --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_MACROS_LIMITS_MACROS_H
+#define __LLVM_LIBC_MACROS_LIMITS_MACROS_H
+
+#ifdef __clang__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wgnu-include-next"
+#endif // __clang__
+
+#include_next <limits.h>
+
+#ifdef __clang__
+#pragma GCC diagnostic pop
+#endif // __clang__
+
+#ifndef CHAR_BIT
+#ifdef __CHAR_BIT__
+#define CHAR_BIT __CHAR_BIT__
+#else
+#define CHAR_BIT 8
+#endif // __CHAR_BIT__
+#endif // CHAR_BIT
+
+// TODO: 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/lattera/glibc/blob/master/include/limits.h#L32
----------------
SchrodingerZhu wrote:

Maybe it is better to refer to `https://github.com/bminor/glibc/blob/master/include/limits.h`

https://github.com/llvm/llvm-project/pull/78887


More information about the libc-commits mailing list