Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)

initstate(3) Guardian Native C Library Calls Reference Manual
NAME
initstate - Initialize random number generator
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZSTFNSRL
G-series native OSS processes: /G/system/sysnn/zstfnsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCREDLL
H-series OSS processes: /G/system/zdllnnn/zcredll
SYNOPSIS
#include <stdlib.h>
char *initstate (
unsigned int seed,
char *state,
size_t size);
PARAMETERS
seed Is an unsigned int used to initialize a state array.
state Is a pointer to a state array.
size Is the size, in bytes, of the state array.
DESCRIPTION
The initstate() function initializes the state array pointed to by the state parameter for future use
by the random() function. The size parameter species the size in bytes of this array and is used
by initstate() to determine the type of random-number generator to use. A larger state array
means the numbers generated will be more random. Standard values for size are 8, 32, 64, 128,
and 256 bytes. Other values greater than eight bytes are rounded down to one of these. If size is
less 8 bytes, the random( ) function uses a simple linear congruential random-number generator.
The seed parameter provides a starting point for the random-number generator.
After you have initialized a state array with the initstate( ) function, you can use the setstate()
function to switch state arrays. Subsequent calls to the random( ) function will use the state
array pointed to by the state parameter until either initstate() is called or setstate() is called
again.
NOTES
This function can be called by native processes only.
RETURN VALUES
The initstate() function returns a pointer to the previous state array.
ERRORS
None. This function does not set errno.
RELATED INFORMATION
Functions: random(3), setstate(3), srandom(3).
STANDARDS CONFORMANCE
The initstate() function is dened in the XPG4 Version 2 specication.
360 Hewlett-Packard Company 527192-007