Commit f5d2a381d1fb5f7def1c86c95d0c093e54e3aa67
1 parent
e553272d
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
Showing
1 changed file
with
6 additions
and
3 deletions
hw/mips_r4k.c
... | ... | @@ -27,11 +27,14 @@ void cpu_mips_irqctrl_init (void) |
27 | 27 | { |
28 | 28 | } |
29 | 29 | |
30 | +/* XXX: do not use a global */ | |
30 | 31 | uint32_t cpu_mips_get_random (CPUState *env) |
31 | 32 | { |
32 | - uint32_t now = qemu_get_clock(vm_clock); | |
33 | - | |
34 | - return now % (MIPS_TLB_NB - env->CP0_Wired) + env->CP0_Wired; | |
33 | + static uint32_t seed = 0; | |
34 | + uint32_t idx; | |
35 | + seed = seed * 314159 + 1; | |
36 | + idx = (seed >> 16) % (MIPS_TLB_NB - env->CP0_Wired) + env->CP0_Wired; | |
37 | + return idx; | |
35 | 38 | } |
36 | 39 | |
37 | 40 | /* MIPS R4K timer */ | ... | ... |