summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2017-05-09 20:22:08 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2017-05-09 20:22:08 -0700
commitf479b76772ecefde3e01fd5c2933ed0536922fd6 (patch)
treeb8c3826af808441bd8faea96d2b0304fe74bc497 /node
parent73f7088b45e562aa129b32b5a19c2e6b18f0a306 (diff)
downloadinfinitytier-f479b76772ecefde3e01fd5c2933ed0536922fd6.tar.gz
infinitytier-f479b76772ecefde3e01fd5c2933ed0536922fd6.zip
define likely/unlikely
Diffstat (limited to 'node')
-rw-r--r--node/Constants.hpp18
-rw-r--r--node/Packet.cpp2
2 files changed, 20 insertions, 0 deletions
diff --git a/node/Constants.hpp b/node/Constants.hpp
index 494ebace..3974f0ec 100644
--- a/node/Constants.hpp
+++ b/node/Constants.hpp
@@ -60,6 +60,8 @@
#endif
#ifdef __APPLE__
+#define likely(x) __builtin_expect((x),1)
+#define unlikely(x) __builtin_expect((x),0)
#include <TargetConditionals.h>
#ifndef __UNIX_LIKE__
#define __UNIX_LIKE__
@@ -132,6 +134,22 @@
#include <endian.h>
#endif
+#if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__)
+#ifndef likely
+#define likely(x) __builtin_expect((x),1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect((x),0)
+#endif
+#else
+#ifndef likely
+#define likely(x) (x)
+#endif
+#ifndef unlikely
+#define unlikely(x) (x)
+#endif
+#endif
+
/**
* Length of a ZeroTier address in bytes
*/
diff --git a/node/Packet.cpp b/node/Packet.cpp
index d60a3a34..e778e3bb 100644
--- a/node/Packet.cpp
+++ b/node/Packet.cpp
@@ -320,6 +320,7 @@ union LZ4_streamDecode_u {
#define FORCE_INLINE static inline
#endif
+#if 0
#if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__)
# define expect(expr,value) (__builtin_expect ((expr),(value)) )
#else
@@ -328,6 +329,7 @@ union LZ4_streamDecode_u {
#define likely(expr) expect((expr) != 0, 1)
#define unlikely(expr) expect((expr) != 0, 0)
+#endif
/*-************************************
* Memory routines