2022-12-24 22:54:58 +00:00
|
|
|
#ifndef _MUSYX_ASSERT
|
|
|
|
#define _MUSYX_ASSERT
|
|
|
|
|
|
|
|
extern void OSPanic(const char* file, int line, const char* msg, ...);
|
2023-02-24 17:42:08 +00:00
|
|
|
extern void OSReport(const char* msg, ...);
|
2022-12-24 22:54:58 +00:00
|
|
|
|
|
|
|
#ifndef ASSERT
|
|
|
|
#ifdef _DEBUG
|
2023-02-24 17:42:08 +00:00
|
|
|
#define ASSERT(cond) \
|
|
|
|
do { \
|
|
|
|
if (!(cond)) { \
|
|
|
|
OSPanic(__FILE__, __LINE__, "Failed assertion " #cond); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
2022-12-24 22:54:58 +00:00
|
|
|
#else
|
|
|
|
#define ASSERT(cond)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ASSERT_MSG
|
|
|
|
#ifdef _DEBUG
|
2023-02-24 17:42:08 +00:00
|
|
|
#define ASSERT_MSG(cond, msg) \
|
|
|
|
do { \
|
|
|
|
if (!(cond)) { \
|
|
|
|
OSPanic(__FILE__, __LINE__, msg); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
2022-12-24 22:54:58 +00:00
|
|
|
#else
|
|
|
|
#define ASSERT_MSG(cond, msg)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2023-02-23 07:04:07 +00:00
|
|
|
#ifndef MUSY_DEBUG
|
2023-02-24 17:42:08 +00:00
|
|
|
#ifdef _DEBUG
|
2023-02-23 07:04:07 +00:00
|
|
|
#define MUSY_DEBUG OSReport
|
2023-02-24 17:42:08 +00:00
|
|
|
#else
|
2023-02-23 07:04:07 +00:00
|
|
|
#define MUSY_DEBUG
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2022-12-24 22:54:58 +00:00
|
|
|
#endif // _MUSYX_ASSERT
|