Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

OSS Library Calls (n - r) rand_r(3)
NAME
rand_r - Returns pseudorandom numbers (reentrant)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCREDLL
32-bit H-series and J-series OSS processes that do not use Standard POSIX Threads: |
/G/system/zdllnnn/zcredll
64-bit H-series and J-series OSS processes that do not use Standard POSIX Threads: |
/G/system/zdllnnn/ycredll
H-series and J-series OSS processes that use the Standard POSIX Threads library:
/G/system/zdllnnn/zsptdll
SYNOPSIS
#include <stdlib.h> | #include <spthread.h>
/* stdlib.h is required for H-series and J-series processes that do not use */
/* the Standard POSIX Threads library */
/* spthread.h is required for G-series native OSS processes, and for H-series */
/* and J-series OSS processes that use the Standard POSIX Threads library */
int rand_r(
unsigned int *seed);
PARAMETERS
seed Specifies the initial value on which random numbers should be based.
DESCRIPTION
The rand_r( ) function is the reentrant version of the rand( ) function.
The rand_r( ) function returns successive pseudorandom numbers in the range from 0 (zero) to
RAND_MAX.Ifrand_r( ) is called with the same initial value for the object pointed to by seed
and that object is not modified between successive returns and calls to rand_r(), the same
sequence is generated.
NOTES
The rand_r( ) function is a very simple random-number generator. Its spectral properties, the
mathematical measurement of how random the number sequence is, are weak.
On systems running H06.21 or later H-series RVUs or J06.10 or later J-series RVUs, you can use
either the POSIX User Thread Model library or the Standard POSIX Threads library for threaded
applications.
If you are NOT using the Standard POSIX Threads library (this is not a threaded application or
you are using the POSIX User Thread Model library), you must:
Include the stdlib.h file
To use the Standard POSIX Threads library, you must:
Include the spthread.h file
Link your application to the Standard POSIX Threads library:
/G/system/sysnn/zsptsrl (G-series)
or
/G/system/zdllnnn/zsptdll (H-series or J-series)
Compile your application using the #define_SPT_MODEL_ macro or an equivalent
compiler command option.
527187-017 Hewlett-Packard Company 5135