From 27ff9a4ae1369b937db8d63984ea721c85670b85 Mon Sep 17 00:00:00 2001 From: Peter Griess Date: Thu, 26 Sep 2013 09:25:58 -0500 Subject: [PATCH] Fix misc compilation errors in ThreadCachedIntTest. Summary: - int64_t is a long on x86_64, but a long long on 32-bit. - Build a uint64_t from pthread_self() before performing masking on it. Test Plan: - fbconfig -r folly && fbmake runtests - ./configure && make check on Ubuntu/FC/Mac Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D998598 --- folly/test/ThreadCachedIntTest.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/folly/test/ThreadCachedIntTest.cpp b/folly/test/ThreadCachedIntTest.cpp index 9272fb29..3f028769 100644 --- a/folly/test/ThreadCachedIntTest.cpp +++ b/folly/test/ThreadCachedIntTest.cpp @@ -162,7 +162,8 @@ struct ShardedAtomicInt { std::atomic ints_[kBuckets_]; inline void inc(int64_t val = 1) { - int bucket = hash::twang_mix64(pthread_self()) & (kBuckets_ - 1); + int bucket = hash::twang_mix64( + uint64_t(pthread_self())) & (kBuckets_ - 1); std::atomic_fetch_add(&ints_[bucket], val); } @@ -193,8 +194,10 @@ REG_BASELINE(_thread64, global__thread64 += 1); REG_BASELINE(_thread32, global__thread32 += 1); REG_BASELINE(ThreadLocal64, *globalTL64Baseline += 1); REG_BASELINE(ThreadLocal32, *globalTL32Baseline += 1); -REG_BASELINE(atomic_inc64, std::atomic_fetch_add(&globalInt64Baseline, 1L)); -REG_BASELINE(atomic_inc32, std::atomic_fetch_add(&globalInt32Baseline, 1)); +REG_BASELINE(atomic_inc64, + std::atomic_fetch_add(&globalInt64Baseline, int64_t(1))); +REG_BASELINE(atomic_inc32, + std::atomic_fetch_add(&globalInt32Baseline, int32_t(1))); REG_BASELINE(ShardedAtm64, shd_int64.inc()); BENCHMARK_PARAM(BM_mt_cache_size64, 0); -- 2.34.1