'Thread safe random number generator in c

Does the c standard provide a thread safe random number generator where instead of using a global state the generator uses and modifies the provided state buffer ? I'm familiar with drand48_r and rand_r but on the documentation it is said that rand_r is a weak random number generator and drand48_r is obsolete. What would be a good thread safe random number generator ? I need one for double and one for int/long type. Also it would be great if it's portable.

c


Solution 1:[1]

C17 defines the random functions rand() (7.22.2.1) and srand() (7.22.2.2). Neither are required to avoid data races.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1