mirror of
https://git.planet-casio.com/Lephenixnoir/OpenLibm.git
synced 2025-04-03 17:17:13 +02:00
Avoid redefining endianness macros with some gcc versions
_LITTLE_ENDIAN and _BIG_ENDIAN are built-in on some platforms/versions. Better use __ORDER_LITTLE_ENDIAN__, __ORDER_BIG_ENDIAN__ and __BYTE_ORDER__, which are standard for gcc and clang, and define them when they are missing. Also remove the special-case for FreeBSD, which is apprently not needed.
This commit is contained in:
parent
949c530994
commit
b5ca785d4c
4 changed files with 27 additions and 42 deletions
53
src/fpmath.h
53
src/fpmath.h
|
@ -41,57 +41,42 @@
|
|||
#include "powerpc_fpmath.h"
|
||||
#endif
|
||||
|
||||
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
|
||||
|
||||
/* Definitions provided directly by GCC and Clang. */
|
||||
#define _LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
|
||||
#define _BIG_ENDIAN __ORDER_BIG_ENDIAN__
|
||||
#define _PDP_ENDIAN __ORDER_PDP_ENDIAN__
|
||||
#define _BYTE_ORDER __BYTE_ORDER__
|
||||
#if !(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__))
|
||||
|
||||
#elif defined(__GLIBC__)
|
||||
#if defined(__GLIBC__)
|
||||
|
||||
#include <features.h>
|
||||
#include <endian.h>
|
||||
#define _LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||
#define _BIG_ENDIAN __BIG_ENDIAN
|
||||
#define _PDP_ENDIAN __PDP_ENDIAN
|
||||
#define _BYTE_ORDER __BYTE_ORDER
|
||||
#define __ORDER_LITTLE_ENDIAN__ __LITTLE_ENDIAN
|
||||
#define __ORDER_BIG_ENDIAN__ __BIG_ENDIAN
|
||||
#define __BYTE_ORDER__ __BYTE_ORDER
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
#include <machine/endian.h>
|
||||
#define _LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
#define _BIG_ENDIAN BIG_ENDIAN
|
||||
#define _PDP_ENDIAN PDP_ENDIAN
|
||||
#define _BYTE_ORDER BYTE_ORDER
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
#include <machine/endian.h>
|
||||
#define __ORDER_LITTLE_ENDIAN__ LITTLE_ENDIAN
|
||||
#define __ORDER_BIG_ENDIAN__ BIG_ENDIAN
|
||||
#define __BYTE_ORDER__ BYTE_ORDER
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#define _LITTLE_ENDIAN 1234
|
||||
#define _BIG_ENDIAN 4321
|
||||
#define _PDP_ENDIAN 3412
|
||||
#define _BYTE_ORDER _LITTLE_ENDIAN
|
||||
#define _FLOAT_WORD_ORDER _LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define BIG_ENDIAN _BIG_ENDIAN
|
||||
#define PDP_ENDIAN _PDP_ENDIAN
|
||||
#define BYTE_ORDER _BYTE_ORDER
|
||||
#define __ORDER_LITTLE_ENDIAN__ 1234
|
||||
#define __ORDER_BIG_ENDIAN__ 4321
|
||||
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _IEEE_WORD_ORDER
|
||||
#define _IEEE_WORD_ORDER _BYTE_ORDER
|
||||
#endif /* __BYTE_ORDER__, __ORDER_LITTLE_ENDIAN__ and __ORDER_BIG_ENDIAN__ */
|
||||
|
||||
#ifndef __FLOAT_WORD_ORDER__
|
||||
#define __FLOAT_WORD_ORDER__ __BYTE_ORDER__
|
||||
#endif
|
||||
|
||||
union IEEEf2bits {
|
||||
float f;
|
||||
struct {
|
||||
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
unsigned int man :23;
|
||||
unsigned int exp :8;
|
||||
unsigned int sign :1;
|
||||
|
@ -109,14 +94,14 @@ union IEEEf2bits {
|
|||
union IEEEd2bits {
|
||||
double d;
|
||||
struct {
|
||||
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#if __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
unsigned int manl :32;
|
||||
#endif
|
||||
unsigned int manh :20;
|
||||
unsigned int exp :11;
|
||||
unsigned int sign :1;
|
||||
#if _IEEE_WORD_ORDER == _BIG_ENDIAN
|
||||
#if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
unsigned int manl :32;
|
||||
#endif
|
||||
#else /* _BIG_ENDIAN */
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
* ints.
|
||||
*/
|
||||
|
||||
#if _IEEE_WORD_ORDER == _BIG_ENDIAN
|
||||
#if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
|
||||
typedef union
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ typedef union
|
|||
|
||||
#endif
|
||||
|
||||
#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
|
||||
#if __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
typedef union
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#ifndef _MATH_PRIVATE_OPENBSD_H_
|
||||
#define _MATH_PRIVATE_OPENBSD_H_
|
||||
|
||||
#if _IEEE_WORD_ORDER == _BIG_ENDIAN
|
||||
#if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
|
||||
typedef union
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ typedef union
|
|||
|
||||
#endif
|
||||
|
||||
#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
|
||||
#if __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
typedef union
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ do { \
|
|||
/* A union which permits us to convert between a long double and
|
||||
three 32 bit ints. */
|
||||
|
||||
#if _IEEE_WORD_ORDER == _BIG_ENDIAN
|
||||
#if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
|
||||
typedef union
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ typedef union
|
|||
|
||||
#endif
|
||||
|
||||
#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
|
||||
#if __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
typedef union
|
||||
{
|
||||
|
|
|
@ -78,7 +78,7 @@ __scan_nan(u_int32_t *words, int num_words, const char *s)
|
|||
;
|
||||
|
||||
/* Scan backwards, filling in the bits in words[] as we go. */
|
||||
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
for (bitpos = 0; bitpos < 32 * num_words; bitpos += 4) {
|
||||
#else
|
||||
for (bitpos = 32 * num_words - 4; bitpos >= 0; bitpos -= 4) {
|
||||
|
@ -98,7 +98,7 @@ nan(const char *s)
|
|||
} u;
|
||||
|
||||
__scan_nan(u.bits, 2, s);
|
||||
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
u.bits[1] |= 0x7ff80000;
|
||||
#else
|
||||
u.bits[0] |= 0x7ff80000;
|
||||
|
|
Loading…
Add table
Reference in a new issue