Whenever I see such libraries, the first thing I check out is their PRNG implementation, and this one must be the worst I've seen so far. (The rest of the library is probably quite good, I'm just talking about the PRNG part)<p>The library has one PRNG, and it is the following:<p><pre><code> tb_spinlock_enter(&g_lock);
g_value = (g_value * 10807 + 1) & 0xffffffff;
tb_spinlock_leave(&g_lock);
</code></pre>
Using this is literally worse than using the rand reference implementation.<p>Also, tb_random_range uses a biased and slow implementation with modulo. (see <a href="https://www.pcg-random.org/posts/bounded-rands.html" rel="nofollow">https://www.pcg-random.org/posts/bounded-rands.html</a> for the proper way to do this)<p>I might look into adding a proper PRNG implementation, but I'll recommend a few resources:<p>A lesson of what not to do: <a href="https://youtu.be/LDPMpc-ENqY" rel="nofollow">https://youtu.be/LDPMpc-ENqY</a> ("rand() Considered Harmful")
Some good modern PRNGs: <a href="https://www.pcg-random.org/" rel="nofollow">https://www.pcg-random.org/</a>, <a href="https://prng.di.unimi.it/" rel="nofollow">https://prng.di.unimi.it/</a>, <a href="https://romu-random.org/" rel="nofollow">https://romu-random.org/</a>
Generating random numbers in a specific range: <a href="https://www.pcg-random.org/posts/bounded-rands.html" rel="nofollow">https://www.pcg-random.org/posts/bounded-rands.html</a>
Looks like a really interesting set of libraries (<a href="https://github.com/tboox" rel="nofollow">https://github.com/tboox</a>), available under Apache 2 license; also xmake looks interesting; definitely worth a closer look; thanks for sharing.