From e3a7eab78923e84cb2301797590583279880cf6c Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 24 Apr 2021 10:05:18 +0100 Subject: [PATCH] unlikely annotation introduction proposal. --- src/ds/defines.h | 4 +++- src/pal/pal.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ds/defines.h b/src/ds/defines.h index 7ccbdb2..e67e36d 100644 --- a/src/ds/defines.h +++ b/src/ds/defines.h @@ -8,6 +8,7 @@ # define SNMALLOC_SLOW_PATH NOINLINE # define SNMALLOC_FAST_PATH ALWAYSINLINE # define SNMALLOC_PURE +# define SNMALLOC_COLD #else # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) @@ -16,6 +17,7 @@ # define SNMALLOC_SLOW_PATH NOINLINE # define SNMALLOC_FAST_PATH inline ALWAYSINLINE # define SNMALLOC_PURE __attribute__((const)) +# define SNMALLOC_COLD __attribute__((cold)) #endif #if !defined(__clang__) && defined(__GNUC__) @@ -37,7 +39,7 @@ namespace snmalloc { // Forwards reference so that the platform can define how to handle errors. - [[noreturn]] void error(const char* const str); + [[noreturn]] SNMALLOC_COLD void error(const char* const str); } // namespace snmalloc #define TOSTRING(expr) TOSTRING2(expr) diff --git a/src/pal/pal.h b/src/pal/pal.h index bcd9293..10f9cd8 100644 --- a/src/pal/pal.h +++ b/src/pal/pal.h @@ -61,7 +61,8 @@ namespace snmalloc DefaultPal; #endif - [[noreturn]] SNMALLOC_SLOW_PATH inline void error(const char* const str) + [[noreturn]] SNMALLOC_SLOW_PATH inline SNMALLOC_COLD void + error(const char* const str) { Pal::error(str); }