1 /*- 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * 9 * %sccs.include.redist.c% 10 */ 11 12 #if defined(LIBC_SCCS) && !defined(lint) 13 static char sccsid[] = "@(#)lshrdi3.c 5.5 (Berkeley) 06/02/92"; 14 #endif /* LIBC_SCCS and not lint */ 15 16 #include "quad.h" 17 18 /* 19 * Shift an (unsigned) quad value right (logical shift right). 20 */ 21 quad 22 __lshrdi3(quad a, u_quad shift) 23 { 24 union uu aa; 25 26 aa.q = a; 27 if (shift >= LONG_BITS) { 28 aa.ul[L] = shift >= QUAD_BITS ? 0 : 29 aa.ul[H] >> (shift - LONG_BITS); 30 aa.ul[H] = 0; 31 } else if (shift > 0) { 32 aa.ul[L] = (aa.ul[L] >> shift) | 33 (aa.ul[H] << (LONG_BITS - shift)); 34 aa.ul[H] >>= shift; 35 } 36 return (aa.q); 37 } 38