+2020-11-15 Joel Brobecker <brobecker@adacore.com>
+
+ * utils.h (uinteger_pow): Add declaration.
+ * utils.c (uinteger_pow): Moved here (without changes)...
+ * valarith.c (uinteger_pow): ... from here.
+
2020-11-15 Joel Brobecker <brobecker@adacore.com>
* gmp-utils.h, gmp-utils.h: New file.
return orglen;
}
+/* See utils.h. */
+
+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;
+ }
+ }
+}
+
void
print_spaces (int n, struct ui_file *file)
{
extern int myread (int, char *, int);
+/* Integer exponentiation: Return V1**V2, where both arguments
+ are integers.
+
+ Requires V1 != 0 if V2 < 0.
+ Returns 1 for 0 ** 0. */
+extern ULONGEST uinteger_pow (ULONGEST v1, LONGEST v2);
+
/* Resource limits used by getrlimit and setrlimit. */
enum resource_limit_kind
}
}
-/* 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