1#ifndef NW4R_DB_ASSERT_H
2#define NW4R_DB_ASSERT_H
15 void VPanic(
const char* file,
int line,
const char* fmt, std::va_list vlist);
16 void VWarning(
const char* file,
int line,
const char* fmt, std::va_list vlist);
19 void Log(
const char* fmt, ...);
20 void Panic(
const char* file,
int line,
const char* fmt, ...);
21 void Warning(
const char* file,
int line,
const char* msg, ...);
34#define NW4R_DB_WARNING(line, exp, ...) \
35 (void)((exp) || (nw4hbm::db::detail::Warning(__FILE__, line, __VA_ARGS__), 0))
36#define NW4R_DB_ASSERTMSG(line, exp, ...) \
37 (void)((exp) || (nw4hbm::db::detail::Panic(__FILE__, line, __VA_ARGS__), 0))
39#define NW4R_DB_WARNING(line, exp, ...) (void)0
40#define NW4R_DB_ASSERTMSG(line, exp, ...) (void)0
43#define NW4R_ASSERT(line, exp) \
44 NW4R_DB_ASSERTMSG(line, (exp), "Failed assertion " #exp)
46#define NW4R_ASSERT_CHECK_NULL(line, ptr) \
47 NW4R_DB_ASSERTMSG(line, (ptr != NULL), "Pointer must not be NULL ("#ptr")")
49#define POINTER_VALID_TEST(ptr_) \
50 (((unsigned long)ptr_ & 0xFF000000) == 0x80000000 || ((unsigned long)ptr_ & 0xFF800000) == 0x81000000 || \
51 ((unsigned long)ptr_ & 0xF8000000) == 0x90000000 || ((unsigned long)ptr_ & 0xFF000000) == 0xC0000000 || \
52 ((unsigned long)ptr_ & 0xFF800000) == 0xC1000000 || ((unsigned long)ptr_ & 0xF8000000) == 0xD0000000 || \
53 ((unsigned long)ptr_ & 0xFFFFC000) == 0xE0000000)
55#define NW4R_ASSERT_VALID_PTR(line, ptr) \
56 NW4R_DB_ASSERTMSG(line, POINTER_VALID_TEST(ptr), "Pointer Error\n" #ptr "(=%p) is not valid pointer.", ptr)
58#define NW4R_ASSERT_MIN(line_, var_, minValue_) \
59 NW4R_DB_ASSERTMSG(line_, minValue_ <= var_, \
60 #var_ " is out of bounds(%d)\n%d <= " #var_ " not satisfied.", (int)(var_), \
63#define NW4R_ASSERT_MINMAX(line_, var_, minValue_, maxValue_) \
64 NW4R_DB_ASSERTMSG(line_, (var_) >= (minValue_) && (var_) < (maxValue_), \
65 #var_ " is out of bounds(%d)\n%d <= " #var_ " < %d not satisfied.", (int)(var_), \
66 (int)(minValue_), (int)(maxValue_))
68#define NW4R_ASSERT_MINMAXLT(line_, var_, minValue_, maxValue_) \
69 NW4R_DB_ASSERTMSG(line_, (var_) >= (minValue_) && (var_) <= (maxValue_), \
70 #var_ " is out of bounds(%d)\n%d <= " #var_ " <= %d not satisfied.", (int)(var_), \
71 (int)(minValue_), (int)(maxValue_))
73#define NW4R_IS_ALIGNED_(x, align) \
74 (((unsigned long)(x) & ((align) - 1)) == 0)
76#define NW4R_ASSERT_ALIGN2(line, exp) \
77 NW4R_DB_ASSERTMSG(line, NW4R_IS_ALIGNED_(exp, 2), \
78 "Alignment Error(0x%x)\n" #exp " must be aligned to 2 bytes boundary.", \
81#define NW4R_ASSERT_ALIGN32(line, exp) \
82 NW4R_DB_ASSERTMSG(line, NW4R_IS_ALIGNED_(exp, 32), \
83 "Alignment Error(0x%x)\n" #exp " must be aligned to 32 bytes boundary.", \
87#define NW4HBM_ASSERT_CHECK_NULL(line, ptr) \
88 NW4R_DB_ASSERTMSG(line, (ptr != NULL), "NW4HBM:Pointer must not be NULL ("#ptr")")
90#define NW4HBM_ASSERT(line, exp) \
91 NW4R_DB_ASSERTMSG(line, (exp), "NW4HBM:Failed assertion " #exp)
93#define NW4HBM_ASSERT_VALID_PTR(line, ptr) \
94 NW4R_DB_ASSERTMSG(line, POINTER_VALID_TEST(ptr), "NW4HBM:Pointer Error\n" #ptr "(=%p) is not valid pointer.", ptr)
96#define NW4HBM_ASSERT_ALIGN2(line, exp) \
97 NW4R_DB_ASSERTMSG(line, NW4R_IS_ALIGNED_(exp, 2), \
98 "NW4HBM:Alignment Error(0x%x)\n" #exp " must be aligned to 2 bytes boundary.", \
101#define NW4HBM_ASSERT_ALIGN32(line, exp) \
102 NW4R_DB_ASSERTMSG(line, NW4R_IS_ALIGNED_(exp, 32), \
103 "NW4HBM:Alignment Error(0x%x)\n" #exp " must be aligned to 32 bytes boundary.", \
106#define NW4HBM_ASSERT_ALIGNED(line, exp, align) \
107 NW4R_DB_ASSERTMSG(line, NW4R_IS_ALIGNED_(exp, align), \
108 "NW4HBM:Alignment Error(0x%x)\n" #exp " must be aligned to " #align " bytes boundary.", \
OSTime time
Definition GXInit.c:34
unsigned long u32
Definition types.h:12
void Log(const char *fmt,...)
Definition db_assert.cpp:144
void Warning(const char *file, int line, const char *msg,...)
Definition db_assert.cpp:127
void Panic(const char *file, int line, const char *fmt,...)
Definition db_assert.cpp:104
void VWarning(const char *file, int line, const char *fmt, std::va_list vlist)
Definition db_assert.cpp:113
void Assertion_HideConsole()
Definition db_assert.cpp:170
detail::ConsoleHead * Assertion_SetConsole(detail::ConsoleHead *console)
Definition db_assert.cpp:149
detail::ConsoleHead * Assertion_GetConsole()
Definition db_assert.cpp:155
void Assertion_SetWarningTime(u32 time)
Definition db_assert.cpp:174
bool Assertion_SetAutoWarning(bool enable)
void Assertion_ShowConsole(u32 time)
Definition db_assert.cpp:159
void VPanic(const char *file, int line, const char *fmt, std::va_list vlist)
Definition db_assert.cpp:70
Definition HBMAnmController.h:6