* Copyright (c) 1992 The Regents of the University of California.
* All rights reserved.
*
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
* %sccs.include.redist.c%
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)lshrdi3.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)lshrdi3.c 5.7 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
-#include "longlong.h"
+#include "quad.h"
-long long
-__lshrdi3 (u, b1)
- long long u;
- long long b1;
+/*
+ * Shift an (unsigned) quad value right (logical shift right).
+ */
+quad_t
+__lshrdi3(a, shift)
+ quad_t a;
+ qshift_t shift;
{
- long_long w;
- unsigned long carries;
- int bm;
- long_long uu;
- int b = b1;
-
- if (b == 0)
- return u;
-
- uu.ll = u;
-
- bm = (sizeof (int) * BITS_PER_UNIT) - b;
- if (bm <= 0)
- {
- w.s.high = 0;
- w.s.low = (unsigned long)uu.s.high >> -bm;
- }
- else
- {
- carries = (unsigned long)uu.s.high << bm;
- w.s.high = (unsigned long)uu.s.high >> b;
- w.s.low = ((unsigned long)uu.s.low >> b) | carries;
- }
+ union uu aa;
- return w.ll;
+ aa.q = a;
+ if (shift >= LONG_BITS) {
+ aa.ul[L] = shift >= QUAD_BITS ? 0 :
+ aa.ul[H] >> (shift - LONG_BITS);
+ aa.ul[H] = 0;
+ } else if (shift > 0) {
+ aa.ul[L] = (aa.ul[L] >> shift) |
+ (aa.ul[H] << (LONG_BITS - shift));
+ aa.ul[H] >>= shift;
+ }
+ return (aa.q);
}