xref: /original-bsd/lib/libc/quad/ashldi3.c (revision 4092c5cc)
1 /*-
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * %sccs.include.redist.c%
10  */
11 
12 #if defined(LIBC_SCCS) && !defined(lint)
13 static char sccsid[] = "@(#)ashldi3.c	8.1 (Berkeley) 06/04/93";
14 #endif /* LIBC_SCCS and not lint */
15 
16 #include "quad.h"
17 
18 /*
19  * Shift a (signed) quad value left (arithmetic shift left).
20  * This is the same as logical shift left!
21  */
22 quad_t
23 __ashldi3(a, shift)
24 	quad_t a;
25 	qshift_t shift;
26 {
27 	union uu aa;
28 
29 	aa.q = a;
30 	if (shift >= LONG_BITS) {
31 		aa.ul[H] = shift >= QUAD_BITS ? 0 :
32 		    aa.ul[L] << (shift - LONG_BITS);
33 		aa.ul[L] = 0;
34 	} else if (shift > 0) {
35 		aa.ul[H] = (aa.ul[H] << shift) |
36 		    (aa.ul[L] >> (LONG_BITS - shift));
37 		aa.ul[L] <<= shift;
38 	}
39 	return (aa.q);
40 }
41