Commit eaed5551 authored by Tudor Bosman's avatar Tudor Bosman

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
parent 217e88e6
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <folly/Malloc.h> #include <folly/Malloc.h>
#include <cstdint>
namespace folly { namespace folly {
// How do we determine that we're using jemalloc? // How do we determine that we're using jemalloc?
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <folly/detail/Malloc.h> #include <folly/detail/Malloc.h>
#include <string> #include <string>
namespace folly { namespace folly {
using std::goodMallocSize; using std::goodMallocSize;
using std::jemallocMinInPlaceExpandable; using std::jemallocMinInPlaceExpandable;
......
...@@ -173,6 +173,7 @@ struct MaxAlign { char c; } __attribute__((aligned)); ...@@ -173,6 +173,7 @@ struct MaxAlign { char c; } __attribute__((aligned));
// the 'std' namespace; the latter uses inline namepsaces. Wrap this decision // the 'std' namespace; the latter uses inline namepsaces. Wrap this decision
// up in a macro to make forward-declarations easier. // up in a macro to make forward-declarations easier.
#if FOLLY_USE_LIBCPP #if FOLLY_USE_LIBCPP
#include <__config>
#define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD #define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD
#define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD #define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD
#else #else
......
...@@ -105,23 +105,28 @@ constexpr size_t ...@@ -105,23 +105,28 @@ constexpr size_t
StateSize<std::subtract_with_carry_engine<UIntType, w, s, r>>::value; StateSize<std::subtract_with_carry_engine<UIntType, w, s, r>>::value;
template <class RNG> template <class RNG>
std::seed_seq generateSeed() { struct SeedData {
std::array<uint32_t, StateSize<RNG>::value> seed_data; SeedData() {
Random::secureRandom(seed_data.begin(), seed_data.size() * sizeof(uint32_t)); Random::secureRandom(seedData.begin(), seedData.size() * sizeof(uint32_t));
return std::seed_seq(std::begin(seed_data), std::end(seed_data)); }
}
static constexpr size_t stateSize = StateSize<RNG>::value;
std::array<uint32_t, stateSize> seedData;
};
} // namespace detail } // namespace detail
template <class RNG> template <class RNG>
void Random::seed(ValidRNG<RNG>& rng) { void Random::seed(ValidRNG<RNG>& rng) {
auto s = detail::generateSeed<RNG>(); detail::SeedData<RNG> sd;
std::seed_seq s(std::begin(sd.seedData), std::end(sd.seedData));
rng.seed(s); rng.seed(s);
} }
template <class RNG> template <class RNG>
auto Random::create() -> ValidRNG<RNG> { auto Random::create() -> ValidRNG<RNG> {
auto s = detail::generateSeed<RNG>(); detail::SeedData<RNG> sd;
std::seed_seq s(std::begin(sd.seedData), std::end(sd.seedData));
return RNG(s); return RNG(s);
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <stdexcept>
namespace folly { namespace wangle { namespace folly { namespace wangle {
/// An Executor accepts units of work with add(), which should be /// An Executor accepts units of work with add(), which should be
......
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