Summary:
There were many templates instantiated with signed types.
Changing them to unsigned avoids the compilation failures
noted below. However, we'll have to watch arc-diff-spawned
tests for new failures, just in case.
This is by far the largest undecomposable patch of those
I've written for this task so far. It is possible that
some subset of these changes accomplishes the same goal,
but once I managed to get a successful compilation, I have
only re-reviewed it once and did not try to shrink it.
Test Plan:
Without these changes, we would get the following 32 errors from gcc-4.9:
https://phabricator.fb.com/P19692642
With them, (and all of the other patches attached to the parent task,
all of fbcode compiles and passes its tests (modulo preexisting
failures and aborts).
Reviewed By: delong.j@fb.com
Subscribers: trunkagent, folly-diffs@
FB internal diff:
D1773461
Tasks:
5941250
Signature: t1:
1773461:
1420821964:
61635f3a2efc95e8d4457c36e7a5ee3a0a50df23
// (No real synchronization needed at destructor time: only one
// thread can be doing this.)
if (!boost::has_trivial_destructor<T>::value) {
// (No real synchronization needed at destructor time: only one
// thread can be doing this.)
if (!boost::has_trivial_destructor<T>::value) {
- int read = readIndex_;
- int end = writeIndex_;
+ size_t read = readIndex_;
+ size_t end = writeIndex_;
while (read != end) {
records_[read].~T();
if (++read == size_) {
while (read != end) {
records_[read].~T();
if (++read == size_) {
const uint32_t size_;
T* const records_;
const uint32_t size_;
T* const records_;
- std::atomic<int> readIndex_;
- std::atomic<int> writeIndex_;
+ std::atomic<unsigned int> readIndex_;
+ std::atomic<unsigned int> writeIndex_;
-typedef int ThroughputType;
+typedef unsigned int ThroughputType;
typedef ProducerConsumerQueue<ThroughputType> ThroughputQueueType;
typedef ProducerConsumerQueue<ThroughputType> ThroughputQueueType;
-typedef long LatencyType;
+typedef unsigned long LatencyType;
typedef ProducerConsumerQueue<LatencyType> LatencyQueueType;
template<class QueueType>
typedef ProducerConsumerQueue<LatencyType> LatencyQueueType;
template<class QueueType>
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
}
for (int i = 0; i < iters_; ++i) {
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
}
for (int i = 0; i < iters_; ++i) {
+ unsigned long enqueue_nsec;
while (!queue_.read(enqueue_nsec)) {
}
while (!queue_.read(enqueue_nsec)) {
}
};
template<> struct TestTraits<std::string> {
};
template<> struct TestTraits<std::string> {
- int limit() const { return 1 << 22; }
+ unsigned int limit() const { return 1 << 22; }
std::string generate() const { return std::string(12, ' '); }
};
std::string generate() const { return std::string(12, ' '); }
};
- for (int i = 0; i < traits_.limit(); ++i) {
+ // This is written differently than you might expect so that
+ // it does not run afoul of -Wsign-compare, regardless of the
+ // signedness of this loop's upper bound.
+ for (auto i = traits_.limit(); i > 0; --i) {
while (!queue_.write(traits_.generate())) {
}
}
while (!queue_.write(traits_.generate())) {
}
}
{
const size_t testSize = traits_.limit();
testData_.reserve(testSize);
{
const size_t testSize = traits_.limit();
testData_.reserve(testSize);
- for (int i = 0; i < testSize; ++i) {
+ for (size_t i = 0; i < testSize; ++i) {
testData_.push_back(traits_.generate());
}
}
testData_.push_back(traits_.generate());
}
}
- static int numInstances;
+ static unsigned int numInstances;
DtorChecker() { ++numInstances; }
DtorChecker(const DtorChecker& o) { ++numInstances; }
~DtorChecker() { --numInstances; }
};
DtorChecker() { ++numInstances; }
DtorChecker(const DtorChecker& o) { ++numInstances; }
~DtorChecker() { --numInstances; }
};
-int DtorChecker::numInstances = 0;
+unsigned int DtorChecker::numInstances = 0;