Merge remote-tracking branch 'origin/master' into snmalloc2

This commit is contained in:
Matthew Parkinson
2021-07-21 09:58:22 +01:00
2 changed files with 13 additions and 23 deletions

View File

@@ -4,8 +4,10 @@
#include "../pal/pal.h"
#include <cstdint>
#include <random>
#include <type_traits>
#ifndef SNMALLOC_PLATFORM_HAS_GETENTROPY
# include <random>
#endif
namespace snmalloc
{
@@ -18,9 +20,13 @@ namespace snmalloc
template<typename PAL>
std::enable_if_t<!pal_supports<Entropy, PAL>, uint64_t> get_entropy64()
{
#ifdef SNMALLOC_PLATFORM_HAS_GETENTROPY
return DefaultPal::get_entropy64();
#else
std::random_device rd;
uint64_t a = rd();
return (a << 32) ^ rd();
#endif
}
class LocalEntropy
@@ -139,4 +145,4 @@ namespace snmalloc
return result;
}
};
} // namespace snmalloc
} // namespace snmalloc