From 6998354505e9112ed772da779507af6a61055c06 Mon Sep 17 00:00:00 2001 From: bernie Date: Mon, 15 May 2006 07:20:35 +0000 Subject: [PATCH] rand() implementation. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@600 38d2e660-2303-0410-9eaa-f027e97ec537 --- mware/rand.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 mware/rand.c diff --git a/mware/rand.c b/mware/rand.c new file mode 100755 index 00000000..11df4213 --- /dev/null +++ b/mware/rand.c @@ -0,0 +1,24 @@ +/** + * \file + * + * + * \brief Very simple rand() algorithm. + * + * \version $Id$ + * \author Bernardo Innocenti + */ + +/* This would really belong to libc */ +static int rand(void) +{ + static unsigned long seed; + + /* Randomize seed */ + seed = (seed ^ 0x4BAD5A39UL) + 6513973UL; + + return (int)(seed>>16); +} -- 2.25.1