From 7f8e2d44ed68b25d1dac08345ddfd86065d0148a Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Wed, 21 Jun 2023 22:19:54 +0100 Subject: [PATCH] Move OPTNONE macro to eficompiler.h This is also useful in downstream projects so add it to public header Signed-off-by: Callum Farmer --- apps/debughook.c | 8 +------- inc/eficompiler.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/debughook.c b/apps/debughook.c index 78e4a76..c862f0f 100644 --- a/apps/debughook.c +++ b/apps/debughook.c @@ -37,13 +37,7 @@ GetVariable(CHAR16 *var, UINT8 **data, UINTN *len, EFI_GUID owner) EFI_GUID DUMMY_GUID = {0x55aad538, 0x8f82, 0x4e2a, {0xa4,0xf0,0xbe, 0x59, 0x13, 0xb6, 0x5f, 0x1e}}; -#if defined(__clang__) -# define _OPTNONE __attribute__((optnone)) -#else -# define _OPTNONE __attribute__((__optimize__("0"))) -#endif - -static _OPTNONE void +static EFI_OPTNONE void DebugHook(void) { EFI_GUID guid = DUMMY_GUID; diff --git a/inc/eficompiler.h b/inc/eficompiler.h index 3b66eb6..8818747 100644 --- a/inc/eficompiler.h +++ b/inc/eficompiler.h @@ -28,6 +28,16 @@ Abstract: #endif #endif +#ifdef _MSC_EXTENSIONS +#define EFI_OPTNONE +#else +#ifdef __clang__ +#define EFI_OPTNONE __attribute__((optnone)) +#else +#define EFI_OPTNONE __attribute__((__optimize__("0"))) +#endif +#endif + #ifdef _MSC_EXTENSIONS #define ALIGN(x) __declspec(align(x)) #else