]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
mini-os: move poor rand function to test.c
authorThomas Leonard <talex5@gmail.com>
Fri, 8 Aug 2014 15:47:32 +0000 (16:47 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 8 Sep 2014 11:15:36 +0000 (12:15 +0100)
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 <talex5@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
lib/math.c
test.c

index c941b4c420b15f9f9ef8bb3a83b29fe7aee69554..561393e6299e37e212fb942b5e2fcb37d281de85 100644 (file)
@@ -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 20d372b888355f80fecaa51f15dfe7db0a0d7e1e..0d7aba41914b067616e418d7b4a6205dd1b98f4b 100644 (file)
--- 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;