ppc64: Don't set Kp bit on SLB
[openbios/afaerber.git] / libgcc / ashrdi3.c
blob8594d5eefa7f46ed08a08c164fdc23f49d92baaf
1 /* ashrdi3.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 __ashrdi3 (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 = 1..1 or 0..0 */
49 w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1);
50 w.s.low = uu.s.high >> -bm;
52 else
54 USItype carries = (USItype)uu.s.high << bm;
55 w.s.high = uu.s.high >> b;
56 w.s.low = ((USItype)uu.s.low >> b) | carries;
59 return w.ll;