Mathias FROEHLICH: fix strange gcc 4.0.* strict aliasing problem
This commit is contained in:
parent
b716c6d15b
commit
ca96f2b3a4
1 changed files with 24 additions and 16 deletions
|
@ -122,42 +122,50 @@ XDR_decode_uint64 ( const xdr_data2_t & n_Val )
|
||||||
xdr_data_t
|
xdr_data_t
|
||||||
XDR_encode_float ( const float & f_Val )
|
XDR_encode_float ( const float & f_Val )
|
||||||
{
|
{
|
||||||
xdr_data_t* tmp;
|
union {
|
||||||
|
xdr_data_t x;
|
||||||
|
float f;
|
||||||
|
} tmp;
|
||||||
|
|
||||||
tmp = (xdr_data_t*) &f_Val;
|
tmp.f = f_Val;
|
||||||
return (XDR_encode_int32 (*tmp));
|
return (XDR_encode_int32 (tmp.x));
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
XDR_decode_float ( const xdr_data_t & f_Val )
|
XDR_decode_float ( const xdr_data_t & f_Val )
|
||||||
{
|
{
|
||||||
float* tmp;
|
union {
|
||||||
static xdr_data_t dummy;
|
xdr_data_t x;
|
||||||
|
float f;
|
||||||
|
} tmp;
|
||||||
|
|
||||||
dummy = XDR_decode_int32 (f_Val);
|
tmp.x = XDR_decode_int32 (f_Val);
|
||||||
tmp = (float*) &dummy;
|
return tmp.f;
|
||||||
return (*tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* double */
|
/* double */
|
||||||
xdr_data2_t
|
xdr_data2_t
|
||||||
XDR_encode_double ( const double & d_Val )
|
XDR_encode_double ( const double & d_Val )
|
||||||
{
|
{
|
||||||
xdr_data2_t* tmp;
|
union {
|
||||||
|
xdr_data2_t x;
|
||||||
|
double d;
|
||||||
|
} tmp;
|
||||||
|
|
||||||
tmp = (xdr_data2_t*) &d_Val;
|
tmp.d = d_Val;
|
||||||
return (XDR_encode_int64 (*tmp));
|
return (XDR_encode_int64 (tmp.x));
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
XDR_decode_double ( const xdr_data2_t & d_Val )
|
XDR_decode_double ( const xdr_data2_t & d_Val )
|
||||||
{
|
{
|
||||||
double* tmp;
|
union {
|
||||||
static xdr_data2_t dummy;
|
xdr_data2_t x;
|
||||||
|
double d;
|
||||||
|
} tmp;
|
||||||
|
|
||||||
dummy = XDR_decode_int64 (d_Val);
|
tmp.x = XDR_decode_int64 (d_Val);
|
||||||
tmp = (double*) &dummy;
|
return tmp.d;
|
||||||
return (*tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue