Commit a6e257a5 authored by Jim Meyering's avatar Jim Meyering Committed by Sara Golemon

folly: allow to build with clang.dev (flex arrays vs. lambda)

Summary:
* folly/test/CacheLocalityTest.cpp (contentionAtWidth): Work around
clang's prohibition against using flexible arrays in a lambda.

Test Plan:
fbconfig --clang --with-project-version clang:dev folly/test \
&& fbmake runtests

Reviewed By: ngbronson@fb.com

FB internal diff: D1263620
parent 970c7961
...@@ -528,7 +528,7 @@ static void contentionAtWidth(size_t iters, size_t stripes, size_t work, ...@@ -528,7 +528,7 @@ static void contentionAtWidth(size_t iters, size_t stripes, size_t work,
// that we get contention on 128 byte boundaries for Ivy Bridge. The // that we get contention on 128 byte boundaries for Ivy Bridge. The
// extra indirection adds 1 or 2 nanos // extra indirection adds 1 or 2 nanos
assert(counterAlignment >= sizeof(std::atomic<size_t>)); assert(counterAlignment >= sizeof(std::atomic<size_t>));
char raw[counterAlignment * stripes]; std::vector<char> raw(counterAlignment * stripes);
// if we happen to be using the tlsRoundRobin, then sequentially // if we happen to be using the tlsRoundRobin, then sequentially
// assigning the thread identifiers is the unlikely best-case scenario. // assigning the thread identifiers is the unlikely best-case scenario.
...@@ -543,7 +543,8 @@ static void contentionAtWidth(size_t iters, size_t stripes, size_t work, ...@@ -543,7 +543,8 @@ static void contentionAtWidth(size_t iters, size_t stripes, size_t work,
threads.push_back(std::thread([&,iters,stripes,work]() { threads.push_back(std::thread([&,iters,stripes,work]() {
std::atomic<size_t>* counters[stripes]; std::atomic<size_t>* counters[stripes];
for (size_t i = 0; i < stripes; ++i) { for (size_t i = 0; i < stripes; ++i) {
counters[i] = new (raw + counterAlignment * i) std::atomic<size_t>(); counters[i]
= new (raw.data() + counterAlignment * i) std::atomic<size_t>();
} }
spreader.current(); spreader.current();
...@@ -702,4 +703,3 @@ int main(int argc, char** argv) { ...@@ -702,4 +703,3 @@ int main(int argc, char** argv) {
} }
return ret; return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment