From f5d2a381d1fb5f7def1c86c95d0c093e54e3aa67 Mon Sep 17 00:00:00 2001 From: bellard Date: Tue, 2 May 2006 22:18:28 +0000 Subject: performance boost (on P4 hosts at least, rdtsc is a _very_ bad random generator) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1892 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/mips_r4k.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'hw') diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 6b6b6cb..0cb1168 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -27,11 +27,14 @@ void cpu_mips_irqctrl_init (void) { } +/* XXX: do not use a global */ uint32_t cpu_mips_get_random (CPUState *env) { - uint32_t now = qemu_get_clock(vm_clock); - - return now % (MIPS_TLB_NB - env->CP0_Wired) + env->CP0_Wired; + static uint32_t seed = 0; + uint32_t idx; + seed = seed * 314159 + 1; + idx = (seed >> 16) % (MIPS_TLB_NB - env->CP0_Wired) + env->CP0_Wired; + return idx; } /* MIPS R4K timer */ -- cgit v1.1