blob: a86bbe395f178604706d982ec77b960c9b8bde33 [file] [log] [blame]
Yoshinori Satoa71a29d2015-01-28 02:48:15 +09001#include "libgcc.h"
2
3DWtype __lshrdi3(DWtype u, word_type b)
4{
5 const DWunion uu = {.ll = u};
6 const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
7 DWunion w;
8
9 if (b == 0)
10 return u;
11
12 if (bm <= 0) {
13 w.s.high = 0;
14 w.s.low = (UWtype) uu.s.high >> -bm;
15 } else {
16 const UWtype carries = (UWtype) uu.s.high << bm;
17
18 w.s.high = (UWtype) uu.s.high >> b;
19 w.s.low = ((UWtype) uu.s.low >> b) | carries;
20 }
21
22 return w.ll;
23}