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

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Tue Jan 23 11:04:42 PST 2024


nickdesaulniers wrote:

FWIW, I was able to get the GCC build back to green with just:
```diff
diff --git a/libc/src/__support/CPP/limits.h b/libc/src/__support/CPP/limits.h
index d9e7090a0b7b..2cc76fe4bbf7 100644
--- a/libc/src/__support/CPP/limits.h
+++ b/libc/src/__support/CPP/limits.h
@@ -13,6 +13,9 @@
 #include "src/__support/CPP/type_traits/is_signed.h"
 #include "src/__support/macros/attributes.h" // LIBC_INLINE
 
+#if !defined(__clang__)
+#define _LIBC_LIMITS_H_
+#endif
 #include <limits.h> // CHAR_BIT
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/time/mktime.cpp b/libc/src/time/mktime.cpp
index e57565f0d1fe..9ea92ebcde3c 100644
--- a/libc/src/time/mktime.cpp
+++ b/libc/src/time/mktime.cpp
@@ -10,6 +10,9 @@
 #include "src/__support/common.h"
 #include "src/time/time_utils.h"
 
+#if !defined(__clang__)
+#define _LIBC_LIMITS_H_
+#endif
 #include <limits.h>
 
 namespace LIBC_NAMESPACE {
diff --git a/libc/src/time/time_utils.cpp b/libc/src/time/time_utils.cpp
index 199a74cb168a..ccdd4d7de50c 100644
--- a/libc/src/time/time_utils.cpp
+++ b/libc/src/time/time_utils.cpp
@@ -9,6 +9,9 @@
 #include "src/time/time_utils.h"
 #include "src/__support/common.h"
 
+#if !defined(__clang__)
+#define _LIBC_LIMITS_H_
+#endif
 #include <limits.h>
 
 namespace LIBC_NAMESPACE {
```
I think we could provide our own limits.h (as you do here) and just do that one define if not clang; then require all TUs to include our limits.h, not `<limits.h>` since it's a tangly mess of include_next for different compiler's resource headers.

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


More information about the libc-commits mailing list