From: Thomas Leonard Date: Fri, 8 Aug 2014 15:47:32 +0000 (+0100) Subject: mini-os: move poor rand function to test.c X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e1a1ed2948e8821acc82c2ea54ea38d49186a7a9;p=people%2Fliuw%2Flibxenctrl-split%2Fmini-os.git mini-os: move poor rand function to test.c It's only used by test.c and probably isn't something that should be exposed for general use (it just calls gettimeofday). This is also useful for ARM, which doesn't use math.c, where this used to live. Signed-off-by: Thomas Leonard Acked-by: Samuel Thibault --- diff --git a/lib/math.c b/lib/math.c index c941b4c..561393e 100644 --- a/lib/math.c +++ b/lib/math.c @@ -424,16 +424,3 @@ __moddi3(quad_t a, quad_t b) (void)__qdivrem(ua, ub, &ur); return (neg ? -ur : ur); } - -#ifndef HAVE_LIBC -/* Should be random enough for our uses */ -int rand(void) -{ - static unsigned int previous; - struct timeval tv; - gettimeofday(&tv, NULL); - previous += tv.tv_sec + tv.tv_usec; - previous *= RAND_MIX; - return previous; -} -#endif diff --git a/test.c b/test.c index 20d372b..0d7aba4 100644 --- a/test.c +++ b/test.c @@ -60,6 +60,19 @@ static void xenbus_tester(void *p) } #endif +#ifndef HAVE_LIBC +/* Should be random enough for our uses */ +int rand(void) +{ + static unsigned int previous; + struct timeval tv; + gettimeofday(&tv, NULL); + previous += tv.tv_sec + tv.tv_usec; + previous *= RAND_MIX; + return previous; +} +#endif + static void periodic_thread(void *p) { struct timeval tv;