/*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Call folly_popcount_ifunc on startup to resolve to either popcount_inst
// or popcount_builtin
int popcount(unsigned int x)
+// Clang does not support ifuncs, so we call directly for now
+#ifdef __clang__
+{ return popcount_builtin(x); }
+#else
__attribute__((ifunc("folly_popcount_ifunc")));
+#endif
// Call folly_popcount_ifunc on startup to resolve to either popcountll_inst
// or popcountll_builtin
int popcountll(unsigned long long x)
+// Clang does not support ifuncs, so we call directly for now
+#ifdef __clang__
+{ return popcount_builtin(x); }
+#else
__attribute__((ifunc("folly_popcountll_ifunc")));
+#endif
} // namespace detail
} // namespace folly
const None none = nullptr;
-/**
- * gcc-4.7 warns about use of uninitialized memory around the use of storage_
- * even though this is explicitly initialized at each point.
- */
-#ifdef __GNUC__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wuninitialized"
-# pragma GCC diagnostic ignored "-Wpragmas"
-# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#endif // __GNUC__
-
template<class Value>
class Optional : boost::totally_ordered<Optional<Value>,
boost::totally_ordered<Optional<Value>, Value>> {
bool hasValue_;
};
-#pragma GCC diagnostic pop
-
template<class T>
const T* get_pointer(const Optional<T>& opt) {
return opt ? &opt.value() : nullptr;
*/
void
appendToChain(unique_ptr<IOBuf>& dst, unique_ptr<IOBuf>&& src, bool pack) {
- if (dst == NULL) {
+ if (dst == nullptr) {
dst = std::move(src);
} else {
IOBuf* tail = dst->prev();
IOBufQueue::append(const void* buf, size_t len) {
auto src = static_cast<const uint8_t*>(buf);
while (len != 0) {
- if ((head_ == NULL) || head_->prev()->isSharedOne() ||
+ if ((head_ == nullptr) || head_->prev()->isSharedOne() ||
(head_->prev()->tailroom() == 0)) {
appendToChain(head_, std::move(
IOBuf::create(std::max(MIN_ALLOC_SIZE,
pair<void*,uint32_t>
IOBufQueue::preallocate(uint32_t min, uint32_t newAllocationSize,
uint32_t max) {
- if (head_ != NULL) {
+ if (head_ != nullptr) {
// If there's enough space left over at the end of the queue, use that.
IOBuf* last = head_->prev();
if (!last->isSharedOne()) {
IOBufQueue::split(size_t n) {
unique_ptr<IOBuf> result;
while (n != 0) {
- if (head_ == NULL) {
+ if (head_ == nullptr) {
throw std::underflow_error(
"Attempt to remove more bytes than are present in IOBufQueue");
} else if (head_->length() <= n) {