lshrdi3.c 468 B

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