summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2022-04-09 02:28:05 +0000
committerLaurent Bercot <ska@appnovation.com>2022-04-09 02:28:05 +0000
commit4e75b40d8a96c5d51490ddea43566fe8e6d4168c (patch)
tree06358f285c713a7f05297cb7d2826319d6561683 /src/include
parent1fedaae65b56b8548cdf2d8c26e2becece5fec07 (diff)
downloadskalibs-4e75b40d8a96c5d51490ddea43566fe8e6d4168c.tar.xz
Prepare for 2.12.0.0. librandom revamp.
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/skalibs/functypes.h6
-rw-r--r--src/include/skalibs/random.h28
2 files changed, 24 insertions, 10 deletions
diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h
index f839877..0c94532 100644
--- a/src/include/skalibs/functypes.h
+++ b/src/include/skalibs/functypes.h
@@ -58,4 +58,10 @@ typedef create_func *create_func_ref ;
typedef int link_func (char const *, char const *) ;
typedef link_func *link_func_ref ;
+typedef void randomgen_func (char *, size_t) ;
+typedef randomgen_func *randomgen_func_ref ;
+
+typedef uint32_t uint32_func (uint32_t) ;
+typedef uint32_func *uint32_func_ref ;
+
#endif
diff --git a/src/include/skalibs/random.h b/src/include/skalibs/random.h
index 6c9dee0..0391d21 100644
--- a/src/include/skalibs/random.h
+++ b/src/include/skalibs/random.h
@@ -3,21 +3,29 @@
#ifndef SKALIBS_RANDOM_H
#define SKALIBS_RANDOM_H
-#include <sys/types.h>
+#include <stddef.h>
#include <stdint.h>
+#include <skalibs/functypes.h>
#include <skalibs/stralloc.h>
-extern void random_makeseed (char *) ; /* fills 160 bytes */
+extern void random_buf (char *, size_t) ;
+extern void random_buf_early (char *, size_t) ;
-extern int random_init (void) ;
-extern void random_finish (void) ;
+extern uint32_t random_uint32_from (uint32_t, randomgen_func_ref) ;
+#define random_uint32(n) random_uint32_from((n), &random_buf)
+#define random_uint32_early(n) random_uint32_from((n), &random_buf_early)
-extern unsigned char random_char (void) ;
-extern void random_string (char *, size_t) ;
-extern uint32_t random_uint32 (uint32_t) ;
-extern void random_name (char *, size_t) ;
-extern void random_unsort (char *, size_t, size_t) ;
-extern int random_sauniquename (stralloc *, size_t) ;
+extern void random_name_from (char *, size_t, randomgen_func_ref) ;
+#define random_name(s, n) random_name_from(s, (n), &random_buf)
+#define random_name_early(s, n) random_name_from(s, (n), &random_buf_early)
+
+extern void random_unsort_from (char *, size_t, size_t, randomgen_func_ref) ;
+#define random_unsort(s, n, c) random_unsort_from(s, n, (c), &random_buf)
+#define random_unsort_early(s, n, c) random_unsort_from(s, n, (c), &random_buf_early)
+
+extern int random_sauniquename_from (stralloc *, size_t, randomgen_func_ref) ;
+#define random_sauniquename(sa, n) random_sauniquename_from(sa, (n), &random_buf)
+#define random_sauniquename_early(sa, n) random_sauniquename_from(sa, (n), &random_buf_early)
#endif