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

Michael Jones via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 13:54:28 PDT 2023


michaelrj added a comment.

alright, in that case since this is exclusively for internal use then I'm okay with having our own definitions for these constants. I'd prefer to use constexpr variables for this instead of macros, since those provide better type checking.



================
Comment at: src/__support/CPP/limits.h:16
+#ifndef LLONG_MAX
+#define LLONG_MAX (~0LL ^ (1LL << 63))
+#define LLONG_MIN (1LL << 63)
----------------
While in almost every case this is safe, I'd still prefer not to assume that `long long` is 64 bits. Either `(sizeof(long long) * 8) - 1` or some other way to calculate the size would be better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157112



More information about the llvm-commits mailing list