blob: 17456024873d20918cc151c16e4d75173b6869ee [file] [log] [blame]
Paul Gortmaker527581b2016-08-21 15:58:15 -04001#include <linux/export.h>
Ralf Baechle72fbfb262006-06-07 13:25:37 +01002
3#include "libgcc.h"
4
Harvey Huntaedcfbe2016-05-25 11:06:35 +01005long long notrace __ashrdi3(long long u, word_type b)
Ralf Baechle72fbfb262006-06-07 13:25:37 +01006{
7 DWunion uu, w;
8 word_type bm;
9
10 if (b == 0)
11 return u;
12
13 uu.ll = u;
14 bm = 32 - b;
15
16 if (bm <= 0) {
17 /* w.s.high = 1..1 or 0..0 */
18 w.s.high =
19 uu.s.high >> 31;
20 w.s.low = uu.s.high >> -bm;
21 } else {
22 const unsigned int carries = (unsigned int) uu.s.high << bm;
23
24 w.s.high = uu.s.high >> b;
25 w.s.low = ((unsigned int) uu.s.low >> b) | carries;
26 }
27
28 return w.ll;
29}
30
31EXPORT_SYMBOL(__ashrdi3);