svn commit: r296113 - in head/lib/libc: powerpc powerpc/gen powerpc64 powerpc64/gen
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Fri Feb 26 20:38:25 UTC 2016
Author: nwhitehorn
Date: Fri Feb 26 20:38:23 2016
New Revision: 296113
URL: https://svnweb.freebsd.org/changeset/base/296113
Log:
Make unions in PowerPC libc endian-safe.
Modified:
head/lib/libc/powerpc/_fpmath.h
head/lib/libc/powerpc/gen/infinity.c
head/lib/libc/powerpc64/_fpmath.h
head/lib/libc/powerpc64/gen/infinity.c
Modified: head/lib/libc/powerpc/_fpmath.h
==============================================================================
--- head/lib/libc/powerpc/_fpmath.h Fri Feb 26 20:33:32 2016 (r296112)
+++ head/lib/libc/powerpc/_fpmath.h Fri Feb 26 20:38:23 2016 (r296113)
@@ -29,10 +29,17 @@
union IEEEl2bits {
long double e;
struct {
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+ unsigned int manl :32;
+ unsigned int manh :20;
+ unsigned int exp :11;
+ unsigned int sign :1;
+#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
unsigned int sign :1;
unsigned int exp :11;
unsigned int manh :20;
unsigned int manl :32;
+#endif
} bits;
};
Modified: head/lib/libc/powerpc/gen/infinity.c
==============================================================================
--- head/lib/libc/powerpc/gen/infinity.c Fri Feb 26 20:33:32 2016 (r296112)
+++ head/lib/libc/powerpc/gen/infinity.c Fri Feb 26 20:38:23 2016 (r296113)
@@ -11,7 +11,20 @@ __FBSDID("$FreeBSD$");
#include <math.h>
/* bytes for +Infinity on powerpc */
-const union __infinity_un __infinity = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
+const union __infinity_un __infinity = {
+#if BYTE_ORDER == BIG_ENDIAN
+ { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
+#else
+ { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
+#endif
+};
/* bytes for NaN */
-const union __nan_un __nan = { { 0xff, 0xc0, 0, 0 } };
+const union __nan_un __nan = {
+#if BYTE_ORDER == BIG_ENDIAN
+ {0xff, 0xc0, 0, 0}
+#else
+ { 0, 0, 0xc0, 0xff }
+#endif
+};
+
Modified: head/lib/libc/powerpc64/_fpmath.h
==============================================================================
--- head/lib/libc/powerpc64/_fpmath.h Fri Feb 26 20:33:32 2016 (r296112)
+++ head/lib/libc/powerpc64/_fpmath.h Fri Feb 26 20:38:23 2016 (r296113)
@@ -29,10 +29,17 @@
union IEEEl2bits {
long double e;
struct {
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+ unsigned int manl :32;
+ unsigned int manh :20;
+ unsigned int exp :11;
+ unsigned int sign :1;
+#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
unsigned int sign :1;
unsigned int exp :11;
unsigned int manh :20;
unsigned int manl :32;
+#endif
} bits;
};
Modified: head/lib/libc/powerpc64/gen/infinity.c
==============================================================================
--- head/lib/libc/powerpc64/gen/infinity.c Fri Feb 26 20:33:32 2016 (r296112)
+++ head/lib/libc/powerpc64/gen/infinity.c Fri Feb 26 20:38:23 2016 (r296113)
@@ -11,7 +11,20 @@ __FBSDID("$FreeBSD$");
#include <math.h>
/* bytes for +Infinity on powerpc */
-const union __infinity_un __infinity = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } };
+const union __infinity_un __infinity = {
+#if BYTE_ORDER == BIG_ENDIAN
+ { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }
+#else
+ { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }
+#endif
+};
/* bytes for NaN */
-const union __nan_un __nan = { { 0xff, 0xc0, 0, 0 } };
+const union __nan_un __nan = {
+#if BYTE_ORDER == BIG_ENDIAN
+ {0xff, 0xc0, 0, 0}
+#else
+ { 0, 0, 0xc0, 0xff }
+#endif
+};
+
More information about the svn-src-all
mailing list