icu/icu.icu6284.strictalias.patch

133 lines
3.5 KiB
Diff
Raw Normal View History

2008-08-26 12:12:03 +00:00
diff -ru icu.orig/source/common/putil.c icu/source/common/putil.c
--- icu.orig/source/common/putil.c 2008-08-26 13:12:58.000000000 +0100
+++ icu/source/common/putil.c 2008-08-26 13:13:01.000000000 +0100
@@ -160,30 +160,46 @@
2008-05-19 14:01:54 +00:00
# define U_POSIX_LOCALE 1
#endif
-/*
- WARNING! u_topNBytesOfDouble and u_bottomNBytesOfDouble
- can't be properly optimized by the gcc compiler sometimes (i.e. gcc 3.2).
-*/
#if !IEEE_754
-static char*
-u_topNBytesOfDouble(double* d, int n)
+static uint32_t
+u_topOfDoubleAsUint32(double d)
{
-#if U_IS_BIG_ENDIAN
- return (char*)d;
-#else
- return (char*)(d + 1) - n;
-#endif
+ union
+ {
+ double d;
+ uint32_t i[2];
+ } u;
+
+ u.d = d;
+ return u.i
+ [
+# if U_IS_BIG_ENDIAN
+ 0
+# else
+ 1
+# endif
+ ];
}
#endif
-static char*
-u_bottomNBytesOfDouble(double* d, int n)
+static uint32_t
+u_bottomOfDoubleAsUint32(double d)
{
-#if U_IS_BIG_ENDIAN
- return (char*)(d + 1) - n;
-#else
- return (char*)d;
-#endif
+ union
+ {
+ double d;
+ uint32_t i[2];
+ } u;
+
+ u.d = d;
+ return u.i
+ [
+# if U_IS_BIG_ENDIAN
+ 1
+# else
+ 0
+# endif
+ ];
}
2008-08-26 12:12:03 +00:00
#if defined (U_DEBUG_FAKETIME)
@@ -297,10 +313,8 @@
2008-05-19 14:01:54 +00:00
return (UBool)((convertedNumber.i64 & U_INT64_MAX) > gInf.i64);
#elif defined(OS390)
- uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
- sizeof(uint32_t));
- uint32_t lowBits = *(uint32_t*)u_bottomNBytesOfDouble(&number,
- sizeof(uint32_t));
+ uint32_t highBits = u_topOfDoubleAsUint32(number);
+ uint32_t lowBits = u_bottomOfDoubleAsUint32(number);
return ((highBits & 0x7F080000L) == 0x7F080000L) &&
(lowBits == 0x00000000L);
2008-08-26 12:12:03 +00:00
@@ -322,10 +336,8 @@
2008-05-19 14:01:54 +00:00
/* Infinity is exactly 0x7FF0000000000000U. */
return (UBool)((convertedNumber.i64 & U_INT64_MAX) == gInf.i64);
#elif defined(OS390)
- uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
- sizeof(uint32_t));
- uint32_t lowBits = *(uint32_t*)u_bottomNBytesOfDouble(&number,
- sizeof(uint32_t));
+ uint32_t highBits = u_topOfDoubleAsUint32(number);
+ uint32_t lowBits = u_bottomOfDoubleAsUint32(number);
return ((highBits & ~SIGN) == 0x70FF0000L) && (lowBits == 0x00000000L);
2008-08-26 12:12:03 +00:00
@@ -354,8 +366,7 @@
2008-05-19 14:01:54 +00:00
return (UBool)(number < 0 && uprv_isInfinite(number));
#else
- uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number,
- sizeof(uint32_t));
+ uint32_t highBits = u_topOfDoubleAsUint32(number);
return((highBits & SIGN) && uprv_isInfinite(number));
#endif
2008-08-26 12:12:03 +00:00
@@ -447,7 +458,7 @@
2008-05-19 14:01:54 +00:00
return uprv_getNaN();
/* check for -0 and 0*/
- lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&x, sizeof(uint32_t));
+ lowBits = u_bottomOfDoubleAsUint32(x);
if(x == 0.0 && y == 0.0 && (lowBits & SIGN))
return y;
2008-08-26 12:12:03 +00:00
@@ -468,7 +479,7 @@
2008-05-19 14:01:54 +00:00
return uprv_getNaN();
/* check for -0 and 0*/
- lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&y, sizeof(uint32_t));
+ lowBits = u_bottomOfDoubleAsUint32(y);
if(x == 0.0 && y == 0.0 && (lowBits & SIGN))
return y;
2008-08-26 12:12:03 +00:00
@@ -497,7 +508,7 @@
2008-05-19 14:01:54 +00:00
if(uprv_isInfinite(d))
return uprv_getInfinity();
- lowBits = *(uint32_t*) u_bottomNBytesOfDouble(&d, sizeof(uint32_t));
+ lowBits = u_bottomOfDoubleAsUint32(d);
if( (d == 0.0 && (lowBits & SIGN)) || d < 0)
return ceil(d);
else
2008-08-26 12:12:03 +00:00
Only in icu/source/common: putil.c.orig