Permalink
Browse files

Minor clang compiler fixes

Summary: Minor clang compiler fixes

Test Plan: - fbmake runtest

Reviewed By: andrewjcg@fb.com

FB internal diff: D707663
  • Loading branch information...
1 parent bae2dcc commit 267e38a8cee0569f04baa0b649c0f65ad29b0440 Gaurav Jain committed with jdelong Feb 13, 2013
Showing with 15 additions and 18 deletions.
  1. +11 −1 folly/Bits.cpp
  2. +0 −13 folly/Optional.h
  3. +4 −4 folly/io/IOBufQueue.cpp
View
@@ -1,5 +1,5 @@
/*
- * 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.
@@ -65,12 +65,22 @@ namespace detail {
// 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
View
@@ -69,17 +69,6 @@ typedef int detail::NoneHelper::*None;
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>> {
@@ -245,8 +234,6 @@ class Optional : boost::totally_ordered<Optional<Value>,
bool hasValue_;
};
-#pragma GCC diagnostic pop
-
template<class T>
const T* get_pointer(const Optional<T>& opt) {
return opt ? &opt.value() : nullptr;
View
@@ -37,7 +37,7 @@ const size_t MAX_PACK_COPY = 4096;
*/
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();
@@ -150,7 +150,7 @@ void
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,
@@ -183,7 +183,7 @@ IOBufQueue::wrapBuffer(const void* buf, size_t len, uint32_t blockSize) {
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()) {
@@ -213,7 +213,7 @@ unique_ptr<IOBuf>
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) {

0 comments on commit 267e38a

Please sign in to comment.