Commit f5d2a381 authored by bellard's avatar bellard
Browse files

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
parent e553272d
...@@ -27,11 +27,14 @@ void cpu_mips_irqctrl_init (void) ...@@ -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 cpu_mips_get_random (CPUState *env)
{ {
uint32_t now = qemu_get_clock(vm_clock); static uint32_t seed = 0;
uint32_t idx;
return now % (MIPS_TLB_NB - env->CP0_Wired) + env->CP0_Wired; seed = seed * 314159 + 1;
idx = (seed >> 16) % (MIPS_TLB_NB - env->CP0_Wired) + env->CP0_Wired;
return idx;
} }
/* MIPS R4K timer */ /* MIPS R4K timer */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment