zephyr/lib/libc/picolibc/assert.c
Keith Packard dc0fd3af17 picolibc: Use common abort(), call from assert when !__ASSERT_ON
Switch to the common abort implementation so that we can use it
from the assert hooks to avoid undefined behavior.

Closes: 84824

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-02-14 10:42:16 +01:00

33 lines
596 B
C

/*
* Copyright © 2021, Keith Packard <keithp@keithp.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "picolibc-hooks.h"
#ifdef CONFIG_PICOLIBC_ASSERT_VERBOSE
FUNC_NORETURN void __assert_func(const char *file, int line,
const char *function, const char *expression)
{
#if __ASSERT_ON
__ASSERT(0, "assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
expression, file, line,
function ? ", function: " : "", function ? function : "");
#endif
abort();
}
#else
FUNC_NORETURN void __assert_no_args(void)
{
#if __ASSERT_ON
__ASSERT_NO_MSG(0);
#endif
abort();
}
#endif