From 3b23a6c40ac42c5673c6817ddf174983497519da Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 1 Feb 2022 15:28:19 +0100 Subject: [PATCH] fundamental: support assert_se() in EFI mode too --- src/boot/efi/assert.c | 5 +---- src/fundamental/macro-fundamental.h | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/boot/efi/assert.c b/src/boot/efi/assert.c index 7a25526de2..bb16d2bf93 100644 --- a/src/boot/efi/assert.c +++ b/src/boot/efi/assert.c @@ -1,9 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#ifndef NDEBUG - #include #include + #include "util.h" void efi_assert(const char *expr, const char *file, unsigned line, const char *function) { @@ -11,5 +10,3 @@ void efi_assert(const char *expr, const char *file, unsigned line, const char *f for (;;) BS->Stall(60 * 1000 * 1000); } - -#endif diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index d597c743bb..a1cbc3a5b3 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -53,14 +53,16 @@ #define CONCATENATE(x, y) XCONCATENATE(x, y) #ifdef SD_BOOT + void efi_assert(const char *expr, const char *file, unsigned line, const char *function) _noreturn_; + #ifdef NDEBUG #define assert(expr) #define assert_not_reached() __builtin_unreachable() #else - void efi_assert(const char *expr, const char *file, unsigned line, const char *function) _noreturn_; #define assert(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); }) #define assert_not_reached() efi_assert("Code should not be reached", __FILE__, __LINE__, __PRETTY_FUNCTION__) #endif + #define assert_se(expr) ({ _likely_(expr) ? VOID_0 : efi_assert(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); }) #define memcpy(a, b, c) CopyMem((a), (b), (c)) #define free(a) FreePool(a) -- 2.25.1