2018-12-20 18:03:39 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
// 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-20 18:03:39 +01:00
|
|
|
|
|
|
|
extern const char *panicstr;
|
|
|
|
extern void panic(const char *) __dead;
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
#if !defined(_NO_DEBUG)
|
|
|
|
|
2018-12-20 18:03:39 +01:00
|
|
|
#define assert(x) do{if(!(x))panic(#x);}while(0);
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
#define assert_never_used(x) do{static bool __##x##_init = FALSE; \
|
|
|
|
assert(__##x##_init == FALSE); __##x##_init = TRUE;}while(0);
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
#define assert_used_once(x) do{static bool __##x##_init; assert(__##x##_init == TRUE);} while(0);
|
2018-12-20 18:03:39 +01:00
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
#else // not debugging
|
|
|
|
|
|
|
|
#if !defined(NDEBUG)
|
|
|
|
#define NDEBUG 1
|
|
|
|
#endif
|
2018-12-20 18:03:39 +01:00
|
|
|
|
|
|
|
#define assert(x)
|
|
|
|
#define assert_never_used(x)
|
|
|
|
#define assert_used_once(x)
|
|
|
|
|
2018-12-24 18:13:58 +01:00
|
|
|
#endif
|
2018-12-20 18:03:39 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|