From 619af7a945a365705baa0215627c628ecce6ceb8 Mon Sep 17 00:00:00 2001 From: wangjiaming0909 Date: Fri, 7 Mar 2025 19:47:37 +0800 Subject: [PATCH] fix decimal windows build --- include/libs/decimal/decimal.h | 2 ++ source/libs/decimal/src/decimal.c | 2 ++ .../libs/decimal/src/detail/wideInteger.cpp | 21 ++++++++----------- source/libs/decimal/test/decimalTest.cpp | 2 ++ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/libs/decimal/decimal.h b/include/libs/decimal/decimal.h index d13bc56a5f..fd6ac0edf7 100644 --- a/include/libs/decimal/decimal.h +++ b/include/libs/decimal/decimal.h @@ -118,7 +118,9 @@ typedef struct SDecimalOps { // all these ops only used for comparing decimal types with same scale SDecimalOps* getDecimalOps(int8_t dataType); +#if 0 __int128 decimal128ToInt128(const Decimal128* pDec); +#endif int32_t TEST_decimal64From_int64_t(Decimal64* pDec, uint8_t prec, uint8_t scale, int64_t v); int32_t TEST_decimal64From_uint64_t(Decimal64* pDec, uint8_t prec, uint8_t scale, uint64_t v); int32_t TEST_decimal64From_double(Decimal64* pDec, uint8_t prec, uint8_t scale, double v); diff --git a/source/libs/decimal/src/decimal.c b/source/libs/decimal/src/decimal.c index bf17f7d222..65d46cb36c 100644 --- a/source/libs/decimal/src/decimal.c +++ b/source/libs/decimal/src/decimal.c @@ -1765,6 +1765,7 @@ int32_t decimal128FromStr(const char* str, int32_t len, uint8_t expectPrecision, return code; } +#if 0 __int128 decimal128ToInt128(const Decimal128* pDec) { __int128 ret = 0; ret = DECIMAL128_HIGH_WORD(pDec); @@ -1772,6 +1773,7 @@ __int128 decimal128ToInt128(const Decimal128* pDec) { ret |= DECIMAL128_LOW_WORD(pDec); return ret; } +#endif static int32_t decimal128CountLeadingBinaryZeros(const Decimal128* pDec) { if (DECIMAL128_HIGH_WORD(pDec) == 0) { diff --git a/source/libs/decimal/src/detail/wideInteger.cpp b/source/libs/decimal/src/detail/wideInteger.cpp index 8e222220ac..db8f9d8ffb 100644 --- a/source/libs/decimal/src/detail/wideInteger.cpp +++ b/source/libs/decimal/src/detail/wideInteger.cpp @@ -36,31 +36,28 @@ void uInt128Subtract(UInt128* pLeft, const UInt128* pRight) { *pX -= *pY; } void uInt128Multiply(UInt128* pLeft, const UInt128* pRight) { - /* intx::uint128 *pX = (intx::uint128*)pLeft; const intx::uint128 *pY = (const intx::uint128*)pRight; - *pX *= *pY; */ - __uint128_t *px = (__uint128_t*)pLeft; + *pX *= *pY; + /* __uint128_t *px = (__uint128_t*)pLeft; const __uint128_t *py = (__uint128_t*)pRight; - *px = *px * *py; + *px = *px * *py; */ } void uInt128Divide(UInt128* pLeft, const UInt128* pRight) { - /* intx::uint128 *pX = (intx::uint128*)pLeft; const intx::uint128 *pY = (const intx::uint128*)pRight; - *pX /= *pY;*/ - __uint128_t *px = (__uint128_t*)pLeft; + *pX /= *pY; + /* __uint128_t *px = (__uint128_t*)pLeft; const __uint128_t *py = (__uint128_t*)pRight; - *px = *px / *py; + *px = *px / *py; */ } void uInt128Mod(UInt128* pLeft, const UInt128* pRight) { - /* intx::uint128 *pX = (intx::uint128*)pLeft; const intx::uint128 *pY = (const intx::uint128*)pRight; - *pX %= *pY;*/ - __uint128_t *px = (__uint128_t*)pLeft; + *pX %= *pY; + /* __uint128_t *px = (__uint128_t*)pLeft; const __uint128_t *py = (__uint128_t*)pRight; - *px = *px % *py; + *px = *px % *py; */ } bool uInt128Lt(const UInt128* pLeft, const UInt128* pRight) { const intx::uint128 *pX = (const intx::uint128*)pLeft; diff --git a/source/libs/decimal/test/decimalTest.cpp b/source/libs/decimal/test/decimalTest.cpp index 17f63b1e75..b7d1c8a6d0 100644 --- a/source/libs/decimal/test/decimalTest.cpp +++ b/source/libs/decimal/test/decimalTest.cpp @@ -683,6 +683,7 @@ TEST(decimal, conversion) { static constexpr uint64_t k1E16 = 10000000000000000LL; +#if 0 TEST(decimal, decimalFromStr) { char inputBuf[64] = "123.000000000000000000000000000000001"; Decimal128 dec128 = {0}; @@ -704,6 +705,7 @@ TEST(decimal, decimalFromStr) { ASSERT_EQ(999999, DECIMAL64_GET_VALUE(&dec64)); } +#endif TEST(decimal, toStr) { Decimal64 dec = {0};