Skip to content

Commit

Permalink
Workaround Windows API garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Mar 12, 2022
1 parent a8fe8be commit 9a1beab
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,7 @@ inline uint128_wrapper umul128(uint64_t x, uint64_t y) noexcept {
result.low_ = _umul128(x, y, &result.high_);
return result;
#else
const uint64_t mask =
static_cast<uint64_t>(std::numeric_limits<uint32_t>::max());
const uint64_t mask = static_cast<uint64_t>(max_value<uint32_t>());

uint64_t a = x >> 32;
uint64_t b = x & mask;
Expand Down Expand Up @@ -1820,12 +1819,12 @@ FMT_INLINE int remove_trailing_zeros(uint32_t& n) noexcept {
int s = 0;
while (true) {
auto q = rotr(n * mod_inv_25, 2);
if (q > std::numeric_limits<uint32_t>::max() / 100) break;
if (q > max_value<uint32_t>() / 100) break;
n = q;
s += 2;
}
auto q = rotr(n * mod_inv_5, 1);
if (q <= std::numeric_limits<uint32_t>::max() / 10) {
if (q <= max_value<uint32_t>() / 10) {
n = q;
s |= 1;
}
Expand All @@ -1852,12 +1851,12 @@ FMT_INLINE int remove_trailing_zeros(uint64_t& n) noexcept {
int s = 8;
while (true) {
auto q = rotr(n32 * mod_inv_25, 2);
if (q > std::numeric_limits<uint32_t>::max() / 100) break;
if (q > max_value<uint32_t>() / 100) break;
n32 = q;
s += 2;
}
auto q = rotr(n32 * mod_inv_5, 1);
if (q <= std::numeric_limits<uint32_t>::max() / 10) {
if (q <= max_value<uint32_t>() / 10) {
n32 = q;
s |= 1;
}
Expand All @@ -1873,12 +1872,12 @@ FMT_INLINE int remove_trailing_zeros(uint64_t& n) noexcept {
int s = 0;
while (true) {
auto q = rotr(n * mod_inv_25, 2);
if (q > std::numeric_limits<uint64_t>::max() / 100) break;
if (q > max_value<uint64_t>() / 100) break;
n = q;
s += 2;
}
auto q = rotr(n * mod_inv_5, 1);
if (q <= std::numeric_limits<uint64_t>::max() / 10) {
if (q <= max_value<uint64_t>() / 10) {
n = q;
s |= 1;
}
Expand Down

0 comments on commit 9a1beab

Please sign in to comment.