Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / libgcc / __lshrdi3.c
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.
3
4 This file is part of GNU CC.
5
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.
10
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.
15
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. */
20
21 #include "libgcc.h"
22
23 #define BITS_PER_UNIT 8
24
25 struct DIstruct {SItype high, low;};
26
27 typedef union
28 {
29   struct DIstruct s;
30   DItype ll;
31 } DIunion;
32
33 DItype
34 __lshrdi3 (DItype u, word_type b)
35 {
36   DIunion w;
37   word_type bm;
38   DIunion uu;
39
40   if (b == 0)
41     return u;
42
43   uu.ll = u;
44
45   bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
46   if (bm <= 0)
47     {
48       w.s.high = 0;
49       w.s.low = (USItype)uu.s.high >> -bm;
50     }
51   else
52     {
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;
56     }
57
58   return w.ll;
59 }