Make unions in PowerPC libc endian-safe.
This commit is contained in:
parent
81e802c14b
commit
97a5390e6d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296113
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user