sfp-util.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * These are copied from glibc/stdlib/longlong.h
  3. */
  4. #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  5. do { \
  6. UWtype __x; \
  7. __x = (al) + (bl); \
  8. (sh) = (ah) + (bh) + (__x < (al)); \
  9. (sl) = __x; \
  10. } while (0)
  11. #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  12. do { \
  13. UWtype __x; \
  14. __x = (al) - (bl); \
  15. (sh) = (ah) - (bh) - (__x > (al)); \
  16. (sl) = __x; \
  17. } while (0)
  18. #define umul_ppmm(w1, w0, u, v) \
  19. __asm__ ("dmulu.l %2,%3\n\tsts macl,%1\n\tsts mach,%0" \
  20. : "=r" ((u32)(w1)), "=r" ((u32)(w0)) \
  21. : "r" ((u32)(u)), "r" ((u32)(v)) \
  22. : "macl", "mach")
  23. #define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
  24. #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
  25. #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
  26. #define udiv_qrnnd(q, r, n1, n0, d) \
  27. do { \
  28. UWtype __d1, __d0, __q1, __q0; \
  29. UWtype __r1, __r0, __m; \
  30. __d1 = __ll_highpart (d); \
  31. __d0 = __ll_lowpart (d); \
  32. \
  33. __r1 = (n1) % __d1; \
  34. __q1 = (n1) / __d1; \
  35. __m = (UWtype) __q1 * __d0; \
  36. __r1 = __r1 * __ll_B | __ll_highpart (n0); \
  37. if (__r1 < __m) \
  38. { \
  39. __q1--, __r1 += (d); \
  40. if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
  41. if (__r1 < __m) \
  42. __q1--, __r1 += (d); \
  43. } \
  44. __r1 -= __m; \
  45. \
  46. __r0 = __r1 % __d1; \
  47. __q0 = __r1 / __d1; \
  48. __m = (UWtype) __q0 * __d0; \
  49. __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
  50. if (__r0 < __m) \
  51. { \
  52. __q0--, __r0 += (d); \
  53. if (__r0 >= (d)) \
  54. if (__r0 < __m) \
  55. __q0--, __r0 += (d); \
  56. } \
  57. __r0 -= __m; \
  58. \
  59. (q) = (UWtype) __q1 * __ll_B | __q0; \
  60. (r) = __r0; \
  61. } while (0)
  62. #define abort() return 0
  63. #define __BYTE_ORDER __LITTLE_ENDIAN