Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/quad Cast things to (digit) where the LHS is (digit...



details:   https://anonhg.NetBSD.org/src/rev/fdbccc439350
branches:  trunk
changeset: 472610:fdbccc439350
user:      christos <christos%NetBSD.org@localhost>
date:      Mon May 03 15:38:41 1999 +0000

description:
Cast things to (digit) where the LHS is (digit) to avoid loss of precision
lint warnings. This change should be harmless.

diffstat:

 lib/libc/quad/qdivrem.c |  53 ++++++++++++++++++++++++------------------------
 1 files changed, 27 insertions(+), 26 deletions(-)

diffs (124 lines):

diff -r ace325388d25 -r fdbccc439350 lib/libc/quad/qdivrem.c
--- a/lib/libc/quad/qdivrem.c   Mon May 03 15:37:48 1999 +0000
+++ b/lib/libc/quad/qdivrem.c   Mon May 03 15:38:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: qdivrem.c,v 1.6 1998/02/03 18:31:40 perry Exp $        */
+/*     $NetBSD: qdivrem.c,v 1.7 1999/05/03 15:38:41 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)qdivrem.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: qdivrem.c,v 1.6 1998/02/03 18:31:40 perry Exp $");
+__RCSID("$NetBSD: qdivrem.c,v 1.7 1999/05/03 15:38:41 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -122,15 +122,15 @@
         */
        tmp.uq = uq;
        u[0] = 0;
-       u[1] = HHALF(tmp.ul[H]);
-       u[2] = LHALF(tmp.ul[H]);
-       u[3] = HHALF(tmp.ul[L]);
-       u[4] = LHALF(tmp.ul[L]);
+       u[1] = (digit)HHALF(tmp.ul[H]);
+       u[2] = (digit)LHALF(tmp.ul[H]);
+       u[3] = (digit)HHALF(tmp.ul[L]);
+       u[4] = (digit)LHALF(tmp.ul[L]);
        tmp.uq = vq;
-       v[1] = HHALF(tmp.ul[H]);
-       v[2] = LHALF(tmp.ul[H]);
-       v[3] = HHALF(tmp.ul[L]);
-       v[4] = LHALF(tmp.ul[L]);
+       v[1] = (digit)HHALF(tmp.ul[H]);
+       v[2] = (digit)LHALF(tmp.ul[H]);
+       v[3] = (digit)HHALF(tmp.ul[L]);
+       v[4] = (digit)LHALF(tmp.ul[L]);
        for (n = 4; v[1] == 0; v++) {
                if (--n == 1) {
                        u_long rbj;     /* r*B+u[j] (not root boy jim) */
@@ -145,13 +145,13 @@
                         * We unroll this completely here.
                         */
                        t = v[2];       /* nonzero, by definition */
-                       q1 = u[1] / t;
+                       q1 = (digit)(u[1] / t);
                        rbj = COMBINE(u[1] % t, u[2]);
-                       q2 = rbj / t;
+                       q2 = (digit)(rbj / t);
                        rbj = COMBINE(rbj % t, u[3]);
-                       q3 = rbj / t;
+                       q3 = (digit)(rbj / t);
                        rbj = COMBINE(rbj % t, u[4]);
-                       q4 = rbj / t;
+                       q4 = (digit)(rbj / t);
                        if (arq)
                                *arq = rbj % t;
                        tmp.ul[H] = COMBINE(q1, q2);
@@ -209,9 +209,9 @@
                        rhat = uj1;
                        goto qhat_too_big;
                } else {
-                       u_long n = COMBINE(uj0, uj1);
-                       qhat = n / v1;
-                       rhat = n % v1;
+                       u_long nn = COMBINE(uj0, uj1);
+                       qhat = nn / v1;
+                       rhat = nn % v1;
                }
                while (v2 * qhat > COMBINE(rhat, uj2)) {
        qhat_too_big:
@@ -227,11 +227,11 @@
                 */
                for (t = 0, i = n; i > 0; i--) {
                        t = u[i + j] - v[i] * qhat - t;
-                       u[i + j] = LHALF(t);
+                       u[i + j] = (digit)LHALF(t);
                        t = (B - HHALF(t)) & (B - 1);
                }
                t = u[j] - t;
-               u[j] = LHALF(t);
+               u[j] = (digit)LHALF(t);
                /*
                 * D5: test remainder.
                 * There is a borrow if and only if HHALF(t) is nonzero;
@@ -242,12 +242,12 @@
                        qhat--;
                        for (t = 0, i = n; i > 0; i--) { /* D6: add back. */
                                t += u[i + j] + v[i];
-                               u[i + j] = LHALF(t);
+                               u[i + j] = (digit)LHALF(t);
                                t = HHALF(t);
                        }
-                       u[j] = LHALF(u[j] + t);
+                       u[j] = (digit)LHALF(u[j] + t);
                }
-               q[j] = qhat;
+               q[j] = (digit)qhat;
        } while (++j <= m);             /* D7: loop on j. */
 
        /*
@@ -258,8 +258,8 @@
        if (arq) {
                if (d) {
                        for (i = m + n; i > m; --i)
-                               u[i] = (u[i] >> d) |
-                                   LHALF(u[i - 1] << (HALF_BITS - d));
+                               u[i] = ((u_long)u[i] >> d) |
+                                   LHALF((u_long)u[i - 1] << (HALF_BITS - d));
                        u[i] = 0;
                }
                tmp.ul[H] = COMBINE(uspace[1], uspace[2]);
@@ -283,6 +283,7 @@
        int i;
 
        for (i = 0; i < len; i++)
-               p[i] = LHALF(p[i] << sh) | (p[i + 1] >> (HALF_BITS - sh));
-       p[i] = LHALF(p[i] << sh);
+               p[i] = LHALF((u_long)p[i] << sh) |
+                   (p[i + 1] >> (HALF_BITS - sh));
+       p[i] = (digit)LHALF(p[i] << sh);
 }



Home | Main Index | Thread Index | Old Index