#include <random.h>
Definition at line 18 of file random.h.
◆ Random() [1/2]
Definition at line 17 of file random.cc.
17 {
18 uint64_t seed = FLAG_random_seed;
19 if (seed == 0) {
22 if (!
callback(
reinterpret_cast<uint8_t*
>(&seed),
sizeof(seed))) {
23
24 seed = 0;
25 }
26 }
27 }
28 if (seed == 0) {
29
31 }
32 Initialize(seed);
33}
static Dart_EntropySource entropy_source_callback()
static int64_t GetCurrentTimeMicros()
bool(* Dart_EntropySource)(uint8_t *buffer, intptr_t length)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
◆ Random() [2/2]
dart::Random::Random |
( |
uint64_t |
seed | ) |
|
|
explicit |
Definition at line 45 of file random.cc.
45 {
46 Initialize(seed);
47}
◆ ~Random()
dart::Random::~Random |
( |
| ) |
|
◆ Cleanup()
void dart::Random::Cleanup |
( |
| ) |
|
|
static |
Definition at line 88 of file random.cc.
88 {
93}
static Mutex * global_random_mutex
static Random * global_random
◆ GlobalNextUInt64()
uint64_t dart::Random::GlobalNextUInt64 |
( |
| ) |
|
|
static |
◆ Init()
void dart::Random::Init |
( |
| ) |
|
|
static |
Definition at line 81 of file random.cc.
81 {
86}
NOT_IN_PRODUCT(LibraryPtr ReloadTestScript(const char *script))
◆ NextDouble()
double dart::Random::NextDouble |
( |
| ) |
|
Definition at line 100 of file random.cc.
100 {
101 uint64_t mantissa =
NextUInt64() & 0xFFFFFFFFFFFFF;
102
103 const uint64_t exp = 1023;
104 return bit_cast<double>(exp << 52 | mantissa) - 1.0;
105}
◆ NextJSInt()
uint64_t dart::Random::NextJSInt |
( |
| ) |
|
|
inline |
Definition at line 37 of file random.h.
37 {
38
39 const uint64_t kMaxJsInt = 0x1FFFFFFFFFFFFF;
41 }
◆ NextUInt32()
uint32_t dart::Random::NextUInt32 |
( |
| ) |
|
Definition at line 73 of file random.cc.
73 {
74 const uint64_t MASK_32 = 0xffffffff;
75 return static_cast<uint32_t>(NextState() & MASK_32);
76}
◆ NextUInt64()
uint64_t dart::Random::NextUInt64 |
( |
| ) |
|
|
inline |
Definition at line 26 of file random.h.
26 {
27 return (
static_cast<uint64_t
>(
NextUInt32()) << 32) |
29 }
The documentation for this class was generated from the following files:
- third_party/dart-lang/sdk/runtime/vm/random.h
- third_party/dart-lang/sdk/runtime/vm/random.cc