diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-03-01 14:36:52 -0800 | 
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-03-01 14:36:52 -0800 | 
| commit | 1d39be61b267a85adebeee9e979bd1d84f55da3c (patch) | |
| tree | 2fa5efbe2406a9a60686c1de422ff2c574802ba5 /node/Utils.hpp | |
| parent | 2bf9145ae65385bf968542619ffcf204cf6241d8 (diff) | |
| download | infinitytier-1d39be61b267a85adebeee9e979bd1d84f55da3c.tar.gz infinitytier-1d39be61b267a85adebeee9e979bd1d84f55da3c.zip | |
ZeroTier now has link quality measurement. We are not using this yet but decided to put it in to prep for future QoS support and SD-WAN stuff.
Diffstat (limited to 'node/Utils.hpp')
| -rw-r--r-- | node/Utils.hpp | 14 | 
1 files changed, 14 insertions, 0 deletions
| diff --git a/node/Utils.hpp b/node/Utils.hpp index 7b1994be..ceb29d7e 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -253,6 +253,20 @@ public:  	}  	/** +	 * Count the number of bits set in an integer +	 * +	 * @param v 64-bit integer +	 * @return Number of bits set in this integer (0-64) +	 */ +	static inline uint64_t countBits(uint64_t v) +	{ +		v = v - ((v >> 1) & (uint64_t)~(uint64_t)0/3); +		v = (v & (uint64_t)~(uint64_t)0/15*3) + ((v >> 2) & (uint64_t)~(uint64_t)0/15*3); +		v = (v + (v >> 4)) & (uint64_t)~(uint64_t)0/255*15; +		return (uint64_t)(v * ((uint64_t)~(uint64_t)0/255)) >> 56; +	} + +	/**  	 * Check if a memory buffer is all-zero  	 *  	 * @param p Memory to scan | 
