[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lost] [PATCH] + libc: random() und srandom()



---
 src/include/errno.h            |    1 +
 src/include/stdlib.h           |   14 ++++++++++++++
 src/modules/lib/stdlibc/rand.c |   24 +++++++++++++++++++++++-
 3 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/src/include/errno.h b/src/include/errno.h
index 606cb2c..8876115 100644
--- a/src/include/errno.h
+++ b/src/include/errno.h
@@ -60,6 +60,7 @@
 #define ENOTTY 22
 #define EDOM 23
 #define ENXIO 24
+#define ESRCH 25
 extern int errno;
 
 #endif
diff --git a/src/include/stdlib.h b/src/include/stdlib.h
index 6278b93..231c3ce 100644
--- a/src/include/stdlib.h
+++ b/src/include/stdlib.h
@@ -120,4 +120,18 @@ void srand(unsigned int seed);
  */
 int rand(void);
 
+/**
+ * Zufallszahl generieren
+ *
+ * @return Zufallszahl
+ */
+long int random(void);
+
+/**
+ * Seed fuer Zufallszahlgenerator setzen
+ *
+ * @param seed Seed
+ */
+void srandom(unsigned int seed);
+
 #endif
diff --git a/src/modules/lib/stdlibc/rand.c b/src/modules/lib/stdlibc/rand.c
index b3f9f11..1dbfd28 100644
--- a/src/modules/lib/stdlibc/rand.c
+++ b/src/modules/lib/stdlibc/rand.c
@@ -53,7 +53,7 @@ void srand(unsigned int seed)
  *
  * @return Zufallszahl
  */
-int rand()
+int rand(void)
 {
     int rnd;
 
@@ -62,3 +62,25 @@ int rand()
     rnd_seed += rnd;
     return rnd;
 }
+
+/**
+ * Zufallszahl generieren
+ *
+ * @return Zufallszahl
+ */
+long int random(void)
+{
+    return rand();
+}
+
+/**
+ * Seed fuer Zufallszahlgenerator setzen
+ *
+ * @param seed Seed
+ */
+void srandom(unsigned int seed)
+{
+    srand(seed);
+}
+
+
-- 
1.5.6.4