summaryrefslogtreecommitdiffstats
path: root/include/randutils.h
diff options
context:
space:
mode:
authorDavidlohr Bueso2012-04-05 23:52:04 +0200
committerKarel Zak2012-04-10 13:12:43 +0200
commitfe72459e414e0d1a55f93e0035766d2313362ac2 (patch)
treec4babbef2b84fcaf03585c98a3cfae84da2fcbd7 /include/randutils.h
parentlib/blkdev: fix compiler warning [-Wreturn-type] (diff)
downloadkernel-qcow2-util-linux-fe72459e414e0d1a55f93e0035766d2313362ac2.tar.gz
kernel-qcow2-util-linux-fe72459e414e0d1a55f93e0035766d2313362ac2.tar.xz
kernel-qcow2-util-linux-fe72459e414e0d1a55f93e0035766d2313362ac2.zip
lib: random utilities
Add a random number(s) generator specific file. The intial functions are based on what libuuid provide. I did some modifications like avoid WIN32 checks - this is util-LINUX. [kzak@redhat.com: - move jrand_seed to lib/randutils.c - use TLS for jrand_seed (like original code from libuuid) - use size_t for buffer sizes - add close() to random_get_bytes] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/randutils.h')
-rw-r--r--include/randutils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/randutils.h b/include/randutils.h
new file mode 100644
index 000000000..dec5e355a
--- /dev/null
+++ b/include/randutils.h
@@ -0,0 +1,12 @@
+#ifndef UTIL_LINUX_RANDUTILS
+#define UTIL_LINUX_RANDUTILS
+
+#ifdef HAVE_SRANDOM
+#define srand(x) srandom(x)
+#define rand() random()
+#endif
+
+extern int random_get_fd(void);
+extern void random_get_bytes(void *buf, size_t nbytes);
+
+#endif