~donmcc/lrnd

lrnd/README.md -rw-r--r-- 1.1 KiB
fd8d136bDon McCaughey Created initial project skeleton. 4 months ago

#lrnd

A C99 library for generating random numbers.

builds.sr.ht status

#Overview

The lrnd library contains functions for generating random numbers using pluggable random number generators.

#Structs

struct lrnd {
    uint32_t const max_value;
    bool (*next_value)(uint32_t *value_out);
};

The max_value field contains the inclusive maximum value that the generator can produce. The next_value field contains a pointer to a function that generates the next random value for this generator.

#Functions

struct lrnd *
lrnd_get_stdlib_rand(void);

Retrieve a static instance of the rand() pseudo-random number generator.

bool
lrnd_next_value(struct lrnd *lrnd, uint32_t *value_out);

Generate the next random value for the given generator. Returns false and sets errno if generation fails.

#License

lrnd is made available under a BSD-style license; see the LICENSE file for details.