#ifndef lib_rnd_h #define lib_rnd_h /* Maria project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file lib/rnd.h * \brief Random Number Generator header. * \ingroup lib */ /** Random number generator context. */ struct lib_rnd_t { #define LIB_MT_N 624 unsigned long state[LIB_MT_N]; int state_index; }; typedef struct lib_rnd_t lib_rnd_t; /** Generate a integer which has a probability of \a prob to be greater than a * random 32 bit integer. */ #define LIB_RND_RATIO(prob) ((u32) ((1ull << 32) * (prob))) void lib_rnd_init (lib_rnd_t *ctx, u32 seed); void lib_rnd_init_by_array (lib_rnd_t *ctx, const u32 init_key[], int key_length); u32 lib_rnd32 (lib_rnd_t *ctx); uint lib_rnd_uniform (lib_rnd_t *ctx, uint bound); #endif /* lib_rnd_h */