icu.icu6284.strictalias.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. diff -ru icu.orig/source/common/putil.c icu/source/common/putil.c
  2. --- icu.orig/source/common/putil.c 2008-08-26 13:12:58.000000000 +0100
  3. +++ icu/source/common/putil.c 2008-08-26 13:13:01.000000000 +0100
  4. @@ -160,30 +160,46 @@
  5. # define U_POSIX_LOCALE 1
  6. #endif
  7. -/*
  8. - WARNING! u_topNBytesOfDouble and u_bottomNBytesOfDouble
  9. - can't be properly optimized by the gcc compiler sometimes (i.e. gcc 3.2).
  10. -*/
  11. #if !IEEE_754
  12. -static char*
  13. -u_topNBytesOfDouble(double* d, int n)
  14. +static uint32_t
  15. +u_topOfDoubleAsUint32(double d)
  16. {
  17. -#if U_IS_BIG_ENDIAN
  18. - return (char*)d;
  19. -#else
  20. - return (char*)(d + 1) - n;
  21. -#endif
  22. + union
  23. + {
  24. + double d;
  25. + uint32_t i[2];
  26. + } u;
  27. +
  28. + u.d = d;
  29. + return u.i
  30. + [
  31. +# if U_IS_BIG_ENDIAN
  32. + 0
  33. +# else
  34. + 1
  35. +# endif
  36. + ];
  37. }
  38. #endif
  39. -static char*
  40. -u_bottomNBytesOfDouble(double* d, int n)
  41. +static uint32_t
  42. +u_bottomOfDoubleAsUint32(double d)
  43. {
  44. -#if U_IS_BIG_ENDIAN
  45. - return (char*)(d + 1) - n;
  46. -#else
  47. - return (char*)d;
  48. -#endif
  49. + union
  50. + {
  51. + double d;
  52. + uint32_t i[2];
  53. + } u;
  54. +
  55. + u.d = d;
  56. + return u.i
  57. + [
  58. +# if U_IS_BIG_ENDIAN
  59. + 1
  60. +# else
  61. + 0
  62. +# endif
  63. + ];
  64. }
  65. #if defined (U_DEBUG_FAKETIME)
  66. @@ -297,10 +313,8 @@
  67. return (UBool)((convertedNumber.i64 & U_INT64_MAX) > gInf.i64);
  68. #elif defined(OS390)
  69. - uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
  70. - sizeof(uint32_t));
  71. - uint32_t lowBits = *(uint32_t*)u_bottomNBytesOfDouble(&number,
  72. - sizeof(uint32_t));
  73. + uint32_t highBits = u_topOfDoubleAsUint32(number);
  74. + uint32_t lowBits = u_bottomOfDoubleAsUint32(number);
  75. return ((highBits & 0x7F080000L) == 0x7F080000L) &&
  76. (lowBits == 0x00000000L);
  77. @@ -322,10 +336,8 @@
  78. /* Infinity is exactly 0x7FF0000000000000U. */
  79. return (UBool)((convertedNumber.i64 & U_INT64_MAX) == gInf.i64);
  80. #elif defined(OS390)
  81. - uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
  82. - sizeof(uint32_t));
  83. - uint32_t lowBits = *(uint32_t*)u_bottomNBytesOfDouble(&number,
  84. - sizeof(uint32_t));
  85. + uint32_t highBits = u_topOfDoubleAsUint32(number);
  86. + uint32_t lowBits = u_bottomOfDoubleAsUint32(number);
  87. return ((highBits & ~SIGN) == 0x70FF0000L) && (lowBits == 0x00000000L);
  88. @@ -354,8 +366,7 @@
  89. return (UBool)(number < 0 && uprv_isInfinite(number));
  90. #else
  91. - uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
  92. - sizeof(uint32_t));
  93. + uint32_t highBits = u_topOfDoubleAsUint32(number);
  94. return((highBits & SIGN) && uprv_isInfinite(number));
  95. #endif
  96. @@ -447,7 +458,7 @@
  97. return uprv_getNaN();
  98. /* check for -0 and 0*/
  99. - lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&x, sizeof(uint32_t));
  100. + lowBits = u_bottomOfDoubleAsUint32(x);
  101. if(x == 0.0 && y == 0.0 && (lowBits & SIGN))
  102. return y;
  103. @@ -468,7 +479,7 @@
  104. return uprv_getNaN();
  105. /* check for -0 and 0*/
  106. - lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&y, sizeof(uint32_t));
  107. + lowBits = u_bottomOfDoubleAsUint32(y);
  108. if(x == 0.0 && y == 0.0 && (lowBits & SIGN))
  109. return y;
  110. @@ -497,7 +508,7 @@
  111. if(uprv_isInfinite(d))
  112. return uprv_getInfinity();
  113. - lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&d, sizeof(uint32_t));
  114. + lowBits = u_bottomOfDoubleAsUint32(d);
  115. if( (d == 0.0 && (lowBits & SIGN)) || d < 0)
  116. return ceil(d);
  117. else
  118. Only in icu/source/common: putil.c.orig