/* libmisc/assert.c - More assertions * * Copyright (C) 2024 Luke T. Shumaker * SPDX-License-Identifier: AGPL-3.0-or-later */ #include /* for bool, true, false */ #include /* for abort() */ #define LOG_NAME ASSERT #include /* for errorf() */ #include #ifndef NDEBUG __attribute__((noreturn, weak)) void __assert_msg_fail(const char *expr, const char *file, unsigned int line, const char *func, const char *msg) { static bool in_fail = false; if (!in_fail) { in_fail = true; errorf("%s:%u:%s(): assertion \"%s\" failed%s%s", file, line, func, expr, msg ? ": " : "", msg); } abort(); } #endif