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

Tue Ly via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 08:25:17 PDT 2023


lntue added inline comments.


================
Comment at: libc/src/__support/CPP/limits.h:19
+#ifndef LLONG_MAX
+constexpr size_t size_bits = sizeof(long long) * 8 - 1;
+constexpr long long LLONG_MAX = ~0LL ^ (1LL << size_bits);
----------------
This constant name in the header is a bit too generic.  Maybe you can name it:
```
constexpr size_t LLONG_BIT_WIDTH = sizeof(long long) * 8;
```
and use `LLONG_BIT_WIDTH - 1` instead of `size_bits` below.

Or we can add the templates `BitWidth<T>::value = sizeof(T) * 8` and `MostSignificantBitExponent<T>::value = BitWidth<T>::value - 1` or something like this, as they are actually used in many places.


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

https://reviews.llvm.org/D157112



More information about the llvm-commits mailing list