[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:05:37 PDT 2023


abrachet updated this revision to Diff 554727.

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 size_bits = sizeof(long long) * 8 - 1;
+constexpr long long LLONG_MAX = ~0LL ^ (1LL << size_bits);
+constexpr long long LLONG_MIN = 1LL << size_bits;
+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.554727.patch
Type: text/x-patch
Size: 642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230830/1ed5e50d/attachment.bin>


More information about the llvm-commits mailing list