Luna/libc/include/assert.h
apio cb59a4e0e3
All checks were successful
continuous-integration/drone/push Build is passing
libc: Add assert.h
2023-01-22 12:51:30 +01:00

34 lines
694 B
C

/* assert.h: Debug assertions. */
#ifndef _ASSERT_H
#define _ASSERT_H
#include <bits/attrs.h>
#ifdef __cplusplus
extern "C"
{
#endif
__noreturn void __assertion_failed(const char* file, int line, const char* function, const char* expr);
#ifdef __cplusplus
}
#endif
#if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define static_assert _Static_assert
#endif
#ifdef NDEBUG
#define assert(expr)
#else
#define assert(expr) ((expr) ? (void)0 : __assertion_failed(__FILE__, __LINE__, __func__, #expr))
#endif
#ifdef _LUNA_SOURCE
#define release_assert(expr) ((expr) ? (void)0 : __assertion_failed(__FILE__, __LINE__, __func__, #expr))
#endif
#endif