_srand_r()

Defined in stdlib.h, this is a reentrant version of the srand() function.

Show/hideSyntax

int __srand_r(struct _rand_state * buffer, unsigned int seed);

where:

buffer

is a pointer to a user-supplied buffer storing the state of the random number generator.

seed

is a seed for a new sequence of pseudo-random numbers to be returned by subsequent calls to _rand_r().

Show/hideUsage

This function enables you to explicitly supply your own buffer that can be used for thread-local storage.

If _srand_r() is repeatedly called with the same seed value, the same sequence of pseudo-random numbers is repeated. If _rand_r() is called before any calls to _srand_r() have been made with the same buffer, undefined behavior occurs because the buffer is not initialized.

Show/hideSee also

Copyright © 2010-2011 ARM. All rights reserved.ARM DUI 0492F
Non-ConfidentialID091611