2017-08-28 18:06:01 +02:00
|
|
|
#ifndef LIGHTNING_COMMON_PSEUDORAND_H
|
|
|
|
#define LIGHTNING_COMMON_PSEUDORAND_H
|
2016-01-21 21:11:47 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include <stdint.h>
|
2023-08-11 05:04:47 +02:00
|
|
|
#include <stdlib.h>
|
2016-01-21 21:11:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* pseudorand - pseudo (guessable!) random number between 0 and max-1.
|
|
|
|
*/
|
|
|
|
uint64_t pseudorand(uint64_t max);
|
2016-06-28 23:19:20 +02:00
|
|
|
|
2019-02-01 03:36:18 +01:00
|
|
|
/**
|
|
|
|
* pseudorand - pseudo (guessable!) random number between 0 and UINT64_MAX.
|
|
|
|
*/
|
|
|
|
uint64_t pseudorand_u64(void);
|
|
|
|
|
2019-04-16 09:15:21 +02:00
|
|
|
/**
|
|
|
|
* pseudorand - pseudo (guessable!) random number between 0 (inclusive) and 1
|
|
|
|
* (exclusive).
|
|
|
|
*/
|
|
|
|
double pseudorand_double(void);
|
|
|
|
|
2016-06-28 23:19:20 +02:00
|
|
|
/**
|
|
|
|
* Get the siphash seed for hash tables.
|
|
|
|
*/
|
|
|
|
const struct siphash_seed *siphash_seed(void);
|
|
|
|
|
2023-08-11 05:04:47 +02:00
|
|
|
/* Shuffle a tal array of type type. */
|
|
|
|
#define tal_arr_randomize(arr, type) \
|
|
|
|
tal_arr_randomize_((arr), sizeof(type) + 0*sizeof(arr == (type *)NULL))
|
|
|
|
void tal_arr_randomize_(void *arr, size_t elemsize);
|
|
|
|
|
2017-08-28 18:06:01 +02:00
|
|
|
#endif /* LIGHTNING_COMMON_PSEUDORAND_H */
|