/* ashrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */1/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.23This file is part of GNU CC.45GNU CC is free software; you can redistribute it and/or modify6it under the terms of the GNU General Public Licence as published by7the Free Software Foundation; either version 2, or (at your option)8any later version.910GNU CC is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public Licence for more details.1415You should have received a copy of the GNU General Public Licence16along with GNU CC; see the file COPYING. If not, write to17the Free Software Foundation, 59 Temple Place - Suite 330,18Boston, MA 02111-1307, USA. */1920#define BITS_PER_UNIT 82122typedef int SItype __attribute__((mode(SI)));23typedef unsigned int USItype __attribute__((mode(SI)));24typedef int DItype __attribute__((mode(DI)));25typedef int word_type __attribute__((mode(__word__)));2627struct DIstruct {28SItype low;29SItype high;30};3132union DIunion {33struct DIstruct s;34DItype ll;35};3637DItype __ashrdi3(DItype u, word_type b)38{39union DIunion w;40union DIunion uu;41word_type bm;4243if (b == 0)44return u;4546uu.ll = u;4748bm = (sizeof(SItype) * BITS_PER_UNIT) - b;49if (bm <= 0) {50/* w.s.high = 1..1 or 0..0 */51w.s.high = uu.s.high >> (sizeof(SItype) * BITS_PER_UNIT - 1);52w.s.low = uu.s.high >> -bm;53} else {54USItype carries = (USItype)uu.s.high << bm;55w.s.high = uu.s.high >> b;56w.s.low = ((USItype)uu.s.low >> b) | carries;57}5859return w.ll;60}616263