Browse Source

Fixes to CoreLib and CoreLibExe.

Darryl Pogue 13 years ago
parent
commit
3e3d713b3b
  1. 19
      Sources/Plasma/CoreLib/hsCritSect.cpp
  2. 3
      Sources/Plasma/CoreLib/hsCritSect.h
  3. 6
      Sources/Plasma/CoreLib/hsMatrix44.cpp
  4. 10
      Sources/Plasma/CoreLibExe/hsExeError.cpp
  5. 4
      Sources/Plasma/CoreLibExe/hsExeMalloc.cpp

19
Sources/Plasma/CoreLib/hsCritSect.cpp

@ -80,4 +80,23 @@ void CCritSect::Enter () {
void CCritSect::Leave () { void CCritSect::Leave () {
LeaveCriticalSection(&m_handle); LeaveCriticalSection(&m_handle);
} }
#elif HS_BUILD_FOR_UNIX
//===========================================================================
CCritSect::CCritSect () {
m_handle = PTHREAD_MUTEX_INITIALIZER;
}
//===========================================================================
CCritSect::~CCritSect () {
}
//===========================================================================
void CCritSect::Enter () {
pthread_mutex_lock(&m_handle);
}
//===========================================================================
void CCritSect::Leave () {
pthread_mutex_unlock(&m_handle);
}
#endif #endif

3
Sources/Plasma/CoreLib/hsCritSect.h

@ -61,6 +61,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifdef HS_BUILD_FOR_WIN32 #ifdef HS_BUILD_FOR_WIN32
typedef CRITICAL_SECTION CritSectHandle; typedef CRITICAL_SECTION CritSectHandle;
#elif HS_BUILD_FOR_UNIX
# include <pthread.h>
typedef pthread_mutex_t CritSectHandle;
#else #else
# error "CCritSect: Not implemented on this platform" # error "CCritSect: Not implemented on this platform"
#endif #endif

6
Sources/Plasma/CoreLib/hsMatrix44.cpp

@ -427,7 +427,8 @@ void hsMatrix44::MakeZRotation(hsScalar radians)
// //
hsMatrix44& hsMatrix44::Make(const hsPoint3* f, const hsPoint3* at, const hsVector3* up) hsMatrix44& hsMatrix44::Make(const hsPoint3* f, const hsPoint3* at, const hsVector3* up)
{ {
MakeTranslateMat(&hsVector3(f->fX, f->fY, f->fZ)); hsVector3 trans(f->fX, f->fY, f->fZ);
MakeTranslateMat(&trans);
hsVector3 back (f,at); // Z hsVector3 back (f,at); // Z
back.Normalize(); back.Normalize();
@ -458,7 +459,8 @@ hsMatrix44& hsMatrix44::Make(const hsPoint3* f, const hsPoint3* at, const hsVect
// //
hsMatrix44& hsMatrix44::MakeUpPreserving(const hsPoint3* f, const hsPoint3* at, const hsVector3* up) hsMatrix44& hsMatrix44::MakeUpPreserving(const hsPoint3* f, const hsPoint3* at, const hsVector3* up)
{ {
MakeTranslateMat(&hsVector3(f->fX, f->fY, f->fZ)); hsVector3 trans(f->fX, f->fY, f->fZ);
MakeTranslateMat(&trans);
hsVector3 topHead = *up; hsVector3 topHead = *up;
topHead.Normalize(); topHead.Normalize();

10
Sources/Plasma/CoreLibExe/hsExeError.cpp

@ -56,7 +56,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
***/ ***/
static bool s_skipBreak; static bool s_skipBreak;
#if HS_BUILD_FOR_WIN32
static CCritSect * s_critsect; static CCritSect * s_critsect;
#endif
// User options // User options
static bool s_options[kNumErrorOptions]; static bool s_options[kNumErrorOptions];
@ -69,12 +71,14 @@ static bool s_options[kNumErrorOptions];
***/ ***/
//=========================================================================== //===========================================================================
#if HS_BUILD_FOR_WIN32
AUTO_INIT_FUNC(hsExeErrorInit) { AUTO_INIT_FUNC(hsExeErrorInit) {
// The critical section has to be initialized // The critical section has to be initialized
// before program startup and never freed // before program startup and never freed
static byte rawMemory[sizeof(CCritSect)]; static byte rawMemory[sizeof(CCritSect)];
s_critsect = new(rawMemory) CCritSect; s_critsect = new(rawMemory) CCritSect;
} }
#endif
//============================================================================ //============================================================================
static void DoAssert (int line, const char file[], const char msg[]) { static void DoAssert (int line, const char file[], const char msg[]) {
@ -118,7 +122,7 @@ static void DoAssert (int line, const char file[], const char msg[]) {
//============================================================================ //============================================================================
#pragma auto_inline(off) #pragma auto_inline(off)
void __cdecl ErrorFatal (int line, const char file[], const char fmt[], ...) { void CDECL ErrorFatal (int line, const char file[], const char fmt[], ...) {
char buffer[256]; char buffer[256];
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
@ -135,7 +139,7 @@ void __cdecl ErrorFatal (int line, const char file[], const char fmt[], ...) {
//============================================================================ //============================================================================
#pragma auto_inline(off) #pragma auto_inline(off)
void __cdecl ErrorAssert (int line, const char file[], const char fmt[], ...) { void CDECL ErrorAssert (int line, const char file[], const char fmt[], ...) {
char buffer[256]; char buffer[256];
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
@ -250,7 +254,7 @@ void DebugMsgV (const char fmt[], va_list args) {
} }
//============================================================================ //============================================================================
void __cdecl DebugMsg (const char fmt[], ...) { void CDECL DebugMsg (const char fmt[], ...) {
#ifdef HS_DEBUGGING #ifdef HS_DEBUGGING
va_list args; va_list args;

4
Sources/Plasma/CoreLibExe/hsExeMalloc.cpp

@ -591,14 +591,16 @@ void * MemRealloc (void * ptr, unsigned bytes, unsigned flags, const char file[]
//=========================================================================== //===========================================================================
unsigned MemSize (void * ptr) { unsigned MemSize (void * ptr) {
ASSERT(ptr); ASSERT(ptr);
unsigned result; unsigned result = 0;
#ifdef MEM_DEBUG #ifdef MEM_DEBUG
const _CrtMemBlockHeader * pHead = pHdr(ptr); const _CrtMemBlockHeader * pHead = pHdr(ptr);
unsigned block = pHead->nBlockUse; unsigned block = pHead->nBlockUse;
#endif #endif
#if HS_BUILD_FOR_WIN32
result = (unsigned)_msize_dbg(ptr, block); result = (unsigned)_msize_dbg(ptr, block);
#endif
return result; return result;
} }

Loading…
Cancel
Save