From 800c0dea9af773b77b89233528efe265fe154db1 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 29 Jul 2024 08:03:50 -0400 Subject: [PATCH] feefrac: rework comments around Mul/MulFallback --- src/util/feefrac.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/util/feefrac.h b/src/util/feefrac.h index 2a1754ac514..00a6a427e68 100644 --- a/src/util/feefrac.h +++ b/src/util/feefrac.h @@ -37,23 +37,21 @@ */ struct FeeFrac { - /** Fallback version for Mul (see below). - * - * Separate to permit testing on platforms where it isn't actually needed. - */ + /** Helper function for 32*64 signed multiplication, returning an unspecified but totally + * ordered type. This is a fallback version, separate so it can be tested on platforms where + * it isn't actually needed. */ static inline std::pair MulFallback(int64_t a, int32_t b) noexcept { - // Otherwise, emulate 96-bit multiplication using two 64-bit multiplies. int64_t low = int64_t{static_cast(a)} * b; int64_t high = (a >> 32) * b; return {high + (low >> 32), static_cast(low)}; } - // Compute a * b, returning an unspecified but totally ordered type. #ifdef __SIZEOF_INT128__ + /** Helper function for 32*64 signed multiplication, returning an unspecified but totally + * ordered type. This is a version relying on __int128. */ static inline __int128 Mul(int64_t a, int32_t b) noexcept { - // If __int128 is available, use 128-bit wide multiply. return __int128{a} * b; } #else