xref: /csrg-svn/lib/libc/quad/ashldi3.c (revision 53794)
153433Sbostic /*-
253433Sbostic  * Copyright (c) 1992 The Regents of the University of California.
353433Sbostic  * All rights reserved.
453433Sbostic  *
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  *
953433Sbostic  * %sccs.include.redist.c%
1053433Sbostic  */
1153433Sbostic 
1253433Sbostic #if defined(LIBC_SCCS) && !defined(lint)
13*53794Sbostic static char sccsid[] = "@(#)ashldi3.c	5.4 (Berkeley) 06/02/92";
1453433Sbostic #endif /* LIBC_SCCS and not lint */
1553433Sbostic 
16*53794Sbostic #include "quad.h"
1753459Sbostic 
18*53794Sbostic /*
19*53794Sbostic  * Shift a (signed) quad value left (arithmetic shift left).
20*53794Sbostic  * This is the same as logical shift left!
21*53794Sbostic  */
22*53794Sbostic quad
23*53794Sbostic __ashldi3(quad a, register unsigned int shift)
2453433Sbostic {
25*53794Sbostic 	union uu aa;
2653433Sbostic 
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);
3853433Sbostic }
39