Commit fea483aa authored by Michael Lee's avatar Michael Lee Committed by facebook-github-bot-1

Make Gold more like Core.

Summary:Adding padding for Android was wrong, instead, we should have
used `std::aligned_storage`.

Reviewed By: fugalh

Differential Revision: D2934566

fb-gh-sync-id: f541b89309be70791fced48f63b6b5aecc49bfbb
shipit-source-id: f541b89309be70791fced48f63b6b5aecc49bfbb
parent e9ae9a1d
...@@ -21,17 +21,10 @@ ...@@ -21,17 +21,10 @@
using namespace folly; using namespace folly;
// On android, we see a different way of memory alignment of this structure.
// Adding some extra padding to make it pass.
#ifdef __ANDROID_
constexpr size_t extraPadding = 8;
#else
constexpr size_t extraPadding = 0;
#endif
TEST(Core, size) { TEST(Core, size) {
static constexpr size_t lambdaBufSize = 8 * sizeof(void*);
struct Gold { struct Gold {
char lambdaBuf_[8 * sizeof(void*)]; typename std::aligned_storage<lambdaBufSize>::type lambdaBuf_;
folly::Optional<Try<Unit>> result_; folly::Optional<Try<Unit>> result_;
std::function<void(Try<Unit>&&)> callback_; std::function<void(Try<Unit>&&)> callback_;
detail::FSM<detail::State> fsm_; detail::FSM<detail::State> fsm_;
...@@ -48,5 +41,5 @@ TEST(Core, size) { ...@@ -48,5 +41,5 @@ TEST(Core, size) {
}; };
// If this number goes down, it's fine! // If this number goes down, it's fine!
// If it goes up, please seek professional advice ;-) // If it goes up, please seek professional advice ;-)
EXPECT_GE(sizeof(Gold) + extraPadding, sizeof(detail::Core<Unit>)); EXPECT_GE(sizeof(Gold), sizeof(detail::Core<Unit>));
} }
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