]>
Commit | Line | Data |
---|---|---|
588cb88c | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
b35cd988 PD |
2 | /* |
3 | * lib/lshrdi3.c | |
b35cd988 PD |
4 | */ |
5 | ||
6 | #include <linux/module.h> | |
4db2b604 | 7 | #include <linux/libgcc.h> |
b35cd988 PD |
8 | |
9 | long long notrace __lshrdi3(long long u, word_type b) | |
10 | { | |
11 | DWunion uu, w; | |
12 | word_type bm; | |
13 | ||
14 | if (b == 0) | |
15 | return u; | |
16 | ||
17 | uu.ll = u; | |
18 | bm = 32 - b; | |
19 | ||
20 | if (bm <= 0) { | |
21 | w.s.high = 0; | |
22 | w.s.low = (unsigned int) uu.s.high >> -bm; | |
23 | } else { | |
24 | const unsigned int carries = (unsigned int) uu.s.high << bm; | |
25 | ||
26 | w.s.high = (unsigned int) uu.s.high >> b; | |
27 | w.s.low = ((unsigned int) uu.s.low >> b) | carries; | |
28 | } | |
29 | ||
30 | return w.ll; | |
31 | } | |
32 | EXPORT_SYMBOL(__lshrdi3); |