xref: /csrg-svn/lib/libc/quad/ashldi3.c (revision 61155)
153433Sbostic /*-
2*61155Sbostic  * Copyright (c) 1992, 1993
3*61155Sbostic  *	The Regents of the University of California.  All rights reserved.
453433Sbostic  *
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  *
953433Sbostic  * %sccs.include.redist.c%
1053433Sbostic  */
1153433Sbostic 
1253433Sbostic #if defined(LIBC_SCCS) && !defined(lint)
13*61155Sbostic static char sccsid[] = "@(#)ashldi3.c	8.1 (Berkeley) 06/04/93";
1453433Sbostic #endif /* LIBC_SCCS and not lint */
1553433Sbostic 
1653794Sbostic #include "quad.h"
1753459Sbostic 
1853794Sbostic /*
1953794Sbostic  * Shift a (signed) quad value left (arithmetic shift left).
2053794Sbostic  * This is the same as logical shift left!
2153794Sbostic  */
2254431Sbostic quad_t
__ashldi3(a,shift)2354431Sbostic __ashldi3(a, shift)
2454431Sbostic 	quad_t a;
2554431Sbostic 	qshift_t shift;
2653433Sbostic {
2753794Sbostic 	union uu aa;
2853433Sbostic 
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);
4053433Sbostic }
41