[libc-commits] [libc] [libc] Fix compilation error on targets without 128-bit int types (PR #97039)

via libc-commits libc-commits at lists.llvm.org
Fri Jun 28 04:32:32 PDT 2024


https://github.com/overmighty created https://github.com/llvm/llvm-project/pull/97039

See Buildbot failures:

- https://lab.llvm.org/buildbot/#/builders/11/builds/743
- https://lab.llvm.org/buildbot/#/builders/182/builds/362


>From d68a218d244e0ea9fc8ae45ae13402d5b0900cc0 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Fri, 28 Jun 2024 13:25:25 +0200
Subject: [PATCH] [libc] Fix compilation error on targets without 128-bit int
 types

---
 libc/src/__support/high_precision_decimal.h  | 3 ++-
 libc/test/src/__support/math_extras_test.cpp | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libc/src/__support/high_precision_decimal.h b/libc/src/__support/high_precision_decimal.h
index 2c5a349e4495e..6a22554165014 100644
--- a/libc/src/__support/high_precision_decimal.h
+++ b/libc/src/__support/high_precision_decimal.h
@@ -409,7 +409,8 @@ class HighPrecisionDecimal {
       result *= 10;
       ++cur_digit;
     }
-    return result + this->should_round_up(this->decimal_point, round);
+    return result + static_cast<unsigned int>(
+                        this->should_round_up(this->decimal_point, round));
   }
 
   // Extra functions for testing.
diff --git a/libc/test/src/__support/math_extras_test.cpp b/libc/test/src/__support/math_extras_test.cpp
index 0047888965177..9f9036b9d5cdf 100644
--- a/libc/test/src/__support/math_extras_test.cpp
+++ b/libc/test/src/__support/math_extras_test.cpp
@@ -102,7 +102,7 @@ TYPED_TEST(LlvmLibcBitTest, CountZeros, UnsignedTypesNoBigInt) {
 }
 
 using UnsignedTypes = testing::TypeList<
-#if defined(__SIZEOF_INT128__)
+#if defined(LIBC_TYPES_HAS_INT128)
     __uint128_t,
 #endif
     unsigned char, unsigned short, unsigned int, unsigned long,



More information about the libc-commits mailing list