/*
- * 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.
* limitations under the License.
*/
-#ifndef FOLLY_EXPERIMENTAL_BITS_H_
-#define FOLLY_EXPERIMENTAL_BITS_H_
+#pragma once
#include <cstddef>
#include <type_traits>
#include <limits>
+#include <glog/logging.h>
-#include "folly/Bits.h"
-#include "folly/Portability.h"
-#include "folly/Range.h"
+#include <folly/Bits.h>
+#include <folly/Portability.h>
+#include <folly/Range.h>
namespace folly {
static T loadRMW(const Unaligned<T>& 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;
}
};
-// Special version that allows to disable address sanitizer on demand.
+// Special version that allows one to disable address sanitizer on demand.
template <class T>
struct BitsTraits<UnalignedNoASan<T>, typename std::enable_if<
(std::is_integral<T>::value)>::type> {
loadRMW(const UnalignedNoASan<T>& 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;
static T loadRMW(const T& x) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
-#if __GNUC_PREREQ(4, 7)
+#if !__clang__ // for gcc version [4.8, ?)
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
return x;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
-#if __GNUC_PREREQ(4, 7)
+#if !__clang__ // for gcc version [4.8, ?)
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
template <class T, class Traits>
inline void Bits<T, Traits>::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<UnderlyingType>::value) {
template <class T, class Traits>
inline auto Bits<T, Traits>::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;
}
} // namespace folly
-
-#endif /* FOLLY_EXPERIMENTAL_BITS_H_ */
-