lshrdi3.c 513 B

123456789101112131415161718192021222324252627282930
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/module.h>
  3. #include "libgcc.h"
  4. long long __lshrdi3(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 = 0;
  14. w.s.low = (unsigned int) uu.s.high >> -bm;
  15. } else {
  16. const unsigned int carries = (unsigned int) uu.s.high << bm;
  17. w.s.high = (unsigned int) uu.s.high >> b;
  18. w.s.low = ((unsigned int) uu.s.low >> b) | carries;
  19. }
  20. return w.ll;
  21. }
  22. EXPORT_SYMBOL(__lshrdi3);