[libc-commits] [libc] 1d1f230 - [libc] Define long long limits if not defined
Alex Brachet via libc-commits
libc-commits at lists.llvm.org
Wed Aug 30 16:03:56 PDT 2023
Author: Alex Brachet
Date: 2023-08-30T23:03:36Z
New Revision: 1d1f230c92eee7d13288f70431ee2fc171d9e0d7
URL: https://github.com/llvm/llvm-project/commit/1d1f230c92eee7d13288f70431ee2fc171d9e0d7
DIFF: https://github.com/llvm/llvm-project/commit/1d1f230c92eee7d13288f70431ee2fc171d9e0d7.diff
LOG: [libc] Define long long limits if not defined
Some older gcc toolchains don't define these on 32 bit platforms. This
is a problem for pigweed which uses an older gcc toolchain and targets
32 bit.
Differential Revision: https://reviews.llvm.org/D157112
Added:
Modified:
libc/src/__support/CPP/limits.h
Removed:
################################################################################
diff --git a/libc/src/__support/CPP/limits.h b/libc/src/__support/CPP/limits.h
index dce0bebdd2cd2c..e42414523a76df 100644
--- a/libc/src/__support/CPP/limits.h
+++ b/libc/src/__support/CPP/limits.h
@@ -14,6 +14,14 @@
namespace __llvm_libc {
namespace cpp {
+// Some older gcc distributions don't define these for 32 bit targets.
+#ifndef LLONG_MAX
+constexpr size_t LLONG_BIT_WIDTH = sizeof(long long) * 8;
+constexpr long long LLONG_MAX = ~0LL ^ (1LL << LLONG_BIT_WIDTH - 1);
+constexpr long long LLONG_MIN = 1LL << LLONG_BIT_WIDTH - 1;
+constexpr unsigned long long ULLONG_MAX = ~0ULL;
+#endif
+
template <class T> class numeric_limits {
public:
static constexpr T max();
More information about the libc-commits
mailing list