mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-19 19:59:09 +00:00
Mingw fixes for pnUtils.
This commit is contained in:
@ -63,6 +63,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#define HASHTABLEDECLSIZE(object,key,link,size) THashTableDecl<object, key, offsetof(object,link), size >
|
#define HASHTABLEDECLSIZE(object,key,link,size) THashTableDecl<object, key, offsetof(object,link), size >
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#define forceinline __forceinline
|
||||||
|
#else
|
||||||
|
#define forceinline inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Forward declarations
|
* Forward declarations
|
||||||
@ -76,6 +83,64 @@ template<class T>
|
|||||||
class TBaseHashTable;
|
class TBaseHashTable;
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* CHashValue
|
||||||
|
*
|
||||||
|
***/
|
||||||
|
|
||||||
|
class CHashValue {
|
||||||
|
private:
|
||||||
|
static const dword s_hashTable[];
|
||||||
|
|
||||||
|
dword m_result;
|
||||||
|
|
||||||
|
inline void Construct () { m_result = 0x325d1eae; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
static dword LookupHashBits (unsigned value) { ASSERT(value < 0x100); return s_hashTable[value]; }
|
||||||
|
|
||||||
|
inline CHashValue () { Construct() ; }
|
||||||
|
inline CHashValue (const CHashValue & source) { m_result = source.m_result; }
|
||||||
|
inline CHashValue (const void * data, unsigned bytes) { Construct(); Hash(data, bytes); }
|
||||||
|
inline CHashValue & operator= (const CHashValue & source) { m_result = source.m_result; return *this; }
|
||||||
|
inline bool operator== (const CHashValue & source) const { return (m_result == source.m_result); }
|
||||||
|
|
||||||
|
inline dword GetHash () const { return m_result; }
|
||||||
|
|
||||||
|
forceinline void Hash (const void * data, unsigned bytes);
|
||||||
|
forceinline void Hash8 (unsigned data);
|
||||||
|
forceinline void Hash16 (unsigned data);
|
||||||
|
forceinline void Hash32 (unsigned data);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void CHashValue::Hash (const void * data, unsigned bytes) {
|
||||||
|
for (const byte * curr = (const byte *)data, * term = curr + bytes; curr != term; ++curr)
|
||||||
|
Hash8(*curr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void CHashValue::Hash8 (unsigned data) {
|
||||||
|
m_result += s_hashTable[m_result >> 24] ^ (m_result >> 6) ^ s_hashTable[data & 0xff];
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void CHashValue::Hash16 (unsigned data) {
|
||||||
|
Hash8(data);
|
||||||
|
Hash8(data >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void CHashValue::Hash32 (unsigned data) {
|
||||||
|
Hash8(data);
|
||||||
|
Hash8(data >> 8);
|
||||||
|
Hash8(data >> 16);
|
||||||
|
Hash8(data >> 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* THashLink
|
* THashLink
|
||||||
@ -661,61 +726,3 @@ typedef THashKeyStr< wchar, THashKeyStrCmp<wchar> > CHashKeyStr;
|
|||||||
typedef THashKeyStr< wchar, THashKeyStrCmpI<wchar> > CHashKeyStrI;
|
typedef THashKeyStr< wchar, THashKeyStrCmpI<wchar> > CHashKeyStrI;
|
||||||
typedef THashKeyStr< char, THashKeyStrCmp<char> > CHashKeyStrChar;
|
typedef THashKeyStr< char, THashKeyStrCmp<char> > CHashKeyStrChar;
|
||||||
typedef THashKeyStr< char, THashKeyStrCmpI<char> > CHashKeyStrCharI;
|
typedef THashKeyStr< char, THashKeyStrCmpI<char> > CHashKeyStrCharI;
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* CHashValue
|
|
||||||
*
|
|
||||||
***/
|
|
||||||
|
|
||||||
class CHashValue {
|
|
||||||
private:
|
|
||||||
static const dword s_hashTable[];
|
|
||||||
|
|
||||||
dword m_result;
|
|
||||||
|
|
||||||
inline void Construct () { m_result = 0x325d1eae; }
|
|
||||||
|
|
||||||
public:
|
|
||||||
static dword LookupHashBits (unsigned value) { ASSERT(value < 0x100); return s_hashTable[value]; }
|
|
||||||
|
|
||||||
inline CHashValue () { Construct() ; }
|
|
||||||
inline CHashValue (const CHashValue & source) { m_result = source.m_result; }
|
|
||||||
inline CHashValue (const void * data, unsigned bytes) { Construct(); Hash(data, bytes); }
|
|
||||||
inline CHashValue & operator= (const CHashValue & source) { m_result = source.m_result; return *this; }
|
|
||||||
inline bool operator== (const CHashValue & source) const { return (m_result == source.m_result); }
|
|
||||||
|
|
||||||
inline dword GetHash () const { return m_result; }
|
|
||||||
|
|
||||||
__forceinline void Hash (const void * data, unsigned bytes);
|
|
||||||
__forceinline void Hash8 (unsigned data);
|
|
||||||
__forceinline void Hash16 (unsigned data);
|
|
||||||
__forceinline void Hash32 (unsigned data);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
void CHashValue::Hash (const void * data, unsigned bytes) {
|
|
||||||
for (const byte * curr = (const byte *)data, * term = curr + bytes; curr != term; ++curr)
|
|
||||||
Hash8(*curr);
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
void CHashValue::Hash8 (unsigned data) {
|
|
||||||
m_result += s_hashTable[m_result >> 24] ^ (m_result >> 6) ^ s_hashTable[data & 0xff];
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
void CHashValue::Hash16 (unsigned data) {
|
|
||||||
Hash8(data);
|
|
||||||
Hash8(data >> 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
void CHashValue::Hash32 (unsigned data) {
|
|
||||||
Hash8(data);
|
|
||||||
Hash8(data >> 8);
|
|
||||||
Hash8(data >> 16);
|
|
||||||
Hash8(data >> 24);
|
|
||||||
}
|
|
||||||
|
@ -79,7 +79,7 @@ void MachineGetName (wchar * computerName, unsigned length = 32);
|
|||||||
***/
|
***/
|
||||||
|
|
||||||
// used to dump the internal state of a module
|
// used to dump the internal state of a module
|
||||||
typedef void (__cdecl * FStateDump)(
|
typedef void (CDECL * FStateDump)(
|
||||||
void * param,
|
void * param,
|
||||||
const wchar fmt[],
|
const wchar fmt[],
|
||||||
...
|
...
|
||||||
|
@ -35,19 +35,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTREF_H
|
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNUTILS_PRIVATE_PNUTREF_H
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
*
|
|
||||||
* Debug macros
|
|
||||||
*
|
|
||||||
***/
|
|
||||||
|
|
||||||
#ifdef REFCOUNT_DEBUGGING
|
|
||||||
#define REFTRACE DEBUG_MSG
|
|
||||||
#else
|
|
||||||
#define REFTRACE NULL_STMT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* AtomicRef
|
* AtomicRef
|
||||||
@ -78,7 +65,9 @@ public:
|
|||||||
ASSERT(!zeroed);
|
ASSERT(!zeroed);
|
||||||
#endif
|
#endif
|
||||||
long prev = AtomicAdd(&m_ref, 1);
|
long prev = AtomicAdd(&m_ref, 1);
|
||||||
REFTRACE("Inc %p: %u", this, prev+1);
|
#ifdef REFCOUNT_DEBUGGING
|
||||||
|
DEBUG_MSG("Inc %p: %u", this, prev+1);
|
||||||
|
#endif
|
||||||
return prev+1;
|
return prev+1;
|
||||||
}
|
}
|
||||||
inline long IncRef (const char tag[]) {
|
inline long IncRef (const char tag[]) {
|
||||||
@ -86,7 +75,9 @@ public:
|
|||||||
ASSERT(!zeroed);
|
ASSERT(!zeroed);
|
||||||
#endif
|
#endif
|
||||||
long prev = AtomicAdd(&m_ref, 1);
|
long prev = AtomicAdd(&m_ref, 1);
|
||||||
REFTRACE("Inc %p %s: %u", this, tag, prev+1);
|
#ifdef REFCOUNT_DEBUGGING
|
||||||
|
DEBUG_MSG("Inc %p %s: %u", this, tag, prev+1);
|
||||||
|
#endif
|
||||||
return prev+1;
|
return prev+1;
|
||||||
}
|
}
|
||||||
inline long IncRef (unsigned n) {
|
inline long IncRef (unsigned n) {
|
||||||
@ -94,7 +85,9 @@ public:
|
|||||||
ASSERT(!zeroed);
|
ASSERT(!zeroed);
|
||||||
#endif
|
#endif
|
||||||
long prev = AtomicAdd(&m_ref, n);
|
long prev = AtomicAdd(&m_ref, n);
|
||||||
REFTRACE("Inc %p: %u", this, prev+n);
|
#ifdef REFCOUNT_DEBUGGING
|
||||||
|
DEBUG_MSG("Inc %p: %u", this, prev+n);
|
||||||
|
#endif
|
||||||
return prev+n;
|
return prev+n;
|
||||||
}
|
}
|
||||||
inline long IncRef (unsigned n, const char tag[]) {
|
inline long IncRef (unsigned n, const char tag[]) {
|
||||||
@ -102,7 +95,9 @@ public:
|
|||||||
ASSERT(!zeroed);
|
ASSERT(!zeroed);
|
||||||
#endif
|
#endif
|
||||||
long prev = AtomicAdd(&m_ref, n);
|
long prev = AtomicAdd(&m_ref, n);
|
||||||
REFTRACE("Inc %p %s: %u", this, tag, prev+n);
|
#ifdef REFCOUNT_DEBUGGING
|
||||||
|
DEBUG_MSG("Inc %p %s: %u", this, tag, prev+n);
|
||||||
|
#endif
|
||||||
return prev+n;
|
return prev+n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +112,9 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
OnZeroRef();
|
OnZeroRef();
|
||||||
}
|
}
|
||||||
REFTRACE("Dec %p: %u", this, prev-1);
|
#ifdef REFCOUNT_DEBUGGING
|
||||||
|
DEBUG_MSG("Dec %p: %u", this, prev-1);
|
||||||
|
#endif
|
||||||
return prev-1;
|
return prev-1;
|
||||||
}
|
}
|
||||||
inline long DecRef (const char tag[]) {
|
inline long DecRef (const char tag[]) {
|
||||||
@ -131,7 +128,9 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
OnZeroRef();
|
OnZeroRef();
|
||||||
}
|
}
|
||||||
REFTRACE("Dec %p %s: %u", this, tag, prev-1);
|
#ifdef REFCOUNT_DEBUGGING
|
||||||
|
DEBUG_MSG("Dec %p %s: %u", this, tag, prev-1);
|
||||||
|
#endif
|
||||||
return prev-1;
|
return prev-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +141,10 @@ public:
|
|||||||
#ifdef HS_DEBUGGING
|
#ifdef HS_DEBUGGING
|
||||||
ASSERT(!zeroed);
|
ASSERT(!zeroed);
|
||||||
#endif
|
#endif
|
||||||
REFTRACE("Inc %p %s: (xfer)", this, newTag);
|
#ifdef REFCOUNT_DEBUGGING
|
||||||
REFTRACE("Dec %p %s: (xfer)", this, oldTag);
|
DEBUG_MSG("Inc %p %s: (xfer)", this, newTag);
|
||||||
|
DEBUG_MSG("Dec %p %s: (xfer)", this, oldTag);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned GetRefCount () {
|
inline unsigned GetRefCount () {
|
||||||
|
Reference in New Issue
Block a user