Start: Seeding API

Fortune for rngxx's current commit: Half curse − 半凶
master
Avril 3 years ago
parent 3ff3db0e3e
commit d9e34e7e70
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -0,0 +1,31 @@
#pragma once
#include "common.h"
namespace rng
{
template<typename T>
struct seed_gen
{
virtual T generate_seed() = 0;
inline virtual ~seed_gen(){}
};
namespace seed
{
typedef u64 sm128r[2];
struct sm128 {
sm128r m_raw;
};
struct splitmix64 : public virtual seed_gen<sm128>
{
splitmix64(u64 i);
sm128 generate_seed() override;
private:
sm128r m_state;
};
}
}

@ -1,10 +0,0 @@
#include <rngxx.hpp>
//XXX: Doing this is not going to work ...
#if 0
void t(Random& r)
{
for(auto&& i : r.iter<int>()) (void)i;
}
#endif

@ -0,0 +1,13 @@
#include <seed.h>
extern "C" {
// TODO: XXX: how to return a god damn array without typedef ffs????
extern u64 (*sm64_compute[2])(u64, u64);
}
namespace rng::seed
{
splitmix64::splitmix64(u64 u) : m_state(sm64_compute(u, 0)){}
sm128 splitmix64::generate_seed() { return sm128 { m_state = sm64_compute(m_state[0], m_state[1]) }; }
}
Loading…
Cancel
Save