1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00
libkernaux/include/kernaux/assert.h

29 lines
1.1 KiB
C
Raw Normal View History

2021-12-14 15:37:11 -05:00
#ifndef KERNAUX_INCLUDED_ASSERT
2021-12-20 01:17:53 -05:00
#define KERNAUX_INCLUDED_ASSERT
2021-12-14 15:37:11 -05:00
#ifdef __cplusplus
extern "C" {
#endif
2022-01-20 11:51:54 -05:00
#define KERNAUX_PANIC(msg) (kernaux_assert_do(__FILE__, __LINE__, #msg))
2022-01-24 12:09:17 -05:00
#define KERNAUX_ASSERT(cond) ((cond) ? (void)0 : KERNAUX_PANIC(cond))
2021-12-17 18:43:19 -05:00
2022-01-23 05:42:06 -05:00
#define KERNAUX_PANIC_RETURN(msg) do { KERNAUX_PANIC(msg); return; } while (0)
#define KERNAUX_PANIC_RETVAL(msg, val) do { KERNAUX_PANIC(msg); return (val); } while (0)
2022-01-23 05:42:06 -05:00
#define KERNAUX_ASSERT_RETURN(cond) do { KERNAUX_ASSERT(cond); if (!(cond)) return; } while (0)
#define KERNAUX_ASSERT_RETVAL(cond, val) do { KERNAUX_ASSERT(cond); if (!(cond)) return (val); } while (0)
2021-12-19 21:22:43 -05:00
2022-01-23 05:42:06 -05:00
#define KERNAUX_NOTNULL_RETURN(cond) do { KERNAUX_ASSERT(cond); if (!(cond)) return; } while (0)
#define KERNAUX_NOTNULL_RETVAL(cond, val) do { KERNAUX_ASSERT(cond); if (!(cond)) return (val); } while (0)
2022-01-20 12:18:18 -05:00
2022-01-24 12:17:23 -05:00
void kernaux_assert_do(const char *file, int line, const char *msg);
2021-12-14 15:37:11 -05:00
2022-01-24 12:17:23 -05:00
extern void (*kernaux_assert_cb)(const char *file, int line, const char *msg);
2021-12-14 15:37:11 -05:00
#ifdef __cplusplus
}
#endif
#endif