xref: /original-bsd/lib/libc/quad/lshldi3.c (revision 31628771)
1 /*-
2  * Copyright (c) 1992 The Regents of the University of California.
3  * 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[] = "@(#)lshldi3.c	5.6 (Berkeley) 06/21/92";
14 #endif /* LIBC_SCCS and not lint */
15 
16 #include "quad.h"
17 
18 /*
19  * Shift an (unsigned) quad value left (logical shift left).
20  * This is the same as arithmetic shift left!
21  */
22 quad
23 __lshldi3(quad a, qshift_t shift)
24 {
25 	union uu aa;
26 
27 	aa.q = a;
28 	if (shift >= LONG_BITS) {
29 		aa.ul[H] = shift >= QUAD_BITS ? 0 :
30 		    aa.ul[L] << (shift - LONG_BITS);
31 		aa.ul[L] = 0;
32 	} else if (shift > 0) {
33 		aa.ul[H] = (aa.ul[H] << shift) |
34 		    (aa.ul[L] >> (LONG_BITS - shift));
35 		aa.ul[L] <<= shift;
36 	}
37 	return (aa.q);
38 }
39