1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-23 11:18:54 +00:00

Make unions in PowerPC libc endian-safe.

This commit is contained in:
Nathan Whitehorn 2016-02-26 20:38:23 +00:00
parent 81e802c14b
commit 97a5390e6d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296113
4 changed files with 44 additions and 4 deletions

View File

@ -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;
};

View File

@ -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
};

View File

@ -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;
};

View File

@ -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
};