ashldi3.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* ashrdi3.c extracted from gcc-2.95.2/libgcc2.c which is: */
  2. /* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
  3. This file is part of GNU CC.
  4. GNU CC is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU CC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details. */
  12. #include <linux/compiler.h>
  13. #include <linux/export.h>
  14. #define BITS_PER_UNIT 8
  15. typedef int SItype __attribute__ ((mode (SI)));
  16. typedef unsigned int USItype __attribute__ ((mode (SI)));
  17. typedef int DItype __attribute__ ((mode (DI)));
  18. typedef int word_type __attribute__ ((mode (__word__)));
  19. struct DIstruct {SItype high, low;};
  20. typedef union
  21. {
  22. struct DIstruct s;
  23. DItype ll;
  24. } DIunion;
  25. DItype
  26. __ashldi3 (DItype u, word_type b)
  27. {
  28. DIunion w;
  29. word_type bm;
  30. DIunion uu;
  31. if (b == 0)
  32. return u;
  33. uu.ll = u;
  34. bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
  35. if (bm <= 0)
  36. {
  37. w.s.low = 0;
  38. w.s.high = (USItype)uu.s.low << -bm;
  39. }
  40. else
  41. {
  42. USItype carries = (USItype)uu.s.low >> bm;
  43. w.s.low = (USItype)uu.s.low << b;
  44. w.s.high = ((USItype)uu.s.high << b) | carries;
  45. }
  46. return w.ll;
  47. }
  48. EXPORT_SYMBOL(__ashldi3);