xref: /csrg-svn/lib/libc/quad/lshldi3.c (revision 53794)
153440Sbostic /*-
253440Sbostic  * Copyright (c) 1992 The Regents of the University of California.
353440Sbostic  * All rights reserved.
453440Sbostic  *
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  *
953440Sbostic  * %sccs.include.redist.c%
1053440Sbostic  */
1153440Sbostic 
1253440Sbostic #if defined(LIBC_SCCS) && !defined(lint)
13*53794Sbostic static char sccsid[] = "@(#)lshldi3.c	5.4 (Berkeley) 06/02/92";
1453440Sbostic #endif /* LIBC_SCCS and not lint */
1553440Sbostic 
16*53794Sbostic #include "quad.h"
1753459Sbostic 
18*53794Sbostic /*
19*53794Sbostic  * Shift an (unsigned) quad value left (logical shift left).
20*53794Sbostic  * This is the same as arithmetic shift left!
21*53794Sbostic  */
22*53794Sbostic quad
23*53794Sbostic __lshldi3(quad a, register unsigned int shift)
2453440Sbostic {
25*53794Sbostic 	union uu aa;
2653440Sbostic 
27*53794Sbostic 	aa.q = a;
28*53794Sbostic 	if (shift >= LONG_BITS) {
29*53794Sbostic 		aa.ul[H] = shift >= QUAD_BITS ? 0 :
30*53794Sbostic 		    aa.ul[L] << (shift - LONG_BITS);
31*53794Sbostic 		aa.ul[L] = 0;
32*53794Sbostic 	} else if (shift > 0) {
33*53794Sbostic 		aa.ul[H] = (aa.ul[H] << shift) |
34*53794Sbostic 		    (aa.ul[L] >> (LONG_BITS - shift));
35*53794Sbostic 		aa.ul[L] <<= shift;
36*53794Sbostic 	}
37*53794Sbostic 	return (aa.q);
3853440Sbostic }
39