Skip to content

Commit

Permalink
Fix compatibility of OPENTELEMETRY_LIKELY_IF
Browse files Browse the repository at this point in the history
Signed-off-by: owent <admin@owent.net>
  • Loading branch information
owent committed May 17, 2022
1 parent 607a060 commit e693959
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions api/include/opentelemetry/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,14 @@

#include "opentelemetry/version.h"

#ifndef OPENTELEMETRY_LIKELY_IF
# if defined(__has_cpp_attribute)
#if !defined(OPENTELEMETRY_LIKELY_IF) && defined(__cplusplus)
// GCC 9 has likely attribute but do not support declare it at the beginning of statement
# if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9)
# if __has_cpp_attribute(likely)
# define OPENTELEMETRY_LIKELY_IF(...) \
if (__VA_ARGS__) \
[[likely]]
# endif
# elif defined(__clang__)
# if __clang_major__ >= 12
# define OPENTELEMETRY_LIKELY_IF(...) \
if (__VA_ARGS__) \
[[likely]]
# endif
# elif defined(__GNUC__)
# if __GNUC__ >= 9
# define OPENTELEMETRY_LIKELY_IF(...) \
if (__VA_ARGS__) \
[[likely]]
# endif
# endif
#endif
#if !defined(OPENTELEMETRY_LIKELY_IF) && (defined(__clang__) || defined(__GNUC__))
Expand Down

0 comments on commit e693959

Please sign in to comment.