From fd9f9fc83e0ae8c97042dae2fbe924d0db3bbe6d Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 26 Apr 2022 18:07:47 -0700 Subject: [PATCH] format code --- openpower/sv/biginteger/divgnu64.c | 17 +++++++++++------ openpower/sv/biginteger/divmnu64.c | 3 +-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/openpower/sv/biginteger/divgnu64.c b/openpower/sv/biginteger/divgnu64.c index 762f8d965..fafd01ee3 100644 --- a/openpower/sv/biginteger/divgnu64.c +++ b/openpower/sv/biginteger/divgnu64.c @@ -73,10 +73,11 @@ void biglsh(unsigned s, unsigned vn[], unsigned const v[], int n) long bigdiv(unsigned v, unsigned q[], unsigned const u[], int m) { long long k = 0; // the case of a - for (int j = m - 1; j >= 0; j--) { // single-digit + for (int j = m - 1; j >= 0; j--) + { // single-digit unsigned long d2 = (k << 32) | u[j]; q[j] = d2 / v; // divisor here. - k = d2 % v; + k = d2 % v; } return k; } @@ -176,7 +177,8 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], if (m < n || n <= 0 || v[n - 1] == 0) return 1; // Return if invalid param. - if (n == 1) { // Take care of + if (n == 1) + { // Take care of k = bigdiv(v[0], q, u, m); if (r != NULL) r[0] = k; @@ -196,14 +198,16 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], un[m] = (unsigned long long)u[m - 1] >> (32 - s); // extra digit biglsh(s, un, u, m); - for (j = m - n; j >= 0; j--) { // Main loop. + for (j = m - n; j >= 0; j--) + { // Main loop. // Compute estimate qhat of q[j] from top 2 digits uint64_t dig2 = ((uint64_t)un[j + n] << 32) | un[j + n - 1]; qhat = dig2 / vn[n - 1]; rhat = dig2 % vn[n - 1]; again: // use 3rd-from-top digit to obtain better accuracy - if (qhat >= b || qhat * vn[n - 2] > b * rhat + un[j + n - 2]) { + if (qhat >= b || qhat * vn[n - 2] > b * rhat + un[j + n - 2]) + { qhat = qhat - 1; rhat = rhat + vn[n - 1]; if (rhat < b) @@ -214,7 +218,8 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], bool need_fixup = bigmulsub(qhat, vn, un_j, j, m, n); q[j] = qhat; // Store quotient digit. - if (need_fixup) { // If we subtracted too + if (need_fixup) + { // If we subtracted too q[j] = q[j] - 1; // much, add back. bigadd(un_j, vn, un_j, m, n, 0); } diff --git a/openpower/sv/biginteger/divmnu64.c b/openpower/sv/biginteger/divmnu64.c index 7906ce099..f2e0eea48 100644 --- a/openpower/sv/biginteger/divmnu64.c +++ b/openpower/sv/biginteger/divmnu64.c @@ -74,8 +74,7 @@ divrem_t divrem_64_by_32(uint64_t n, uint32_t d) } } -bool bigmul(uint32_t qhat, unsigned product[], unsigned vn[], int m, - int n) +bool bigmul(uint32_t qhat, unsigned product[], unsigned vn[], int m, int n) { long long t, k; int s, i; -- 2.30.2