From bc6d9518e10bceb07ea128dc7b83decee2f082c7 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 9 Aug 2019 08:39:04 -0700 Subject: Make it use builtin functions on clang --- upb/port_def.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'upb/port_def.inc') diff --git a/upb/port_def.inc b/upb/port_def.inc index 3e0a7f4..1b7c335 100644 --- a/upb/port_def.inc +++ b/upb/port_def.inc @@ -45,14 +45,14 @@ /* UPB_INLINE: inline if possible, emit standalone code if required. */ #ifdef __cplusplus #define UPB_INLINE inline -#elif defined (__GNUC__) +#elif defined (__GNUC__) || defined(__clang__) #define UPB_INLINE static __inline__ #else #define UPB_INLINE static #endif /* Hints to the compiler about likely/unlikely branches. */ -#ifdef __GNUC__ +#if defined (__GNUC__) || defined(__clang__) #define UPB_LIKELY(x) __builtin_expect((x),1) #define UPB_UNLIKELY(x) __builtin_expect((x),0) #else @@ -139,7 +139,7 @@ int msvc_snprintf(char* s, size_t n, const char* format, ...); * exist in debug mode. This turns into regular assert. */ #define UPB_ASSERT_DEBUGVAR(expr) assert(expr) -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__clang__) #define UPB_UNREACHABLE() do { assert(0); __builtin_unreachable(); } while(0) #else #define UPB_UNREACHABLE() do { assert(0); } while(0) -- cgit v1.2.3