diff options
| author | Damian Gryski <dgryski@gmail.com> | 2012-02-02 14:09:27 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-02-02 14:09:27 -0500 |
| commit | 8e765da941f4f0649aca2b28234ac31adde45f06 (patch) | |
| tree | 1decf5c6f8e83df0c7ce68ba49f1dfa805a0804b /src/pkg/runtime/runtime.h | |
| parent | 16ce2f9369fd76334880a3883ca1def77d41c7e3 (diff) | |
| download | go-8e765da941f4f0649aca2b28234ac31adde45f06.tar.xz | |
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
Diffstat (limited to 'src/pkg/runtime/runtime.h')
| -rw-r--r-- | src/pkg/runtime/runtime.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index df2cd149f2..692992150a 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -566,6 +566,7 @@ void runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp); void runtime·resetcpuprofiler(int32); void runtime·setcpuprofilerate(void(*)(uintptr*, int32), int32); void runtime·usleep(uint32); +int64 runtime·cputicks(void); #pragma varargck argpos runtime·printf 1 #pragma varargck type "d" int32 |
