diff options
Diffstat (limited to 'gcc/dfp.c')
-rw-r--r-- | gcc/dfp.c | 84 |
1 files changed, 58 insertions, 26 deletions
diff --git a/gcc/dfp.c b/gcc/dfp.c index 875e8c409a0..5e1dbcc41eb 100644 --- a/gcc/dfp.c +++ b/gcc/dfp.c @@ -133,6 +133,7 @@ encode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED, decNumber dn; decimal32 d32; decContext set; + int32_t image; decContextDefault (&set, DEC_INIT_DECIMAL128); set.traps = 0; @@ -140,7 +141,8 @@ encode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED, decimal_to_decnumber (r, &dn); decimal32FromNumber (&d32, &dn, &set); - memcpy (&buf[0], d32.bytes, sizeof (uint32_t)); + memcpy (&image, d32.bytes, sizeof (int32_t)); + buf[0] = image; } /* Decode an IEEE 754 decimal32 type into a real. */ @@ -152,11 +154,13 @@ decode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED, decNumber dn; decimal32 d32; decContext set; + int32_t image; decContextDefault (&set, DEC_INIT_DECIMAL128); set.traps = 0; - memcpy (&d32.bytes, &buf[0], sizeof (uint32_t)); + image = buf[0]; + memcpy (&d32.bytes, &image, sizeof (int32_t)); decimal32ToNumber (&d32, &dn); decimal_from_decnumber (r, &dn, &set); @@ -171,6 +175,7 @@ encode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED, decNumber dn; decimal64 d64; decContext set; + int32_t image; decContextDefault (&set, DEC_INIT_DECIMAL128); set.traps = 0; @@ -180,13 +185,17 @@ encode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED, if (WORDS_BIGENDIAN == FLOAT_WORDS_BIG_ENDIAN) { - memcpy (&buf[0], &d64.bytes[0], sizeof (uint32_t)); - memcpy (&buf[1], &d64.bytes[4], sizeof (uint32_t)); + memcpy (&image, &d64.bytes[0], sizeof (int32_t)); + buf[0] = image; + memcpy (&image, &d64.bytes[4], sizeof (int32_t)); + buf[1] = image; } else { - memcpy (&buf[0], &d64.bytes[4], sizeof (uint32_t)); - memcpy (&buf[1], &d64.bytes[0], sizeof (uint32_t)); + memcpy (&image, &d64.bytes[4], sizeof (int32_t)); + buf[0] = image; + memcpy (&image, &d64.bytes[0], sizeof (int32_t)); + buf[1] = image; } } @@ -199,19 +208,24 @@ decode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED, decNumber dn; decimal64 d64; decContext set; + int32_t image; decContextDefault (&set, DEC_INIT_DECIMAL128); set.traps = 0; if (WORDS_BIGENDIAN == FLOAT_WORDS_BIG_ENDIAN) { - memcpy (&d64.bytes[0], &buf[0], sizeof (uint32_t)); - memcpy (&d64.bytes[4], &buf[1], sizeof (uint32_t)); + image = buf[0]; + memcpy (&d64.bytes[0], &image, sizeof (int32_t)); + image = buf[1]; + memcpy (&d64.bytes[4], &image, sizeof (int32_t)); } else { - memcpy (&d64.bytes[0], &buf[1], sizeof (uint32_t)); - memcpy (&d64.bytes[4], &buf[0], sizeof (uint32_t)); + image = buf[1]; + memcpy (&d64.bytes[0], &image, sizeof (int32_t)); + image = buf[0]; + memcpy (&d64.bytes[4], &image, sizeof (int32_t)); } decimal64ToNumber (&d64, &dn); @@ -227,6 +241,7 @@ encode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED, decNumber dn; decContext set; decimal128 d128; + int32_t image; decContextDefault (&set, DEC_INIT_DECIMAL128); set.traps = 0; @@ -236,17 +251,25 @@ encode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED, if (WORDS_BIGENDIAN == FLOAT_WORDS_BIG_ENDIAN) { - memcpy (&buf[0], &d128.bytes[0], sizeof (uint32_t)); - memcpy (&buf[1], &d128.bytes[4], sizeof (uint32_t)); - memcpy (&buf[2], &d128.bytes[8], sizeof (uint32_t)); - memcpy (&buf[3], &d128.bytes[12], sizeof (uint32_t)); + memcpy (&image, &d128.bytes[0], sizeof (int32_t)); + buf[0] = image; + memcpy (&image, &d128.bytes[4], sizeof (int32_t)); + buf[1] = image; + memcpy (&image, &d128.bytes[8], sizeof (int32_t)); + buf[2] = image; + memcpy (&image, &d128.bytes[12], sizeof (int32_t)); + buf[3] = image; } else { - memcpy (&buf[0], &d128.bytes[12], sizeof (uint32_t)); - memcpy (&buf[1], &d128.bytes[8], sizeof (uint32_t)); - memcpy (&buf[2], &d128.bytes[4], sizeof (uint32_t)); - memcpy (&buf[3], &d128.bytes[0], sizeof (uint32_t)); + memcpy (&image, &d128.bytes[12], sizeof (int32_t)); + buf[0] = image; + memcpy (&image, &d128.bytes[8], sizeof (int32_t)); + buf[1] = image; + memcpy (&image, &d128.bytes[4], sizeof (int32_t)); + buf[2] = image; + memcpy (&image, &d128.bytes[0], sizeof (int32_t)); + buf[3] = image; } } @@ -259,23 +282,32 @@ decode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED, decNumber dn; decimal128 d128; decContext set; + int32_t image; decContextDefault (&set, DEC_INIT_DECIMAL128); set.traps = 0; if (WORDS_BIGENDIAN == FLOAT_WORDS_BIG_ENDIAN) { - memcpy (&d128.bytes[0], &buf[0], sizeof (uint32_t)); - memcpy (&d128.bytes[4], &buf[1], sizeof (uint32_t)); - memcpy (&d128.bytes[8], &buf[2], sizeof (uint32_t)); - memcpy (&d128.bytes[12], &buf[3], sizeof (uint32_t)); + image = buf[0]; + memcpy (&d128.bytes[0], &image, sizeof (int32_t)); + image = buf[1]; + memcpy (&d128.bytes[4], &image, sizeof (int32_t)); + image = buf[2]; + memcpy (&d128.bytes[8], &image, sizeof (int32_t)); + image = buf[3]; + memcpy (&d128.bytes[12], &image, sizeof (int32_t)); } else { - memcpy (&d128.bytes[0], &buf[3], sizeof (uint32_t)); - memcpy (&d128.bytes[4], &buf[2], sizeof (uint32_t)); - memcpy (&d128.bytes[8], &buf[1], sizeof (uint32_t)); - memcpy (&d128.bytes[12], &buf[0], sizeof (uint32_t)); + image = buf[3]; + memcpy (&d128.bytes[0], &image, sizeof (int32_t)); + image = buf[2]; + memcpy (&d128.bytes[4], &image, sizeof (int32_t)); + image = buf[1]; + memcpy (&d128.bytes[8], &image, sizeof (int32_t)); + image = buf[0]; + memcpy (&d128.bytes[12], &image, sizeof (int32_t)); } decimal128ToNumber (&d128, &dn); |