8054054: 8040121 is broken

C++ code pattern from 8040121 is incorrect

Reviewed-by: kvn
This commit is contained in:
Roland Westrelin 2014-07-31 19:59:36 +02:00
parent 7a9fc5ff21
commit e546e2a060
2 changed files with 14 additions and 7 deletions

View file

@ -42,29 +42,34 @@ typedef union {
} DoubleIntConv;
static inline int high(double d) {
DoubleIntConv x = { d };
DoubleIntConv x;
x.d = d;
return x.split.hi;
}
static inline int low(double d) {
DoubleIntConv x = { d };
DoubleIntConv x;
x.d = d;
return x.split.lo;
}
static inline void set_high(double* d, int high) {
DoubleIntConv conv = { *d };
DoubleIntConv conv;
conv.d = *d;
conv.split.hi = high;
*d = conv.d;
}
static inline void set_low(double* d, int low) {
DoubleIntConv conv = { *d };
DoubleIntConv conv;
conv.d = *d;
conv.split.lo = low;
*d = conv.d;
}
static double copysignA(double x, double y) {
DoubleIntConv convX = { x };
DoubleIntConv convX;
convX.d = x;
convX.split.hi = (convX.split.hi & 0x7fffffff) | (high(y) & 0x80000000);
return convX.d;
}