From: bernie Date: Mon, 15 May 2006 07:20:35 +0000 (+0000) Subject: rand() implementation. X-Git-Tag: 1.0.0~641 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=6998354505e9112ed772da779507af6a61055c06;p=bertos.git rand() implementation. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@600 38d2e660-2303-0410-9eaa-f027e97ec537 --- 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); +}