diff options
Diffstat (limited to 'src/shared/util.h')
-rw-r--r-- | src/shared/util.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/shared/util.h b/src/shared/util.h index 488ce3ba6d..338d79c7ac 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -249,8 +249,19 @@ int make_stdio(int fd); int make_null_stdio(void); int make_console_stdio(void); -unsigned long long random_ull(void); -unsigned random_u(void); +void random_bytes(void *p, size_t n); + +static inline uint64_t random_u64(void) { + uint64_t u; + random_bytes(&u, sizeof(u)); + return u; +} + +static inline uint32_t random_u32(void) { + uint32_t u; + random_bytes(&u, sizeof(u)); + return u; +} /* For basic lookup tables with strictly enumerated entries */ #define __DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \ |