os-k/src/kaleid/common/assert.h

52 lines
1.3 KiB
C
Raw Normal View History

//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Authors: spectral` //
// NeoX //
// //
// Desc: Assertions //
//----------------------------------------------------------------------------//
2018-12-24 18:13:58 +01:00
#ifndef _KALCOMM_ASSERT_H
#define _KALCOMM_ASSERT_H
2018-12-25 19:09:58 +01:00
#ifndef _KALCOMM_COMMON_H
#error "don't include common/types.h without common/common.h"
#endif
#ifdef _OSK_SOURCE
2018-12-24 22:38:14 +01:00
#if !defined(_NO_DEBUG) && !defined(NDEBUG)
2018-12-24 22:38:14 +01:00
// uses panic() in kernel, abort() in system
noreturn void ___assert_handler(const char *, const char *, int, const char *);
2018-12-24 18:13:58 +01:00
2018-12-25 19:09:58 +01:00
#define assert(x) do{if(unlikely(!(x)))___assert_handler(#x, __FILE__, __LINE__, __func__);}while(0);
2018-12-24 18:13:58 +01:00
#else // not debugging
#if !defined(NDEBUG)
#define NDEBUG 1
#endif
2018-12-24 22:38:14 +01:00
#if !defined(_NO_DEBUG)
#define _NO_DEBUG 1
#endif
#define assert(x)
2018-12-25 19:09:58 +01:00
#endif
#else // !defined(_OSK_SOURCE)
#if defined(_NO_DEBUG) && !defined(NDEBUG)
#define NDEBUG 1
#endif
#include <assert.h>
2018-12-24 18:13:58 +01:00
#endif
#endif