- 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 - gdtoa now performs all type aliasing through unions. -Wall has been added
to the GCC flags for the library to help verify this. to the GCC flags for the library to help verify this.
- Changed A_SpawnFly to do nothing if reactiontime is 0. Reactiontime was - 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_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${REL_CXX_FLAGS}" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${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 ) if( NOT NO_STRIP )
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s" ) set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s" )

View file

@ -35,22 +35,6 @@
#ifndef AUTOSEGS_H #ifndef AUTOSEGS_H
#define 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) #define REGMARKER(x) (x)
typedef void *REGINFO; typedef void *REGINFO;
@ -74,56 +58,45 @@ extern REGINFO MRegTail;
extern REGINFO YRegHead; extern REGINFO YRegHead;
extern REGINFO YRegTail; extern REGINFO YRegTail;
template<class T, REGINFO *_head, REGINFO *_tail> class FAutoSegIterator
class TAutoSegIteratorNoArrow
{ {
public: public:
TAutoSegIteratorNoArrow () FAutoSegIterator(REGINFO &head, REGINFO &tail)
{ {
// Weirdness. Mingw's linker puts these together backwards. // Weirdness. Mingw's linker puts these together backwards.
if (_head < _tail) if (&head <= &tail)
{ {
Head = _head; Head = &head;
Tail = _tail; Tail = &tail;
} }
else else
{ {
Head = _tail; Head = &tail;
Tail = _head; Tail = &head;
} }
Probe = (T *)REGMARKER(Head); Probe = Head;
} }
operator T () const REGINFO operator*() const
{ {
return *Probe; return *Probe;
} }
TAutoSegIteratorNoArrow &operator++() FAutoSegIterator &operator++()
{ {
do do
{ {
++Probe; ++Probe;
} while (*Probe == 0 && Probe < (T *)REGMARKER(Tail)); } while (*Probe == 0 && Probe < Tail);
return *this; return *this;
} }
void Reset () void Reset()
{ {
Probe = (T *)REGMARKER(Head); Probe = Head;
} }
protected: protected:
T *Probe; REGINFO *Probe;
REGINFO *Head; REGINFO *Head;
REGINFO *Tail; REGINFO *Tail;
}; };
template<class T, REGINFO *head, REGINFO *tail>
class TAutoSegIterator : public TAutoSegIteratorNoArrow<T, head, tail>
{
public:
T operator->() const
{
return *(this->Probe);
}
};
#endif #endif

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -71,11 +71,11 @@ void PClass::StaticInit ()
} }
qsort (head + 1, tail - head - 1, sizeof(REGINFO), cregcmp); 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); assert (MyClass != NULL);

View file

@ -155,9 +155,9 @@ enum
struct PalEntry struct PalEntry
{ {
PalEntry () {} PalEntry () {}
PalEntry (DWORD argb) { *(DWORD *)this = argb; } PalEntry (DWORD argb) { d = argb; }
operator DWORD () const { return *(DWORD *)this; } operator DWORD () const { return d; }
PalEntry &operator= (DWORD other) { *(DWORD *)this = other; return *this; } 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; } 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 WORDS_BIGENDIAN
PalEntry (BYTE ir, BYTE ig, BYTE ib) : a(0), r(ir), g(ig), b(ib) {} PalEntry (BYTE ir, BYTE ig, BYTE ib) : a(0), r(ir), g(ig), b(ib) {}
@ -166,7 +166,14 @@ struct PalEntry
#else #else
PalEntry (BYTE ir, BYTE ig, BYTE ib) : b(ib), g(ig), r(ir), a(0) {} 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) {} PalEntry (BYTE ia, BYTE ir, BYTE ig, BYTE ib) : b(ib), g(ig), r(ir), a(ia) {}
BYTE b,g,r,a; union
{
struct
{
BYTE b,g,r,a;
};
DWORD d;
};
#endif #endif
}; };
@ -187,4 +194,20 @@ char ( &_ArraySizeHelper( T (&array)[N] ))[N];
#define countof( array ) (sizeof( _ArraySizeHelper( array ) )) #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 #endif

View file

