]> Cypherpunks repositories - gostls13.git/commit
runtime: add runtime.cputicks() and seed fastrand with it
authorDamian Gryski <dgryski@gmail.com>
Thu, 2 Feb 2012 19:09:27 +0000 (14:09 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 2 Feb 2012 19:09:27 +0000 (14:09 -0500)
commit8e765da941f4f0649aca2b28234ac31adde45f06
tree1decf5c6f8e83df0c7ce68ba49f1dfa805a0804b
parent16ce2f9369fd76334880a3883ca1def77d41c7e3
runtime: add runtime.cputicks() and seed fastrand with it

This patch adds a function to get the current cpu ticks.  This is
deemed to be 'sufficiently random' to use to seed fastrand to mitigate
the algorithmic complexity attacks on the hash table implementation.

On AMD64 we use the RDTSC instruction.  For 386, this instruction,
while valid, is not recognized by 8a so I've inserted the opcode by
hand.  For ARM, this routine is currently stubbed to return a constant
0 value.

Future work: update 8a to recognize RDTSC.

Fixes #2630.

R=rsc
CC=golang-dev
https://golang.org/cl/5606048
src/pkg/runtime/asm_386.s
src/pkg/runtime/asm_amd64.s
src/pkg/runtime/asm_arm.s
src/pkg/runtime/proc.c
src/pkg/runtime/runtime.h