First Support on Ginger and OMAP TI
[linux-ginger.git] / arch / blackfin / lib / lshrdi3.c
blob53f1741047e50f6a06fd92aa25055f3b305cf61e
1 /*
2 * Copyright 2004-2009 Analog Devices Inc.
4 * Licensed under the GPL-2 or later.
5 */
7 #include "gcclib.h"
9 #ifdef CONFIG_ARITHMETIC_OPS_L1
10 DItype __lshrdi3(DItype u, word_type b)__attribute__((l1_text));
11 #endif
13 DItype __lshrdi3(DItype u, word_type b)
15 DIunion w;
16 word_type bm;
17 DIunion uu;
19 if (b == 0)
20 return u;
22 uu.ll = u;
24 bm = (sizeof(SItype) * BITS_PER_UNIT) - b;
25 if (bm <= 0) {
26 w.s.high = 0;
27 w.s.low = (USItype) uu.s.high >> -bm;
28 } else {
29 USItype carries = (USItype) uu.s.high << bm;
30 w.s.high = (USItype) uu.s.high >> b;
31 w.s.low = ((USItype) uu.s.low >> b) | carries;
34 return w.ll;