PATCH for PUT_REAL/GET_REAL
mark@codesourcery.com
mark@codesourcery.com
Sun Jun 6 23:01:00 GMT 1999
As Linus pointed out, these macros are not ANSI/ISO conformant.
Here's what I think is a fix. I'm bootstrapping now on x86-linux-gnu,
but I have no confidence that these macros are actually used on that
system. (I haven't unravelled all the #ifdefs in real.c). I
therefore suggest that someone who knows this code check the patch
carefully before approving it.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
Sun Jun 6 22:57:11 1999 Mark Mitchell <mark@codesourcery.com>
* real.c (GET_REAL): Don't violate ANSI/ISO aliasing rules.
(PUT_REAL): Likewise.
Index: real.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/real.c,v
retrieving revision 1.25
diff -u -p -r1.25 real.c
--- real.c 1999/03/06 05:34:25 1.25
+++ real.c 1999/06/07 06:00:01
@@ -269,34 +269,34 @@ do { \
/* Emulator uses target format internally
but host stores it in host endian-ness. */
-#define GET_REAL(r,e) \
-do { \
- if (HOST_FLOAT_WORDS_BIG_ENDIAN == REAL_WORDS_BIG_ENDIAN) \
- e53toe ((unsigned EMUSHORT *) (r), (e)); \
- else \
- { \
- unsigned EMUSHORT w[4]; \
- w[3] = ((EMUSHORT *) r)[0]; \
- w[2] = ((EMUSHORT *) r)[1]; \
- w[1] = ((EMUSHORT *) r)[2]; \
- w[0] = ((EMUSHORT *) r)[3]; \
- e53toe (w, (e)); \
- } \
+#define GET_REAL(r,e) \
+do { \
+ if (HOST_FLOAT_WORDS_BIG_ENDIAN == REAL_WORDS_BIG_ENDIAN) \
+ e53toe ((unsigned EMUSHORT *) (r), (e)); \
+ else \
+ { \
+ unsigned EMUSHORT w[4]; \
+ bcopy (((EMUSHORT *) r), &w[3], sizeof (ENUMSHORT)); \
+ bcopy (((EUMSHORT *) r) + 1, &w[2], sizeof (ENUMSHORT)); \
+ bcopy (((EMUSHORT *) r) + 2, &w[1], sizeof (ENUMSHORT)); \
+ bcopy (((EMUSHORT *) r) + 3, &w[0], sizeof (ENUMSHORT)); \
+ e53toe (w, (e)); \
+ } \
} while (0)
-#define PUT_REAL(e,r) \
-do { \
- if (HOST_FLOAT_WORDS_BIG_ENDIAN == REAL_WORDS_BIG_ENDIAN) \
- etoe53 ((e), (unsigned EMUSHORT *) (r)); \
- else \
- { \
- unsigned EMUSHORT w[4]; \
- etoe53 ((e), w); \
- *((EMUSHORT *) r) = w[3]; \
- *((EMUSHORT *) r + 1) = w[2]; \
- *((EMUSHORT *) r + 2) = w[1]; \
- *((EMUSHORT *) r + 3) = w[0]; \
- } \
+#define PUT_REAL(e,r) \
+do { \
+ if (HOST_FLOAT_WORDS_BIG_ENDIAN == REAL_WORDS_BIG_ENDIAN) \
+ etoe53 ((e), (unsigned EMUSHORT *) (r)); \
+ else \
+ { \
+ unsigned EMUSHORT w[4]; \
+ etoe53 ((e), w); \
+ bcopy (&w[3], ((EUMSHORT *) r), sizeof (ENUMSHORT)); \
+ bcopy (&w[2], ((EUMSHORT *) r) + 1, sizeof (ENUMSHORT)); \
+ bcopy (&w[1], ((EUMSHORT *) r) + 2, sizeof (ENUMSHORT)); \
+ bcopy (&w[0], ((EUMSHORT *) r) + 3, sizeof (ENUMSHORT)); \
+ } \
} while (0)
#else /* not REAL_ARITHMETIC */
More information about the Gcc-patches
mailing list