From 6c08816de83ab5f3ce76b988c08fe45cdf64ccd5 Mon Sep 17 00:00:00 2001
From: Yichao Yu <yyc1992@gmail.com>
Date: Mon, 16 Jun 2014 03:49:33 -0400
Subject: [PATCH] PYOPENCL_(UN)LIKELY

---
 src/c_wrapper/error.h         | 2 +-
 src/c_wrapper/memory_object.h | 2 +-
 src/c_wrapper/utils.h         | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/c_wrapper/error.h b/src/c_wrapper/error.h
index 4084eeb2..6d59bf44 100644
--- a/src/c_wrapper/error.h
+++ b/src/c_wrapper/error.h
@@ -173,7 +173,7 @@ retry_mem_error(Func func) -> decltype(func())
     try {
         return func();
     } catch (clerror &e) {
-        if (!e.is_out_of_memory() || !py::gc()) {
+        if (PYOPENCL_LIKELY(!e.is_out_of_memory()) || !py::gc()) {
             throw;
         }
     }
diff --git a/src/c_wrapper/memory_object.h b/src/c_wrapper/memory_object.h
index 5f1bb91b..83248b66 100644
--- a/src/c_wrapper/memory_object.h
+++ b/src/c_wrapper/memory_object.h
@@ -33,7 +33,7 @@ public:
     void
     release() const
     {
-        if (!m_valid.exchange(false)) {
+        if (PYOPENCL_UNLIKELY(!m_valid.exchange(false))) {
             throw clerror("MemoryObject.release", CL_INVALID_VALUE,
                           "trying to double-unref mem object");
         }
diff --git a/src/c_wrapper/utils.h b/src/c_wrapper/utils.h
index cf9c4ace..241ef0af 100644
--- a/src/c_wrapper/utils.h
+++ b/src/c_wrapper/utils.h
@@ -15,8 +15,8 @@
 #  define PYOPENCL_EXPECT(exp, var) (exp)
 #endif
 
-#define PYOPENCL_LIKELY(x) pyopencl_expect(bool(x), true)
-#define PYOPENCL_UNLIKELY(x) pyopencl_expect(bool(x), false)
+#define PYOPENCL_LIKELY(x) PYOPENCL_EXPECT(bool(x), true)
+#define PYOPENCL_UNLIKELY(x) PYOPENCL_EXPECT(bool(x), false)
 
 template<class T>
 PYOPENCL_USE_RESULT static PYOPENCL_INLINE std::string
-- 
GitLab