9#if defined(V8_OS_STARBOARD)
10#include "starboard/system.h"
49#if V8_OS_CYGWIN || V8_OS_WIN
52 unsigned first_half, second_half;
53 errno_t
result = rand_s(&first_half);
55 result = rand_s(&second_half);
58 SetSeed((
static_cast<int64_t
>(first_half) << 32) + second_half);
59#elif V8_OS_DARWIN || V8_OS_FREEBSD || V8_OS_OPENBSD
64 arc4random_buf(&seed,
sizeof(seed));
67 SetSeed(SbSystemGetRandomUInt64());
73 size_t n = fread(&seed,
sizeof(seed), 1, fp);
101 return static_cast<int>((max *
static_cast<int64_t
>(
Next(31))) >> 31);
107 if (std::numeric_limits<int>::max() - (rnd - val) >= (max - 1)) {
127 for (
size_t n = 0; n < buflen; ++
n) {
128 static_cast<uint8_t*
>(buffer)[n] =
static_cast<uint8_t
>(
Next(8));
133 const std::unordered_set<uint64_t>& set, uint64_t max) {
134 std::vector<uint64_t>
result;
135 result.reserve(max - set.size());
136 for (uint64_t
i = 0;
i < max;
i++) {
149 return std::vector<uint64_t>();
153 size_t smaller_part =
static_cast<size_t>(
154 std::min(max -
static_cast<uint64_t
>(n),
static_cast<uint64_t
>(n)));
155 std::unordered_set<uint64_t> selected;
158 while (selected.size() != smaller_part && counter / 3 < smaller_part) {
166 if (selected.size() == smaller_part) {
167 if (smaller_part != n) {
170 return std::vector<uint64_t>(selected.begin(), selected.end());
178 uint64_t max,
size_t n,
const std::unordered_set<uint64_t>& excluded) {
181 std::vector<uint64_t>
result;
182 result.reserve(max - excluded.size());
184 for (uint64_t
i = 0;
i <
max;
i++) {
185 if (!excluded.count(
i)) {
192 size_t larger_part =
static_cast<size_t>(
193 std::max(max -
static_cast<uint64_t
>(n),
static_cast<uint64_t
>(n)));
197 while (
result.size() != larger_part &&
result.size() > n) {
207 std::unordered_set<uint64_t>(
result.begin(),
result.end()), max);
230 h *= uint64_t{0xFF51AFD7ED558CCD};
232 h *= uint64_t{0xC4CEB9FE1A85EC53};
void NextBytes(void *buffer, size_t buflen)
void SetSeed(int64_t seed)
double NextDouble() V8_WARN_UNUSED_RESULT
std::vector< uint64_t > NextSample(uint64_t max, size_t n) V8_WARN_UNUSED_RESULT
static constexpr result_type max()
static double ToDouble(uint64_t state0)
bool(*)(unsigned char *buffer, size_t buflen) EntropySource
std::vector< uint64_t > NextSampleSlow(uint64_t max, size_t n, const std::unordered_set< uint64_t > &excluded=std::unordered_set< uint64_t >{}) V8_WARN_UNUSED_RESULT
int Next(int bits) V8_WARN_UNUSED_RESULT
int64_t NextInt64() V8_WARN_UNUSED_RESULT
static uint64_t MurmurHash3(uint64_t)
static void SetEntropySource(EntropySource entropy_source)
static void XorShift128(uint64_t *state0, uint64_t *state1)
V8_INLINE int NextInt() V8_WARN_UNUSED_RESULT
static Time NowFromSystemTime()
int64_t ToInternalValue() const
ZoneVector< RpoNumber > & result
InstructionOperand source
#define LAZY_MUTEX_INITIALIZER
constexpr bool IsPowerOfTwo(T value)
static LazyMutex entropy_mutex
static RandomNumberGenerator::EntropySource entropy_source
V8_INLINE Dest bit_cast(Source const &source)
static std::vector< uint64_t > ComplementSample(const std::unordered_set< uint64_t > &set, uint64_t max)
FILE * Fopen(const char *filename, const char *mode)
#define CHECK_GE(lhs, rhs)
#define CHECK_LT(lhs, rhs)
#define CHECK_LE(lhs, rhs)
#define DCHECK_GE(v1, v2)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)