From 3f003e06db9aa22af243def51bdb34566c24d196 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 31 Aug 2009 21:47:29 +0000 Subject: [PATCH] - Replaced the use of autoconf's WORDS_BIGENDIAN with __BIG_ENDIAN__, since latter comes predefined by GCC. SVN r1779 (trunk) --- docs/rh-log.txt | 6 +++++- src/basictypes.h | 2 +- src/doomdef.h | 2 +- src/doomtype.h | 2 +- src/farchive.cpp | 2 +- src/g_strife/strife_sbar.cpp | 2 +- src/m_swap.h | 4 ++-- src/md5.cpp | 2 +- src/textures/ddstexture.cpp | 2 +- src/textures/pcxtexture.cpp | 2 -- src/textures/tgatexture.cpp | 8 -------- src/timidity/instrum_sf2.cpp | 2 +- src/v_pfx.cpp | 10 +++++----- src/win32/i_crash.cpp | 2 +- tools/zipdir/zipdir.c | 2 +- 15 files changed, 22 insertions(+), 28 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 10807c7b7a..621461fba2 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ -August 29, 2009 (Changes by Graf Zahl) +August 31, 2009 +- Replaced the use of autoconf's WORDS_BIGENDIAN with __BIG_ENDIAN__, since + latter comes predefined by GCC. + +August 29, 2009 (Changes by Graf Zahl) - fixed: R_InitColormaps was broken since the resource file code rewrite. - fixed: WIF_STAFF2_KICKBACK did not work anymore because it depended on conditions that were changed some time ago. diff --git a/src/basictypes.h b/src/basictypes.h index 98b44c9d69..37d7aec75a 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -60,7 +60,7 @@ union QWORD_UNION QWORD AsOne; struct { -#ifdef WORDS_BIG_ENDIAN +#ifdef __BIG_ENDIAN__ unsigned int Hi, Lo; #else unsigned int Lo, Hi; diff --git a/src/doomdef.h b/src/doomdef.h index 108435605c..3892e8001b 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -347,7 +347,7 @@ enum #define BLINKTHRESHOLD (4*32) -#ifndef WORDS_BIGENDIAN +#ifndef __BIG_ENDIAN__ #define MAKE_ID(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24)) #else #define MAKE_ID(a,b,c,d) ((d)|((c)<<8)|((b)<<16)|((a)<<24)) diff --git a/src/doomtype.h b/src/doomtype.h index 2748f18273..7757a3cc6a 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -159,7 +159,7 @@ struct PalEntry operator uint32 () const { return d; } PalEntry &operator= (uint32 other) { d = other; return *this; } PalEntry InverseColor() const { PalEntry nc; nc.a = a; nc.r = 255 - r; nc.g = 255 - g; nc.b = 255 - b; return nc; } -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ PalEntry (BYTE ir, BYTE ig, BYTE ib) : a(0), r(ir), g(ig), b(ib) {} PalEntry (BYTE ia, BYTE ir, BYTE ig, BYTE ib) : a(ia), r(ir), g(ig), b(ib) {} union diff --git a/src/farchive.cpp b/src/farchive.cpp index 9a4692cf27..1a6fba5bf8 100644 --- a/src/farchive.cpp +++ b/src/farchive.cpp @@ -79,7 +79,7 @@ #define NEW_SPRITE ((BYTE)11) // A new sprite name follows #define OLD_SPRITE ((BYTE)12) // Reference to an old sprite name follows -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ static inline WORD SWAP_WORD(x) { return x; } static inline DWORD SWAP_DWORD(x) { return x; } static inline QWORD SWAP_QWORD(x) { return x; } diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index 7066282eb1..8469e1947f 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -172,7 +172,7 @@ void FHealthBar::MakeTexture () void FHealthBar::FillBar (int min, int max, BYTE light, BYTE dark) { -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ SDWORD fill = (light << 24) | (dark << 16) | (light << 8) | dark; #else SDWORD fill = light | (dark << 8) | (light << 16) | (dark << 24); diff --git a/src/m_swap.h b/src/m_swap.h index deaa52ae7a..8379461b4b 100644 --- a/src/m_swap.h +++ b/src/m_swap.h @@ -27,7 +27,7 @@ // Endianess handling. // WAD files are stored little endian. -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ // Swap 16bit, that is, MSB and LSB byte. // No masking with 0xFF should be necessary. @@ -122,6 +122,6 @@ inline int BigLong (int x) } #endif -#endif // WORDS_BIGENDIAN +#endif // __BIG_ENDIAN__ #endif // __M_SWAP_H__ diff --git a/src/md5.cpp b/src/md5.cpp index 11d41d5775..481774c7ac 100644 --- a/src/md5.cpp +++ b/src/md5.cpp @@ -21,7 +21,7 @@ #include "md5.h" #include "templates.h" -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ void byteSwap(DWORD *buf, unsigned words) { BYTE *p = (BYTE *)buf; diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 52258e8c90..82b96db051 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -231,7 +231,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum) data.Seek (4, SEEK_SET); data.Read (&surfdesc, sizeof(surfdesc)); -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ // Every single element of the header is a DWORD for (unsigned int i = 0; i < sizeof(DDSURFACEDESC2) / 4; ++i) { diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index e04bfa37ec..283550a956 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -125,11 +125,9 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum) return NULL; } -#ifdef WORDS_BIGENDIAN hdr.xmin = LittleShort(hdr.xmin); hdr.xmax = LittleShort(hdr.xmax); hdr.bytesPerScanLine = LittleShort(hdr.bytesPerScanLine); -#endif if (hdr.manufacturer != 10 || hdr.encoding != 1) return NULL; if (hdr.version != 0 && hdr.version != 2 && hdr.version != 3 && hdr.version != 4 && hdr.version != 5) return NULL; diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index c77ff264dc..595cef5222 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -114,10 +114,8 @@ FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum) file.Seek(0, SEEK_SET); file.Read(&hdr, sizeof(hdr)); -#ifdef WORDS_BIGENDIAN hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); -#endif // Not much that can be done here because TGA does not have a proper // header to be identified with. @@ -130,10 +128,8 @@ FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum) file.Seek(0, SEEK_SET); file.Read(&hdr, sizeof(hdr)); -#ifdef WORDS_BIGENDIAN hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); -#endif return new FTGATexture(lumpnum, &hdr); } @@ -303,12 +299,10 @@ void FTGATexture::MakeTexture () lump.Read(&hdr, sizeof(hdr)); lump.Seek(hdr.id_len, SEEK_CUR); -#ifdef WORDS_BIGENDIAN hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); hdr.cm_first = LittleShort(hdr.cm_first); hdr.cm_length = LittleShort(hdr.cm_length); -#endif if (hdr.has_cm) { @@ -507,12 +501,10 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int w, int h, i if (w < 0 || w > Width) w = Width; if (h < 0 || h > Height) h = Height; -#ifdef WORDS_BIGENDIAN hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); hdr.cm_first = LittleShort(hdr.cm_first); hdr.cm_length = LittleShort(hdr.cm_length); -#endif if (hdr.has_cm) { diff --git a/src/timidity/instrum_sf2.cpp b/src/timidity/instrum_sf2.cpp index f8dc79f98e..5064c9fe11 100644 --- a/src/timidity/instrum_sf2.cpp +++ b/src/timidity/instrum_sf2.cpp @@ -587,7 +587,7 @@ static void ParseGen(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen) { gen->Oper = read_uword(f); gen->uAmount = read_uword(f); -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ if (gen->Oper == GEN_keyRange || gen->Oper == GEN_velRange) { // Reswap range generators diff --git a/src/v_pfx.cpp b/src/v_pfx.cpp index ce510d1953..2bc41266fd 100644 --- a/src/v_pfx.cpp +++ b/src/v_pfx.cpp @@ -360,7 +360,7 @@ static void Scale8 (BYTE *src, int srcpitch, { DWORD work; -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ work = src[xf >> FRACBITS] << 24; xf += xstep; work |= src[xf >> FRACBITS] << 16; xf += xstep; work |= src[xf >> FRACBITS] << 8; xf += xstep; @@ -416,7 +416,7 @@ static void Convert8 (BYTE *src, int srcpitch, for (savedx = x, x >>= 2; x != 0; x--) { *(DWORD *)dest = -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ (GPfxPal.Pal8[src[0]] << 24) | (GPfxPal.Pal8[src[1]] << 16) | (GPfxPal.Pal8[src[2]] << 8) | @@ -454,7 +454,7 @@ static void Convert8 (BYTE *src, int srcpitch, { DWORD work; -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ work = GPfxPal.Pal8[src[xf >> FRACBITS]] << 24; xf += xstep; work |= GPfxPal.Pal8[src[xf >> FRACBITS]] << 16; xf += xstep; work |= GPfxPal.Pal8[src[xf >> FRACBITS]] << 8; xf += xstep; @@ -510,7 +510,7 @@ static void Convert16 (BYTE *src, int srcpitch, for (savedx = x, x >>= 1; x != 0; x--) { *(DWORD *)dest = -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ (GPfxPal.Pal16[src[0]] << 16) | (GPfxPal.Pal16[src[1]]); #else @@ -544,7 +544,7 @@ static void Convert16 (BYTE *src, int srcpitch, { DWORD work; -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ work = GPfxPal.Pal16[src[xf >> FRACBITS]] << 16; xf += xstep; work |= GPfxPal.Pal16[src[xf >> FRACBITS]]; xf += xstep; #else diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp index 496c6189c6..5996be87a1 100644 --- a/src/win32/i_crash.cpp +++ b/src/win32/i_crash.cpp @@ -88,7 +88,7 @@ // Maximum number of files that might appear in a crash report. #define MAX_FILES 5 -#ifndef WORDS_BIGENDIAN +#ifndef __BIG_ENDIAN__ #define MAKE_ID(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24)) #else #define MAKE_ID(a,b,c,d) ((d)|((c)<<8)|((b)<<16)|((a)<<24)) diff --git a/tools/zipdir/zipdir.c b/tools/zipdir/zipdir.c index 193b707e1d..9080b2d2a3 100644 --- a/tools/zipdir/zipdir.c +++ b/tools/zipdir/zipdir.c @@ -58,7 +58,7 @@ #define __cdecl #endif -#ifndef WORDS_BIGENDIAN +#ifndef __BIG_ENDIAN__ #define MAKE_ID(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24)) #define LittleShort(x) (x) #define LittleLong(x) (x)