random_r(3) Library Functions Manual random_r(3) random_r, srandom_r, initstate_r, setstate_r - LIBRARY Standard C library (libc, -lc) #include int random_r(struct random_data *restrict buf, int32_t *restrict result); int srandom_r(unsigned int seed, struct random_data *buf); int initstate_r(unsigned int seed, char statebuf[restrict .statelen], size_t statelen, struct random_data *restrict buf); int setstate_r(char *restrict statebuf, struct random_data *restrict buf); glibc (. feature_test_macros(7)): random_r(), srandom_r(), initstate_r(), setstate_r(): /* glibc >= 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE , random(3). , , . random_r() random(3), , , , buf, initstate_r(). result. srandom_r() srandom(3), , , buf initstate_r(), . initstate_r() initstate(3), , buf, . buf.state NULL. initstate_r() statebuf , buf. , statebuf buf ( statebuf malloc(3) ). setstate_r() setstate(3), , buf, . state initstate_r() setstate_r(). All of these functions return 0 on success. On error, -1 is returned, with errno set to indicate the error. EINVAL initstate_r() 8 . EINVAL statebuf buf setstate_r() NULL. EINVAL buf result random_r() NULL. attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |random_r(), srandom_r(), | | MT-Safe race:buf | |initstate_r(), setstate_r() | | | +----------------------------+----------------------------------------------------------+--------------------------+ GNU. initstate_r() . , random_data , , buf.state NULL, . . drand48(3), rand(3), random(3) aereiae , Azamat Hackimov , Dmitriy S. Seregin , Katrin Kutepova , Lockal , Yuri Kozlov , ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . random_r(3)