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 signed long shifts to unsigned long to av...



details:   https://anonhg.NetBSD.org/src/rev/ace325388d25
branches:  trunk
changeset: 472609:ace325388d25
user:      christos <christos%NetBSD.org@localhost>
date:      Mon May 03 15:37:48 1999 +0000

description:
Cast signed long shifts to unsigned long to avoid lint portability warnings.
The comment above the code mentions that it should work even on machines
that shift in zeroes.

diffstat:

 lib/libc/quad/ashrdi3.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (35 lines):

diff -r 9c809c78236c -r ace325388d25 lib/libc/quad/ashrdi3.c
--- a/lib/libc/quad/ashrdi3.c   Mon May 03 15:34:05 1999 +0000
+++ b/lib/libc/quad/ashrdi3.c   Mon May 03 15:37:48 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ashrdi3.c,v 1.5 1998/01/29 03:23:41 mouse Exp $        */
+/*     $NetBSD: ashrdi3.c,v 1.6 1999/05/03 15:37:48 christos Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ashrdi3.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: ashrdi3.c,v 1.5 1998/01/29 03:23:41 mouse Exp $");
+__RCSID("$NetBSD: ashrdi3.c,v 1.6 1999/05/03 15:37:48 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -71,13 +71,13 @@
                 * LONG_BITS is undefined, so we shift (LONG_BITS-1),
                 * then 1 more, to get our answer.
                 */
-               s = (aa.sl[H] >> (LONG_BITS - 1)) >> 1;
-               aa.ul[L] = aa.sl[H] >> (shift - LONG_BITS);
+               s = ((u_long)aa.sl[H] >> (LONG_BITS - 1)) >> 1;
+               aa.ul[L] = (u_long)aa.sl[H] >> (shift - LONG_BITS);
                aa.ul[H] = s;
        } else {
                aa.ul[L] = (aa.ul[L] >> shift) |
                    (aa.ul[H] << (LONG_BITS - shift));
-               aa.sl[H] >>= shift;
+               aa.sl[H] = (u_long)aa.sl[H] >> shift;
        }
        return (aa.q);
 }



Home | Main Index | Thread Index | Old Index