153441Sbostic /*- 253441Sbostic * Copyright (c) 1992 The Regents of the University of California. 353441Sbostic * All rights reserved. 453441Sbostic * 553441Sbostic * %sccs.include.redist.c% 653441Sbostic */ 753441Sbostic 853441Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*53459Sbostic static char sccsid[] = "@(#)lshrdi3.c 5.3 (Berkeley) 05/12/92"; 1053441Sbostic #endif /* LIBC_SCCS and not lint */ 1153441Sbostic 12*53459Sbostic /* Copyright (C) 1989, 1992 Free Software Foundation, Inc. 13*53459Sbostic 14*53459Sbostic This file is part of GNU CC. 15*53459Sbostic 16*53459Sbostic GNU CC is free software; you can redistribute it and/or modify 17*53459Sbostic it under the terms of the GNU General Public License as published by 18*53459Sbostic the Free Software Foundation; either version 2, or (at your option) 19*53459Sbostic any later version. 20*53459Sbostic 21*53459Sbostic GNU CC is distributed in the hope that it will be useful, 22*53459Sbostic but WITHOUT ANY WARRANTY; without even the implied warranty of 23*53459Sbostic MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24*53459Sbostic GNU General Public License for more details. 25*53459Sbostic 26*53459Sbostic You should have received a copy of the GNU General Public License 27*53459Sbostic along with GNU CC; see the file COPYING. If not, write to 28*53459Sbostic the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 29*53459Sbostic 30*53459Sbostic /* As a special exception, if you link this library with files 31*53459Sbostic compiled with GCC to produce an executable, this does not cause 32*53459Sbostic the resulting executable to be covered by the GNU General Public License. 33*53459Sbostic This exception does not however invalidate any other reasons why 34*53459Sbostic the executable file might be covered by the GNU General Public License. */ 35*53459Sbostic 3653441Sbostic #include "longlong.h" 3753441Sbostic 3853441Sbostic long long 3953441Sbostic __lshrdi3 (u, b1) 4053441Sbostic long long u; 4153441Sbostic long long b1; 4253441Sbostic { 4353441Sbostic long_long w; 4453441Sbostic unsigned long carries; 4553441Sbostic int bm; 4653441Sbostic long_long uu; 4753441Sbostic int b = b1; 4853441Sbostic 4953441Sbostic if (b == 0) 5053441Sbostic return u; 5153441Sbostic 5253441Sbostic uu.ll = u; 5353441Sbostic 5453452Sbostic bm = (sizeof (int) * NBBY) - b; 5553441Sbostic if (bm <= 0) 5653441Sbostic { 5753441Sbostic w.s.high = 0; 5853441Sbostic w.s.low = (unsigned long)uu.s.high >> -bm; 5953441Sbostic } 6053441Sbostic else 6153441Sbostic { 6253441Sbostic carries = (unsigned long)uu.s.high << bm; 6353441Sbostic w.s.high = (unsigned long)uu.s.high >> b; 6453441Sbostic w.s.low = ((unsigned long)uu.s.low >> b) | carries; 6553441Sbostic } 6653441Sbostic 6753441Sbostic return w.ll; 6853441Sbostic } 69