Commit 267e38a8 authored by Gaurav Jain's avatar Gaurav Jain Committed by Jordan DeLong

Minor clang compiler fixes

Summary: Minor clang compiler fixes

Test Plan: - fbmake runtest

Reviewed By: andrewjcg@fb.com

FB internal diff: D707663
parent bae2dccf
/* /*
* Copyright 2012 Facebook, Inc. * Copyright 2013 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -65,12 +65,22 @@ namespace detail { ...@@ -65,12 +65,22 @@ namespace detail {
// Call folly_popcount_ifunc on startup to resolve to either popcount_inst // Call folly_popcount_ifunc on startup to resolve to either popcount_inst
// or popcount_builtin // or popcount_builtin
int popcount(unsigned int x) 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"))); __attribute__((ifunc("folly_popcount_ifunc")));
#endif
// Call folly_popcount_ifunc on startup to resolve to either popcountll_inst // Call folly_popcount_ifunc on startup to resolve to either popcountll_inst
// or popcountll_builtin // or popcountll_builtin
int popcountll(unsigned long long x) 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"))); __attribute__((ifunc("folly_popcountll_ifunc")));
#endif
} // namespace detail } // namespace detail
} // namespace folly } // namespace folly
......
...@@ -69,17 +69,6 @@ typedef int detail::NoneHelper::*None; ...@@ -69,17 +69,6 @@ typedef int detail::NoneHelper::*None;
const None none = nullptr; 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> template<class Value>
class Optional : boost::totally_ordered<Optional<Value>, class Optional : boost::totally_ordered<Optional<Value>,
boost::totally_ordered<Optional<Value>, Value>> { boost::totally_ordered<Optional<Value>, Value>> {
...@@ -245,8 +234,6 @@ class Optional : boost::totally_ordered<Optional<Value>, ...@@ -245,8 +234,6 @@ class Optional : boost::totally_ordered<Optional<Value>,
bool hasValue_; bool hasValue_;
}; };
#pragma GCC diagnostic pop
template<class T> template<class T>
const T* get_pointer(const Optional<T>& opt) { const T* get_pointer(const Optional<T>& opt) {
return opt ? &opt.value() : nullptr; return opt ? &opt.value() : nullptr;
......
...@@ -37,7 +37,7 @@ const size_t MAX_PACK_COPY = 4096; ...@@ -37,7 +37,7 @@ const size_t MAX_PACK_COPY = 4096;
*/ */
void void
appendToChain(unique_ptr<IOBuf>& dst, unique_ptr<IOBuf>&& src, bool pack) { appendToChain(unique_ptr<IOBuf>& dst, unique_ptr<IOBuf>&& src, bool pack) {
if (dst == NULL) { if (dst == nullptr) {
dst = std::move(src); dst = std::move(src);
} else { } else {
IOBuf* tail = dst->prev(); IOBuf* tail = dst->prev();
...@@ -150,7 +150,7 @@ void ...@@ -150,7 +150,7 @@ void
IOBufQueue::append(const void* buf, size_t len) { IOBufQueue::append(const void* buf, size_t len) {
auto src = static_cast<const uint8_t*>(buf); auto src = static_cast<const uint8_t*>(buf);
while (len != 0) { while (len != 0) {
if ((head_ == NULL) || head_->prev()->isSharedOne() || if ((head_ == nullptr) || head_->prev()->isSharedOne() ||
(head_->prev()->tailroom() == 0)) { (head_->prev()->tailroom() == 0)) {
appendToChain(head_, std::move( appendToChain(head_, std::move(
IOBuf::create(std::max(MIN_ALLOC_SIZE, IOBuf::create(std::max(MIN_ALLOC_SIZE,
...@@ -183,7 +183,7 @@ IOBufQueue::wrapBuffer(const void* buf, size_t len, uint32_t blockSize) { ...@@ -183,7 +183,7 @@ IOBufQueue::wrapBuffer(const void* buf, size_t len, uint32_t blockSize) {
pair<void*,uint32_t> pair<void*,uint32_t>
IOBufQueue::preallocate(uint32_t min, uint32_t newAllocationSize, IOBufQueue::preallocate(uint32_t min, uint32_t newAllocationSize,
uint32_t max) { uint32_t max) {
if (head_ != NULL) { if (head_ != nullptr) {
// If there's enough space left over at the end of the queue, use that. // If there's enough space left over at the end of the queue, use that.
IOBuf* last = head_->prev(); IOBuf* last = head_->prev();
if (!last->isSharedOne()) { if (!last->isSharedOne()) {
...@@ -213,7 +213,7 @@ unique_ptr<IOBuf> ...@@ -213,7 +213,7 @@ unique_ptr<IOBuf>
IOBufQueue::split(size_t n) { IOBufQueue::split(size_t n) {
unique_ptr<IOBuf> result; unique_ptr<IOBuf> result;
while (n != 0) { while (n != 0) {
if (head_ == NULL) { if (head_ == nullptr) {
throw std::underflow_error( throw std::underflow_error(
"Attempt to remove more bytes than are present in IOBufQueue"); "Attempt to remove more bytes than are present in IOBufQueue");
} else if (head_->length() <= n) { } else if (head_->length() <= n) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment