Previous: SVID Random Number Function, Up: Pseudo-Random Numbers [Contents][Index]
This section describes the random number functions provided as a GNU extension, based on OpenBSD interfaces.
The GNU C Library uses kernel entropy obtained either through getrandom
or by reading /dev/urandom to seed.
These functions provide higher random quality than ISO, BSD, and SVID functions, and may be used in cryptographic contexts.
The prototypes for these functions are in stdlib.h.
| MT-Safe | AS-Unsafe corrupt | AC-Safe | See POSIX Safety Concepts.
This function returns a single 32-bit value in the range of 0
to
2^32−1
(inclusive), which is twice the range of rand
and
random
.
| MT-Safe | AS-Unsafe corrupt | AC-Safe | See POSIX Safety Concepts.
This function fills the region buffer of length length bytes with random data.
| MT-Safe | AS-Unsafe corrupt | AC-Safe | See POSIX Safety Concepts.
This function returns a single 32-bit value, uniformly distributed but less than the upper_bound. It avoids the modulo bias when the upper bound is not a power of two.