Commit 64728214 authored by Luqun Lou's avatar Luqun Lou Committed by Facebook GitHub Bot

Update DigestBuilder to align its cpuLocalBuffers_

Summary:
CpuLocalBuffer need extend alignment, which isn't honored by std::vector's default allocator due to compiler bug

  http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3396.htm
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65122
  https://bugs.llvm.org/show_bug.cgi?id=22634

the fix is to use custom allocator to honor extend alignment requirement.

Reviewed By: yfeldblum

Differential Revision: D21405041

fbshipit-source-id: 53cfe1bfd66580990c8a1a0c5f0c09f6651bda24
parent b14c9ea6
......@@ -18,6 +18,7 @@
#include <memory>
#include <folly/Memory.h>
#include <folly/SpinLock.h>
namespace folly {
......@@ -60,7 +61,13 @@ class DigestBuilder {
std::unique_ptr<DigestT> digest;
};
std::vector<CpuLocalBuffer> cpuLocalBuffers_;
// cpulocalbuffer_alloc custom allocator is necessary until C++17
// http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3396.htm
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65122
// https://bugs.llvm.org/show_bug.cgi?id=22634
using cpulocalbuffer_alloc =
AlignedSysAllocator<CpuLocalBuffer, FixedAlign<alignof(CpuLocalBuffer)>>;
std::vector<CpuLocalBuffer, cpulocalbuffer_alloc> cpuLocalBuffers_;
size_t bufferSize_;
size_t digestSize_;
};
......
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