mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #17574 from kfessel/p-fix-asserth
core/assert: avoid including panic.h with assert.h
This commit is contained in:
commit
726c461cb5
@ -20,6 +20,7 @@
|
|||||||
#define PERIPH_CONF_H
|
#define PERIPH_CONF_H
|
||||||
|
|
||||||
#include "periph_cpu.h"
|
#include "periph_cpu.h"
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -16,15 +16,17 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "assert.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); \
|
printf("%s:%u => ", file, line);
|
||||||
core_panic(PANIC_ASSERT_FAIL, assert_crash_message); \
|
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
|
#ifndef ASSERT_H
|
||||||
#define ASSERT_H
|
#define ASSERT_H
|
||||||
|
|
||||||
#include "panic.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -51,9 +49,21 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief the string that is passed to panic in case of a failing assertion
|
* @def __NORETURN
|
||||||
|
* @brief hidden (__) NORETURN definition
|
||||||
|
* @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.
|
||||||
*/
|
*/
|
||||||
extern const char assert_crash_message[];
|
#ifndef __NORETURN
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define __NORETURN __attribute__((noreturn))
|
||||||
|
#else /*__GNUC__*/
|
||||||
|
#define __NORETURN
|
||||||
|
#endif /*__GNUC__*/
|
||||||
|
#endif /*__NORETURN*/
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define assert(ignore)((void)0)
|
#define assert(ignore)((void)0)
|
||||||
@ -68,8 +78,7 @@ extern const char assert_crash_message[];
|
|||||||
* @param[in] file The file name of the file the assertion failed in
|
* @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
|
* @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
|
* @brief abort the program if assertion is false
|
||||||
*
|
*
|
||||||
@ -103,10 +112,10 @@ NORETURN void _assert_failure(const char *file, unsigned line);
|
|||||||
*/
|
*/
|
||||||
#define assert(cond) ((cond) ? (void)0 : _assert_failure(RIOT_FILE_RELATIVE, \
|
#define assert(cond) ((cond) ? (void)0 : _assert_failure(RIOT_FILE_RELATIVE, \
|
||||||
__LINE__))
|
__LINE__))
|
||||||
#else
|
#else /* DEBUG_ASSERT_VERBOSE */
|
||||||
#define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, \
|
__NORETURN void _assert_panic(void);
|
||||||
assert_crash_message))
|
#define assert(cond) ((cond) ? (void)0 : _assert_panic())
|
||||||
#endif
|
#endif /* DEBUG_ASSERT_VERBOSE */
|
||||||
|
|
||||||
#if !defined __cplusplus
|
#if !defined __cplusplus
|
||||||
#if __STDC_VERSION__ >= 201112L
|
#if __STDC_VERSION__ >= 201112L
|
||||||
|
@ -21,10 +21,6 @@
|
|||||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "assert.h"
|
|
||||||
#include "kernel_defines.h"
|
#include "kernel_defines.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
@ -43,8 +39,6 @@
|
|||||||
#include "usb_board_reset.h"
|
#include "usb_board_reset.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char assert_crash_message[] = "FAILED ASSERTION.";
|
|
||||||
|
|
||||||
/* flag preventing "recursive crash printing loop" */
|
/* flag preventing "recursive crash printing loop" */
|
||||||
static int crashed = 0;
|
static int crashed = 0;
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "byteorder.h"
|
#include "byteorder.h"
|
||||||
|
#include "panic.h"
|
||||||
|
|
||||||
#include "cpu_conf_stm32_common.h"
|
#include "cpu_conf_stm32_common.h"
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "pm_layered.h"
|
#include "pm_layered.h"
|
||||||
|
#include "panic.h"
|
||||||
|
|
||||||
#include "periph/i2c.h"
|
#include "periph/i2c.h"
|
||||||
#include "periph/gpio.h"
|
#include "periph/gpio.h"
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -16,9 +16,7 @@
|
|||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#if IS_USED(MODULE_SAUL)
|
|
||||||
#include "saul_reg.h"
|
#include "saul_reg.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "sgp30.h"
|
#include "sgp30.h"
|
||||||
#include "sgp30_params.h"
|
#include "sgp30_params.h"
|
||||||
@ -28,7 +26,6 @@
|
|||||||
*/
|
*/
|
||||||
static sgp30_t sgp30_devs[SGP30_NUM];
|
static sgp30_t sgp30_devs[SGP30_NUM];
|
||||||
|
|
||||||
#if IS_USED(MODULE_SAUL)
|
|
||||||
/**
|
/**
|
||||||
* @brief Memory for the SAUL registry entries
|
* @brief Memory for the SAUL registry entries
|
||||||
*/
|
*/
|
||||||
@ -41,7 +38,6 @@ static saul_reg_t saul_entries[SGP30_NUM * 2];
|
|||||||
extern const saul_driver_t sgp30_saul_driver_eco2;
|
extern const saul_driver_t sgp30_saul_driver_eco2;
|
||||||
extern const saul_driver_t sgp30_saul_driver_tvoc;
|
extern const saul_driver_t sgp30_saul_driver_tvoc;
|
||||||
/** @} */
|
/** @} */
|
||||||
#endif
|
|
||||||
|
|
||||||
void auto_init_sgp30(void)
|
void auto_init_sgp30(void)
|
||||||
{
|
{
|
||||||
@ -55,7 +51,6 @@ void auto_init_sgp30(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IS_USED(MODULE_SAUL)
|
|
||||||
/* eCO2 */
|
/* eCO2 */
|
||||||
saul_entries[(i * 2)].dev = &(sgp30_devs[i]);
|
saul_entries[(i * 2)].dev = &(sgp30_devs[i]);
|
||||||
saul_entries[(i * 2)].name = sgp30_saul_info[i].name;
|
saul_entries[(i * 2)].name = sgp30_saul_info[i].name;
|
||||||
@ -69,6 +64,5 @@ void auto_init_sgp30(void)
|
|||||||
/* register to saul */
|
/* register to saul */
|
||||||
saul_reg_add(&(saul_entries[(i * 2)]));
|
saul_reg_add(&(saul_entries[(i * 2)]));
|
||||||
saul_reg_add(&(saul_entries[(i * 2) + 1]));
|
saul_reg_add(&(saul_entries[(i * 2) + 1]));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "net/nanocoap.h"
|
#include "net/nanocoap.h"
|
||||||
#include "hashes/sha256.h"
|
#include "hashes/sha256.h"
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
/* internal value that can be read/written via CoAP */
|
/* internal value that can be read/written via CoAP */
|
||||||
static uint8_t internal_value = 0;
|
static uint8_t internal_value = 0;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "net/nanocoap.h"
|
#include "net/nanocoap.h"
|
||||||
#include "suit/transport/coap.h"
|
#include "suit/transport/coap.h"
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
static ssize_t _riot_board_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, void *context)
|
static ssize_t _riot_board_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, void *context)
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
ssize_t write(int fildes, const void *buf, size_t nbyte);
|
ssize_t write(int fildes, const void *buf, size_t nbyte);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "kernel_defines.h"
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
|
|
||||||
static const char _hex_chars[16] = "0123456789ABCDEF";
|
static const char _hex_chars[16] = "0123456789ABCDEF";
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define NET_GNRC_IPV6_NIB_PL_H
|
#define NET_GNRC_IPV6_NIB_PL_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <kernel_defines.h>
|
||||||
|
|
||||||
#if IS_USED(MODULE_EVTIMER)
|
#if IS_USED(MODULE_EVTIMER)
|
||||||
#include "evtimer.h"
|
#include "evtimer.h"
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "net/ipv6/addr.h"
|
#include "net/ipv6/addr.h"
|
||||||
#include "timex.h"
|
#include "timex.h"
|
||||||
|
#include <kernel_defines.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -39,6 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
/** @brief Version number */
|
/** @brief Version number */
|
||||||
#define UTLIST_VERSION 1.9.9
|
#define UTLIST_VERSION 1.9.9
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "fmt.h"
|
#include "fmt.h"
|
||||||
#include "net/nanocoap.h"
|
#include "net/nanocoap.h"
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
#define _MAX_PAYLOAD_LEN (16)
|
#define _MAX_PAYLOAD_LEN (16)
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "architecture.h"
|
#include "architecture.h"
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
|
||||||
/* On all but 8bit architectures, at least one of the following should be
|
/* On all but 8bit architectures, at least one of the following should be
|
||||||
* misaligned */
|
* misaligned */
|
||||||
|
Loading…
Reference in New Issue
Block a user