xref: /csrg-svn/lib/libc/quad/lshldi3.c (revision 53452)
1 /*-
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)lshldi3.c	5.2 (Berkeley) 05/12/92";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include "longlong.h"
13 
14 long long
15 __lshldi3 (u, b1)
16      long long u;
17      long long b1;
18 {
19   long_long w;
20   unsigned long carries;
21   int bm;
22   long_long uu;
23   int b = b1;
24 
25   if (b == 0)
26     return u;
27 
28   uu.ll = u;
29 
30   bm = (sizeof (int) * NBBY) - b;
31   if (bm <= 0)
32     {
33       w.s.low = 0;
34       w.s.high = (unsigned long)uu.s.low << -bm;
35     }
36   else
37     {
38       carries = (unsigned long)uu.s.low >> bm;
39       w.s.low = (unsigned long)uu.s.low << b;
40       w.s.high = ((unsigned long)uu.s.high << b) | carries;
41     }
42 
43   return w.ll;
44 }
45