Commit 869662db authored by Amol Bhave's avatar Amol Bhave Committed by Facebook Github Bot

Make InlineFunctionRef work for 32-bit

Summary:
InlineFuctionRef fails to compile on 32-bit machines and fails the
static assert. This diff makes the assert generic to add support for 32-bit as
well.

Reviewed By: yfeldblum

Differential Revision: D14752182

fbshipit-source-id: eb00487248c93c6c32226cb227e8d119bcc7af7a
parent e8751dea
...@@ -66,14 +66,17 @@ class InlineFunctionRef; ...@@ -66,14 +66,17 @@ class InlineFunctionRef;
template <typename ReturnType, typename... Args, std::size_t Size> template <typename ReturnType, typename... Args, std::size_t Size>
class InlineFunctionRef<ReturnType(Args...), Size> { class InlineFunctionRef<ReturnType(Args...), Size> {
using Storage = std::aligned_storage_t<Size - 8, 8>; using Storage =
std::aligned_storage_t<Size - sizeof(uintptr_t), sizeof(uintptr_t)>;
using Call = ReturnType (*)(const Storage&, Args&&...); using Call = ReturnType (*)(const Storage&, Args&&...);
struct InSituTag {}; struct InSituTag {};
struct RefTag {}; struct RefTag {};
static_assert((Size % 8) == 0, "Size has to be a multiple of 8"); static_assert(
static_assert(Size >= 16, "This doesn't work"); (Size % sizeof(uintptr_t)) == 0,
"Size has to be a multiple of sizeof(uintptr_t)");
static_assert(Size >= 2 * sizeof(uintptr_t), "This doesn't work");
static_assert(alignof(Call) == alignof(Storage), "Mismatching alignments"); static_assert(alignof(Call) == alignof(Storage), "Mismatching alignments");
// This defines a mode tag that is used in the construction of // This defines a mode tag that is used in the construction of
......
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