diff options
author | Ben Elliston <bje@au.ibm.com> | 2009-04-07 01:29:54 +0000 |
---|---|---|
committer | Ben Elliston <bje@gcc.gnu.org> | 2009-04-07 11:29:54 +1000 |
commit | 95aac11b84177539a883f263c599ea2e033b1c3f (patch) | |
tree | 631dcaeae2fcdba1ca4a8be81fd0551c052c484b /gcc | |
parent | 633dd06142627746f63384bea70fa63ec90bbf7a (diff) | |
download | gcc-95aac11b84177539a883f263c599ea2e033b1c3f.zip gcc-95aac11b84177539a883f263c599ea2e033b1c3f.tar.gz gcc-95aac11b84177539a883f263c599ea2e033b1c3f.tar.bz2 |
dfp.c: Replace type punning assignments with memcpy throughout.
* dfp.c: Replace type punning assignments with memcpy throughout.
* Makefile.in (dfp.o-warn): Remove.
From-SVN: r145644
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/Makefile.in | 2 | ||||
-rw-r--r-- | gcc/dfp.c | 55 |
3 files changed, 33 insertions, 29 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 22efccf..5e8549d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2009-04-07 Ben Elliston <bje@au.ibm.com> + + * dfp.c: Replace type punning assignments with memcpy throughout. + * Makefile.in (dfp.o-warn): Remove. + 2009-04-07 Alan Modra <amodra@bigpond.net.au> PR target/39634 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 2a0a177..63dddc0 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -175,8 +175,6 @@ GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn) # be subject to -Werror: # flex output may yield harmless "no previous prototype" warnings build/gengtype-lex.o-warn = -Wno-error -# dfp.c contains many alias violations -dfp.o-warn = -fno-strict-aliasing # mips-tfile.c contains -Wcast-qual warnings. mips-tfile.o-warn = -Wno-error @@ -1,5 +1,6 @@ /* Decimal floating point support. - Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software + Foundation, Inc. This file is part of GCC. @@ -139,7 +140,7 @@ encode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED, decimal_to_decnumber (r, &dn); decimal32FromNumber (&d32, &dn, &set); - buf[0] = *(uint32_t *) d32.bytes; + memcpy (&buf[0], d32.bytes, sizeof (uint32_t)); } /* Decode an IEEE 754 decimal32 type into a real. */ @@ -155,7 +156,7 @@ decode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED, decContextDefault (&set, DEC_INIT_DECIMAL128); set.traps = 0; - *((uint32_t *) d32.bytes) = (uint32_t) buf[0]; + memcpy (&d32.bytes, &buf[0], sizeof (uint32_t)); decimal32ToNumber (&d32, &dn); decimal_from_decnumber (r, &dn, &set); @@ -179,13 +180,13 @@ encode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED, if (WORDS_BIGENDIAN == FLOAT_WORDS_BIG_ENDIAN) { - buf[0] = *(uint32_t *) &d64.bytes[0]; - buf[1] = *(uint32_t *) &d64.bytes[4]; + memcpy (&buf[0], &d64.bytes[0], sizeof (uint32_t)); + memcpy (&buf[1], &d64.bytes[4], sizeof (uint32_t)); } else { - buf[0] = *(uint32_t *) &d64.bytes[4]; - buf[1] = *(uint32_t *) &d64.bytes[0]; + memcpy (&buf[0], &d64.bytes[4], sizeof (uint32_t)); + memcpy (&buf[1], &d64.bytes[0], sizeof (uint32_t)); } } @@ -204,13 +205,13 @@ decode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED, if (WORDS_BIGENDIAN == FLOAT_WORDS_BIG_ENDIAN) { - *((uint32_t *) &d64.bytes[0]) = (uint32_t) buf[0]; - *((uint32_t *) &d64.bytes[4]) = (uint32_t) buf[1]; + memcpy (&d64.bytes[0], &buf[0], sizeof (uint32_t)); + memcpy (&d64.bytes[4], &buf[1], sizeof (uint32_t)); } else { - *((uint32_t *) &d64.bytes[0]) = (uint32_t) buf[1]; - *((uint32_t *) &d64.bytes[4]) = (uint32_t) buf[0]; + memcpy (&d64.bytes[0], &buf[1], sizeof (uint32_t)); + memcpy (&d64.bytes[4], &buf[0], sizeof (uint32_t)); } decimal64ToNumber (&d64, &dn); @@ -235,17 +236,17 @@ encode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED, if (WORDS_BIGENDIAN == FLOAT_WORDS_BIG_ENDIAN) { - buf[0] = *(uint32_t *) &d128.bytes[0]; - buf[1] = *(uint32_t *) &d128.bytes[4]; - buf[2] = *(uint32_t *) &d128.bytes[8]; - buf[3] = *(uint32_t *) &d128.bytes[12]; + 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)); } else { - buf[0] = *(uint32_t *) &d128.bytes[12]; - buf[1] = *(uint32_t *) &d128.bytes[8]; - buf[2] = *(uint32_t *) &d128.bytes[4]; - buf[3] = *(uint32_t *) &d128.bytes[0]; + 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)); } } @@ -264,17 +265,17 @@ decode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED, if (WORDS_BIGENDIAN == FLOAT_WORDS_BIG_ENDIAN) { - *((uint32_t *) &d128.bytes[0]) = (uint32_t) buf[0]; - *((uint32_t *) &d128.bytes[4]) = (uint32_t) buf[1]; - *((uint32_t *) &d128.bytes[8]) = (uint32_t) buf[2]; - *((uint32_t *) &d128.bytes[12]) = (uint32_t) buf[3]; + 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)); } else { - *((uint32_t *) &d128.bytes[0]) = (uint32_t) buf[3]; - *((uint32_t *) &d128.bytes[4]) = (uint32_t) buf[2]; - *((uint32_t *) &d128.bytes[8]) = (uint32_t) buf[1]; - *((uint32_t *) &d128.bytes[12]) = (uint32_t) buf[0]; + 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)); } decimal128ToNumber (&d128, &dn); |