From e3e94ca23883309b241cbd4fd34de3ba63a24a60 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 16 Apr 2023 19:15:22 +0200 Subject: [PATCH] Add M_ATTR_COLD_FUNCTION attribute --- m-core.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/m-core.h b/m-core.h index 8f34fa2b..5eafa905 100644 --- a/m-core.h +++ b/m-core.h @@ -126,10 +126,21 @@ # define M_ATTR_NO_RETURN _Noreturn #elif defined(__GNUC__) # define M_ATTR_NO_RETURN __attribute__ ((noreturn)) +#elif defined(_MSC_VER) +# define M_ATTR_NO_RETURN __declspec(noreturn) #else # define M_ATTR_NO_RETURN #endif +/* The cold attribute on functions is used to inform the compiler + that the function is unlikely to be executed. */ +#if defined(__GNUC__) +# define M_ATTR_COLD_FUNCTION __attribute__ ((cold)) +#else +# define M_ATTR_COLD_FUNCTION +#endif + + /* Ignore some warnings detected by some compilers in the library. * Whatever we do, there is some warnings that cannot be fixed. * So they are ignored in order to avoid polluting the user with