ashldi3.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, see the file COPYING, or write
  14. * to the Free Software Foundation, Inc.
  15. */
  16. #include <linux/export.h>
  17. #include <linux/libgcc.h>
  18. long long notrace __ashldi3(long long u, word_type b)
  19. {
  20. DWunion uu, w;
  21. word_type bm;
  22. if (b == 0)
  23. return u;
  24. uu.ll = u;
  25. bm = 32 - b;
  26. if (bm <= 0) {
  27. w.s.low = 0;
  28. w.s.high = (unsigned int) uu.s.low << -bm;
  29. } else {
  30. const unsigned int carries = (unsigned int) uu.s.low >> bm;
  31. w.s.low = (unsigned int) uu.s.low << b;
  32. w.s.high = ((unsigned int) uu.s.high << b) | carries;
  33. }
  34. return w.ll;
  35. }
  36. EXPORT_SYMBOL(__ashldi3);