52 lines
1.3 KiB
C
52 lines
1.3 KiB
C
//----------------------------------------------------------------------------//
|
|
// GNU GPL OS/K //
|
|
// //
|
|
// Authors: spectral` //
|
|
// NeoX //
|
|
// //
|
|
// Desc: Assertions //
|
|
//----------------------------------------------------------------------------//
|
|
|
|
#ifndef _KALCOMM_ASSERT_H
|
|
#define _KALCOMM_ASSERT_H
|
|
|
|
#ifndef _KALCOMM_COMMON_H
|
|
#error "don't include common/types.h without common/common.h"
|
|
#endif
|
|
|
|
#ifdef _OSK_SOURCE
|
|
|
|
#if !defined(_NO_DEBUG) && !defined(NDEBUG)
|
|
|
|
// uses panic() in kernel, abort() in system
|
|
noreturn void ___assert_handler(const char *, const char *, int, const char *);
|
|
|
|
#define assert(x) do{if(unlikely(!(x)))___assert_handler(#x, __FILE__, __LINE__, __func__);}while(0);
|
|
|
|
#else // not debugging
|
|
|
|
#if !defined(NDEBUG)
|
|
#define NDEBUG 1
|
|
#endif
|
|
|
|
#if !defined(_NO_DEBUG)
|
|
#define _NO_DEBUG 1
|
|
#endif
|
|
|
|
#define assert(x)
|
|
|
|
#endif
|
|
|
|
#else // !defined(_OSK_SOURCE)
|
|
|
|
#if defined(_NO_DEBUG) && !defined(NDEBUG)
|
|
#define NDEBUG 1
|
|
#endif
|
|
|
|
#include <assert.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|