From b00819bcca0c7b98af7e7e1717ccbedc2a426d57 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 29 Nov 2018 09:33:50 +0100 Subject: Atomic: Avoid conflicts with definitions in other areas While atomics library was trying to use "user-space" defined LIKELY() and UNLIKELY(), this is not always true that user code was checking for those macro coming from an unrelated area. --- intern/atomic/intern/atomic_ops_ext.h | 2 +- intern/atomic/intern/atomic_ops_utils.h | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'intern/atomic') diff --git a/intern/atomic/intern/atomic_ops_ext.h b/intern/atomic/intern/atomic_ops_ext.h index 1b1fea9642d..9c3104108b1 100644 --- a/intern/atomic/intern/atomic_ops_ext.h +++ b/intern/atomic/intern/atomic_ops_ext.h @@ -206,7 +206,7 @@ ATOMIC_INLINE float atomic_add_and_fetch_fl(float *p, const float x) oldval = *p; newval = oldval + x; prevval = atomic_cas_uint32((uint32_t *)p, *(uint32_t *)(&oldval), *(uint32_t *)(&newval)); - } while (UNLIKELY(prevval != *(uint32_t *)(&oldval))); + } while (_ATOMIC_UNLIKELY(prevval != *(uint32_t *)(&oldval))); return newval; } diff --git a/intern/atomic/intern/atomic_ops_utils.h b/intern/atomic/intern/atomic_ops_utils.h index 621b3e95906..413983bc9a6 100644 --- a/intern/atomic/intern/atomic_ops_utils.h +++ b/intern/atomic/intern/atomic_ops_utils.h @@ -66,14 +66,12 @@ # define ATOMIC_INLINE static inline __attribute__((always_inline)) #endif -#ifndef LIKELY -# ifdef __GNUC__ -# define LIKELY(x) __builtin_expect(!!(x), 1) -# define UNLIKELY(x) __builtin_expect(!!(x), 0) -# else -# define LIKELY(x) (x) -# define UNLIKELY(x) (x) -# endif +#ifdef __GNUC__ +# define _ATOMIC_LIKELY(x) __builtin_expect(!!(x), 1) +# define _ATOMIC_UNLIKELY(x) __builtin_expect(!!(x), 0) +#else +# define _ATOMIC_LIKELY(x) (x) +# define _ATOMIC_UNLIKELY(x) (x) #endif #if defined(__SIZEOF_POINTER__) -- cgit v1.2.3