Commit 89c89d11 by Richard Kenner

(FLO_union_type): Add words field if double precision to get at the separate words.

(FLO_union_type): Add words field if double precision to get at the separate
words.
(FLO_union_type, pack_d, unpack_d): Use FLOAT_BIT_ORDER_MISMATCH to
determine when the bitfields need to be reversed, and
FLOAT_WORD_ORDER_MISMATCH when the words need to be reversed.

From-SVN: r10357
parent 6136d594
...@@ -243,7 +243,11 @@ typedef union ...@@ -243,7 +243,11 @@ typedef union
FLO_type value; FLO_type value;
fractype value_raw; fractype value_raw;
#ifdef FLOAT_WORD_ORDER_MISMATCH #ifndef FLOAT
halffractype words[2];
#endif
#ifdef FLOAT_BIT_ORDER_MISMATCH
struct struct
{ {
fractype fraction:FRACBITS __attribute__ ((packed)); fractype fraction:FRACBITS __attribute__ ((packed));
...@@ -254,8 +258,6 @@ typedef union ...@@ -254,8 +258,6 @@ typedef union
#endif #endif
#ifdef _DEBUG_BITFLOAT #ifdef _DEBUG_BITFLOAT
halffractype l[2];
struct struct
{ {
unsigned int sign:1 __attribute__ ((packed)); unsigned int sign:1 __attribute__ ((packed));
...@@ -414,7 +416,7 @@ pack_d ( fp_number_type * src) ...@@ -414,7 +416,7 @@ pack_d ( fp_number_type * src)
/* We previously used bitfields to store the number, but this doesn't /* We previously used bitfields to store the number, but this doesn't
handle little/big endian systems conviently, so use shifts and handle little/big endian systems conviently, so use shifts and
masks */ masks */
#ifdef FLOAT_WORD_ORDER_MISMATCH #ifdef FLOAT_BIT_ORDER_MISMATCH
dst.bits.fraction = fraction; dst.bits.fraction = fraction;
dst.bits.exp = exp; dst.bits.exp = exp;
dst.bits.sign = sign; dst.bits.sign = sign;
...@@ -424,6 +426,14 @@ pack_d ( fp_number_type * src) ...@@ -424,6 +426,14 @@ pack_d ( fp_number_type * src)
dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS); dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS);
#endif #endif
#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
{
halffractype tmp = dst.words[0];
dst.words[0] = dst.words[1];
dst.words[1] = tmp;
}
#endif
return dst.value; return dst.value;
} }
...@@ -437,7 +447,15 @@ unpack_d (FLO_union_type * src, fp_number_type * dst) ...@@ -437,7 +447,15 @@ unpack_d (FLO_union_type * src, fp_number_type * dst)
int exp; int exp;
int sign; int sign;
#ifdef FLOAT_WORD_ORDER_MISMATCH #if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT)
FLO_union_type swapped;
swapped.words[0] = src->words[1];
swapped.words[1] = src->words[0];
src = &swapped;
#endif
#ifdef FLOAT_BIT_ORDER_MISMATCH
fraction = src->bits.fraction; fraction = src->bits.fraction;
exp = src->bits.exp; exp = src->bits.exp;
sign = src->bits.sign; sign = src->bits.sign;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment