patch-mpi_longlong_h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --- libgcrypt-1.4.4.orig/mpi/longlong.h 2008-08-19 17:20:03.000000000 +0200
  2. +++ libgcrypt-1.4.4/mpi/longlong.h 2009-06-14 19:45:28.000000000 +0200
  3. @@ -710,18 +710,35 @@ extern USItype __udiv_qrnnd ();
  4. #endif /* __m88110__ */
  5. #endif /* __m88000__ */
  6. +/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */
  7. +#if defined (__GNUC__) && defined (__GNUC_MINOR__)
  8. +#define __GNUC_PREREQ(maj, min) \
  9. + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
  10. +#else
  11. +#define __GNUC_PREREQ(maj, min) 0
  12. +#endif
  13. +
  14. /***************************************
  15. ************** MIPS *****************
  16. ***************************************/
  17. #if defined (__mips__) && W_TYPE_SIZE == 32
  18. -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
  19. +#if __GNUC_PREREQ (4,4)
  20. +#define umul_ppmm(w1, w0, u, v) \
  21. + do { \
  22. + UDItype __ll = (UDItype)(u) * (v); \
  23. + w1 = __ll >> 32; \
  24. + w0 = __ll; \
  25. + } while (0)
  26. +#endif
  27. +#if !defined (umul_ppmm) && __GNUC_PREREQ (2,7)
  28. #define umul_ppmm(w1, w0, u, v) \
  29. __asm__ ("multu %2,%3" \
  30. : "=l" ((USItype)(w0)), \
  31. "=h" ((USItype)(w1)) \
  32. : "d" ((USItype)(u)), \
  33. "d" ((USItype)(v)))
  34. -#else
  35. +#endif
  36. +#if !defined (umul_ppmm)
  37. #define umul_ppmm(w1, w0, u, v) \
  38. __asm__ ("multu %2,%3 \n" \
  39. "mflo %0 \n" \
  40. @@ -739,14 +756,24 @@ extern USItype __udiv_qrnnd ();
  41. ************** MIPS/64 **************
  42. ***************************************/
  43. #if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64
  44. -#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
  45. +#if __GNUC_PREREQ (4,4)
  46. +#define umul_ppmm(w1, w0, u, v) \
  47. + do { \
  48. + typedef unsigned int __ll_UTItype __attribute__((mode(TI))); \
  49. + __ll_UTItype __ll = (__ll_UTItype)(u) * (v); \
  50. + w1 = __ll >> 64; \
  51. + w0 = __ll; \
  52. + } while (0)
  53. +#endif
  54. +#if !defined (umul_ppmm) && __GNUC_PREREQ (2,7)
  55. #define umul_ppmm(w1, w0, u, v) \
  56. __asm__ ("dmultu %2,%3" \
  57. : "=l" ((UDItype)(w0)), \
  58. "=h" ((UDItype)(w1)) \
  59. : "d" ((UDItype)(u)), \
  60. "d" ((UDItype)(v)))
  61. -#else
  62. +#endif
  63. +#if !defined (umul_ppmm)
  64. #define umul_ppmm(w1, w0, u, v) \
  65. __asm__ ("dmultu %2,%3 \n" \
  66. "mflo %0 \n" \