shifts parameters are quads too
[unix-history] / usr / src / lib / libc / quad / lshldi3.c
/*-
* Copyright (c) 1992 The Regents of the University of California.
* All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* %sccs.include.redist.c%
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)lshldi3.c 5.5 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
/*
* Shift an (unsigned) quad value left (logical shift left).
* This is the same as arithmetic shift left!
*/
quad
__lshldi3(quad a, u_quad shift)
{
union uu aa;
aa.q = a;
if (shift >= LONG_BITS) {
aa.ul[H] = shift >= QUAD_BITS ? 0 :
aa.ul[L] << (shift - LONG_BITS);
aa.ul[L] = 0;
} else if (shift > 0) {
aa.ul[H] = (aa.ul[H] << shift) |
(aa.ul[L] >> (LONG_BITS - shift));
aa.ul[L] <<= shift;
}
return (aa.q);
}