summaryrefslogtreecommitdiff
path: root/src/common/assert.h
diff options
context:
space:
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!")