From 0af2af09652296647926bcbf3d5b17b1bb5bcd95 Mon Sep 17 00:00:00 2001 From: Peter Griess Date: Tue, 6 Jan 2015 12:30:32 -0800 Subject: [PATCH] Fix HHWheelTimer compilation bug in libc++ build Summary: - Manually swap bucket_ entries in HHWheelTimer to work around a bug in libc++ Test Plan: - fbconfig -r folly/io/async && fbmake runtests --extended-tests - Sync to OS X and build there Reviewed By: davejwatson@fb.com Subscribers: trunkagent, doug, seanc, folly-diffs@ FB internal diff: D1766601 Signature: t1:1766601:1420566916:24a2911e997ee04f0934884bdf7b82345cb2b752 --- folly/io/async/HHWheelTimer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/folly/io/async/HHWheelTimer.cpp b/folly/io/async/HHWheelTimer.cpp index d7622248..aab67784 100644 --- a/folly/io/async/HHWheelTimer.cpp +++ b/folly/io/async/HHWheelTimer.cpp @@ -205,7 +205,20 @@ void HHWheelTimer::timeoutExpired() noexcept { size_t HHWheelTimer::cancelAll() { decltype(buckets_) buckets; + +// Work around std::swap() bug in libc++ +// +// http://llvm.org/bugs/show_bug.cgi?id=22106 +#if FOLLY_USE_LIBCPP + for (size_t i = 0; i < WHEEL_BUCKETS; ++i) { + for (size_t ii = 0; i < WHEEL_SIZE; ++ii) { + std::swap(buckets_[i][ii], buckets[i][ii]); + } + } +#else std::swap(buckets, buckets_); +#endif + size_t count = 0; for (auto& tick : buckets) { -- 2.34.1