From c2d90c70100b75c634f65b5e73a686d4f7e56ae1 Mon Sep 17 00:00:00 2001 From: Orvid King <cdykes@fb.com> Date: Mon, 30 Apr 2018 16:53:00 -0700 Subject: [PATCH] Use uint32_t rather than uint Summary: Because Windows doesn't have `uint` as it's non-standard. Reviewed By: djwatson Differential Revision: D7821774 fbshipit-source-id: 4f7ff4468fc56052e28995f386e194fe70c6c513 --- folly/Benchmark.h | 4 +-- .../test/ConcurrentHashMapTest.cpp | 34 ++++++++++--------- folly/synchronization/test/RcuTest.cpp | 8 ++--- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/folly/Benchmark.h b/folly/Benchmark.h index a5c22bd9b..8e68875c0 100644 --- a/folly/Benchmark.h +++ b/folly/Benchmark.h @@ -390,7 +390,7 @@ void printResultComparison( * common for benchmarks that need a "problem size" in addition to * "number of iterations". Consider: * - * void pushBack(uint n, size_t initialSize) { + * void pushBack(uint32_t n, size_t initialSize) { * vector<int> v; * BENCHMARK_SUSPEND { * v.resize(initialSize); @@ -426,7 +426,7 @@ void printResultComparison( * * For example: * - * void addValue(uint n, int64_t bucketSize, int64_t min, int64_t max) { + * void addValue(uint32_t n, int64_t bucketSize, int64_t min, int64_t max) { * Histogram<int64_t> hist(bucketSize, min, max); * int64_t num = min; * FOR_EACH_RANGE (i, 0, n) { diff --git a/folly/concurrency/test/ConcurrentHashMapTest.cpp b/folly/concurrency/test/ConcurrentHashMapTest.cpp index cd60bb0a5..8dd1a3e67 100644 --- a/folly/concurrency/test/ConcurrentHashMapTest.cpp +++ b/folly/concurrency/test/ConcurrentHashMapTest.cpp @@ -13,11 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include <folly/concurrency/ConcurrentHashMap.h> + #include <atomic> #include <memory> #include <thread> -#include <folly/concurrency/ConcurrentHashMap.h> #include <folly/hash/Hash.h> #include <folly/portability/GTest.h> #include <folly/test/DeterministicSchedule.h> @@ -323,15 +325,15 @@ TEST(ConcurrentHashMap, UpdateStressTest) { Mutex> m(2); - for (uint i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { m.insert(i, i); } std::vector<std::thread> threads; unsigned int num_threads = 32; - for (uint t = 0; t < num_threads; t++) { + for (uint32_t t = 0; t < num_threads; t++) { threads.push_back(lib::thread([&, t]() { int offset = (iters * t / num_threads); - for (uint i = 0; i < iters / num_threads; i++) { + for (uint32_t i = 0; i < iters / num_threads; i++) { unsigned long k = folly::hash::jenkins_rev_mix32((i + offset)); k = k % (iters / num_threads) + offset; unsigned long val = 3; @@ -370,16 +372,16 @@ TEST(ConcurrentHashMap, EraseStressTest) { Mutex> m(2); - for (uint i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { unsigned long k = folly::hash::jenkins_rev_mix32(i); m.insert(k, k); } std::vector<std::thread> threads; unsigned int num_threads = 32; - for (uint t = 0; t < num_threads; t++) { + for (uint32_t t = 0; t < num_threads; t++) { threads.push_back(lib::thread([&, t]() { int offset = (iters * t / num_threads); - for (uint i = 0; i < iters / num_threads; i++) { + for (uint32_t i = 0; i < iters / num_threads; i++) { unsigned long k = folly::hash::jenkins_rev_mix32((i + offset)); auto res = m.insert(k, k).second; if (res) { @@ -429,19 +431,19 @@ TEST(ConcurrentHashMap, IterateStressTest) { Mutex> m(2); - for (uint i = 0; i < size; i++) { + for (uint32_t i = 0; i < size; i++) { unsigned long k = folly::hash::jenkins_rev_mix32(i); m.insert(k, k); } - for (uint i = 0; i < 10; i++) { + for (uint32_t i = 0; i < 10; i++) { m.insert(i, i); } std::vector<std::thread> threads; unsigned int num_threads = 32; - for (uint t = 0; t < num_threads; t++) { + for (uint32_t t = 0; t < num_threads; t++) { threads.push_back(lib::thread([&, t]() { int offset = (iters * t / num_threads); - for (uint i = 0; i < iters / num_threads; i++) { + for (uint32_t i = 0; i < iters / num_threads; i++) { unsigned long k = folly::hash::jenkins_rev_mix32((i + offset)); auto res = m.insert(k, k).second; if (res) { @@ -488,10 +490,10 @@ TEST(ConcurrentHashMap, insertStressTest) { EXPECT_FALSE(m.insert(0, 0).second); std::vector<std::thread> threads; unsigned int num_threads = 32; - for (uint t = 0; t < num_threads; t++) { + for (uint32_t t = 0; t < num_threads; t++) { threads.push_back(lib::thread([&, t]() { int offset = (iters * t / num_threads); - for (uint i = 0; i < iters / num_threads; i++) { + for (uint32_t i = 0; i < iters / num_threads; i++) { auto var = offset + i + 1; EXPECT_TRUE(m.insert(var, var).second); EXPECT_FALSE(m.insert(0, 0).second); @@ -542,7 +544,7 @@ TEST(ConcurrentHashMap, assignStressTest) { Mutex> m(2); - for (uint i = 0; i < iters; i++) { + for (uint32_t i = 0; i < iters; i++) { big_value a; a.set(i); m.insert(i, a); @@ -550,9 +552,9 @@ TEST(ConcurrentHashMap, assignStressTest) { std::vector<std::thread> threads; unsigned int num_threads = 32; - for (uint t = 0; t < num_threads; t++) { + for (uint32_t t = 0; t < num_threads; t++) { threads.push_back(lib::thread([&]() { - for (uint i = 0; i < iters; i++) { + for (uint32_t i = 0; i < iters; i++) { auto res = m.find(i); EXPECT_NE(res, m.cend()); res->second.check(); diff --git a/folly/synchronization/test/RcuTest.cpp b/folly/synchronization/test/RcuTest.cpp index 7fdcd8552..b610fe3c0 100644 --- a/folly/synchronization/test/RcuTest.cpp +++ b/folly/synchronization/test/RcuTest.cpp @@ -112,7 +112,7 @@ TEST(RcuTest, Stress) { std::vector<std::thread> threads; constexpr uint32_t sz = 1000; std::atomic<int*> ints[sz]; - for (uint i = 0; i < sz; i++) { + for (uint32_t i = 0; i < sz; i++) { ints[i].store(new int(0)); } for (unsigned th = 0; th < FLAGS_threads; th++) { @@ -121,10 +121,10 @@ TEST(RcuTest, Stress) { rcu_reader g; int sum = 0; int* ptrs[sz]; - for (uint j = 0; j < sz; j++) { + for (uint32_t j = 0; j < sz; j++) { ptrs[j] = ints[j].load(std::memory_order_acquire); } - for (uint j = 0; j < sz; j++) { + for (uint32_t j = 0; j < sz; j++) { sum += *ptrs[j]; } EXPECT_EQ(sum, 0); @@ -149,7 +149,7 @@ TEST(RcuTest, Stress) { updater.join(); // Cleanup for asan synchronize_rcu(); - for (uint i = 0; i < sz; i++) { + for (uint32_t i = 0; i < sz; i++) { delete ints[i].exchange(nullptr); } } -- 2.26.2