Bug 488747 - Fix endian handling in qcms. r=joe

This commit is contained in:
Jeff Muizelaar 2009-04-21 22:22:29 -04:00
Родитель dcd15d3bce
Коммит 90fcc20f84
2 изменённых файлов: 16 добавлений и 18 удалений

Просмотреть файл

@ -29,17 +29,13 @@
typedef uint32_t __be32;
typedef uint16_t __be16;
#if !defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
#error Unknown endianess
#endif
#if 0
not used yet
/* __builtin_bswap isn't available in older gccs
* so open code it for now */
static __be32 cpu_to_be32(int32_t v)
{
#ifdef LITTLE_ENDIAN
#ifdef IS_LITTLE_ENDIAN
return ((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | ((v & 0xff000000) >> 24);
//return __builtin_bswap32(v);
return v;
@ -49,7 +45,7 @@ static __be32 cpu_to_be32(int32_t v)
static uint32_t be32_to_cpu(__be32 v)
{
#ifdef LITTLE_ENDIAN
#ifdef IS_LITTLE_ENDIAN
return ((v & 0xff) << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | ((v & 0xff000000) >> 24);
//return __builtin_bswap32(v);
#else
@ -59,7 +55,7 @@ static uint32_t be32_to_cpu(__be32 v)
static uint32_t be16_to_cpu(__be16 v)
{
#ifdef LITTLE_ENDIAN
#ifdef IS_LITTLE_ENDIAN
return ((v & 0xff) << 8) | ((v & 0xff00) >> 8);
#else
return v;

Просмотреть файл

@ -5,15 +5,7 @@
#include "prtypes.h"
#if !defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
#ifdef IS_LITTLE_ENDIAN
#define LITTLE_ENDIAN
#endif
#ifdef IS_BIG_ENDIAN
#define BIG_ENDIAN
#endif
#endif
/* prtypes.h defines IS_LITTLE_ENDIAN and IS_BIG ENDIAN */
#if defined (__SVR4) && defined (__sun)
/* int_types.h gets included somehow, so avoid redefining the types differently */
@ -40,14 +32,24 @@ typedef PRUptrdiff uintptr_t;
#else // MOZ_QCMS
#if BYTE_ORDER == LITTLE_ENDIAN
#define IS_LITTLE_ENDIAN
#elif BYTE_ORDER == BIG_ENDIAN
#define IS_BIG_ENDIAN
#endif
/* all of the platforms that we use _MSC_VER on are little endian
* so this is sufficient for now */
#ifdef _MSC_VER
#define LITTLE_ENDIAN
#define IS_LITTLE_ENDIAN
#endif
#ifdef __OS2__
#define LITTLE_ENDIAN
#define IS_LITTLE_ENDIAN
#endif
#if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
#error Unknown endianess
#endif
#if defined (_SVR4) || defined (SVR4) || defined (__OpenBSD__) || defined (_sgi) || defined (__sun) || defined (sun) || defined (__digital__)