^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* ashrdi3.c extracted from gcc-2.95.2/libgcc2.c which is: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) This file is part of GNU CC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) GNU CC is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) the Free Software Foundation; either version 2, or (at your option)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) GNU CC is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) GNU General Public License for more details. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define BITS_PER_UNIT 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) typedef int SItype __mode(SI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) typedef unsigned int USItype __mode(SI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) typedef int DItype __mode(DI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) typedef int word_type __mode(__word__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct DIstruct {SItype high, low;};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) typedef union
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct DIstruct s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) DItype ll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) } DIunion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) DItype
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __ashldi3 (DItype u, word_type b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) DIunion w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) word_type bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) DIunion uu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (b == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) uu.ll = u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (bm <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) w.s.low = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) w.s.high = (USItype)uu.s.low << -bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) USItype carries = (USItype)uu.s.low >> bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) w.s.low = (USItype)uu.s.low << b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) w.s.high = ((USItype)uu.s.high << b) | carries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) return w.ll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) EXPORT_SYMBOL(__ashldi3);