X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fexperimental%2FBits.h;h=61844e8eeb347bff7ddea4c597336bc5126512bb;hb=aabeca717ad6cb7e168fbfdcd0ed9c29bf0fa0e2;hp=3677010533222b57a16f5cfb33727919ff751947;hpb=ff03c3a89d70f49f5fdedcb1e6af7a1c9fc9bacb;p=folly.git diff --git a/folly/experimental/Bits.h b/folly/experimental/Bits.h index 36770105..61844e8e 100644 --- a/folly/experimental/Bits.h +++ b/folly/experimental/Bits.h @@ -1,5 +1,5 @@ /* - * Copyright 2014 Facebook, Inc. + * Copyright 2016 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,16 +14,16 @@ * limitations under the License. */ -#ifndef FOLLY_EXPERIMENTAL_BITS_H_ -#define FOLLY_EXPERIMENTAL_BITS_H_ +#pragma once #include #include #include +#include -#include "folly/Bits.h" -#include "folly/Portability.h" -#include "folly/Range.h" +#include +#include +#include namespace folly { @@ -57,8 +57,7 @@ struct BitsTraits, typename std::enable_if< static T loadRMW(const Unaligned& x) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuninitialized" -// make sure we compile without warning on gcc 4.6 with -Wpragmas -#if __GNUC_PREREQ(4, 7) +#if !__clang__ // for gcc version [4.8, ?) #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif return x.value; @@ -66,7 +65,7 @@ struct BitsTraits, typename std::enable_if< } }; -// Special version that allows to disable address sanitizer on demand. +// Special version that allows one to disable address sanitizer on demand. template struct BitsTraits, typename std::enable_if< (std::is_integral::value)>::type> { @@ -79,8 +78,7 @@ struct BitsTraits, typename std::enable_if< loadRMW(const UnalignedNoASan& x) { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuninitialized" -// make sure we compile without warning on gcc 4.6 with -Wpragmas -#if __GNUC_PREREQ(4, 7) +#if !__clang__ // for gcc version [4.8, ?) #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif return x.value; @@ -98,7 +96,7 @@ struct BitsTraits::clear(T* p, size_t bit) { template inline void Bits::set(T* p, size_t bitStart, size_t count, UnderlyingType value) { - assert(count <= sizeof(UnderlyingType) * 8); + DCHECK_LE(count, sizeof(UnderlyingType) * 8); size_t cut = bitsPerBlock - count; - assert(value == (value << cut >> cut)); + DCHECK_EQ(value, value << cut >> cut); size_t idx = blockIndex(bitStart); size_t offset = bitOffset(bitStart); if (std::is_signed::value) { @@ -268,7 +266,7 @@ inline bool Bits::test(const T* p, size_t bit) { template inline auto Bits::get(const T* p, size_t bitStart, size_t count) -> UnderlyingType { - assert(count <= sizeof(UnderlyingType) * 8); + DCHECK_LE(count, sizeof(UnderlyingType) * 8); size_t idx = blockIndex(bitStart); size_t offset = bitOffset(bitStart); UnderlyingType ret; @@ -305,6 +303,3 @@ inline size_t Bits::count(const T* begin, const T* end) { } } // namespace folly - -#endif /* FOLLY_EXPERIMENTAL_BITS_H_ */ -