summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2020-07-28 11:54:18 -0700
committerCommit Bot <commit-bot@chromium.org>2020-08-17 20:14:48 +0000
commit84c97f043260e0b06b585ae2a46cc4e9977e0ccd (patch)
treef0dc2821c9df89780f98b6ab0b98b236056eda06
parentaca8db3d63a3521784d5b6ca38f285bc7680404d (diff)
downloadchrome-ec-84c97f043260e0b06b585ae2a46cc4e9977e0ccd.tar.gz
Replace __attribute__((noreturn)) with noreturn
_Noreturn was added in C11 and the convenience macro "noreturn" is specified by stdnoreturn.h: https://en.cppreference.com/w/c/language/_Noreturn. BRANCH=none BUG=none TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I30361bb5290cea1c776a7356f7e3a68edf1f8e39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2324816 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--board/zinger/runtime.c2
-rw-r--r--builtin/assert.h10
-rw-r--r--chip/host/reboot.c2
-rw-r--r--chip/host/reboot.h4
-rw-r--r--chip/ish/power_mgt.c8
-rw-r--r--chip/ish/power_mgt.h6
-rw-r--r--chip/ish/system.c2
-rw-r--r--chip/mchp/lfw/ec_lfw.h7
-rw-r--r--chip/mchp/system.c5
-rw-r--r--chip/mec1322/lfw/ec_lfw.h4
-rw-r--r--chip/mec1322/system.c2
-rw-r--r--chip/npcx/system-npcx5.c6
-rw-r--r--chip/npcx/system-npcx7.c6
-rw-r--r--core/cortex-m0/panic-internal.h4
-rw-r--r--core/minute-ia/interrupts.c6
-rw-r--r--core/minute-ia/mia_panic_internal.h2
-rw-r--r--core/minute-ia/panic.c2
-rw-r--r--include/panic.h14
-rw-r--r--include/system.h4
-rw-r--r--util/kconfig/preprocess.c3
20 files changed, 60 insertions, 39 deletions
diff --git a/board/zinger/runtime.c b/board/zinger/runtime.c
index 1400fd6cc7..da1a11a7ee 100644
--- a/board/zinger/runtime.c
+++ b/board/zinger/runtime.c
@@ -234,7 +234,7 @@ uint32_t task_wait_event_mask(uint32_t event_mask, int timeout_us)
return evt & event_mask;
}
-__attribute__((noreturn))
+noreturn
void __keep cpu_reset(void)
{
/* Disable interrupts */
diff --git a/builtin/assert.h b/builtin/assert.h
index 4682fecbd7..e58a450fa8 100644
--- a/builtin/assert.h
+++ b/builtin/assert.h
@@ -6,6 +6,8 @@
#ifndef __CROS_EC_ASSERT_H__
#define __CROS_EC_ASSERT_H__
+#include <stdnoreturn.h>
+
/* Include CONFIG definitions for EC sources. */
#ifndef THIRD_PARTY
#include "common.h"
@@ -19,17 +21,15 @@ extern "C" {
#ifdef CONFIG_DEBUG_ASSERT_REBOOTS
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
-extern void panic_assert_fail(const char *fname, int linenum)
- __attribute__((noreturn));
+extern noreturn void panic_assert_fail(const char *fname, int linenum);
#define ASSERT(cond) \
do { \
if (!(cond)) \
panic_assert_fail(__FILE__, __LINE__); \
} while (0)
#else
-extern void panic_assert_fail(const char *msg, const char *func,
- const char *fname, int linenum)
- __attribute__((noreturn));
+extern noreturn void panic_assert_fail(const char *msg, const char *func,
+ const char *fname, int linenum);
#define ASSERT(cond) \
do { \
if (!(cond)) \
diff --git a/chip/host/reboot.c b/chip/host/reboot.c
index bc0d348255..e932c5f11a 100644
--- a/chip/host/reboot.c
+++ b/chip/host/reboot.c
@@ -20,7 +20,7 @@ void emulator_reboot(void)
ccprints("Emulator would reboot here. Fuzzing: doing nothing.");
}
#else /* !TEST_FUZZ */
-__attribute__((noreturn))
+noreturn
void emulator_reboot(void)
{
char *argv[] = {strdup(__get_prog_name()), NULL};
diff --git a/chip/host/reboot.h b/chip/host/reboot.h
index af04677d0d..1c1201f451 100644
--- a/chip/host/reboot.h
+++ b/chip/host/reboot.h
@@ -8,8 +8,10 @@
#ifndef __CROS_EC_REBOOT_H
#define __CROS_EC_REBOOT_H
+#include <stdnoreturn.h>
+
#ifndef TEST_FUZZ
-__attribute__((noreturn))
+noreturn
#endif
void emulator_reboot(void);
diff --git a/chip/ish/power_mgt.c b/chip/ish/power_mgt.c
index ca03d6c29a..6664b589a8 100644
--- a/chip/ish/power_mgt.c
+++ b/chip/ish/power_mgt.c
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+#include <stdnoreturn.h>
+
#include "aontaskfw/ish_aon_share.h"
#include "console.h"
#include "hwtimer.h"
@@ -256,7 +258,7 @@ static void switch_to_aontask(void)
interrupt_enable();
}
-__attribute__ ((noreturn))
+noreturn
static void handle_reset_in_aontask(enum ish_pm_state pm_state)
{
pm_ctx.aon_share->pm_state = pm_state;
@@ -649,7 +651,7 @@ void ish_pm_init(void)
}
}
-__attribute__ ((noreturn))
+noreturn
void ish_pm_reset(enum ish_pm_state pm_state)
{
if (IS_ENABLED(CONFIG_ISH_PM_AONTASK) &&
@@ -756,7 +758,7 @@ DECLARE_IRQ(ISH_PMU_WAKEUP_IRQ, pmu_wakeup_isr);
*
*/
-__maybe_unused __attribute__ ((noreturn))
+__maybe_unused noreturn
static void reset_prep_isr(void)
{
/* mask reset prep avail interrupt */
diff --git a/chip/ish/power_mgt.h b/chip/ish/power_mgt.h
index 6144502286..a1fd5aabb6 100644
--- a/chip/ish/power_mgt.h
+++ b/chip/ish/power_mgt.h
@@ -6,6 +6,8 @@
#ifndef __CROS_EC_POWER_MGT_H
#define __CROS_EC_POWER_MGT_H
+#include <stdnoreturn.h>
+
#include "common.h"
#include "registers.h"
@@ -56,7 +58,7 @@ static inline void ish_mia_halt(void)
}
/* reset ISH mintue-ia cpu core */
-__attribute__((noreturn))
+noreturn
static inline void ish_mia_reset(void)
{
/**
@@ -81,7 +83,7 @@ __maybe_unused static void ish_pm_init(void)
/**
* reset ISH (reset minute-ia cpu core, and power off main SRAM)
*/
-void ish_pm_reset(enum ish_pm_state pm_state) __attribute__((noreturn));
+noreturn void ish_pm_reset(enum ish_pm_state pm_state);
/**
* notify the power management module that the UART for the console is in use.
diff --git a/chip/ish/system.c b/chip/ish/system.c
index caa5e15255..1e6fe87800 100644
--- a/chip/ish/system.c
+++ b/chip/ish/system.c
@@ -57,7 +57,7 @@ uint32_t chip_read_reset_flags(void)
* Used when the watchdog timer exceeds max retries and we want to
* disable ISH completely.
*/
-__attribute__((noreturn))
+noreturn
static void system_halt(void)
{
cflush();
diff --git a/chip/mchp/lfw/ec_lfw.h b/chip/mchp/lfw/ec_lfw.h
index 8d9da760a7..c989a3bc1b 100644
--- a/chip/mchp/lfw/ec_lfw.h
+++ b/chip/mchp/lfw/ec_lfw.h
@@ -6,6 +6,9 @@
*
*/
+#include <stdint.h>
+#include <stdnoreturn.h>
+
/* Why naked? This is dangerous except for
* function/ISR wrappers using inline assembly.
* lfw_main() makes many calls and has one local variable.
@@ -16,9 +19,9 @@
* We also do not know how much stack space is available when
* EC_RO calls lfw_main().
*
-void lfw_main(void) __attribute__ ((noreturn, naked));
+noreturn void lfw_main(void) __attribute__ ((naked));
*/
-void lfw_main(void) __attribute__ ((noreturn));
+noreturn void lfw_main(void);
void fault_handler(void) __attribute__((naked));
/*
diff --git a/chip/mchp/system.c b/chip/mchp/system.c
index 579d138d4b..1d152f0b79 100644
--- a/chip/mchp/system.c
+++ b/chip/mchp/system.c
@@ -5,6 +5,8 @@
/* System module for Chrome EC : MCHP hardware specific implementation */
+#include <stdnoreturn.h>
+
#include "clock.h"
#include "common.h"
#include "console.h"
@@ -210,8 +212,7 @@ void chip_save_reset_flags(uint32_t flags)
MCHP_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS) = flags;
}
-void __attribute__((noreturn)) _system_reset(int flags,
- int wake_from_hibernate)
+noreturn void _system_reset(int flags, int wake_from_hibernate)
{
uint32_t save_flags = 0;
diff --git a/chip/mec1322/lfw/ec_lfw.h b/chip/mec1322/lfw/ec_lfw.h
index b7f9f6359f..dd26fbd323 100644
--- a/chip/mec1322/lfw/ec_lfw.h
+++ b/chip/mec1322/lfw/ec_lfw.h
@@ -6,7 +6,9 @@
*
*/
-void lfw_main(void) __attribute__ ((noreturn, naked));
+#include <stdnoreturn.h>
+
+noreturn void lfw_main(void) __attribute__ ((naked));
void fault_handler(void) __attribute__((naked));
struct int_vector_t {
diff --git a/chip/mec1322/system.c b/chip/mec1322/system.c
index 9104bc17b1..a3043ba46b 100644
--- a/chip/mec1322/system.c
+++ b/chip/mec1322/system.c
@@ -105,7 +105,7 @@ uint32_t chip_read_reset_flags(void)
return MEC1322_VBAT_RAM(HIBDATA_INDEX_SAVED_RESET_FLAGS);
}
-__attribute__((noreturn))
+noreturn
void _system_reset(int flags, int wake_from_hibernate)
{
uint32_t save_flags = 0;
diff --git a/chip/npcx/system-npcx5.c b/chip/npcx/system-npcx5.c
index b991bb18b8..4dd12fbae2 100644
--- a/chip/npcx/system-npcx5.c
+++ b/chip/npcx/system-npcx5.c
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+#include <stdnoreturn.h>
+
/* System module driver depends on chip series for Chrome EC */
#include "common.h"
#include "console.h"
@@ -59,7 +61,7 @@ void system_mpu_config(void)
/**
* hibernate function in low power ram for npcx5 series.
*/
-void __keep __attribute__ ((noreturn, section(".lowpower_ram")))
+noreturn void __keep __attribute__ ((section(".lowpower_ram")))
__enter_hibernate_in_lpram(void)
{
/*
@@ -146,7 +148,7 @@ void __hibernate_npcx_series(void)
#ifdef CONFIG_EXTERNAL_STORAGE
/* Sysjump utilities in low power ram for npcx5 series. */
-void __keep __attribute__ ((noreturn, section(".lowpower_ram2")))
+noreturn void __keep __attribute__ ((section(".lowpower_ram2")))
__start_gdma(uint32_t exeAddr)
{
/* Enable GDMA now */
diff --git a/chip/npcx/system-npcx7.c b/chip/npcx/system-npcx7.c
index 1ec719c641..ffc64bee41 100644
--- a/chip/npcx/system-npcx7.c
+++ b/chip/npcx/system-npcx7.c
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+#include <stdnoreturn.h>
+
/* System module driver depends on chip series for Chrome EC */
#include "common.h"
#include "console.h"
@@ -57,7 +59,7 @@ void system_enter_psl_mode(void)
}
/* Hibernate function implemented by PSL (Power Switch Logic) mode. */
-void __keep __attribute__ ((noreturn)) __enter_hibernate_in_psl(void)
+noreturn void __keep __enter_hibernate_in_psl(void)
{
system_enter_psl_mode();
/* Spin and wait for PSL cuts power; should never return */
@@ -104,7 +106,7 @@ int system_config_psl_mode(enum gpio_signal signal)
* Hibernate function in last 32K ram block for npcx7 series.
* Do not use global variable since we also turn off data ram.
*/
-void __keep __attribute__ ((noreturn, section(".after_init")))
+noreturn void __keep __attribute__ ((section(".after_init")))
__enter_hibernate_in_last_block(void)
{
/*
diff --git a/core/cortex-m0/panic-internal.h b/core/cortex-m0/panic-internal.h
index e32db54320..51c12f65b2 100644
--- a/core/cortex-m0/panic-internal.h
+++ b/core/cortex-m0/panic-internal.h
@@ -6,6 +6,8 @@
#ifndef __CROS_EC_PANIC_INTERNAL_H
#define __CROS_EC_PANIC_INTERNAL_H
-void exception_panic(void) __attribute__((noreturn, naked));
+#include <stdnoreturn.h>
+
+noreturn void exception_panic(void) __attribute__((naked));
#endif /* __CROS_EC_PANIC_INTERNAL_H */
diff --git a/core/minute-ia/interrupts.c b/core/minute-ia/interrupts.c
index cb79eb119b..2d55d3129e 100644
--- a/core/minute-ia/interrupts.c
+++ b/core/minute-ia/interrupts.c
@@ -183,7 +183,7 @@ static const irq_desc_t system_irqs[] = {
_DEFINE_EXN_HANDLER(vector, exception_panic_##vector)
#define _DEFINE_EXN_HANDLER(vector, name) \
void __keep name(void); \
- __attribute__((noreturn)) void name(void) \
+ noreturn void name(void) \
{ \
__asm__ ("push $0\n" \
"push $" #vector "\n" \
@@ -195,7 +195,7 @@ static const irq_desc_t system_irqs[] = {
_DEFINE_EXN_HANDLER_W_ERRORCODE(vector, exception_panic_##vector)
#define _DEFINE_EXN_HANDLER_W_ERRORCODE(vector, name) \
void __keep name(void); \
- __attribute__((noreturn)) void name(void) \
+ noreturn void name(void) \
{ \
__asm__ ("push $" #vector "\n" \
"call exception_panic\n"); \
@@ -228,7 +228,7 @@ DEFINE_EXN_HANDLER(20);
* watchdog timer expiration. However, this time, hardware does not
* push errorcode, and we must account for that by pushing zero.
*/
-__attribute__((noreturn)) __keep
+noreturn __keep
void exception_panic_wdt(uint32_t cs)
{
exception_panic(
diff --git a/core/minute-ia/mia_panic_internal.h b/core/minute-ia/mia_panic_internal.h
index e4d3aa0cdd..748ccbf2dd 100644
--- a/core/minute-ia/mia_panic_internal.h
+++ b/core/minute-ia/mia_panic_internal.h
@@ -8,7 +8,7 @@
* convenientely in the same order as pushed by hardwared during a
* processor exception.
*/
-__attribute__((noreturn))
+noreturn
void exception_panic(
uint32_t vector,
uint32_t errorcode,
diff --git a/core/minute-ia/panic.c b/core/minute-ia/panic.c
index cbdabc3eec..ba3d895c08 100644
--- a/core/minute-ia/panic.c
+++ b/core/minute-ia/panic.c
@@ -171,7 +171,7 @@ void exception_panic(
__builtin_unreachable();
}
-__attribute__((noreturn))
+noreturn
void software_panic(uint32_t reason, uint32_t info)
{
uint16_t code_segment;
diff --git a/include/panic.h b/include/panic.h
index 4708a9ff13..6daa4c408f 100644
--- a/include/panic.h
+++ b/include/panic.h
@@ -11,6 +11,7 @@
#include <stdarg.h>
#include <stdint.h>
+#include <stdnoreturn.h>
#include "software_panic.h"
@@ -152,11 +153,10 @@ void panic_data_print(const struct panic_data *pdata);
* @param linenum Line number where assertion happened
*/
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
-void panic_assert_fail(const char *fname, int linenum)
- __attribute__((noreturn));
+noreturn void panic_assert_fail(const char *fname, int linenum);
#else
-void panic_assert_fail(const char *msg, const char *func, const char *fname,
- int linenum) __attribute__((noreturn));
+noreturn void panic_assert_fail(const char *msg, const char *func,
+ const char *fname, int linenum);
#endif
/**
@@ -164,19 +164,19 @@ void panic_assert_fail(const char *msg, const char *func, const char *fname,
*
* @param msg Panic message
*/
-void panic(const char *msg) __attribute__((noreturn));
+noreturn void panic(const char *msg);
/**
* Display a default message and reset
*/
-void panic_reboot(void) __attribute__((noreturn));
+noreturn void panic_reboot(void);
#ifdef CONFIG_SOFTWARE_PANIC
/**
* Store a panic log and halt the system for a software-related reason, such as
* stack overflow or assertion failure.
*/
-void software_panic(uint32_t reason, uint32_t info) __attribute__((noreturn));
+noreturn void software_panic(uint32_t reason, uint32_t info);
/**
* Log a panic in the panic log, but don't halt the system. Normally
diff --git a/include/system.h b/include/system.h
index 9842111997..dbdea7623b 100644
--- a/include/system.h
+++ b/include/system.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_SYSTEM_H
#define __CROS_EC_SYSTEM_H
+#include <stdnoreturn.h>
+
#include "atomic.h"
#include "common.h"
#include "compile_time_macros.h"
@@ -293,7 +295,7 @@ const char *system_get_build_info(void);
* @param flags Reset flags; see SYSTEM_RESET_* above.
*/
#ifndef TEST_FUZZ
-__attribute__((noreturn))
+noreturn
#endif
void system_reset(int flags);
diff --git a/util/kconfig/preprocess.c b/util/kconfig/preprocess.c
index 0243086fb1..67b9731a0a 100644
--- a/util/kconfig/preprocess.c
+++ b/util/kconfig/preprocess.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdnoreturn.h>
#include "list.h"
#include "lkc.h"
@@ -17,7 +18,7 @@
static char *expand_string_with_args(const char *in, int argc, char *argv[]);
static char *expand_string(const char *in);
-static void __attribute__((noreturn)) pperror(const char *format, ...)
+static noreturn void pperror(const char *format, ...)
{
va_list ap;