- Removed -fno-strict-aliasing from the GCC flags for ZDoom and fixed the

issues that caused its inclusion. Is an optimized GCC build any faster
  for being able to use strict aliasing rules? I dunno. It's still slower
  than a VC++ build.
  
  I did run into two cases where TAutoSegIterator caused intractable problems
  with breaking strict aliasing rules, so I removed the templating from it,
  and the caller is now responsible for casting the probe value from void *.
- Removed #include "autosegs.h" from several files that did not need it
  (in particular, dobject.h when not compiling with VC++).


SVN r1743 (trunk)
This commit is contained in:
Randy Heit 2009-08-02 03:38:57 +00:00
parent d3792c2291
commit 93202a5488
35 changed files with 298 additions and 189 deletions

View file

@ -1,4 +1,16 @@
July 31, 2009
August 1, 2009
- Removed -fno-strict-aliasing from the GCC flags for ZDoom and fixed the
issues that caused its inclusion. Is an optimized GCC build any faster
for being able to use strict aliasing rules? I dunno. It's still slower
than a VC++ build.
I did run into two cases where TAutoSegIterator caused intractable problems
with breaking strict aliasing rules, so I removed the templating from it,
and the caller is now responsible for casting the probe value from void *.
July 31, 2009
- Removed #include "autosegs.h" from several files that did not need it
(in particular, dobject.h when not compiling with VC++).
- gdtoa now performs all type aliasing through unions. -Wall has been added
to the GCC flags for the library to help verify this.
- Changed A_SpawnFly to do nothing if reactiontime is 0. Reactiontime was

View file

@ -324,7 +324,14 @@ if( CMAKE_COMPILER_IS_GNUCXX )
set( CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${REL_CXX_FLAGS}" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${REL_CXX_FLAGS}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused -fno-strict-aliasing" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused" )
# Remove extra warnings when using the official DirectX headers.
# Also, TDM-GCC 4.4.0 no longer accepts glibc-style printf formats as valid,
# which is a royal pain. The previous version I had been using was fine with them.
if( WIN32 )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-comment -Wno-format" )
endif( WIN32 )
if( NOT NO_STRIP )
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s" )

View file

@ -35,22 +35,6 @@
#ifndef AUTOSEGS_H
#define AUTOSEGS_H
#ifdef __GNUC__
#ifdef __MACH__
#define AREG_SECTION "__DATA,areg"
#define CREG_SECTION "__DATA,creg"
#define GREG_SECTION "__DATA,greg"
#define MREG_SECTION "__DATA,mreg"
#define YREG_SECTION "__DATA,yreg"
#else
#define AREG_SECTION "areg"
#define CREG_SECTION "creg"
#define GREG_SECTION "greg"
#define MREG_SECTION "mreg"
#define YREG_SECTION "yreg"
#endif
#endif
#define REGMARKER(x) (x)
typedef void *REGINFO;
@ -74,56 +58,45 @@ extern REGINFO MRegTail;
extern REGINFO YRegHead;
extern REGINFO YRegTail;
template<class T, REGINFO *_head, REGINFO *_tail>
class TAutoSegIteratorNoArrow
class FAutoSegIterator
{
public:
TAutoSegIteratorNoArrow ()
FAutoSegIterator(REGINFO &head, REGINFO &tail)
{
// Weirdness. Mingw's linker puts these together backwards.
if (_head < _tail)
if (&head <= &tail)
{
Head = _head;
Tail = _tail;
Head = &head;
Tail = &tail;
}
else
{
Head = _tail;
Tail = _head;
Head = &tail;
Tail = &head;
}
Probe = (T *)REGMARKER(Head);
Probe = Head;
}
operator T () const
REGINFO operator*() const
{
return *Probe;
}
TAutoSegIteratorNoArrow &operator++()
FAutoSegIterator &operator++()
{
do
{
++Probe;
} while (*Probe == 0 && Probe < (T *)REGMARKER(Tail));
} while (*Probe == 0 && Probe < Tail);
return *this;
}
void Reset()
{
Probe = (T *)REGMARKER(Head);
Probe = Head;
}
protected:
T *Probe;
REGINFO *Probe;
REGINFO *Head;
REGINFO *Tail;
};
template<class T, REGINFO *head, REGINFO *tail>
class TAutoSegIterator : public TAutoSegIteratorNoArrow<T, head, tail>
{
public:
T operator->() const
{
return *(this->Probe);
}
};
#endif

View file

@ -86,11 +86,13 @@ void *YRegHead = 0;
#elif defined(__GNUC__)
void *ARegHead __attribute__((section(AREG_SECTION))) = 0;
void *CRegHead __attribute__((section(CREG_SECTION))) = 0;
void *GRegHead __attribute__((section(GREG_SECTION))) = 0;
void *MRegHead __attribute__((section(MREG_SECTION))) = 0;
void *YRegHead __attribute__((section(YREG_SECTION))) = 0;
#include "doomtype.h"
void *ARegHead __attribute__((section(SECTION_AREG))) = 0;
void *CRegHead __attribute__((section(SECTION_CREG))) = 0;
void *GRegHead __attribute__((section(SECTION_GREG))) = 0;
void *MRegHead __attribute__((section(SECTION_MREG))) = 0;
void *YRegHead __attribute__((section(SECTION_YREG))) = 0;
#else

