zephyr/lib/os/assert.c
Joakim Andersson 27bbfb66b4 assert: Completely remove file info and condition expression
Completely remove the file info and condition expression from the
the print statement if they are not enabled. This saves a little code
space which adds up when there are many assert calls.

In bluetooth shell test this saves around 4.5k bytes.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-13 13:59:55 +01:00

47 lines
931 B
C

/*
* Copyright (c) 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <sys/__assert.h>
#include <zephyr.h>
/**
*
* @brief Assert Action Handler
*
* This routine implements the action to be taken when an assertion fails.
*
* System designers may wish to substitute this implementation to take other
* actions, such as logging program counter, line number, debug information
* to a persistent repository and/or rebooting the system.
*
* @param N/A
*
* @return N/A
*/
#ifdef CONFIG_ASSERT_NO_FILE_INFO
__weak void assert_post_action(void)
#else
__weak void assert_post_action(const char *file, unsigned int line)
#endif
{
#ifndef CONFIG_ASSERT_NO_FILE_INFO
ARG_UNUSED(file);
ARG_UNUSED(line);
#endif
#ifdef CONFIG_USERSPACE
/* User threads aren't allowed to induce kernel panics; generate
* an oops instead.
*/
if (_is_user_context()) {
k_oops();
}
#endif
k_panic();
}