21#if !defined(__RLIB_H_INCLUDE_GUARD__) && !defined(RLIB_COMPILATION)
22#error "#include <rlib.h> only please."
101#define r_rand_std_srand(seed) srand (seed)
103#define r_rand_std_rand() rand ()
109#define r_rand_prng_new r_prng_new_kiss
111#define r_prng_ref r_ref_ref
113#define r_prng_unref r_ref_unref
176 rsize size) R_ATTR_MALLOC;
#define R_API
Public-API decoration: resolves to R_API_EXPORT while building rlib and R_API_IMPORT for consumers.
Definition rmacros.h:115
#define R_BEGIN_DECLS
Open an extern "C" block under C++ (no-op in C).
Definition rmacros.h:196
ruint64 r_rand_entropy_u64(void)
Read a 64-bit value from the OS entropy source.
RPrng * r_prng_new_mt_with_seed_array(const ruint64 *array, rsize size)
Mersenne Twister PRNG seeded from an array of 64-bit values (recommended for reproducing a specific s...
struct RPrng RPrng
Opaque, refcounted PRNG handle.
Definition rrand.h:106
RPrng * r_prng_new_crypto(void)
Cryptographically-secure PRNG: a ChaCha20 DRBG seeded from the OS entropy source and periodically res...
rboolean r_prng_fill_base64(RPrng *prng, rchar *buf, rsize size)
Fill buf with size base64-alphabet characters; useful for token / nonce generation.
RPrng * r_prng_new_mt_with_seed(ruint64 seed)
Mersenne Twister PRNG seeded from a single 64-bit value.
RPrng * r_prng_new_mt(void)
Mersenne Twister PRNG seeded from OS entropy.
rboolean r_prng_fill_nonzero(RPrng *prng, ruint8 *buf, rsize size)
Like r_prng_fill, but every byte is guaranteed non-zero.
RPrng * r_prng_new_kiss(void)
KISS PRNG seeded from OS entropy.
RPrng * r_prng_new_kiss_with_seed(ruint64 x, ruint64 y, ruint64 z, ruint64 c)
KISS PRNG with explicit four-component seed.
ruint32 r_rand_entropy_u32(void)
Read a 32-bit value from the OS entropy source.
rboolean r_prng_fill(RPrng *prng, ruint8 *buf, rsize size)
Fill buf with size pseudo-random bytes from prng.
ruint64 r_prng_get_u64(RPrng *prng)
Draw a 64-bit sample from prng.
RPrng * r_prng_new_system(void)
Cryptographically-secure PRNG that reads every output directly from the OS entropy source (see r_rand...
rboolean r_rand_entropy_fill(ruint8 *buf, rsize size)
Fill buf with size bytes of cryptographic-grade OS entropy.
char rchar
Default character type (char).
Definition rtypes.h:137
int rboolean
Boolean type (typedef'd to int).
Definition rtypes.h:59
unsigned int ruint32
Unsigned 32-bit integer.
Definition rtypes.h:192
unsigned char ruint8
Unsigned 8-bit integer.
Definition rtypes.h:190
unsigned long rsize
Unsigned pointer-sized size type (like size_t).
Definition rtypes.h:290
unsigned long ruint64
Unsigned 64-bit integer.
Definition rtypes.h:193
Refcount base struct shared by every refcounted type in rlib.
Foundational type aliases used by every rlib header.