mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
define likely/unlikely
This commit is contained in:
parent
73f7088b45
commit
f479b76772
2 changed files with 20 additions and 0 deletions
|
@ -60,6 +60,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
#define likely(x) __builtin_expect((x),1)
|
||||||
|
#define unlikely(x) __builtin_expect((x),0)
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
#ifndef __UNIX_LIKE__
|
#ifndef __UNIX_LIKE__
|
||||||
#define __UNIX_LIKE__
|
#define __UNIX_LIKE__
|
||||||
|
@ -132,6 +134,22 @@
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
#endif
|
#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
|
* Length of a ZeroTier address in bytes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -320,6 +320,7 @@ union LZ4_streamDecode_u {
|
||||||
#define FORCE_INLINE static inline
|
#define FORCE_INLINE static inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
#if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__)
|
#if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__)
|
||||||
# define expect(expr,value) (__builtin_expect ((expr),(value)) )
|
# define expect(expr,value) (__builtin_expect ((expr),(value)) )
|
||||||
#else
|
#else
|
||||||
|
@ -328,6 +329,7 @@ union LZ4_streamDecode_u {
|
||||||
|
|
||||||
#define likely(expr) expect((expr) != 0, 1)
|
#define likely(expr) expect((expr) != 0, 1)
|
||||||
#define unlikely(expr) expect((expr) != 0, 0)
|
#define unlikely(expr) expect((expr) != 0, 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-************************************
|
/*-************************************
|
||||||
* Memory routines
|
* Memory routines
|
||||||
|
|
Loading…
Add table
Reference in a new issue