ppc64: Don't set Kp bit on SLB
[openbios/afaerber.git] / libgcc / __lshrdi3.c
blob4c1a38cd534b45321a04d77ebb63cb909f29e767
1 /* lshrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */
2 /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 51 Franklin St, Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 #include "libgcc.h"
23 #define BITS_PER_UNIT 8
25 struct DIstruct {SItype high, low;};
27 typedef union
29 struct DIstruct s;
30 DItype ll;
31 } DIunion;
33 DItype
34 __lshrdi3 (DItype u, word_type b)
36 DIunion w;
37 word_type bm;
38 DIunion uu;
40 if (b == 0)
41 return u;
43 uu.ll = u;
45 bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
46 if (bm <= 0)
48 w.s.high = 0;
49 w.s.low = (USItype)uu.s.high >> -bm;
51 else
53 USItype carries = (USItype)uu.s.high << bm;
54 w.s.high = (USItype)uu.s.high >> b;
55 w.s.low = ((USItype)uu.s.low >> b) | carries;
58 return w.ll;