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

Alex Brachet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 08:44:32 PDT 2023


abrachet created this revision.
abrachet added reviewers: mcgrathr, michaelrj, lntue.
Herald added a project: All.
abrachet requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157112

Files:
  src/__support/CPP/limits.h


Index: src/__support/CPP/limits.h
===================================================================
--- src/__support/CPP/limits.h
+++ src/__support/CPP/limits.h
@@ -11,6 +11,13 @@
 
 #include <limits.h>
 
+// Some older gcc distributions don't define these for 32 bit targets.
+#ifndef LLONG_MAX
+#define LLONG_MAX (~0LL ^ (1LL << 63))
+#define LLONG_MIN (1LL << 63)
+#define ULLONG_MAX (~0ULL)
+#endif
+
 namespace __llvm_libc {
 namespace cpp {
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157112.547236.patch
Type: text/x-patch
Size: 452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230804/bd9141b7/attachment.bin>


More information about the llvm-commits mailing list