lshrdi3.c 559 B

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