1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

low-level RNG interfaces deal in scm_t_uint32, not unsigned long

* libguile/random.h (scm_t_rng): random_bits returns a scm_t_uint32.
  (scm_i_uniform32, scm_t_i_rstate): Internal RNG returns a
  scm_t_uint32, as advertised, instead of unsigned long.
  (scm_c_random): Return a scm_t_uint32 instead of an unsigned long.

* libguile/random.c (scm_i_uniform32, scm_i_init_rstate_scm):
  (scm_i_expose_rstate, scm_c_random, scm_c_random_bignum, scm_random)
  (scm_init_random): Adapt types to match implementation.
This commit is contained in:
Andy Wingo 2010-07-22 21:26:19 +02:00
parent 4ca4826997
commit b606ff6af9
2 changed files with 33 additions and 59 deletions

View file

@ -46,7 +46,7 @@ typedef struct scm_t_rstate {
typedef struct scm_t_rng {
size_t rstate_size; /* size of random state */
unsigned long (*random_bits) (scm_t_rstate *state); /* gives 32 random bits */
scm_t_uint32 (*random_bits) (scm_t_rstate *state); /* gives 32 random bits */
void (*init_rstate) (scm_t_rstate *state, const char *seed, int n);
scm_t_rstate *(*copy_rstate) (scm_t_rstate *state);
void (*init_rstate_scm) (scm_t_rstate *state, SCM exposed);
@ -61,11 +61,11 @@ SCM_API scm_t_rng scm_the_rng;
*/
typedef struct scm_t_i_rstate {
scm_t_rstate rstate;
unsigned long w;
unsigned long c;
scm_t_uint32 w;
scm_t_uint32 c;
} scm_t_i_rstate;
SCM_INTERNAL unsigned long scm_i_uniform32 (scm_t_i_rstate *);
SCM_INTERNAL scm_t_uint32 scm_i_uniform32 (scm_t_i_rstate *);
SCM_INTERNAL void scm_i_init_rstate (scm_t_i_rstate *, const char *seed, int n);
SCM_INTERNAL scm_t_i_rstate *scm_i_copy_rstate (scm_t_i_rstate *);
SCM_INTERNAL void scm_i_init_rstate_scm (scm_t_i_rstate *state, SCM value);
@ -82,7 +82,7 @@ SCM_API scm_t_rstate *scm_c_default_rstate (void);
SCM_API double scm_c_uniform01 (scm_t_rstate *);
SCM_API double scm_c_normal01 (scm_t_rstate *);
SCM_API double scm_c_exp1 (scm_t_rstate *);
SCM_API unsigned long scm_c_random (scm_t_rstate *, unsigned long m);
SCM_API scm_t_uint32 scm_c_random (scm_t_rstate *, scm_t_uint32 m);
SCM_API SCM scm_c_random_bignum (scm_t_rstate *, SCM m);