View file

@ -58,11 +58,13 @@ void *YRegTail = 0;
#elif defined(__GNUC__)
void *ARegTail __attribute__((section(AREG_SECTION))) = 0;
void *CRegTail __attribute__((section(CREG_SECTION))) = 0;
void *GRegTail __attribute__((section(GREG_SECTION))) = 0;
void *MRegTail __attribute__((section(MREG_SECTION))) = 0;
void *YRegTail __attribute__((section(YREG_SECTION))) = 0;
#include "doomtype.h"
void *ARegTail __attribute__((section(SECTION_AREG))) = 0;
void *CRegTail __attribute__((section(SECTION_CREG))) = 0;
void *GRegTail __attribute__((section(SECTION_GREG))) = 0;
void *MRegTail __attribute__((section(SECTION_MREG))) = 0;
void *YRegTail __attribute__((section(SECTION_YREG))) = 0;
#else

View file

@ -9,6 +9,7 @@ union FMD5Holder
{
BYTE Bytes[16];
DWORD DWords[4];
hash_t Hash;
};
struct FCompatValues
@ -21,7 +22,7 @@ struct FMD5HashTraits
{
hash_t Hash(const FMD5Holder key)
{
return *(hash_t *)key.Bytes;
return key.Hash;
}
int Compare(const FMD5Holder left, const FMD5Holder right)
{

View file

@ -36,9 +36,6 @@
#include <stdlib.h>
#include "doomtype.h"
#ifndef _MSC_VER
#include "autosegs.h"
#endif
struct PClass;
@ -146,7 +143,7 @@ struct ClassReg
const size_t *Pointers;
void (*ConstructNative)(void *);
void RegisterClass();
void RegisterClass() const;
};
enum EInPlace { EC_InPlace };
@ -177,7 +174,7 @@ private: \
# pragma data_seg()
# define _DECLARE_TI(cls) __declspec(allocate(".creg$u")) ClassReg *cls::RegistrationInfoPtr = &cls::RegistrationInfo;
#else
# define _DECLARE_TI(cls) ClassReg *cls::RegistrationInfoPtr __attribute__((section(CREG_SECTION))) = &cls::RegistrationInfo;
# define _DECLARE_TI(cls) ClassReg *cls::RegistrationInfoPtr __attribute__((section(SECTION_CREG))) = &cls::RegistrationInfo;
#endif
#define _IMP_PCLASS(cls,ptrs,create) \
@ -323,7 +320,17 @@ namespace GC
// Unroots an object.
void DelSoftRoot(DObject *obj);
template<class T> void Mark(T *&obj) { Mark((DObject **)&obj); }
template<class T> void Mark(T *&obj)
{
union
{
T *t;
DObject *o;
};
o = obj;
Mark(&o);
obj = t;
}
template<class T> void Mark(TObjPtr<T> &obj);
}
@ -334,6 +341,7 @@ template<class T>
class TObjPtr
{
T *p;
DObject *o; // For GC::Mark below to make GCC's strict aliasing happy
public:
TObjPtr() throw()
{
@ -398,6 +406,7 @@ public:
}
template<class U> friend inline FArchive &operator<<(FArchive &arc, TObjPtr<U> &o);
template<class U> friend inline void GC::Mark(TObjPtr<U> &obj);
friend class DObject;
};
@ -413,7 +422,10 @@ template<class T,class U> inline T barrier_cast(TObjPtr<U> &o)
return static_cast<T>(static_cast<U *>(o));
}
template<class T> void GC::Mark(TObjPtr<T> &obj) { GC::Mark((DObject **)&obj); }
template<class T> inline void GC::Mark(TObjPtr<T> &obj)
{
GC::Mark(&obj.o);
}
class DObject
{

View file

@ -270,7 +270,7 @@ void Mark(DObject **obj)
{
if (lobj->ObjectFlags & OF_EuthanizeMe)
{
*obj = NULL;
*obj = (DObject *)NULL;
}
else if (lobj->IsWhite())
{

View file

@ -71,11 +71,11 @@ void PClass::StaticInit ()
}
qsort (head + 1, tail - head - 1, sizeof(REGINFO), cregcmp);
TAutoSegIterator<ClassReg *, &CRegHead, &CRegTail> probe;
FAutoSegIterator probe(CRegHead, CRegTail);
while (++probe != NULL)
while (*++probe != NULL)
{
probe->RegisterClass ();
((ClassReg *)*probe)->RegisterClass ();
}
}
@ -153,7 +153,7 @@ void PClass::StaticFreeData (PClass *type)
}
}
void ClassReg::RegisterClass ()
void ClassReg::RegisterClass () const
{
assert (MyClass != NULL);

View file

@ -155,9 +155,9 @@ enum
struct PalEntry
{
PalEntry () {}
PalEntry (DWORD argb) { *(DWORD *)this = argb; }
operator DWORD () const { return *(DWORD *)this; }
PalEntry &operator= (DWORD other) { *(DWORD *)this = other; return *this; }
PalEntry (DWORD argb) { d = argb; }
operator DWORD () const { return d; }
PalEntry &operator= (DWORD 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
PalEntry (BYTE ir, BYTE ig, BYTE ib) : a(0), r(ir), g(ig), b(ib) {}
@ -166,7 +166,14 @@ struct PalEntry
#else
PalEntry (BYTE ir, BYTE ig, BYTE ib) : b(ib), g(ig), r(ir), a(0) {}
PalEntry (BYTE ia, BYTE ir, BYTE ig, BYTE ib) : b(ib), g(ig), r(ir), a(ia) {}
union
{
struct
{
BYTE b,g,r,a;
};
DWORD d;
};
#endif
};
@ -187,4 +194,20 @@ char ( &_ArraySizeHelper( T (&array)[N] ))[N];
#define countof( array ) (sizeof( _ArraySizeHelper( array ) ))
// Auto-registration sections for GCC.
// Apparently, you cannot do string concatenation inside section attributes.
#ifdef __MACH__
#define SECTION_AREG "__DATA,areg"
#define SECTION_CREG "__DATA,creg"
#define SECTION_GREG "__DATA,greg"
#define SECTION_MREG "__DATA,mreg"
#define SECTION_YREG "__DATA,yreg"
#else
#define SECTION_AREG "areg"
#define SECTION_CREG "creg"
#define SECTION_GREG "greg"
#define SECTION_MREG "mreg"
#define SECTION_YREG "yreg"
#endif
#endif

View file

@ -150,7 +150,7 @@ void F_StartFinale (const char *music, int musicorder, int cdtrack, unsigned int
if (ending)
{
FinaleSequence = *((WORD *)&level.nextmap[6]);
FinaleSequence = level.EndSequence;
if (EndSequences[FinaleSequence].EndType == END_Chess)
{
TEXTSPEED = 3; // Slow the text to its original rate to match the music.
@ -244,7 +244,7 @@ void F_Ticker ()
// [RH] Don't automatically advance end-of-game messages
if (interrupt)
{
FinaleSequence = *((WORD *)&level.nextmap[6]);
FinaleSequence = level.EndSequence;
if (EndSequences[FinaleSequence].EndType == END_Cast)
{
F_StartCast ();

View file

@ -92,8 +92,10 @@ static inline DWORD SWAP_DWORD(DWORD x) { return _byteswap_ulong(x); }
static inline QWORD SWAP_QWORD(QWORD x) { return _byteswap_uint64(x); }
static inline void SWAP_DOUBLE(double &dst, double &src)
{
union twiddle { QWORD q; double d; } *tdst = (twiddle *)&dst, *tsrc = (twiddle *)&src;
tdst->q = _byteswap_uint64(tsrc->q);
union twiddle { QWORD q; double d; } tdst, tsrc;
tsrc.d = src;
tdst.q = _byteswap_uint64(tsrc.q);
dst = tdst.d;
}
#else
static inline WORD SWAP_WORD(WORD x) { return (((x)<<8) | ((x)>>8)); }
@ -108,17 +110,22 @@ static inline QWORD SWAP_QWORD(QWORD x)
}
static inline void SWAP_DOUBLE(double &dst, double &src)
{
union twiddle { double f; DWORD d[2]; } *tdst = (twiddle *)&dst, *tsrc = (twiddle *)&src;
union twiddle { double f; DWORD d[2]; } tdst, tsrc;
DWORD t;
t = tsrc->d[0];
tdst->d[0] = SWAP_DWORD(tsrc->d[1]);
tdst->d[1] = SWAP_DWORD(t);
tsrc.f = src;
t = tsrc.d[0];
tdst.d[0] = SWAP_DWORD(tsrc.d[1]);
tdst.d[1] = SWAP_DWORD(t);
dst = tdst.f;
}
#endif
static inline void SWAP_FLOAT(float &x)
{
union twiddle { DWORD i; float f; } *t = (twiddle *)&x;
t->i = SWAP_DWORD(t->i);
union twiddle { DWORD i; float f; } t;
t.f = x;
t.i = SWAP_DWORD(t.i);
x = t.f;
}
#endif
@ -1278,11 +1285,11 @@ int FArchive::ReadSprite ()
Read (&name, 4);
hint = ReadCount ();
if (hint >= NumStdSprites || *(DWORD *)&sprites[hint].name != name)
if (hint >= NumStdSprites || sprites[hint].dwName != name)
{
for (hint = NumStdSprites; hint-- != 0; )
{
if (*(DWORD *)&sprites[hint].name == name)
if (sprites[hint].dwName == name)
{
break;
}

View file

@ -36,7 +36,7 @@
#include "doomtype.h"
#include "doomdef.h"
#include "autosegs.h"
//#include "autosegs.h"
#include "sc_man.h"
struct level_info_t;
@ -51,7 +51,7 @@ class FScanner;
#define GCC_YSEG
#else
#define MSVC_YSEG
#define GCC_YSEG __attribute__((section(YREG_SECTION)))
#define GCC_YSEG __attribute__((section(SECTION_YREG)))
#endif
@ -355,7 +355,18 @@ struct FLevelLocals
int levelnum;
int lumpnum;
FString LevelName;
union
{
char mapname[256]; // the server name (base1, etc)
// The endsequence is embedded in the name so that it can be
// carried around as a name. The first 6 character ought to
// match the string "enDSeQ".
struct
{
char pad[6];
WORD EndSequence;
};
};
char nextmap[9]; // go here when fraglimit is hit
char secretmap[9]; // map to go to when used secret exit

View file

@ -50,6 +50,7 @@
#include "p_acs.h"
#include "doomstat.h"
#include "d_player.h"
#include "autosegs.h"
int FindEndSequence (int type, const char *picname);
@ -1434,14 +1435,14 @@ void FMapInfoParser::ParseMapDefinition(level_info_t &info)
}
else
{
TAutoSegIterator<FMapOptInfo*, &YRegHead, &YRegTail> probe;
FAutoSegIterator probe(YRegHead, YRegTail);
bool success = false;
while (++probe != NULL)
while (*++probe != NULL)
{
if (sc.Compare(probe->name))
if (sc.Compare(((FMapOptInfo *)(*probe))->name))
{
probe->handler(*this, &info);
((FMapOptInfo *)(*probe))->handler(*this, &info);
success = true;
break;
}

View file

@ -55,9 +55,6 @@ class FScanner;
class SBarInfoCoordinate
{
public:
SBarInfoCoordinate() {}
SBarInfoCoordinate(int coord, bool relCenter);
SBarInfoCoordinate &Add(int add);
int Coordinate() const { return value; }
bool RelCenter() const { return relCenter; }
@ -132,8 +129,16 @@ struct SBarInfoCommand
int type;
int special;
union
{
int special2;
SBarInfoCoordinate sbcoord2;
};
union
{
int special3;
SBarInfoCoordinate sbcoord3;
};
int special4;
int flags;
SBarInfoCoordinate x;

View file

@ -91,11 +91,6 @@ enum
////////////////////////////////////////////////////////////////////////////////
SBarInfoCoordinate::SBarInfoCoordinate(int coord, bool relCenter) :
relCenter(relCenter), value(coord)
{
}
SBarInfoCoordinate &SBarInfoCoordinate::Add(int add)
{
value += add;
@ -756,7 +751,7 @@ void DSBarInfo::doCommands(SBarInfoBlock &block, int xOffset, int yOffset, int a
{
drawingFont = cmd.font;
}
DrawNumber(CPlayer->mo->InvSel->Amount, 3, *(SBarInfoCoordinate*)&cmd.special2, *(SBarInfoCoordinate*)&cmd.special3, xOffset, yOffset, alpha, block.fullScreenOffsets, cmd.translation, cmd.special4, false, !!(cmd.flags & DRAWSELECTEDINVENTORY_DRAWSHADOW));
DrawNumber(CPlayer->mo->InvSel->Amount, 3, cmd.sbcoord2, cmd.sbcoord3, xOffset, yOffset, alpha, block.fullScreenOffsets, cmd.translation, cmd.special4, false, !!(cmd.flags & DRAWSELECTEDINVENTORY_DRAWSHADOW));
}
}
else if((cmd.flags & DRAWSELECTEDINVENTORY_ALTERNATEONEMPTY))
@ -785,7 +780,7 @@ void DSBarInfo::doCommands(SBarInfoBlock &block, int xOffset, int yOffset, int a
{
drawingFont = cmd.font;
}
DrawInventoryBar(cmd.special, cmd.value, cmd.x, cmd.y, xOffset, yOffset, alpha, block.fullScreenOffsets, alwaysshow, *(SBarInfoCoordinate*)&cmd.special2, *(SBarInfoCoordinate*)&cmd.special3, cmd.translation, artibox, noarrows, alwaysshowcounter, bgalpha);
DrawInventoryBar(cmd.special, cmd.value, cmd.x, cmd.y, xOffset, yOffset, alpha, block.fullScreenOffsets, alwaysshow, cmd.sbcoord2, cmd.sbcoord3, cmd.translation, artibox, noarrows, alwaysshowcounter, bgalpha);
break;
}
case SBARINFO_DRAWBAR:

View file

@ -765,12 +765,12 @@ void SBarInfo::ParseSBarInfoBlock(FScanner &sc, SBarInfoBlock &block)
sc.MustGetToken(',');
}
this->getCoordinates(sc, block.fullScreenOffsets, cmd.x, cmd.y);
*(SBarInfoCoordinate*)&cmd.special2 = cmd.x + 30;
*(SBarInfoCoordinate*)&cmd.special3 = cmd.y + 24;
cmd.sbcoord2 = cmd.x + 30;
cmd.sbcoord3 = cmd.y + 24;
cmd.translation = CR_GOLD;
if(sc.CheckToken(',')) //more font information
{
this->getCoordinates(sc, block.fullScreenOffsets, *(SBarInfoCoordinate*)&cmd.special2, *(SBarInfoCoordinate*)&cmd.special3);
this->getCoordinates(sc, block.fullScreenOffsets, cmd.sbcoord2, cmd.sbcoord3);
if(sc.CheckToken(','))
{
sc.MustGetToken(TK_Identifier);
@ -847,12 +847,12 @@ void SBarInfo::ParseSBarInfoBlock(FScanner &sc, SBarInfoBlock &block)
sc.MustGetToken(',');
this->getCoordinates(sc, block.fullScreenOffsets, cmd.x, cmd.y);
*(SBarInfoCoordinate*)&cmd.special2 = cmd.x + 26;
*(SBarInfoCoordinate*)&cmd.special3 = cmd.y + 22;
cmd.sbcoord2 = cmd.x + 26;
cmd.sbcoord3 = cmd.y + 22;
cmd.translation = CR_GOLD;
if(sc.CheckToken(',')) //more font information
{
this->getCoordinates(sc, block.fullScreenOffsets, *(SBarInfoCoordinate*)&cmd.special2, *(SBarInfoCoordinate*)&cmd.special3);
this->getCoordinates(sc, block.fullScreenOffsets, cmd.sbcoord2, cmd.sbcoord3);
if(sc.CheckToken(','))
{
sc.MustGetToken(TK_Identifier);

View file

@ -3152,6 +3152,9 @@ void M_ButtonHandler(EMenuKey key, bool repeat)
PlayerRotation ^= 8;
}
break;
default:
break; // Keep GCC quiet
}
}
@ -3204,6 +3207,9 @@ static void M_SaveLoadButtonHandler(EMenuKey key)
M_SaveSelect (SelSaveGame);
}
break;
default:
break; // Keep GCC quiet
}
}

View file

@ -2169,6 +2169,9 @@ void M_OptButtonHandler(EMenuKey key, bool repeat)
switch (key)
{
default:
break; // Keep GCC quiet
case MKEY_Down:
if (CurrentMenu->numitems > 1)
{
@ -3289,7 +3292,7 @@ void UpdateJoystickMenu(IJoystickConfig *selected)
break;
}
}
if (i == Joysticks.Size())
if (i == (int)Joysticks.Size())
{
SELECTED_JOYSTICK = NULL;
if (CurrentMenu == &JoystickConfigMenu)

View file

@ -41,6 +41,7 @@
#include "m_swap.h"
#include "mus2midi.h"
#include "doomdef.h"
static const BYTE StaticMIDIhead[] =
{ 'M','T','h','d', 0, 0, 0, 6,
@ -52,7 +53,7 @@ static const BYTE StaticMIDIhead[] =
0, 255, 81, 3, 0x07, 0xa1, 0x20
};
static const BYTE MUSMagic[4] = { 'M','U','S',0x1a };
static const DWORD MUSMagic = MAKE_ID('M','U','S',0x1a);
static const BYTE CtrlTranslate[15] =
{
@ -122,7 +123,7 @@ bool ProduceMIDI (const BYTE *musBuf, TArray<BYTE> &outFile)
long trackLen;
// Do some validation of the MUS file
if (*(DWORD *)MUSMagic != musHead->Magic)
if (MUSMagic != musHead->Magic)
return false;
if (LittleShort(musHead->NumChans) > 15)

View file

@ -1069,8 +1069,12 @@ struct spriteframe_t
// a number of animation frames.
//
struct spritedef_t
{
union
{
char name[5];
DWORD dwName;
};
BYTE numframes;
WORD spriteframes;
};

View file

@ -347,7 +347,7 @@ void R_InitSpriteDefs ()
FTexture *tex = TexMan.ByIndex(i);
if (tex->UseType == FTexture::TEX_Sprite && strlen(tex->Name) >= 6)
{
DWORD bucket = *(DWORD *)tex->Name % max;
DWORD bucket = tex->dwName % max;
hashes[i].Next = hashes[bucket].Head;
hashes[bucket].Head = i;
}
@ -363,14 +363,14 @@ void R_InitSpriteDefs ()
}
maxframe = -1;
intname = *(DWORD *)sprites[i].name;
intname = sprites[i].dwName;
// scan the lumps, filling in the frames for whatever is found
int hash = hashes[intname % max].Head;
while (hash != -1)
{
FTexture *tex = TexMan[hash];
if (*(DWORD *)tex->Name == intname)
if (tex->dwName == intname)
{
R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false);
@ -673,7 +673,7 @@ void R_InitSkins (void)
{
char name[9];
Wads.GetLumpName (name, base+1);
intname = *(DWORD *)name;
memcpy(&intname, name, 4);
}
int basens = Wads.GetLumpNamespace(base);
@ -703,8 +703,10 @@ void R_InitSkins (void)
for (k = base + 1; Wads.GetLumpNamespace(k) == basens; k++)
{
char lname[9];
DWORD lnameint;
Wads.GetLumpName (lname, k);
if (*(DWORD *)lname == intname)
memcpy(&lnameint, lname, 4);
if (lnameint == intname)
{
FTextureID picnum = TexMan.CreateTexture(k, FTexture::TEX_SkinSprite);
R_InstallSpriteLump (picnum, lname[4] - 'A', lname[5], false);

View file

@ -13,7 +13,13 @@ struct FResourceLump
int LumpSize;
char * FullName; // only valid for files loaded from a .zip file
union
{
char Name[9];
DWORD dwName; // These are for accessing the first 4 or 8 chars of
QWORD qwName; // Name as a unit without breaking strict aliasing rules
};
BYTE Flags;
SBYTE RefCount;
char * Cache;

View file

@ -101,7 +101,11 @@ public:
int SourceLump;
union
{
char Name[9];
DWORD dwName; // Used with sprites
};
BYTE UseType; // This texture's primary purpose
BYTE bNoDecals:1; // Decals should not stick to texture

View file

@ -178,7 +178,6 @@ struct AFuncDesc
AFuncDesc *FindFunction(const char * string);
void ParseStates(FScanner &sc, FActorInfo *actor, AActor *defaults, Baggage &bag);
PSymbolActionFunction *FindGlobalActionFunction(const char *name);
@ -250,11 +249,11 @@ enum EDefinitionType
#define GCC_MSEG
#else
#define MSVC_ASEG
#define GCC_ASEG __attribute__((section(AREG_SECTION)))
#define GCC_ASEG __attribute__((section(SECTION_AREG)))
#define MSVC_PSEG
#define GCC_PSEG __attribute__((section(GREG_SECTION)))
#define GCC_PSEG __attribute__((section(SECTION_GREG)))
#define MSVC_MSEG
#define GCC_MSEG __attribute__((section(MREG_SECTION)))
#define GCC_MSEG __attribute__((section(SECTION_MREG)))
#endif

View file

@ -444,7 +444,7 @@ AFuncDesc * FindFunction(const char * string)
//==========================================================================
//
// Find a varIABLE by name using a binary search
// Find a variable by name using a binary search
//
//==========================================================================
@ -541,11 +541,11 @@ void InitThingdef()
// Create a sorted list of properties
{
TAutoSegIterator<FPropertyInfo *, &GRegHead, &GRegTail> probe;
FAutoSegIterator probe(GRegHead, GRegTail);
while (++probe != NULL)
while (*++probe != NULL)
{
properties.Push(probe);
properties.Push((FPropertyInfo *)*probe);
}
properties.ShrinkToFit();
qsort(&properties[0], properties.Size(), sizeof(properties[0]), propcmp);
@ -553,11 +553,11 @@ void InitThingdef()
// Create a sorted list of native action functions
{
TAutoSegIterator<AFuncDesc *, &ARegHead, &ARegTail> probe;
FAutoSegIterator probe(ARegHead, ARegTail);
while (++probe != NULL)
while (*++probe != NULL)
{
AFTable.Push(*probe);
AFTable.Push(*(AFuncDesc *)*probe);
}
AFTable.ShrinkToFit();
qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp);
@ -565,11 +565,11 @@ void InitThingdef()
// Create a sorted list of native variables
{
TAutoSegIterator<FVariableInfo *, &MRegHead, &MRegTail> probe;
FAutoSegIterator probe(MRegHead, MRegTail);
while (++probe != NULL)
while (*++probe != NULL)
{
variables.Push(probe);
variables.Push((FVariableInfo *)*probe);
}
variables.ShrinkToFit();
qsort(&variables[0], variables.Size(), sizeof(variables[0]), varcmp);

View file

@ -49,7 +49,6 @@
#include "p_lnspec.h"
#include "doomstat.h"
#include "thingdef_exp.h"
#include "autosegs.h"
int testglobalvar = 1337; // just for having one global variable to test with
DEFINE_GLOBAL_VARIABLE(testglobalvar)

View file

@ -48,7 +48,6 @@
#include "templates.h"
#include "v_palette.h"
#include "doomerrors.h"
#include "autosegs.h"
#include "i_system.h"
#include "thingdef_exp.h"
#include "w_wad.h"
@ -311,7 +310,7 @@ static void ParseVariable (FScanner &sc, PSymbolTable * symt, PClass *cls)
}
sc.MustGetToken(';');
FVariableInfo *vi = FindVariable(symname, cls);
const FVariableInfo *vi = FindVariable(symname, cls);
if (vi == NULL)
{
sc.ScriptError("Unknown native variable '%s'", symname.GetChars());
@ -746,7 +745,7 @@ static void ParseActionDef (FScanner &sc, PClass *cls)
};
bool error = false;
AFuncDesc *afd;
const AFuncDesc *afd;
FName funcname;
FString args;
TArray<FxExpression *> DefaultParams;

View file

@ -67,7 +67,6 @@
#include "r_translate.h"
#include "a_morph.h"
#include "colormatcher.h"
#include "autosegs.h"
//==========================================================================

View file

@ -39,7 +39,6 @@
*/
#include "actor.h"
#include "autosegs.h"
#include "info.h"
#include "sc_man.h"
#include "tarray.h"

View file

@ -368,8 +368,12 @@ int FWadCollection::GetNumWads () const
//==========================================================================
int FWadCollection::CheckNumForName (const char *name, int space)
{
union
{
char uname[8];
QWORD qname;
};
DWORD i;
if (name == NULL)
@ -391,7 +395,7 @@ int FWadCollection::CheckNumForName (const char *name, int space)
{
FResourceLump *lump = LumpInfo[i].lump;
if (*(QWORD *)&lump->Name == *(QWORD *)&uname)
if (lump->qwName == qname)
{
if (lump->Namespace == space) break;
// If the lump is from one of the special namespaces exclusive to Zips
@ -411,7 +415,11 @@ int FWadCollection::CheckNumForName (const char *name, int space)
int FWadCollection::CheckNumForName (const char *name, int space, int wadnum, bool exact)
{
FResourceLump *lump;
union
{
char uname[8];
QWORD qname;
};
DWORD i;
if (wadnum < 0)
@ -426,7 +434,7 @@ int FWadCollection::CheckNumForName (const char *name, int space, int wadnum, bo
// also those in earlier WADs.
while (i != NULL_INDEX &&
(lump = LumpInfo[i].lump, *(QWORD *)&lump->Name != *(QWORD *)&uname ||
(lump = LumpInfo[i].lump, lump->qwName != qname ||
lump->Namespace != space ||
(exact? (LumpInfo[i].wadnum != wadnum) : (LumpInfo[i].wadnum > wadnum)) ))
{
@ -738,7 +746,7 @@ void FWadCollection::RenameSprites ()
// some frames need to be renamed.
if (LumpInfo[i].lump->Namespace == ns_sprites)
{
if (*(DWORD *)LumpInfo[i].lump->Name == MAKE_ID('M', 'N', 'T', 'R') && LumpInfo[i].lump->Name[4] == 'Z' )
if (LumpInfo[i].lump->dwName == MAKE_ID('M', 'N', 'T', 'R') && LumpInfo[i].lump->Name[4] == 'Z' )
{
MNTRZfound = true;
break;
@ -757,9 +765,9 @@ void FWadCollection::RenameSprites ()
{
for (int j = 0; j < numrenames; ++j)
{
if (*(DWORD *)LumpInfo[i].lump->Name == renames[j*2])
if (LumpInfo[i].lump->dwName == renames[j*2])
{
*(DWORD *)LumpInfo[i].lump->Name = renames[j*2+1];
LumpInfo[i].lump->dwName = renames[j*2+1];
}
}
if (gameinfo.gametype == GAME_Hexen)
@ -774,7 +782,7 @@ void FWadCollection::RenameSprites ()
if (!MNTRZfound)
{
if (*(DWORD *)LumpInfo[i].lump->Name == MAKE_ID('M', 'N', 'T', 'R'))
if (LumpInfo[i].lump->dwName == MAKE_ID('M', 'N', 'T', 'R'))
{
if (LumpInfo[i].lump->Name[4] >= 'F' && LumpInfo[i].lump->Name[4] <= 'K')
{
@ -787,9 +795,9 @@ void FWadCollection::RenameSprites ()
// the same blood states can be used everywhere
if (!(gameinfo.gametype & GAME_DoomChex))
{
if (*(DWORD *)LumpInfo[i].lump->Name == MAKE_ID('B', 'L', 'O', 'D'))
if (LumpInfo[i].lump->dwName == MAKE_ID('B', 'L', 'O', 'D'))
{
*(DWORD *)LumpInfo[i].lump->Name = MAKE_ID('B', 'L', 'U', 'D');
LumpInfo[i].lump->dwName = MAKE_ID('B', 'L', 'U', 'D');
}
}
}
@ -806,8 +814,12 @@ void FWadCollection::RenameSprites ()
//==========================================================================
int FWadCollection::FindLump (const char *name, int *lastlump, bool anyns)
{
union
{
char name8[8];
QWORD qname;
};
LumpRecord *lump_p;
uppercopy (name8, name);
@ -817,8 +829,7 @@ int FWadCollection::FindLump (const char *name, int *lastlump, bool anyns)
{
FResourceLump *lump = lump_p->lump;
if ((anyns || lump->Namespace == ns_global) &&
*(QWORD *)&lump->Name == *(QWORD *)&name8)
if ((anyns || lump->Namespace == ns_global) && lump->qwName == qname)
{
int lump = int(lump_p - &LumpInfo[0]);
*lastlump = lump + 1;

View file

@ -732,8 +732,10 @@ HANDLE WriteTextReport ()
for (i = 0; i < 8; ++i)
{
Writef (file, "MM%d=%08x%08x\r\n", i, *(DWORD *)(&ctxt->FloatSave.RegisterArea[20*i+4]),
*(DWORD *)(&ctxt->FloatSave.RegisterArea[20*i]));
DWORD d0, d1;
memcpy(&d0, &ctxt->FloatSave.RegisterArea[20*i+4], sizeof(DWORD));
memcpy(&d1, &ctxt->FloatSave.RegisterArea[20*i], sizeof(DWORD));
Writef (file, "MM%d=%08x%08x\r\n", i, d0, d1);
}
#else
for (i = 0; i < 8; ++i)
@ -2115,7 +2117,9 @@ repeat:
{
if (i <= read - 4)
{
buff_p += mysnprintf (buff_p, buff_end - buff_p, " %08lx", *(DWORD *)&buf16[i]);
DWORD d;
memcpy(&d, &buf16[i], sizeof(d));
buff_p += mysnprintf (buff_p, buff_end - buff_p, " %08lx", d);
i += 4;
}
else

View file

@ -1293,7 +1293,7 @@ bool FDInputJoystickManager::IsXInputDeviceFast(const GUID *guid)
cbSize = rdi.cbSize = sizeof(rdi);
if (MyGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &rdi, &cbSize) >= 0)
{
if(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == guid->Data1)
if(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == (LONG)guid->Data1)
{
char name[256];
UINT namelen = countof(name);

View file

@ -73,9 +73,9 @@ haveid:
// Get vendor ID
__cpuid(foo, 0);
((int *)cpu->VendorID)[0] = foo[1];
((int *)cpu->VendorID)[1] = foo[3];
((int *)cpu->VendorID)[2] = foo[2];
cpu->VendorID[0] = foo[1];
cpu->VendorID[1] = foo[3];
cpu->VendorID[2] = foo[2];
if (foo[1] == MAKE_ID('A','u','t','h') &&
foo[3] == MAKE_ID('e','n','t','i') &&
foo[2] == MAKE_ID('c','A','M','D'))
@ -85,9 +85,9 @@ haveid:
// Get features flags and other info
__cpuid(foo, 1);
((int *)cpu)[17] = foo[1]; // Store brand index and other stuff
((int *)cpu)[18] = foo[2]; // Store extended feature flags
((int *)cpu)[19] = foo[3]; // Store feature flags
cpu->FeatureFlags[0] = foo[1]; // Store brand index and other stuff
cpu->FeatureFlags[1] = foo[2]; // Store extended feature flags
cpu->FeatureFlags[2] = foo[3]; // Store feature flags
// If CLFLUSH instruction is supported, get the real cache line size.
if (foo[3] & (1 << 19))
@ -115,9 +115,9 @@ haveid:
if (maxext >= 0x80000004)
{ // Get processor brand string.
__cpuid((int *)&cpu->CPUString[0], 0x80000002);
__cpuid((int *)&cpu->CPUString[16], 0x80000003);
__cpuid((int *)&cpu->CPUString[32], 0x80000004);
__cpuid((int *)&cpu->dwCPUString[0], 0x80000002);
__cpuid((int *)&cpu->dwCPUString[4], 0x80000003);
__cpuid((int *)&cpu->dwCPUString[8], 0x80000004);
}
if (cpu->bIsAMD)
@ -125,7 +125,7 @@ haveid:
if (maxext >= 0x80000005)
{ // Get data L1 cache info.
__cpuid(foo, 0x80000005);
*(int *)(&cpu->DataL1LineSize) = foo[2];
cpu->AMD_DataL1Info = foo[2];
}
if (maxext >= 0x80000001)
{ // Get AMD-specific feature flags.

View file

@ -4,10 +4,22 @@
#include "basictypes.h"
struct CPUInfo // 92 bytes
{
union
{
char VendorID[16];
DWORD dwVendorID[4];
};
union
{
char CPUString[48];
DWORD dwCPUString[12];
};
union
{
struct
{
BYTE Stepping;
BYTE Model;
BYTE Family;
@ -25,6 +37,9 @@ struct CPUInfo // 92 bytes
DWORD bSSE41:1;
DWORD bSSE42:1;
DWORD DontCare2a:11;
};
DWORD FeatureFlags[3];
};
DWORD bFPU:1;
DWORD bVME:1;
@ -71,11 +86,18 @@ struct CPUInfo // 92 bytes
BYTE AMDFamily;
BYTE bIsAMD;
union
{
struct
{
BYTE DataL1LineSize;
BYTE DataL1LinesPerTag;
BYTE DataL1Associativity;
BYTE DataL1SizeKB;
};
DWORD AMD_DataL1Info;
};
};
extern "C" CPUInfo CPU;