rand() implementation.
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 15 May 2006 07:20:35 +0000 (07:20 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 15 May 2006 07:20:35 +0000 (07:20 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@600 38d2e660-2303-0410-9eaa-f027e97ec537

mware/rand.c [new file with mode: 0755]

diff --git a/mware/rand.c b/mware/rand.c
new file mode 100755 (executable)
index 0000000..11df421
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * \file
+ * <!--
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
+ * This file is part of DevLib - See README.devlib for information.
+ * -->
+ *
+ * \brief Very simple rand() algorithm.
+ *
+ * \version $Id$
+ * \author Bernardo Innocenti <bernie@develer.com>
+ */
+
+/* This would really belong to libc */
+static int rand(void)
+{
+       static unsigned long seed;
+
+       /* Randomize seed */
+       seed = (seed ^ 0x4BAD5A39UL) + 6513973UL;
+
+       return (int)(seed>>16);
+}