xref: /csrg-svn/lib/libc/quad/lshldi3.c (revision 61160)
153440Sbostic /*-
2*61160Sbostic  * Copyright (c) 1992, 1993
3*61160Sbostic  *	The Regents of the University of California.  All rights reserved.
453440Sbostic  *
553794Sbostic  * This software was developed by the Computer Systems Engineering group
653794Sbostic  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
753794Sbostic  * contributed to Berkeley.
853794Sbostic  *
953440Sbostic  * %sccs.include.redist.c%
1053440Sbostic  */
1153440Sbostic 
1253440Sbostic #if defined(LIBC_SCCS) && !defined(lint)
13*61160Sbostic static char sccsid[] = "@(#)lshldi3.c	8.1 (Berkeley) 06/04/93";
1453440Sbostic #endif /* LIBC_SCCS and not lint */
1553440Sbostic 
1653794Sbostic #include "quad.h"
1753459Sbostic 
1853794Sbostic /*
1953794Sbostic  * Shift an (unsigned) quad value left (logical shift left).
2053794Sbostic  * This is the same as arithmetic shift left!
2153794Sbostic  */
2254431Sbostic quad_t
__lshldi3(a,shift)2354431Sbostic __lshldi3(a, shift)
2454431Sbostic 	quad_t a;
2554431Sbostic 	qshift_t shift;
2653440Sbostic {
2753794Sbostic 	union uu aa;
2853440Sbostic 
2953794Sbostic 	aa.q = a;
3053794Sbostic 	if (shift >= LONG_BITS) {
3153794Sbostic 		aa.ul[H] = shift >= QUAD_BITS ? 0 :
3253794Sbostic 		    aa.ul[L] << (shift - LONG_BITS);
3353794Sbostic 		aa.ul[L] = 0;
3453794Sbostic 	} else if (shift > 0) {
3553794Sbostic 		aa.ul[H] = (aa.ul[H] << shift) |
3653794Sbostic 		    (aa.ul[L] >> (LONG_BITS - shift));
3753794Sbostic 		aa.ul[L] <<= shift;
3853794Sbostic 	}
3953794Sbostic 	return (aa.q);
4053440Sbostic }
41