summaryrefslogtreecommitdiff
path: root/src/common/assert.h
diff options
context:
space:
mode:
authorGravatar bunnei2015-02-10 23:08:04 -0500
committerGravatar bunnei2015-02-10 23:08:04 -0500
commit2fb1e4c9a2e45aad6c3e9408a3895369b8a8729f (patch)
treefca138e8377c4d66bd1fe026a3d2fef54a7f090c /src/common/assert.h
parentGSP: Fixed typo in SignalInterrupt (diff)
parentAsserts: break/crash program, fit to style guide; log.h->assert.h (diff)
downloadyuzu-2fb1e4c9a2e45aad6c3e9408a3895369b8a8729f.tar.gz
yuzu-2fb1e4c9a2e45aad6c3e9408a3895369b8a8729f.tar.xz
yuzu-2fb1e4c9a2e45aad6c3e9408a3895369b8a8729f.zip
Merge pull request #500 from archshift/assert
Made asserts actually break the debugger, or crash if the program is not in debug mode.
Diffstat (limited to 'src/common/assert.h')
-rw-r--r--src/common/assert.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/common/assert.h b/src/common/assert.h
new file mode 100644
index 000000000..3b2232a7e
--- /dev/null
+++ b/src/common/assert.h
@@ -0,0 +1,36 @@
1// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_funcs.h"
8
9// TODO (yuriks) allow synchronous logging so we don't need printf
10#define ASSERT(_a_) \
11 do if (!(_a_)) {\
12 fprintf(stderr, "Assertion Failed!\n\n Line: %d\n File: %s\n Time: %s\n", \
13 __LINE__, __FILE__, __TIME__); \
14 Crash(); \
15 } while (0)
16
17#define ASSERT_MSG(_a_, ...) \
18 do if (!(_a_)) {\
19 fprintf(stderr, "Assertion Failed!\n\n Line: %d\n File: %s\n Time: %s\n", \
20 __LINE__, __FILE__, __TIME__); \
21 fprintf(stderr, __VA_ARGS__); \
22 fprintf(stderr, "\n"); \
23 Crash(); \
24 } while (0)
25
26#define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!")
27
28#ifdef _DEBUG
29#define DEBUG_ASSERT(_a_) ASSERT(_a_)
30#define DEBUG_ASSERT_MSG(_a_, ...) ASSERT_MSG(_a_, __VA_ARGS__)
31#else // not debug
32#define DEBUG_ASSERT(_a_)
33#define DEBUG_ASSERT_MSG(_a_, _desc_, ...)
34#endif
35
36#define UNIMPLEMENTED() DEBUG_ASSERT_MSG(false, "Unimplemented code!")