add missing files
This commit is contained in:
7
include/libtorrent/random.hpp
Normal file
7
include/libtorrent/random.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
void random_seed(boost::uint32_t v);
|
||||
boost::uint32_t random();
|
||||
}
|
30
src/random.cpp
Normal file
30
src/random.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "libtorrent/random.hpp"
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
uint32_t x = 123456789;
|
||||
}
|
||||
|
||||
void random_seed(boost::uint32_t v)
|
||||
{
|
||||
x = v;
|
||||
}
|
||||
|
||||
// this is an xorshift random number generator
|
||||
// see: http://en.wikipedia.org/wiki/Xorshift
|
||||
boost::uint32_t random()
|
||||
{
|
||||
static uint32_t y = 362436069;
|
||||
static uint32_t z = 521288629;
|
||||
static uint32_t w = 88675123;
|
||||
uint32_t t;
|
||||
|
||||
t = x ^ (x << 11);
|
||||
x = y; y = z; z = w;
|
||||
return w = w ^ (w >> 19) ^ (t ^ (t >> 8));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user