* random.cc (initstate): Align to POSIX definition.

(setstate): Ditto.
This commit is contained in:
Corinna Vinschen 2008-05-13 11:40:45 +00:00
parent 080fcb854e
commit a065930a3a
2 changed files with 10 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2008-05-13 Corinna Vinschen <corinna@vinschen.de>
* random.cc (initstate): Align to POSIX definition.
(setstate): Ditto.
2008-05-10 Corinna Vinschen <corinna@vinschen.de> 2008-05-10 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Remove _def_time.o. * Makefile.in (DLL_OFILES): Remove _def_time.o.

View File

@ -354,9 +354,9 @@ srandomdev()
* complain about mis-alignment, but you should disregard these messages. * complain about mis-alignment, but you should disregard these messages.
*/ */
char * char *
initstate(unsigned long seed, /* seed for R.N.G. */ initstate(unsigned seed, /* seed for R.N.G. */
char *arg_state, /* pointer to state array */ char *arg_state, /* pointer to state array */
long n) /* # bytes of state info */ size_t n) /* # bytes of state info */
{ {
char *ostate = (char *)(&state[-1]); char *ostate = (char *)(&state[-1]);
uint32_t *int_arg_state = (uint32_t *)arg_state; uint32_t *int_arg_state = (uint32_t *)arg_state;
@ -367,7 +367,8 @@ initstate(unsigned long seed, /* seed for R.N.G. */
state[-1] = MAX_TYPES * (rptr - state) + rand_type; state[-1] = MAX_TYPES * (rptr - state) + rand_type;
if (n < BREAK_0) { if (n < BREAK_0) {
(void)fprintf(stderr, (void)fprintf(stderr,
"random: not enough state (%ld bytes); ignored.\n", n); "random: not enough state (%lu bytes); ignored.\n",
(unsigned long) n);
return(0); return(0);
} }
if (n < BREAK_1) { if (n < BREAK_1) {
@ -421,7 +422,7 @@ initstate(unsigned long seed, /* seed for R.N.G. */
* complain about mis-alignment, but you should disregard these messages. * complain about mis-alignment, but you should disregard these messages.
*/ */
char * char *
setstate(char *arg_state /* pointer to state array */) setstate(const char *arg_state /* pointer to state array */)
{ {
uint32_t *new_state = (uint32_t *)arg_state; uint32_t *new_state = (uint32_t *)arg_state;
uint32_t type = new_state[0] % MAX_TYPES; uint32_t type = new_state[0] % MAX_TYPES;