REORG: tools: promote the debug PRNG to more general use as a statistical one
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Mar 2021 13:01:35 +0000 (14:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 5 Mar 2021 07:30:08 +0000 (08:30 +0100)
commit06e69b556ce5839f74d82698350301d50e3b46ca
tree3a7075e4ca8fe45a2d7cc3c97a4a0636456d9144
parentb1adf03df970958e82ad33efadba3c2586ffc02f
REORG: tools: promote the debug PRNG to more general use as a statistical one

We frequently need to access a simple and fast PRNG for statistical
purposes. The debug_prng() function did exactly this using a xorshift
generator but its use was limited to debug only. Let's move this to
tools.h and tools.c to make it accessible everywhere. Since it needs to
be fast, its state is thread-local. An initialization function starts a
different initial value for each thread for better distribution.
include/haproxy/tools.h
src/debug.c
src/tools.c