lshrdi3.c 621 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright 2004-2009 Analog Devices Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #include "gcclib.h"
  7. #ifdef CONFIG_ARITHMETIC_OPS_L1
  8. DItype __lshrdi3(DItype u, word_type b)__attribute__((l1_text));
  9. #endif
  10. DItype __lshrdi3(DItype u, word_type b)
  11. {
  12. DIunion w;
  13. word_type bm;
  14. DIunion uu;
  15. if (b == 0)
  16. return u;
  17. uu.ll = u;
  18. bm = (sizeof(SItype) * BITS_PER_UNIT) - b;
  19. if (bm <= 0) {
  20. w.s.high = 0;
  21. w.s.low = (USItype) uu.s.high >> -bm;
  22. } else {
  23. USItype carries = (USItype) uu.s.high << bm;
  24. w.s.high = (USItype) uu.s.high >> b;
  25. w.s.low = ((USItype) uu.s.low >> b) | carries;
  26. }
  27. return w.ll;
  28. }