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