diff options
author | Aaron Durbin <adurbin@chromium.org> | 2018-09-05 09:37:11 -0600 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-09-10 15:02:51 +0000 |
commit | 0370bcf40ce3a07e6e2d33b8bcebf28a0ac98807 (patch) | |
tree | 8dbdeded229ced4fc7bf7579954798ddfb7d7439 | |
parent | 261d626669ea244a55ec310a11a23ca56b609b51 (diff) |
complier.h: add __noreturn and use it in code base
Add a __noreturn macro that wraps __attribute__((noreturn)) and replace
current users with the macro.
Change-Id: Iddd0728cf79678c3d1c1f7e7946c27375a644a7d
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/28505
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
-rw-r--r-- | src/console/die.c | 3 | ||||
-rw-r--r-- | src/drivers/intel/fsp1_0/fsp_util.c | 3 | ||||
-rw-r--r-- | src/include/compiler.h | 1 | ||||
-rw-r--r-- | src/include/console/console.h | 3 | ||||
-rw-r--r-- | src/include/halt.h | 3 | ||||
-rw-r--r-- | src/include/reset.h | 8 | ||||
-rw-r--r-- | src/lib/reset.c | 2 | ||||
-rw-r--r-- | src/lib/ubsan.c | 13 | ||||
-rw-r--r-- | src/northbridge/amd/lx/raminit.c | 3 | ||||
-rw-r--r-- | src/soc/nvidia/tegra124/lp0/tegra_lp0_resume.c | 4 | ||||
-rw-r--r-- | src/soc/nvidia/tegra210/lp0/tegra_lp0_resume.c | 4 |
11 files changed, 25 insertions, 22 deletions
diff --git a/src/console/die.c b/src/console/die.c index 3f5ca45068..59411256be 100644 --- a/src/console/die.c +++ b/src/console/die.c @@ -20,7 +20,6 @@ #include <halt.h> #ifndef __ROMCC__ -#define NORETURN __attribute__((noreturn)) /* * The method should be overwritten in mainboard directory to signal that a @@ -33,7 +32,7 @@ __weak void die_notify(void) } /* Report a fatal error */ -void NORETURN die(const char *msg) +void __noreturn die(const char *msg) { printk(BIOS_EMERG, "%s", msg); die_notify(); diff --git a/src/drivers/intel/fsp1_0/fsp_util.c b/src/drivers/intel/fsp1_0/fsp_util.c index c19c1a1186..5d866bfad8 100644 --- a/src/drivers/intel/fsp1_0/fsp_util.c +++ b/src/drivers/intel/fsp1_0/fsp_util.c @@ -15,6 +15,7 @@ #include <types.h> #include <string.h> +#include <compiler.h> #include <console/console.h> #include <bootstate.h> #include <cbmem.h> @@ -66,7 +67,7 @@ void FspNotify (u32 Phase) * Call the FSP to do memory init. The FSP doesn't return to this function. * The FSP returns to the romstage_main_continue(). */ -void __attribute__((noreturn)) fsp_early_init (FSP_INFO_HEADER *fsp_ptr) +void __noreturn fsp_early_init (FSP_INFO_HEADER *fsp_ptr) { FSP_FSP_INIT FspInitApi; FSP_INIT_PARAMS FspInitParams; diff --git a/src/include/compiler.h b/src/include/compiler.h index e088eb1a51..4df1cab7e6 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -26,5 +26,6 @@ #define __always_unused __attribute__((unused)) #define __must_check __attribute__((warn_unused_result)) #define __weak __attribute__((weak)) +#define __noreturn __attribute__((noreturn)) #endif diff --git a/src/include/console/console.h b/src/include/console/console.h index 535401f7db..ff20782398 100644 --- a/src/include/console/console.h +++ b/src/include/console/console.h @@ -19,6 +19,7 @@ #include <stdint.h> #include <rules.h> #include <arch/cpu.h> +#include <compiler.h> #include <console/post_codes.h> #include <commonlib/loglevel.h> @@ -40,7 +41,7 @@ void post_log_clear(void); #endif /* this function is weak and can be overridden by a mainboard function. */ void mainboard_post(u8 value); -void __attribute__((noreturn)) die(const char *msg); +void __noreturn die(const char *msg); /* * This function is weak and can be overridden to provide additional diff --git a/src/include/halt.h b/src/include/halt.h index 7ecd41a6cd..e8f1b51976 100644 --- a/src/include/halt.h +++ b/src/include/halt.h @@ -20,10 +20,11 @@ #ifdef __ROMCC__ #include <lib/halt.c> #else +#include <compiler.h> /** * halt the system reliably */ -void __attribute__((noreturn)) halt(void); +void __noreturn halt(void); #endif /* __ROMCC__ */ /* Power off the system. */ diff --git a/src/include/reset.h b/src/include/reset.h index 934ed9b1fc..48999164bb 100644 --- a/src/include/reset.h +++ b/src/include/reset.h @@ -1,14 +1,16 @@ #ifndef RESET_H #define RESET_H +#include <compiler.h> + /* Generic reset functions. Call from code that wants to trigger a reset. */ /* Super-hard reset specific to some Intel SoCs. */ -__attribute__((noreturn)) void global_reset(void); +__noreturn void global_reset(void); /* Full board reset. Resets SoC and most/all board components (e.g. DRAM). */ -__attribute__((noreturn)) void hard_reset(void); +__noreturn void hard_reset(void); /* Board reset. Resets SoC some board components (e.g. TPM but not DRAM). */ -__attribute__((noreturn)) void soft_reset(void); +__noreturn void soft_reset(void); /* Reset implementations. Implement these in SoC or mainboard code. Implement at least hard_reset() if possible, others fall back to it if necessary. */ diff --git a/src/lib/reset.c b/src/lib/reset.c index 2c9529277e..d5676e5cd4 100644 --- a/src/lib/reset.c +++ b/src/lib/reset.c @@ -19,7 +19,7 @@ #include <halt.h> #include <reset.h> -__attribute__((noreturn)) static void __hard_reset(void) { +__noreturn static void __hard_reset(void) { if (IS_ENABLED(CONFIG_HAVE_HARD_RESET)) do_hard_reset(); else diff --git a/src/lib/ubsan.c b/src/lib/ubsan.c index ead0e18026..128340092f 100644 --- a/src/lib/ubsan.c +++ b/src/lib/ubsan.c @@ -43,8 +43,7 @@ typedef uintptr_t ubsan_value_handle_t; */ #pragma GCC diagnostic ignored "-Wmissing-prototypes" -__attribute__((noreturn)) -static void ubsan_abort(const struct ubsan_source_location *location, +static void __noreturn ubsan_abort(const struct ubsan_source_location *location, const char *violation) { static const struct ubsan_source_location unknown_location = { "<unknown file>", @@ -61,8 +60,8 @@ static void ubsan_abort(const struct ubsan_source_location *location, } #define ABORT_VARIANT(name, params, call) \ - __attribute__((noreturn)) void __ubsan_handle_##name##_abort params; \ - __attribute__((noreturn)) void __ubsan_handle_##name##_abort params { \ + __noreturn void __ubsan_handle_##name##_abort params; \ + __noreturn void __ubsan_handle_##name##_abort params { \ __ubsan_handle_##name call; \ __builtin_unreachable(); \ } @@ -212,16 +211,14 @@ struct ubsan_unreachable_data { struct ubsan_source_location location; }; -__attribute__((noreturn)) -void __ubsan_handle_builtin_unreachable(void *data_raw) +void __noreturn __ubsan_handle_builtin_unreachable(void *data_raw) { struct ubsan_unreachable_data *data = (struct ubsan_unreachable_data *)data_raw; ubsan_abort(&data->location, "reached unreachable"); } -__attribute__((noreturn)) -void __ubsan_handle_missing_return(void *data_raw) +void __noreturn __ubsan_handle_missing_return(void *data_raw) { const struct ubsan_unreachable_data *data = (struct ubsan_unreachable_data *)data_raw; diff --git a/src/northbridge/amd/lx/raminit.c b/src/northbridge/amd/lx/raminit.c index 5f83331861..55dcefde62 100644 --- a/src/northbridge/amd/lx/raminit.c +++ b/src/northbridge/amd/lx/raminit.c @@ -13,6 +13,7 @@ * GNU General Public License for more details. */ +#include <compiler.h> #include <console/console.h> #include <cpu/x86/msr.h> #include <cpu/amd/lxdef.h> @@ -33,7 +34,7 @@ static void banner(const char *s) printk(BIOS_DEBUG, " * %s\n", s); } -static void __attribute__((noreturn)) hcf(void) +static void __noreturn hcf(void) { printk(BIOS_EMERG, "DIE\n"); /* this guarantees we flush the UART fifos (if any) and also diff --git a/src/soc/nvidia/tegra124/lp0/tegra_lp0_resume.c b/src/soc/nvidia/tegra124/lp0/tegra_lp0_resume.c index 4d4eae95bc..00dc0f715f 100644 --- a/src/soc/nvidia/tegra124/lp0/tegra_lp0_resume.c +++ b/src/soc/nvidia/tegra124/lp0/tegra_lp0_resume.c @@ -265,7 +265,7 @@ static uint32_t *sysctr_cntfid0_ptr = (void *)(SYSCTR_CTLR_BASE + 0x20); /* Utility functions. */ static inline void __attribute__((always_inline)) - __attribute__((noreturn)) halt(void) + __noreturn halt(void) { for (;;); } @@ -290,7 +290,7 @@ static inline void clrbits32(uint32_t bits, void *addr) write32(addr, read32(addr) & ~bits); } -static void __attribute__((noreturn)) reset(void) +static void __noreturn reset(void) { write32(clk_rst_rst_devices_l_ptr, SWR_TRIG_SYS_RST); halt(); diff --git a/src/soc/nvidia/tegra210/lp0/tegra_lp0_resume.c b/src/soc/nvidia/tegra210/lp0/tegra_lp0_resume.c index 01cf2163f9..2e8c9bb6b3 100644 --- a/src/soc/nvidia/tegra210/lp0/tegra_lp0_resume.c +++ b/src/soc/nvidia/tegra210/lp0/tegra_lp0_resume.c @@ -429,7 +429,7 @@ enum { /* Utility functions. */ static inline void __attribute__((always_inline)) - __attribute__((noreturn)) halt(void) + __noreturn halt(void) { for (;;); } @@ -454,7 +454,7 @@ static inline void clrbits32(uint32_t bits, void *addr) write32(addr, read32(addr) & ~bits); } -static void __attribute__((noreturn)) reset(void) +static void __noreturn reset(void) { write32(clk_rst_rst_devices_l_ptr, SWR_TRIG_SYS_RST); halt(); |