^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/libgcc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) long long notrace __ashrdi3(long long u, word_type b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) DWunion uu, w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) word_type bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) if (b == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) return u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) uu.ll = u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) bm = 32 - b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) if (bm <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* w.s.high = 1..1 or 0..0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) w.s.high =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) uu.s.high >> 31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) w.s.low = uu.s.high >> -bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) const unsigned int carries = (unsigned int) uu.s.high << bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) w.s.high = uu.s.high >> b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) w.s.low = ((unsigned int) uu.s.low >> b) | carries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) return w.ll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) EXPORT_SYMBOL(__ashrdi3);