mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
core/assert: remove panic include from assert.h
This commit is contained in:
parent
07a4756242
commit
0b52b3e62e
@ -16,15 +16,17 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "panic.h"
|
||||
|
||||
#ifdef DEBUG_ASSERT_VERBOSE
|
||||
NORETURN void _assert_failure(const char *file, unsigned line)
|
||||
__NORETURN void _assert_failure(const char *file, unsigned line)
|
||||
{
|
||||
printf("%s:%u => ", file, line); \
|
||||
core_panic(PANIC_ASSERT_FAIL, assert_crash_message); \
|
||||
printf("%s:%u => ", file, line);
|
||||
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION.");
|
||||
}
|
||||
|
||||
__NORETURN void _assert_panic(void)
|
||||
{
|
||||
core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION.");
|
||||
}
|
||||
#else
|
||||
typedef int dont_be_pedantic;
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
@ -22,8 +22,6 @@
|
||||
#ifndef ASSERT_H
|
||||
#define ASSERT_H
|
||||
|
||||
#include "panic.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -51,9 +49,18 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief the string that is passed to panic in case of a failing assertion
|
||||
*/
|
||||
extern const char assert_crash_message[];
|
||||
* @def __NORETURN
|
||||
* @internal
|
||||
* Duplicating the definitions of kernel_defines.h as these are unsuitable for
|
||||
* system header files like the assert.h.
|
||||
* kernel_defines.h would define symbols that are not reserved. */
|
||||
#ifndef __NORETURN
|
||||
#ifdef __GNUC__
|
||||
#define __NORETURN __attribute__((noreturn))
|
||||
#else /*__GNUC__*/
|
||||
#define __NORETURN
|
||||
#endif /*__GNUC__*/
|
||||
#endif /*__NORETURN*/
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assert(ignore)((void)0)
|
||||
@ -68,8 +75,7 @@ extern const char assert_crash_message[];
|
||||
* @param[in] file The file name of the file the assertion failed in
|
||||
* @param[in] line The code line of @p file the assertion failed in
|
||||
*/
|
||||
NORETURN void _assert_failure(const char *file, unsigned line);
|
||||
|
||||
__NORETURN void _assert_failure(const char *file, unsigned line);
|
||||
/**
|
||||
* @brief abort the program if assertion is false
|
||||
*
|
||||
@ -103,10 +109,10 @@ NORETURN void _assert_failure(const char *file, unsigned line);
|
||||
*/
|
||||
#define assert(cond) ((cond) ? (void)0 : _assert_failure(RIOT_FILE_RELATIVE, \
|
||||
__LINE__))
|
||||
#else
|
||||
#define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, \
|
||||
assert_crash_message))
|
||||
#endif
|
||||
#else /* DEBUG_ASSERT_VERBOSE */
|
||||
__NORETURN void _assert_panic(void);
|
||||
#define assert(cond) ((cond) ? (void)0 : _assert_panic())
|
||||
#endif /* DEBUG_ASSERT_VERBOSE */
|
||||
|
||||
#if !defined __cplusplus
|
||||
#if __STDC_VERSION__ >= 201112L
|
||||
|
@ -43,8 +43,6 @@
|
||||
#include "usb_board_reset.h"
|
||||
#endif
|
||||
|
||||
const char assert_crash_message[] = "FAILED ASSERTION.";
|
||||
|
||||
/* flag preventing "recursive crash printing loop" */
|
||||
static int crashed = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user