[Bf-blender-cvs] [b00819bcca0] master: Atomic: Avoid conflicts with definitions in other areas

Sergey Sharybin noreply at git.blender.org
Thu Nov 29 09:35:28 CET 2018


Commit: b00819bcca0c7b98af7e7e1717ccbedc2a426d57
Author: Sergey Sharybin
Date:   Thu Nov 29 09:33:50 2018 +0100
Branches: master
https://developer.blender.org/rBb00819bcca0c7b98af7e7e1717ccbedc2a426d57

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.

===================================================================

M	intern/atomic/intern/atomic_ops_ext.h
M	intern/atomic/intern/atomic_ops_utils.h

===================================================================

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__)



More information about the Bf-blender-cvs mailing list