Add random number generator and related functions

This commit is contained in:
Julien BLACHE
2010-05-02 10:58:25 +02:00
parent 47589ff34a
commit 5e9c245e39
2 changed files with 153 additions and 0 deletions

25
src/rng.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef __RNG_H__
#define __RNG_H__
struct rng_ctx {
int32_t iy;
int32_t iv[32]; /* shuffle array */
int32_t seed;
};
void
rng_init(struct rng_ctx *ctx);
int32_t
rng_rand(struct rng_ctx *ctx);
int32_t
rng_rand_range(struct rng_ctx *ctx, int32_t min, int32_t max);
void
shuffle_ptr(struct rng_ctx *ctx, void **values, int len);
#endif /* !__RNG_H__ */