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[] = "@(#)ashrdi3.c 5.1 (Berkeley) 05/12/92"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include "longlong.h" 13 14 long long 15 __ashrdi3 (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) * BITS_PER_UNIT) - b; 31 if (bm <= 0) 32 { 33 w.s.high = uu.s.high >> 31; /* just to make w.s.high 1..1 or 0..0 */ 34 w.s.low = uu.s.high >> -bm; 35 } 36 else 37 { 38 carries = (unsigned long)uu.s.high << bm; 39 w.s.high = uu.s.high >> b; 40 w.s.low = ((unsigned long)uu.s.low >> b) | carries; 41 } 42 43 return w.ll; 44 } 45