diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/platform/bits.h | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/platform/bits.h')
-rw-r--r-- | src/mongo/platform/bits.h | 95 |
1 files changed, 49 insertions, 46 deletions
diff --git a/src/mongo/platform/bits.h b/src/mongo/platform/bits.h index 2276318ba1a..8a59614af8f 100644 --- a/src/mongo/platform/bits.h +++ b/src/mongo/platform/bits.h @@ -35,7 +35,8 @@ // figure out if we're on a 64 or 32 bit system -#if defined(__x86_64__) || defined(__amd64__) || defined(_WIN64) || defined(__aarch64__) || defined(__powerpc64__) +#if defined(__x86_64__) || defined(__amd64__) || defined(_WIN64) || defined(__aarch64__) || \ + defined(__powerpc64__) #define MONGO_PLATFORM_64 #elif defined(__i386__) || defined(_WIN32) || defined(__arm__) #define MONGO_PLATFORM_32 @@ -45,60 +46,62 @@ namespace mongo { - /** - * Returns the number of leading 0-bits in num. Returns 64 if num is 0. - */ - inline int countLeadingZeros64(unsigned long long num); +/** + * Returns the number of leading 0-bits in num. Returns 64 if num is 0. + */ +inline int countLeadingZeros64(unsigned long long num); - /** - * Returns the number of trailing 0-bits in num. Returns 64 if num is 0. - */ - inline int countTrailingZeros64(unsigned long long num); +/** + * Returns the number of trailing 0-bits in num. Returns 64 if num is 0. + */ +inline int countTrailingZeros64(unsigned long long num); #if defined(__GNUC__) - int countLeadingZeros64(unsigned long long num) { - if (num == 0) return 64; - return __builtin_clzll(num); - } - - int countTrailingZeros64(unsigned long long num) { - if (num == 0) return 64; - return __builtin_ctzll(num); - } -#elif defined(_MSC_VER) && defined(_WIN64) - int countLeadingZeros64(unsigned long long num) { - unsigned long out; - if (_BitScanReverse64(&out, num)) - return 63 ^ out; +int countLeadingZeros64(unsigned long long num) { + if (num == 0) return 64; - } + return __builtin_clzll(num); +} - int countTrailingZeros64(unsigned long long num) { - unsigned long out; - if (_BitScanForward64(&out, num)) - return out; +int countTrailingZeros64(unsigned long long num) { + if (num == 0) return 64; - } + return __builtin_ctzll(num); +} +#elif defined(_MSC_VER) && defined(_WIN64) +int countLeadingZeros64(unsigned long long num) { + unsigned long out; + if (_BitScanReverse64(&out, num)) + return 63 ^ out; + return 64; +} + +int countTrailingZeros64(unsigned long long num) { + unsigned long out; + if (_BitScanForward64(&out, num)) + return out; + return 64; +} #elif defined(_MSC_VER) && defined(_WIN32) - int countLeadingZeros64(unsigned long long num) { - unsigned long out; - if (_BitScanReverse(&out, static_cast<unsigned long>(num >> 32))) - return 31 ^ out; - if (_BitScanReverse(&out, static_cast<unsigned long>(num))) - return 63 ^ out; - return 64; - } +int countLeadingZeros64(unsigned long long num) { + unsigned long out; + if (_BitScanReverse(&out, static_cast<unsigned long>(num >> 32))) + return 31 ^ out; + if (_BitScanReverse(&out, static_cast<unsigned long>(num))) + return 63 ^ out; + return 64; +} - int countTrailingZeros64(unsigned long long num) { - unsigned long out; - if (_BitScanForward(&out, static_cast<unsigned long>(num))) - return out; - if (_BitScanForward(&out, static_cast<unsigned long>(num >> 32))) - return out + 32; - return 64; - } +int countTrailingZeros64(unsigned long long num) { + unsigned long out; + if (_BitScanForward(&out, static_cast<unsigned long>(num))) + return out; + if (_BitScanForward(&out, static_cast<unsigned long>(num >> 32))) + return out + 32; + return 64; +} #else -# error "No bit-ops definitions for your platform" +#error "No bit-ops definitions for your platform" #endif } |