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

Alex Brachet via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 30 16:04:05 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d1f230c92ee: [libc] Define long long limits if not defined (authored by abrachet).
Herald added a project: libc-project.
Herald added a subscriber: libc-commits.

Repository:
  rG LLVM Github Monorepo

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.554850.patch
Type: text/x-patch
Size: 664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230830/1c94605f/attachment-0001.bin>


More information about the libc-commits mailing list