ashrdi3.c 498 B

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