ashrdi3.c 445 B

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