From e55c6530dbf96bfbe2e4a232c0feb19c0a4a2294 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Sun, 15 Nov 2020 03:10:52 -0500 Subject: Move uinteger_pow gdb/valarith.c to gdb/utils.c and make it public This is a generic function which I would like to use in a followup patch adding support for fixed-point types. So this commit moves it out of valarith.c into util.c, and makes it non-static. gdb/ChangeLog: * utils.h (uinteger_pow): Add declaration. * utils.c (uinteger_pow): Moved here (without changes)... * valarith.c (uinteger_pow): ... from here. --- gdb/valarith.c | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'gdb/valarith.c') diff --git a/gdb/valarith.c b/gdb/valarith.c index 21b597a..f6caf3d 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -819,37 +819,6 @@ integer_pow (LONGEST v1, LONGEST v2) } } -/* Integer exponentiation: V1**V2, where both arguments are - integers. Requires V1 != 0 if V2 < 0. Returns 1 for 0 ** 0. */ - -static ULONGEST -uinteger_pow (ULONGEST v1, LONGEST v2) -{ - if (v2 < 0) - { - if (v1 == 0) - error (_("Attempt to raise 0 to negative power.")); - else - return 0; - } - else - { - /* The Russian Peasant's Algorithm. */ - ULONGEST v; - - v = 1; - for (;;) - { - if (v2 & 1L) - v *= v1; - v2 >>= 1; - if (v2 == 0) - return v; - v1 *= v1; - } - } -} - /* Obtain argument values for binary operation, converting from other types if one of them is not floating point. */ static void -- cgit v1.1