blob: 268098a962a1cf06120cb81ec69645661000097f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Michal Simekd64af912013-02-01 13:10:35 +01002#include <linux/export.h>
Michal Simek4e07dba2010-08-12 14:28:53 +02003
4#include "libgcc.h"
5
6long long __ashrdi3(long long u, word_type b)
7{
8 DWunion uu, w;
9 word_type bm;
10
11 if (b == 0)
12 return u;
13
14 uu.ll = u;
15 bm = 32 - b;
16
17 if (bm <= 0) {
18 /* w.s.high = 1..1 or 0..0 */
19 w.s.high =
20 uu.s.high >> 31;
21 w.s.low = uu.s.high >> -bm;
22 } else {
23 const unsigned int carries = (unsigned int) uu.s.high << bm;
24
25 w.s.high = uu.s.high >> b;
26 w.s.low = ((unsigned int) uu.s.low >> b) | carries;
27 }
28
29 return w.ll;
30}
Michal Simek4e07dba2010-08-12 14:28:53 +020031EXPORT_SYMBOL(__ashrdi3);