diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-11-28 07:23:42 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2004-11-28 07:23:42 +0000 |
commit | 9bd24be8e0a2e9abc43eaa237cf2e27c5464e716 (patch) | |
tree | 89366a36a6a5c8923d0a6e790b85676f8e585a52 /sys/lib/libkern/ashrdi3.c | |
parent | 69611256b74018387f3e3355f9e7f5b670087451 (diff) |
sync from libc
Diffstat (limited to 'sys/lib/libkern/ashrdi3.c')
-rw-r--r-- | sys/lib/libkern/ashrdi3.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/sys/lib/libkern/ashrdi3.c b/sys/lib/libkern/ashrdi3.c index b00d6174bab..dd265216c6b 100644 --- a/sys/lib/libkern/ashrdi3.c +++ b/sys/lib/libkern/ashrdi3.c @@ -1,6 +1,3 @@ -/* $OpenBSD: ashrdi3.c,v 1.4 2004/08/07 00:38:32 deraadt Exp $ */ -/* $NetBSD: ashrdi3.c,v 1.5 1995/10/07 09:26:18 mycroft Exp $ */ - /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -35,11 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)ashrdi3.c 8.1 (Berkeley) 6/4/93"; -#else -static char rcsid[] = "$OpenBSD: ashrdi3.c,v 1.4 2004/08/07 00:38:32 deraadt Exp $"; -#endif +static char rcsid[] = "$OpenBSD: ashrdi3.c,v 1.5 2004/11/28 07:23:41 mickey Exp $"; #endif /* LIBC_SCCS and not lint */ #include "quad.h" @@ -52,24 +45,28 @@ __ashrdi3(quad_t a, qshift_t shift) { union uu aa; + if (shift == 0) + return(a); aa.q = a; - if (shift >= LONG_BITS) { - long s; + if (shift >= INT_BITS) { + int s; /* * Smear bits rightward using the machine's right-shift * method, whether that is sign extension or zero fill, * to get the `sign word' s. Note that shifting by - * LONG_BITS is undefined, so we shift (LONG_BITS-1), + * INT_BITS is undefined, so we shift (INT_BITS-1), * then 1 more, to get our answer. */ - s = (aa.sl[H] >> (LONG_BITS - 1)) >> 1; - aa.ul[L] = shift >= QUAD_BITS ? s : - aa.sl[H] >> (shift - LONG_BITS); + /* LINTED inherits machine dependency */ + s = (aa.sl[H] >> (INT_BITS - 1)) >> 1; + /* LINTED inherits machine dependency*/ + aa.ul[L] = aa.sl[H] >> (shift - INT_BITS); aa.ul[H] = s; - } else if (shift > 0) { + } else { aa.ul[L] = (aa.ul[L] >> shift) | - (aa.ul[H] << (LONG_BITS - shift)); + (aa.ul[H] << (INT_BITS - shift)); + /* LINTED inherits machine dependency */ aa.sl[H] >>= shift; } return (aa.q); |