From e3b7337f03ed3138e4cb7b277013e64f22a25602 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 12 Feb 2021 15:23:36 +1100 Subject: [PATCH] esp_common: Don't redefine likely/unlikely if already defined As these macros aren't namespaced, they may have been defined by another header. Also reported in https://github.com/espressif/esp-idf/issues/6445 --- components/esp_common/include/esp_compiler.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/esp_common/include/esp_compiler.h b/components/esp_common/include/esp_compiler.h index 7ab8cb9af5..917c660253 100644 --- a/components/esp_common/include/esp_compiler.h +++ b/components/esp_common/include/esp_compiler.h @@ -23,12 +23,20 @@ * code. */ #if (CONFIG_COMPILER_OPTIMIZATION_PERF) +#ifndef likely #define likely(x) __builtin_expect(!!(x), 1) +#endif +#ifndef unlikely #define unlikely(x) __builtin_expect(!!(x), 0) +#endif #else +#ifndef likely #define likely(x) (x) +#endif +#ifndef unlikely #define unlikely(x) (x) #endif +#endif /* * Utility macros used for designated initializers, which work differently