From eaed555139d0186bab0fd71a50434b5041a23a66 Mon Sep 17 00:00:00 2001 From: Tudor Bosman Date: Sat, 5 Jul 2014 08:50:38 -0700 Subject: [PATCH] Fix libc++ build errors Summary: Reported externally: https://github.com/facebook/folly/issues/70 https://github.com/facebook/folly/issues/71 https://github.com/facebook/folly/issues/72 https://github.com/facebook/folly/issues/73 Note that I can't test on libc++ myself, but the reports suggested fixes which sounded good. Test Plan: fbconfig -r folly && fbmake runtests_opt Reviewed By: marcelo.juchem@fb.com Subscribers: jhj, ntv, lesha, kma, fugalh, jdelong FB internal diff: D1421029 --- folly/Malloc.cpp | 2 ++ folly/Malloc.h | 1 + folly/Portability.h | 1 + folly/Random-inl.h | 19 ++++++++++++------- folly/wangle/Executor.h | 1 + 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/folly/Malloc.cpp b/folly/Malloc.cpp index fe8d8b6a..d81c30d2 100644 --- a/folly/Malloc.cpp +++ b/folly/Malloc.cpp @@ -16,6 +16,8 @@ #include +#include + namespace folly { // How do we determine that we're using jemalloc? diff --git a/folly/Malloc.h b/folly/Malloc.h index b8ee18c5..59745b5f 100644 --- a/folly/Malloc.h +++ b/folly/Malloc.h @@ -29,6 +29,7 @@ #include #include + namespace folly { using std::goodMallocSize; using std::jemallocMinInPlaceExpandable; diff --git a/folly/Portability.h b/folly/Portability.h index 9c65c650..61b9eb22 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -173,6 +173,7 @@ struct MaxAlign { char c; } __attribute__((aligned)); // the 'std' namespace; the latter uses inline namepsaces. Wrap this decision // up in a macro to make forward-declarations easier. #if FOLLY_USE_LIBCPP +#include <__config> #define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD #define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD #else diff --git a/folly/Random-inl.h b/folly/Random-inl.h index 9da9a824..f18a0b51 100644 --- a/folly/Random-inl.h +++ b/folly/Random-inl.h @@ -105,23 +105,28 @@ constexpr size_t StateSize>::value; template -std::seed_seq generateSeed() { - std::array::value> seed_data; - Random::secureRandom(seed_data.begin(), seed_data.size() * sizeof(uint32_t)); - return std::seed_seq(std::begin(seed_data), std::end(seed_data)); -} +struct SeedData { + SeedData() { + Random::secureRandom(seedData.begin(), seedData.size() * sizeof(uint32_t)); + } + + static constexpr size_t stateSize = StateSize::value; + std::array seedData; +}; } // namespace detail template void Random::seed(ValidRNG& rng) { - auto s = detail::generateSeed(); + detail::SeedData sd; + std::seed_seq s(std::begin(sd.seedData), std::end(sd.seedData)); rng.seed(s); } template auto Random::create() -> ValidRNG { - auto s = detail::generateSeed(); + detail::SeedData sd; + std::seed_seq s(std::begin(sd.seedData), std::end(sd.seedData)); return RNG(s); } diff --git a/folly/wangle/Executor.h b/folly/wangle/Executor.h index a248c28e..00a52b17 100644 --- a/folly/wangle/Executor.h +++ b/folly/wangle/Executor.h @@ -20,6 +20,7 @@ #include #include #include +#include namespace folly { namespace wangle { /// An Executor accepts units of work with add(), which should be -- 2.34.1