[SLOF] [PATCH v2 3/7] libc: Add srand() call
Thomas Huth
thuth at redhat.com
Tue Dec 22 21:08:39 AEDT 2015
Needed for seeding the state of the pseudo-random number generator.
Signed-off-by: Thomas Huth <thuth at redhat.com>
Reviewed-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
---
lib/libc/include/stdlib.h | 1 +
lib/libc/stdlib/rand.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/lib/libc/include/stdlib.h b/lib/libc/include/stdlib.h
index dff57f5..5e0eda9 100644
--- a/lib/libc/include/stdlib.h
+++ b/lib/libc/include/stdlib.h
@@ -29,5 +29,6 @@ unsigned long int strtoul(const char *nptr, char **endptr, int base);
long int strtol(const char *nptr, char **endptr, int base);
int rand(void);
+void srand(unsigned int seed);
#endif
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index 98c7e6d..39f5a9a 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -22,3 +22,8 @@ rand(void)
return ((unsigned int) (_rand >> 16) & RAND_MAX);
}
+
+void srand(unsigned int seed)
+{
+ _rand = seed;
+}
--
1.8.3.1
More information about the SLOF
mailing list