|
|
@ -30,7 +30,7 @@ namespace rng
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void crand::_deleter::delete_object(_opaque** state) { _jr_free(reinterpret_cast<jr_state*>(*state)); *state = nullptr; }
|
|
|
|
void crand::_deleter::delete_object(_opaque** state) { _jr_free(reinterpret_cast<jr_state*>(*state)); *state = nullptr; }
|
|
|
|
|
|
|
|
|
|
|
|
crand::crand(_opaque* raw) :_state(mem::aligned_ptr<_opaque, _deleter>(raw)){}
|
|
|
|
crand::crand(_opaque* raw) : Random(), _state(mem::aligned_ptr<_opaque, _deleter>(raw)){}
|
|
|
|
|
|
|
|
|
|
|
|
crand::crand(u64 seed) : crand(reinterpret_cast<_opaque*>(_jr_new(seed))){}
|
|
|
|
crand::crand(u64 seed) : crand(reinterpret_cast<_opaque*>(_jr_new(seed))){}
|
|
|
|
crand::crand() : crand(0xabad1dea){}
|
|
|
|
crand::crand() : crand(0xabad1dea){}
|
|
|
@ -70,23 +70,3 @@ namespace rng
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void rng_test()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rng::crand _r(123);
|
|
|
|
|
|
|
|
Random& r = _r;
|
|
|
|
|
|
|
|
printf("%lu %lu %lu\n", r.next_u64(), r.next_u64(), r.next_u64());
|
|
|
|
|
|
|
|
printf("%d %d %d\n", r.next_i32(), r.next_i32(), r.next_i32());
|
|
|
|
|
|
|
|
printf("%u %u %u\n", r.next_u32(), r.next_u32(), r.next_u32());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
|
|
|
volatile u64 u;
|
|
|
|
|
|
|
|
u8 b[sizeof(u64)];
|
|
|
|
|
|
|
|
std::array<u8, sizeof(u64)> a;
|
|
|
|
|
|
|
|
} thing = {0};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r.next_bytes(thing.b, sizeof(u64));
|
|
|
|
|
|
|
|
printf("chaos: %lu, %lu, %lu\n", thing.u, (r.next_bytes(thing.a), thing.u), (r.next_bytes(thing.b), thing.u));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: these aren't implemented yet in the base Random huh...
|
|
|
|
|
|
|
|
printf("---\n%u %d %d %u\n", r.next_u32(10, 20), r.next_i32(10, 20), r.next_i32(10), r.next_u32(10));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|