Skip to content

Commit

Permalink
Merge pull request #6438 from lioncash/assert
Browse files Browse the repository at this point in the history
Assert: Uppercase assertion macros
  • Loading branch information
lioncash committed Mar 16, 2018
2 parents 1259370 + 50a476c commit 9f4d512
Show file tree
Hide file tree
Showing 135 changed files with 719 additions and 741 deletions.
2 changes: 1 addition & 1 deletion Source/Core/AudioCommon/OpenSLESStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void* context)
// Comment from sample code:
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
// which for this code example would indicate a programming error
_assert_msg_(AUDIO, SL_RESULT_SUCCESS == result, "Couldn't enqueue audio stream.");
ASSERT_MSG(AUDIO, SL_RESULT_SUCCESS == result, "Couldn't enqueue audio stream.");
}

bool OpenSLESStream::Init()
Expand Down
312 changes: 152 additions & 160 deletions Source/Core/Common/Arm64Emitter.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Source/Core/Common/Arm64Emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ class ArithOption
return (m_shifttype << 22) | (m_shift << 10);
break;
default:
_dbg_assert_msg_(DYNA_REC, false, "Invalid type in GetData");
DEBUG_ASSERT_MSG(DYNA_REC, false, "Invalid type in GetData");
break;
}
return 0;
Expand Down Expand Up @@ -846,7 +846,7 @@ class ARM64XEmitter
template <class P>
void MOVP2R(ARM64Reg Rd, P* ptr)
{
_assert_msg_(DYNA_REC, Is64Bit(Rd), "Can't store pointers in 32-bit registers");
ASSERT_MSG(DYNA_REC, Is64Bit(Rd), "Can't store pointers in 32-bit registers");
MOVI2R(Rd, (uintptr_t)ptr);
}

Expand Down
20 changes: 10 additions & 10 deletions Source/Core/Common/Assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
#include "Common/MsgHandler.h"

#ifdef _WIN32
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
#define ASSERT_MSG(_t_, _a_, _fmt_, ...) \
if (!(_a_)) \
{ \
if (!PanicYesNo(_fmt_ "\n\nIgnore and continue?", __VA_ARGS__)) \
Crash(); \
}

#define _dbg_assert_msg_(_t_, _a_, _msg_, ...) \
#define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) \
{ \
ERROR_LOG(_t_, _msg_, __VA_ARGS__); \
if (!PanicYesNo(_msg_, __VA_ARGS__)) \
Crash(); \
}
#else
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
#define ASSERT_MSG(_t_, _a_, _fmt_, ...) \
if (!(_a_)) \
{ \
if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) \
Crash(); \
}

#define _dbg_assert_msg_(_t_, _a_, _msg_, ...) \
#define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) \
{ \
ERROR_LOG(_t_, _msg_, ##__VA_ARGS__); \
Expand All @@ -41,11 +41,11 @@
}
#endif

#define _assert_(_a_) \
_assert_msg_(MASTER_LOG, _a_, \
_trans("An error occurred.\n\n Line: %d\n File: %s\n\nIgnore and continue?"), \
__LINE__, __FILE__)
#define ASSERT(_a_) \
ASSERT_MSG(MASTER_LOG, _a_, \
_trans("An error occurred.\n\n Line: %d\n File: %s\n\nIgnore and continue?"), \
__LINE__, __FILE__)

#define _dbg_assert_(_t_, _a_) \
#define DEBUG_ASSERT(_t_, _a_) \
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) \
_assert_(_a_)
ASSERT(_a_)
2 changes: 1 addition & 1 deletion Source/Core/Common/ChunkFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class PointerWrap
break;

case MODE_VERIFY:
_dbg_assert_msg_(COMMON, !memcmp(data, *ptr, size),
DEBUG_ASSERT_MSG(COMMON, !memcmp(data, *ptr, size),
"Savestate verification failure: buf %p != %p (size %u).\n", data, *ptr,
size);
break;
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Common/CodeBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CodeBlock : public T
// Call this when shutting down. Don't rely on the destructor, even though it'll do the job.
void FreeCodeSpace()
{
_assert_(!m_is_child);
ASSERT(!m_is_child);
Common::FreeMemoryPages(region, total_region_size);
region = nullptr;
region_size = 0;
Expand All @@ -87,7 +87,7 @@ class CodeBlock : public T
void ResetCodePtr() { T::SetCodePtr(region); }
size_t GetSpaceLeft() const
{
_assert_(static_cast<size_t>(T::GetCodePtr() - region) < region_size);
ASSERT(static_cast<size_t>(T::GetCodePtr() - region) < region_size);
return region_size - (T::GetCodePtr() - region);
}

Expand All @@ -100,7 +100,7 @@ class CodeBlock : public T
bool HasChildren() const { return region_size != total_region_size; }
u8* AllocChildCodeSpace(size_t child_size)
{
_assert_msg_(DYNA_REG, child_size < GetSpaceLeft(), "Insufficient space for child allocation.");
ASSERT_MSG(DYNA_REG, child_size < GetSpaceLeft(), "Insufficient space for child allocation.");
u8* child_region = region + region_size - child_size;
region_size -= child_size;
return child_region;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/FileUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ std::string GetSysDirectory()
sysDir = GetExeDirectory() + DIR_SEP + SYSDATA_DIR;
#elif defined ANDROID
sysDir = s_android_sys_directory;
_assert_msg_(COMMON, !sysDir.empty(), "Sys directory has not been set");
ASSERT_MSG(COMMON, !sysDir.empty(), "Sys directory has not been set");
#else
sysDir = SYSDATA_DIR;
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/SysConf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static size_t GetNonArrayEntrySize(SysConf::Entry::Type type)
case SysConf::Entry::Type::LongLong:
return 8;
default:
_assert_(false);
ASSERT(false);
return 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/SysConf.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SysConf final
template <typename T>
void SetData(T value)
{
_assert_(sizeof(value) == bytes.size());
ASSERT(sizeof(value) == bytes.size());
std::memcpy(bytes.data(), &value, bytes.size());
}

Expand Down

0 comments on commit 9f4d512

Please sign in to comment.