xref: /csrg-svn/lib/libc/quad/ashldi3.c (revision 53452)
153433Sbostic /*-
253433Sbostic  * Copyright (c) 1992 The Regents of the University of California.
353433Sbostic  * All rights reserved.
453433Sbostic  *
553433Sbostic  * %sccs.include.redist.c%
653433Sbostic  */
753433Sbostic 
853433Sbostic #if defined(LIBC_SCCS) && !defined(lint)
9*53452Sbostic static char sccsid[] = "@(#)ashldi3.c	5.2 (Berkeley) 05/12/92";
1053433Sbostic #endif /* LIBC_SCCS and not lint */
1153433Sbostic 
1253433Sbostic #include "longlong.h"
1353433Sbostic 
1453433Sbostic long long
1553433Sbostic __ashldi3 (u, b1)
1653433Sbostic      long long u;
1753433Sbostic      long long b1;
1853433Sbostic {
1953433Sbostic   long_long w;
2053433Sbostic   unsigned long carries;
2153433Sbostic   int bm;
2253433Sbostic   long_long uu;
2353433Sbostic   int b = b1;
2453433Sbostic 
2553433Sbostic   if (b == 0)
2653433Sbostic     return u;
2753433Sbostic 
2853433Sbostic   uu.ll = u;
2953433Sbostic 
30*53452Sbostic   bm = (sizeof (int) * NBBY) - b;
3153433Sbostic   if (bm <= 0)
3253433Sbostic     {
3353433Sbostic       w.s.low = 0;
3453433Sbostic       w.s.high = (unsigned long)uu.s.low << -bm;
3553433Sbostic     }
3653433Sbostic   else
3753433Sbostic     {
3853433Sbostic       carries = (unsigned long)uu.s.low >> bm;
3953433Sbostic       w.s.low = (unsigned long)uu.s.low << b;
4053433Sbostic       w.s.high = ((unsigned long)uu.s.high << b) | carries;
4153433Sbostic     }
4253433Sbostic 
4353433Sbostic   return w.ll;
4453433Sbostic }
45