blob: f30359b73f07e11ace90b45f474c27af61b57fa7 [file] [log] [blame]
Marek Vasutd2aa5dc2012-08-12 16:53:35 +02001#include "libgcc.h"
2
3long long __ashrdi3(long long u, word_type b)
4{
5 DWunion uu, w;
6 word_type bm;
7
8 if (b == 0)
9 return u;
10
11 uu.ll = u;
12 bm = 32 - b;
13
14 if (bm <= 0) {
15 /* w.s.high = 1..1 or 0..0 */
16 w.s.high =
17 uu.s.high >> 31;
18 w.s.low = uu.s.high >> -bm;
19 } else {
20 const unsigned int carries = (unsigned int) uu.s.high << bm;
21
22 w.s.high = uu.s.high >> b;
23 w.s.low = ((unsigned int) uu.s.low >> b) | carries;
24 }
25
26 return w.ll;
27}