From 19ac565e0dafccd3728b58a0d92cdc0cb74e4be0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 26 Sep 2015 16:39:47 -0400 Subject: [PATCH] Common: Move asserts to their own header --- Source/Core/Common/Arm64Emitter.cpp | 1 + Source/Core/Common/Arm64Emitter.h | 1 + Source/Core/Common/Assert.h | 45 +++++++++++++++++++ Source/Core/Common/ChunkFile.h | 2 + Source/Core/Common/CodeBlock.h | 2 +- Source/Core/Common/Common.vcxproj | 1 + Source/Core/Common/GL/GLUtil.cpp | 1 + Source/Core/Common/Logging/Log.h | 41 ----------------- Source/Core/Common/x64Emitter.h | 1 + Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp | 2 +- .../Core/FifoPlayer/FifoPlaybackAnalyzer.cpp | 3 +- Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 1 + .../Core/FifoPlayer/FifoRecordAnalyzer.cpp | 2 +- Source/Core/Core/HW/MMIO.h | 1 + Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.cpp | 3 +- .../Core/PowerPC/Interpreter/Interpreter.cpp | 2 + .../Interpreter/Interpreter_Branch.cpp | 2 + .../Interpreter_LoadStorePaired.cpp | 2 + .../Interpreter_SystemRegisters.cpp | 2 + Source/Core/DiscIO/VolumeDirectory.cpp | 2 + Source/Core/DiscIO/WiiWad.cpp | 1 + Source/Core/DolphinWX/FifoPlayerDlg.cpp | 1 + .../ControllerInterface/evdev/evdev.cpp | 1 + 23 files changed, 73 insertions(+), 47 deletions(-) create mode 100644 Source/Core/Common/Assert.h diff --git a/Source/Core/Common/Arm64Emitter.cpp b/Source/Core/Common/Arm64Emitter.cpp index aa01434b43..16031372f4 100644 --- a/Source/Core/Common/Arm64Emitter.cpp +++ b/Source/Core/Common/Arm64Emitter.cpp @@ -6,6 +6,7 @@ #include #include "Common/Arm64Emitter.h" +#include "Common/Assert.h" #include "Common/CommonTypes.h" #include "Common/MathUtil.h" diff --git a/Source/Core/Common/Arm64Emitter.h b/Source/Core/Common/Arm64Emitter.h index 8ca8c001a0..3cb5dfe0a8 100644 --- a/Source/Core/Common/Arm64Emitter.h +++ b/Source/Core/Common/Arm64Emitter.h @@ -7,6 +7,7 @@ #include #include "Common/ArmCommon.h" +#include "Common/Assert.h" #include "Common/BitSet.h" #include "Common/CodeBlock.h" #include "Common/Common.h" diff --git a/Source/Core/Common/Assert.h b/Source/Core/Common/Assert.h new file mode 100644 index 0000000000..bedcbdee48 --- /dev/null +++ b/Source/Core/Common/Assert.h @@ -0,0 +1,45 @@ +// Copyright 2015 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include "Common/CommonFuncs.h" +#include "Common/MsgHandler.h" +#include "Common/Logging/Log.h" + +#ifdef _WIN32 +#define _assert_msg_(_t_, _a_, _fmt_, ...) \ + if (!(_a_)) {\ + if (!PanicYesNo(_fmt_, __VA_ARGS__)) \ + Crash(); \ + } + +#define _dbg_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_, ...) \ + if (!(_a_)) {\ + if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) \ + Crash(); \ + } + +#define _dbg_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(); \ + } +#endif + +#define _assert_(_a_) \ + _assert_msg_(MASTER_LOG, _a_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ + __LINE__, __FILE__, __TIME__) + +#define _dbg_assert_(_t_, _a_) \ + if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) \ + _assert_(_a_) diff --git a/Source/Core/Common/ChunkFile.h b/Source/Core/Common/ChunkFile.h index fcf1bdb3e4..d3babbb11d 100644 --- a/Source/Core/Common/ChunkFile.h +++ b/Source/Core/Common/ChunkFile.h @@ -24,9 +24,11 @@ #include #include +#include "Common/Assert.h" #include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Common/Flag.h" +#include "Common/Logging/Log.h" // ewww #if _LIBCPP_VERSION || __GNUC__ >= 5 diff --git a/Source/Core/Common/CodeBlock.h b/Source/Core/Common/CodeBlock.h index 864dac5e63..8f02f08336 100644 --- a/Source/Core/Common/CodeBlock.h +++ b/Source/Core/Common/CodeBlock.h @@ -4,7 +4,7 @@ #pragma once -#include "Common/Common.h" +#include "Common/Assert.h" #include "Common/MemoryUtil.h" #include "Common/NonCopyable.h" diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj index 12cbc07e8a..f367557b2e 100644 --- a/Source/Core/Common/Common.vcxproj +++ b/Source/Core/Common/Common.vcxproj @@ -35,6 +35,7 @@ + diff --git a/Source/Core/Common/GL/GLUtil.cpp b/Source/Core/Common/GL/GLUtil.cpp index 3cb8499b0d..ece39e5a61 100644 --- a/Source/Core/Common/GL/GLUtil.cpp +++ b/Source/Core/Common/GL/GLUtil.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Common/Assert.h" #include "Common/GL/GLInterfaceBase.h" #include "Common/GL/GLUtil.h" #include "Common/Logging/Log.h" diff --git a/Source/Core/Common/Logging/Log.h b/Source/Core/Common/Logging/Log.h index 41d9aa503a..24a4aa8884 100644 --- a/Source/Core/Common/Logging/Log.h +++ b/Source/Core/Common/Logging/Log.h @@ -4,9 +4,6 @@ #pragma once -#include "Common/CommonFuncs.h" -#include "Common/MsgHandler.h" - namespace LogTypes { @@ -101,41 +98,3 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, #define NOTICE_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } while (0) #define INFO_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } while (0) #define DEBUG_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } while (0) - -#ifdef _WIN32 -#define _dbg_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 _dbg_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(); \ - } -#endif - -#ifdef _WIN32 -#define _assert_msg_(_t_, _a_, _fmt_, ...) \ - if (!(_a_)) {\ - if (!PanicYesNo(_fmt_, __VA_ARGS__)) \ - Crash(); \ - } -#else // not win32 -#define _assert_msg_(_t_, _a_, _fmt_, ...) \ - if (!(_a_)) {\ - if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) \ - Crash(); \ - } -#endif // WIN32 - -#define _assert_(_a_) \ - _assert_msg_(MASTER_LOG, _a_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \ - __LINE__, __FILE__, __TIME__) - -#define _dbg_assert_(_t_, _a_) \ - if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) \ - _assert_(_a_) diff --git a/Source/Core/Common/x64Emitter.h b/Source/Core/Common/x64Emitter.h index cd6a2bd03c..928478af49 100644 --- a/Source/Core/Common/x64Emitter.h +++ b/Source/Core/Common/x64Emitter.h @@ -10,6 +10,7 @@ #include #include +#include "Common/Assert.h" #include "Common/BitSet.h" #include "Common/CodeBlock.h" #include "Common/CommonTypes.h" diff --git a/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp index 05eb13cce5..40cdcdf49e 100644 --- a/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp @@ -2,10 +2,10 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Common/Assert.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/FifoPlayer/FifoAnalyzer.h" - #include "VideoCommon/VertexLoader.h" #include "VideoCommon/VertexLoader_Normal.h" #include "VideoCommon/VertexLoader_Position.h" diff --git a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp index 4ca0335fe0..462cbae576 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp @@ -2,12 +2,11 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Common/Assert.h" #include "Common/CommonTypes.h" - #include "Core/FifoPlayer/FifoAnalyzer.h" #include "Core/FifoPlayer/FifoDataFile.h" #include "Core/FifoPlayer/FifoPlaybackAnalyzer.h" - #include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/TextureDecoder.h" #include "VideoCommon/VertexLoader.h" diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index f4bef742a7..1d2cdaa76e 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -5,6 +5,7 @@ #include #include +#include "Common/Assert.h" #include "Common/CommonTypes.h" #include "Core/ConfigManager.h" #include "Core/Core.h" diff --git a/Source/Core/Core/FifoPlayer/FifoRecordAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoRecordAnalyzer.cpp index e92b94e8d8..f13b0cdf48 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecordAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecordAnalyzer.cpp @@ -4,12 +4,12 @@ #include +#include "Common/Assert.h" #include "Core/Core.h" #include "Core/FifoPlayer/FifoAnalyzer.h" #include "Core/FifoPlayer/FifoRecordAnalyzer.h" #include "Core/FifoPlayer/FifoRecorder.h" #include "Core/HW/Memmap.h" - #include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/TextureDecoder.h" diff --git a/Source/Core/Core/HW/MMIO.h b/Source/Core/Core/HW/MMIO.h index b03a42f09e..25b5a1e0cb 100644 --- a/Source/Core/Core/HW/MMIO.h +++ b/Source/Core/Core/HW/MMIO.h @@ -8,6 +8,7 @@ #include #include +#include "Common/Assert.h" #include "Common/CommonTypes.h" #include "Core/ConfigManager.h" #include "Core/HW/MMIOHandlers.h" diff --git a/Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.cpp b/Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.cpp index 1803fb1933..33f994e45f 100644 --- a/Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.cpp +++ b/Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.cpp @@ -4,7 +4,8 @@ #include -#include "Common/Common.h" +#include "Common/Assert.h" +#include "Common/CommonTypes.h" #include "Common/MsgHandler.h" #include "Common/Logging/Log.h" #include "Core/IPC_HLE/WiiMote_HID_Attr.h" diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index 50f7fe721b..76e4c2b59a 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -6,6 +6,8 @@ #include #include +#include "Common/Assert.h" +#include "Common/CommonTypes.h" #include "Common/GekkoDisassembler.h" #include "Common/StringUtil.h" #include "Core/Host.h" diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp index 8726da7320..842c4ec863 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Common/Assert.h" +#include "Common/CommonTypes.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/Interpreter/Interpreter.h" diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp index d280faca21..4b13a1550b 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_LoadStorePaired.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Common/Assert.h" +#include "Common/CommonTypes.h" #include "Common/MathUtil.h" #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp index 08f165bcde..5b27df0a40 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include "Common/Assert.h" +#include "Common/CommonTypes.h" #include "Common/CPUDetect.h" #include "Common/FPURoundMode.h" #include "Core/HW/GPFifo.h" diff --git a/Source/Core/DiscIO/VolumeDirectory.cpp b/Source/Core/DiscIO/VolumeDirectory.cpp index eadb198eeb..8be726fd66 100644 --- a/Source/Core/DiscIO/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/VolumeDirectory.cpp @@ -10,10 +10,12 @@ #include #include +#include "Common/Assert.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Common/MathUtil.h" +#include "Common/Logging/Log.h" #include "DiscIO/FileBlob.h" #include "DiscIO/FileMonitor.h" #include "DiscIO/Volume.h" diff --git a/Source/Core/DiscIO/WiiWad.cpp b/Source/Core/DiscIO/WiiWad.cpp index f6b8574983..a7ba92b2fb 100644 --- a/Source/Core/DiscIO/WiiWad.cpp +++ b/Source/Core/DiscIO/WiiWad.cpp @@ -7,6 +7,7 @@ #include #include +#include "Common/Assert.h" #include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Common/MathUtil.h" diff --git a/Source/Core/DolphinWX/FifoPlayerDlg.cpp b/Source/Core/DolphinWX/FifoPlayerDlg.cpp index 0ab444c7c8..0ad790d720 100644 --- a/Source/Core/DolphinWX/FifoPlayerDlg.cpp +++ b/Source/Core/DolphinWX/FifoPlayerDlg.cpp @@ -25,6 +25,7 @@ #include #include +#include "Common/Assert.h" #include "Common/CommonTypes.h" #include "Core/FifoPlayer/FifoDataFile.h" #include "Core/FifoPlayer/FifoPlaybackAnalyzer.h" diff --git a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp index 3d45244847..d88a44b7ef 100644 --- a/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp +++ b/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp @@ -7,6 +7,7 @@ #include #include +#include "Common/Assert.h" #include "Common/Logging/Log.h" #include "InputCommon/ControllerInterface/evdev/evdev.h"