OSDN Git Service

Fixup byte order handling. Not all architectures define __BIG_ENDIAN__ so i.e.
authorEric Andersen <andersen@codepoet.org>
Wed, 14 Dec 2005 02:33:36 +0000 (02:33 -0000)
committerEric Andersen <andersen@codepoet.org>
Wed, 14 Dec 2005 02:33:36 +0000 (02:33 -0000)
on big endian mips the code is compiled as little-endian and the wrong half of
the 64-bit point value is examined to check for NaN, etc.  This bug also broke
fpclassify(), isfinite(), isnormal(), isinf(), finite(), and signbit().

14 files changed:
libc/string/sh64/memset.S
libc/string/sh64/strcpy.S
libc/sysdeps/linux/sh/bits/kernel_stat.h
libm/fp_private.h
libm/powerpc/s_ceil.c
libm/powerpc/s_floor.c
libm/powerpc/s_frexp.c
libm/powerpc/s_ldexp.c
libm/powerpc/s_logb.c
libm/powerpc/s_modf.c
libm/powerpc/s_rint.c
libm/powerpc/s_round.c
libm/powerpc/s_trunc.c
libm/powerpc/w_scalb.c

index e167923..d878797 100644 (file)
@@ -9,7 +9,9 @@
 ! Copyright 2002 SuperH Ltd.
 !
 
-#ifdef __LITTLE_ENDIAN__
+#include <endian.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define SHHI shlld
 #define SHLO shlrd
 #else
index faa071c..f662cc8 100644 (file)
@@ -6,7 +6,9 @@
 !
 ! SH5 code Copyright 2002 SuperH Ltd.
 
-#ifdef __LITTLE_ENDIAN__
+#include <endian.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define SHHI shlld
 #define SHLO shlrd
 #else
@@ -67,7 +69,7 @@ no_lddst:
        add r5, r63, r4
        addi r0, 8, r0
 shortstring:
-#ifndef __LITTLE_ENDIAN__
+#if __BYTE_ORDER != __LITTLE_ENDIAN
        pta/l shortstring2,tr1
        byterev r4,r4
 #endif
index cd81846..c841b0c 100644 (file)
@@ -30,10 +30,10 @@ struct kernel_stat {
 };
 
 struct kernel_stat64 {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
        unsigned char   __pad0b[6];
        unsigned short  st_dev;
-#elif defined(__LITTLE_ENDIAN__)
+#elif (__BYTE_ORDER == __LITTLE_ENDIAN)
        unsigned short  st_dev;
        unsigned char   __pad0b[6];
 #else
@@ -48,7 +48,7 @@ struct kernel_stat64 {
        unsigned long   st_uid;
        unsigned long   st_gid;
 
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
        unsigned char   __pad3b[6];
        unsigned short  st_rdev;
 #else /* Must be little */
@@ -60,7 +60,7 @@ struct kernel_stat64 {
        long long       st_size;
        unsigned long   st_blksize;
 
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
        unsigned long   __pad4;         /* Future possible st_blocks hi bits */
        unsigned long   st_blocks;      /* Number 512-byte blocks allocated. */
 #else /* Must be little */
index 505400e..0ddb616 100644 (file)
 *******************************************************************************/
 
 #include <stdint.h>
+#include <endian.h>
 
 typedef struct                   /*      Hex representation of a double.      */
       {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
       uint32_t high;
       uint32_t low;
 #else
index fd073de..f6680ee 100644 (file)
 *                                                                              *
 *******************************************************************************/
 
+#include <endian.h>
+
 static const double        twoTo52  = 4503599627370496.0;
 static const unsigned long signMask = 0x80000000ul;
 
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
        unsigned long int hi;
        unsigned long int lo;
 #else
index 94677b4..0ddbb9b 100644 (file)
 *                                                                              *
 *******************************************************************************/
 
+#include <endian.h>
+
 static const double        twoTo52  = 4503599627370496.0;
 static const unsigned long signMask = 0x80000000ul;
 
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
        unsigned long int hi;
        unsigned long int lo;
 #else
index 9909f2c..7c998f8 100644 (file)
 
 #include <limits.h>
 #include <math.h>
+#include <endian.h>
 
 static const double two54 =  1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
 
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
         unsigned long int hi;
         unsigned long int lo;
 #else
index ce9ec8b..7e52352 100644 (file)
 
 #include <limits.h>
 #include <math.h>
+#include <endian.h>
 
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
         unsigned long int hi;
         unsigned long int lo;
 #else
index 23c7270..3caecd9 100644 (file)
 *     Standard 754.                                                            *
 *******************************************************************************/
 
+#include <endian.h>
+
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
         unsigned long int hi;
         unsigned long int lo;
 #else
index f4344bd..cb8338a 100644 (file)
 
 #include <limits.h>
 #include <math.h>
+#include <endian.h>
 
 #define      SET_INVALID      0x01000000UL
 
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
         unsigned long int hi;
         unsigned long int lo;
 #else
index 72c4834..c229515 100644 (file)
 
 #include <limits.h>
 #include <math.h>
+#include <endian.h>
 
 #define      SET_INVALID      0x01000000UL
 
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
         unsigned long int hi;
         unsigned long int lo;
 #else
index 81f4d0f..a0f72eb 100644 (file)
@@ -1,10 +1,11 @@
 #include <limits.h>
 #include <math.h>
+#include <endian.h>
 
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
         unsigned long int hi;
         unsigned long int lo;
 #else
index 4b61355..7db7606 100644 (file)
@@ -1,10 +1,11 @@
 #include <limits.h>
 #include <math.h>
+#include <endian.h>
 
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
         unsigned long int hi;
         unsigned long int lo;
 #else
index c93c74b..fe23ece 100644 (file)
 **
 ***********************************************************************/
 
+#include <endian.h>
+
 typedef union
       {
       struct {
-#if defined(__BIG_ENDIAN__)
+#if (__BYTE_ORDER == __BIG_ENDIAN)
         unsigned long int hi;
         unsigned long int lo;
 #else