153441Sbostic /*- 253441Sbostic * Copyright (c) 1992 The Regents of the University of California. 353441Sbostic * All rights reserved. 453441Sbostic * 5*53794Sbostic * This software was developed by the Computer Systems Engineering group 6*53794Sbostic * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7*53794Sbostic * contributed to Berkeley. 8*53794Sbostic * 953441Sbostic * %sccs.include.redist.c% 1053441Sbostic */ 1153441Sbostic 1253441Sbostic #if defined(LIBC_SCCS) && !defined(lint) 13*53794Sbostic static char sccsid[] = "@(#)lshrdi3.c 5.4 (Berkeley) 06/02/92"; 1453441Sbostic #endif /* LIBC_SCCS and not lint */ 1553441Sbostic 16*53794Sbostic #include "quad.h" 1753459Sbostic 18*53794Sbostic /* 19*53794Sbostic * Shift an (unsigned) quad value right (logical shift right). 20*53794Sbostic */ 21*53794Sbostic quad 22*53794Sbostic __lshrdi3(quad a, register unsigned int shift) 2353441Sbostic { 24*53794Sbostic union uu aa; 2553441Sbostic 26*53794Sbostic aa.q = a; 27*53794Sbostic if (shift >= LONG_BITS) { 28*53794Sbostic aa.ul[L] = shift >= QUAD_BITS ? 0 : 29*53794Sbostic aa.ul[H] >> (shift - LONG_BITS); 30*53794Sbostic aa.ul[H] = 0; 31*53794Sbostic } else if (shift > 0) { 32*53794Sbostic aa.ul[L] = (aa.ul[L] >> shift) | 33*53794Sbostic (aa.ul[H] << (LONG_BITS - shift)); 34*53794Sbostic aa.ul[H] >>= shift; 35*53794Sbostic } 36*53794Sbostic return (aa.q); 3753441Sbostic } 38