ashrdi3.c 535 B

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/module.h>
  3. #include "libgcc.h"
  4. long long __ashrdi3(long long u, word_type b)
  5. {
  6. DWunion uu, w;
  7. word_type bm;
  8. if (b == 0)
  9. return u;
  10. uu.ll = u;
  11. bm = 32 - b;
  12. if (bm <= 0) {
  13. /* w.s.high = 1..1 or 0..0 */
  14. w.s.high =
  15. uu.s.high >> 31;
  16. w.s.low = uu.s.high >> -bm;
  17. } else {
  18. const unsigned int carries = (unsigned int) uu.s.high << bm;
  19. w.s.high = uu.s.high >> b;
  20. w.s.low = ((unsigned int) uu.s.low >> b) | carries;
  21. }
  22. return w.ll;
  23. }
  24. EXPORT_SYMBOL(__ashrdi3);