ashrdi3.c 494 B

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