/* 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 printf() */ #include /* for abort() */ #include #ifndef NDEBUG static bool in_fail = false; __attribute__((noreturn, weak)) void __assert_msg_fail(const char *expr, const char *file, unsigned int line, const char *func, const char *msg) { if (!in_fail) { in_fail = true; printf("error: %s:%u:%s(): assertion \"%s\" failed%s%s\n", file, line, func, expr, msg ? ": " : "", msg); } abort(); } #endif