[PATCH] D157112: [libc] Define long long limits if not defined

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 08:32:40 PDT 2023


abrachet updated this revision to Diff 554737.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157112/new/

https://reviews.llvm.org/D157112

Files:
  libc/src/__support/CPP/limits.h


Index: libc/src/__support/CPP/limits.h
===================================================================
--- libc/src/__support/CPP/limits.h
+++ 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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157112.554737.patch
Type: text/x-patch
Size: 664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230830/530dc5aa/attachment.bin>


More information about the llvm-commits mailing list