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 @@
#include <folly/Malloc.h>
#include <cstdint>
namespace folly {
// How do we determine that we're using jemalloc?
......
......@@ -29,6 +29,7 @@
#include <folly/detail/Malloc.h>
#include <string>
namespace folly {
using std::goodMallocSize;
using std::jemallocMinInPlaceExpandable;
......
......@@ -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
......
......@@ -105,23 +105,28 @@ constexpr size_t
StateSize<std::subtract_with_carry_engine<UIntType, w, s, r>>::value;
template <class RNG>
std::seed_seq generateSeed() {
std::array<uint32_t, StateSize<RNG>::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<RNG>::value;
std::array<uint32_t, stateSize> seedData;
};
} // namespace detail
template <class 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);
}
template <class 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);
}
......
......@@ -20,6 +20,7 @@
#include <chrono>
#include <functional>
#include <memory>
#include <stdexcept>
namespace folly { namespace wangle {
/// 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