@ -150,7 +150,7 @@ void F_StartFinale (const char *music, int musicorder, int cdtrack, unsigned int
if (ending) if (ending)
{ {
FinaleSequence = *((WORD *)&level.nextmap[6]); FinaleSequence = level.EndSequence;
if (EndSequences[FinaleSequence].EndType == END_Chess) if (EndSequences[FinaleSequence].EndType == END_Chess)
{ {
TEXTSPEED = 3; // Slow the text to its original rate to match the music. 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 // [RH] Don't automatically advance end-of-game messages
if (interrupt) if (interrupt)
{ {
FinaleSequence = *((WORD *)&level.nextmap[6]); FinaleSequence = level.EndSequence;
if (EndSequences[FinaleSequence].EndType == END_Cast) if (EndSequences[FinaleSequence].EndType == END_Cast)
{ {
F_StartCast (); 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 QWORD SWAP_QWORD(QWORD x) { return _byteswap_uint64(x); }
static inline void SWAP_DOUBLE(double &dst, double &src) static inline void SWAP_DOUBLE(double &dst, double &src)
{ {
union twiddle { QWORD q; double d; } *tdst = (twiddle *)&dst, *tsrc = (twiddle *)&src; union twiddle { QWORD q; double d; } tdst, tsrc;
tdst->q = _byteswap_uint64(tsrc->q); tsrc.d = src;
tdst.q = _byteswap_uint64(tsrc.q);
dst = tdst.d;
} }
#else #else
static inline WORD SWAP_WORD(WORD x) { return (((x)<<8) | ((x)>>8)); } 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) 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; DWORD t;
t = tsrc->d[0];
tdst->d[0] = SWAP_DWORD(tsrc->d[1]); tsrc.f = src;
tdst->d[1] = SWAP_DWORD(t); t = tsrc.d[0];
tdst.d[0] = SWAP_DWORD(tsrc.d[1]);
tdst.d[1] = SWAP_DWORD(t);
dst = tdst.f;
} }
#endif #endif
static inline void SWAP_FLOAT(float &x) static inline void SWAP_FLOAT(float &x)
{ {
union twiddle { DWORD i; float f; } *t = (twiddle *)&x; union twiddle { DWORD i; float f; } t;
t->i = SWAP_DWORD(t->i); t.f = x;
t.i = SWAP_DWORD(t.i);
x = t.f;
} }
#endif #endif
@ -1278,11 +1285,11 @@ int FArchive::ReadSprite ()
Read (&name, 4); Read (&name, 4);
hint = ReadCount (); hint = ReadCount ();
if (hint >= NumStdSprites || *(DWORD *)&sprites[hint].name != name) if (hint >= NumStdSprites || sprites[hint].dwName != name)
{ {
for (hint = NumStdSprites; hint-- != 0; ) for (hint = NumStdSprites; hint-- != 0; )
{ {
if (*(DWORD *)&sprites[hint].name == name) if (sprites[hint].dwName == name)
{ {
break; break;
} }

View file

@ -36,7 +36,7 @@
#include "doomtype.h" #include "doomtype.h"
#include "doomdef.h" #include "doomdef.h"
#include "autosegs.h" //#include "autosegs.h"
#include "sc_man.h" #include "sc_man.h"
struct level_info_t; struct level_info_t;
@ -51,7 +51,7 @@ class FScanner;
#define GCC_YSEG #define GCC_YSEG
#else #else
#define MSVC_YSEG #define MSVC_YSEG
#define GCC_YSEG __attribute__((section(YREG_SECTION))) #define GCC_YSEG __attribute__((section(SECTION_YREG)))
#endif #endif
@ -355,7 +355,18 @@ struct FLevelLocals
int levelnum; int levelnum;
int lumpnum; int lumpnum;
FString LevelName; FString LevelName;
char mapname[256]; // the server name (base1, etc) 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 nextmap[9]; // go here when fraglimit is hit
char secretmap[9]; // map to go to when used secret exit char secretmap[9]; // map to go to when used secret exit

View file

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

View file

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

View file

@ -91,11 +91,6 @@ enum
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
SBarInfoCoordinate::SBarInfoCoordinate(int coord, bool relCenter) :
relCenter(relCenter), value(coord)
{
}
SBarInfoCoordinate &SBarInfoCoordinate::Add(int add) SBarInfoCoordinate &SBarInfoCoordinate::Add(int add)
{ {
value += add; value += add;
@ -756,7 +751,7 @@ void DSBarInfo::doCommands(SBarInfoBlock &block, int xOffset, int yOffset, int a
{ {
drawingFont = cmd.font; 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)) else if((cmd.flags & DRAWSELECTEDINVENTORY_ALTERNATEONEMPTY))
@ -785,7 +780,7 @@ void DSBarInfo::doCommands(SBarInfoBlock &block, int xOffset, int yOffset, int a
{ {
drawingFont = cmd.font; 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; break;
} }
case SBARINFO_DRAWBAR: case SBARINFO_DRAWBAR:

View file

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

View file

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

View file

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

View file

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

View file

@ -1070,7 +1070,11 @@ struct spriteframe_t
// //
struct spritedef_t struct spritedef_t
{ {
char name[5]; union
{
char name[5];
DWORD dwName;
};
BYTE numframes; BYTE numframes;
WORD spriteframes; WORD spriteframes;
}; };

View file

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

View file

@ -13,7 +13,13 @@ struct FResourceLump
int LumpSize; int LumpSize;
char * FullName; // only valid for files loaded from a .zip file char * FullName; // only valid for files loaded from a .zip file
char Name[9]; 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; BYTE Flags;
SBYTE RefCount; SBYTE RefCount;
char * Cache; char * Cache;

View file

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

View file

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

View file

@ -417,7 +417,7 @@ FPropertyInfo *FindProperty(const char * string)
// //
//========================================================================== //==========================================================================
AFuncDesc * FindFunction(const char * string) AFuncDesc *FindFunction(const char * string)
{ {
int min = 0, max = AFTable.Size()-1; int min = 0, max = AFTable.Size()-1;
@ -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 // 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(); properties.ShrinkToFit();
qsort(&properties[0], properties.Size(), sizeof(properties[0]), propcmp); qsort(&properties[0], properties.Size(), sizeof(properties[0]), propcmp);
@ -553,11 +553,11 @@ void InitThingdef()
// Create a sorted list of native action functions // 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(); AFTable.ShrinkToFit();
qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp); qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp);
@ -565,11 +565,11 @@ void InitThingdef()
// Create a sorted list of native variables // 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(); variables.ShrinkToFit();
qsort(&variables[0], variables.Size(), sizeof(variables[0]), varcmp); qsort(&variables[0], variables.Size(), sizeof(variables[0]), varcmp);

View file

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

View file

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

View file

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

View file

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

View file

@ -369,7 +369,11 @@ int FWadCollection::GetNumWads () const
int FWadCollection::CheckNumForName (const char *name, int space) int FWadCollection::CheckNumForName (const char *name, int space)
{ {
char uname[8]; union
{
char uname[8];
QWORD qname;
};
DWORD i; DWORD i;
if (name == NULL) if (name == NULL)
@ -391,7 +395,7 @@ int FWadCollection::CheckNumForName (const char *name, int space)
{ {
FResourceLump *lump = LumpInfo[i].lump; FResourceLump *lump = LumpInfo[i].lump;
if (*(QWORD *)&lump->Name == *(QWORD *)&uname) if (lump->qwName == qname)
{ {
if (lump->Namespace == space) break; if (lump->Namespace == space) break;
// If the lump is from one of the special namespaces exclusive to Zips // 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) int FWadCollection::CheckNumForName (const char *name, int space, int wadnum, bool exact)
{ {
FResourceLump *lump; FResourceLump *lump;
char uname[8]; union
{
char uname[8];
QWORD qname;
};
DWORD i; DWORD i;
if (wadnum < 0) if (wadnum < 0)
@ -426,7 +434,7 @@ int FWadCollection::CheckNumForName (const char *name, int space, int wadnum, bo
// also those in earlier WADs. // also those in earlier WADs.
while (i != NULL_INDEX && while (i != NULL_INDEX &&
(lump = LumpInfo[i].lump, *(QWORD *)&lump->Name != *(QWORD *)&uname || (lump = LumpInfo[i].lump, lump->qwName != qname ||
lump->Namespace != space || lump->Namespace != space ||
(exact? (LumpInfo[i].wadnum != wadnum) : (LumpInfo[i].wadnum > wadnum)) )) (exact? (LumpInfo[i].wadnum != wadnum) : (LumpInfo[i].wadnum > wadnum)) ))
{ {
@ -738,7 +746,7 @@ void FWadCollection::RenameSprites ()
// some frames need to be renamed. // some frames need to be renamed.
if (LumpInfo[i].lump->Namespace == ns_sprites) 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; MNTRZfound = true;
break; break;
@ -757,9 +765,9 @@ void FWadCollection::RenameSprites ()
{ {
for (int j = 0; j < numrenames; ++j) 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) if (gameinfo.gametype == GAME_Hexen)
@ -774,7 +782,7 @@ void FWadCollection::RenameSprites ()
if (!MNTRZfound) 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') 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 // the same blood states can be used everywhere
if (!(gameinfo.gametype & GAME_DoomChex)) 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');
} }
} }
} }
@ -807,7 +815,11 @@ void FWadCollection::RenameSprites ()
int FWadCollection::FindLump (const char *name, int *lastlump, bool anyns) int FWadCollection::FindLump (const char *name, int *lastlump, bool anyns)
{ {
char name8[8]; union
{
char name8[8];
QWORD qname;
};
LumpRecord *lump_p; LumpRecord *lump_p;
uppercopy (name8, name); uppercopy (name8, name);
@ -817,8 +829,7 @@ int FWadCollection::FindLump (const char *name, int *lastlump, bool anyns)
{ {
FResourceLump *lump = lump_p->lump; FResourceLump *lump = lump_p->lump;
if ((anyns || lump->Namespace == ns_global) && if ((anyns || lump->Namespace == ns_global) && lump->qwName == qname)
*(QWORD *)&lump->Name == *(QWORD *)&name8)
{ {
int lump = int(lump_p - &LumpInfo[0]); int lump = int(lump_p - &LumpInfo[0]);
*lastlump = lump + 1; *lastlump = lump + 1;

View file

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

View file

@ -1293,7 +1293,7 @@ bool FDInputJoystickManager::IsXInputDeviceFast(const GUID *guid)
cbSize = rdi.cbSize = sizeof(rdi); cbSize = rdi.cbSize = sizeof(rdi);
if (MyGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &rdi, &cbSize) >= 0) 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]; char name[256];
UINT namelen = countof(name); UINT namelen = countof(name);

View file

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

View file

@ -5,26 +5,41 @@
struct CPUInfo // 92 bytes struct CPUInfo // 92 bytes
{ {
char VendorID[16]; union
char CPUString[48]; {
char VendorID[16];
DWORD dwVendorID[4];
};
union
{
char CPUString[48];
DWORD dwCPUString[12];
};
BYTE Stepping; union
BYTE Model; {
BYTE Family; struct
BYTE Type; {
BYTE Stepping;
BYTE Model;
BYTE Family;
BYTE Type;
BYTE BrandIndex; BYTE BrandIndex;
BYTE CLFlush; BYTE CLFlush;
BYTE CPUCount; BYTE CPUCount;
BYTE APICID; BYTE APICID;
DWORD bSSE3:1; DWORD bSSE3:1;
DWORD DontCare1:8; DWORD DontCare1:8;
DWORD bSSSE3:1; DWORD bSSSE3:1;
DWORD DontCare1a:9; DWORD DontCare1a:9;
DWORD bSSE41:1; DWORD bSSE41:1;
DWORD bSSE42:1; DWORD bSSE42:1;
DWORD DontCare2a:11; DWORD DontCare2a:11;
};
DWORD FeatureFlags[3];
};
DWORD bFPU:1; DWORD bFPU:1;
DWORD bVME:1; DWORD bVME:1;
@ -71,10 +86,17 @@ struct CPUInfo // 92 bytes
BYTE AMDFamily; BYTE AMDFamily;
BYTE bIsAMD; BYTE bIsAMD;
BYTE DataL1LineSize; union
BYTE DataL1LinesPerTag; {
BYTE DataL1Associativity; struct
BYTE DataL1SizeKB; {
BYTE DataL1LineSize;
BYTE DataL1LinesPerTag;
BYTE DataL1Associativity;
BYTE DataL1SizeKB;
};
DWORD AMD_DataL1Info;
};
}; };