#include <stdlib.h> int random_r(struct random_data *buf, int32_t *result); int srandom_r(unsigned int seed, struct random_data *buf); int initstate_r(unsigned int seed, char *statebuf, size_t statelen, struct random_data *buf); int setstate_r(char *statebuf, struct random_data *buf);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
random_r(), srandom_r(), initstate_r(), setstate_r():
The random_r() function is like random(3), except that instead of using state information maintained in a global variable, it uses the state information in the argument pointed to by buf, which must have been previously initialized by initstate_r(). The generated random number is returned in the argument result.
The srandom_r() function is like srandom(3), except that it initializes the seed for the random number generator whose state is maintained in the object pointed to by buf, which must have been previously initialized by initstate_r(), instead of the seed associated with the global state variable.
The initstate_r() function is like initstate(3) except that it initializes the state in the object pointed to by buf, rather than initializing the global state variable. Before calling this function, the buf.state field must be initialized to NULL. The initstate_r() function records a pointer to the statebuf argument inside the structure pointed to by buf. Thus, statebuf should not be deallocated so long as buf is still in use. (So, statebuf should typically be allocated as a static variable, or allocated on the heap using malloc(3) or similar.)
The setstate_r() function is like setstate(3) except that it modifies the state in the object pointed to by buf, rather than modifying the global state variable. state must first have been initialized using initstate_r() or be the result of a previous call of setstate_r().
インターフェース | 属性 | 値 |
random_r(), srandom_r(), initstate_r(), setstate_r() |
Thread safety | MT-Safe race:buf |
[man1]
[man2]
[man3]
[man4]
[man5]
[man6]
[man7]
[man8]
[a]
[b]
[c]
[d]
[e]
[f]
[g]
[h]
[i]
[j]
[k]
[l]
[m]
[n]
[o]
[p]
[q]
[r]
[s]
[t]
[u]
[v]
[w]
[x]
[y]
[z]