From 376056a0cf419cfa260efec43214bfed5b140258 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Thu, 27 Dec 2012 13:52:49 -0500 Subject: [PATCH] fix file/line numbers in ASSERT_M/FAIL_M --- src/RageThreads.h | 6 ++++-- src/global.h | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/RageThreads.h b/src/RageThreads.h index 1fc7c7f49f..fbe99b86b5 100644 --- a/src/RageThreads.h +++ b/src/RageThreads.h @@ -79,8 +79,10 @@ namespace Checkpoints void GetLogs( char *pBuf, int iSize, const char *delim ); }; -#define CHECKPOINT (Checkpoints::SetCheckpoint(__FILE__, __LINE__, NULL)) -#define CHECKPOINT_M(m) (Checkpoints::SetCheckpoint(__FILE__, __LINE__, m)) +/* Keep this section synchronized with global.h until refactored */ +#define _CHECKPOINT_M(f, l, m) (Checkpoints::SetCheckpoint(f, l, m)) +#define CHECKPOINT_M(m) (_CHECKPOINT_M(__FILE__, __LINE__, m)) +#define CHECKPOINT (_CHECKPOINT_M(__FILE__, __LINE__, NULL)) /* Mutex class that follows the behavior of Windows mutexes: if the same * thread locks the same mutex twice, we just increase a refcount; a mutex diff --git a/src/global.h b/src/global.h index 4c960faf2d..a28cae9360 100644 --- a/src/global.h +++ b/src/global.h @@ -82,15 +82,17 @@ using namespace std; #undef ASSERT #endif +/* Keep this section synchronized with RageThreads.h until refactored */ /** @brief RageThreads defines (don't pull in all of RageThreads.h here) */ namespace Checkpoints { void SetCheckpoint( const char *file, int line, const char *message ); } -/** @brief Set a checkpoint with no message. */ -#define CHECKPOINT (Checkpoints::SetCheckpoint(__FILE__, __LINE__, NULL)) /** @brief Set a checkpoint with a specified message. */ -#define CHECKPOINT_M(m) (Checkpoints::SetCheckpoint(__FILE__, __LINE__, m)) +#define _CHECKPOINT_M(f, l, m) (Checkpoints::SetCheckpoint(f, l, m)) +#define CHECKPOINT_M(m) (_CHECKPOINT_M(__FILE__, __LINE__, m)) +/** @brief Set a checkpoint with no message. */ +#define CHECKPOINT (_CHECKPOINT_M(__FILE__, __LINE__, NULL)) /** @@ -125,19 +127,21 @@ void NORETURN sm_crash( const char *reason = "Internal error" ); * This should probably be used instead of throwing an exception in most * cases we expect never to happen (but not in cases that we do expect, * such as DSound init failure.) */ -static inline void FAIL_M(const char * MESSAGE) +static inline void NORETURN _FAIL_M(const char * file, int line, const char * message) { - CHECKPOINT_M(MESSAGE); - sm_crash(MESSAGE); + _CHECKPOINT_M(file, line, message); + sm_crash(message); } +#define FAIL_M(m) (_FAIL_M(__FILE__, __LINE__, m)) -static inline void ASSERT_M(bool COND, const char * MESSAGE) +static inline void _ASSERT_M(const char * file, int line, bool cond, const char * message) { - if (unlikely(!(COND))) + if (unlikely(!(cond))) { - FAIL_M(MESSAGE); + _FAIL_M(file, line, message); } } +#define ASSERT_M(c, m) (_ASSERT_M(__FILE__, __LINE__, c, m)) #if !defined(CO_EXIST_WITH_MFC) #define ASSERT(COND) ASSERT_M((COND), "Assertion '" #COND "' failed")