Merge tag 'locking-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / sh / lib / ashrdi3.c
blobae263fbf25383b70ca5ff4a92999351da6646be7
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/module.h>
4 #include "libgcc.h"
6 long long __ashrdi3(long long u, word_type b)
8 DWunion uu, w;
9 word_type bm;
11 if (b == 0)
12 return u;
14 uu.ll = u;
15 bm = 32 - b;
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;
25 w.s.high = uu.s.high >> b;
26 w.s.low = ((unsigned int) uu.s.low >> b) | carries;
29 return w.ll;
32 EXPORT_SYMBOL(__ashrdi3);