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.