summaryrefslogtreecommitdiffstats
path: root/sys/lib/libkern/ashrdi3.c
diff options
context:
space:
mode:
authormickey <mickey@openbsd.org>2004-11-28 07:23:41 +0000
committermickey <mickey@openbsd.org>2004-11-28 07:23:41 +0000
commitf6a3c9b1fa71b1a71957242d0da17e5e1f46240e (patch)
tree923ecdd7af5dbaae56d4af536e50c2c9c2c46dba /sys/lib/libkern/ashrdi3.c
parenta tiny hppa64 bit (diff)
downloadwireguard-openbsd-f6a3c9b1fa71b1a71957242d0da17e5e1f46240e.tar.xz
wireguard-openbsd-f6a3c9b1fa71b1a71957242d0da17e5e1f46240e.zip
sync from libc
Diffstat (limited to 'sys/lib/libkern/ashrdi3.c')
-rw-r--r--sys/lib/libkern/ashrdi3.c29
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);