diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
commit | 64d2a7c8945ba05af859901f5e248f1befdd8621 (patch) | |
tree | 013fcb7e9e3296ecdda876012252c36bd6bcb063 /src/pkg/runtime/alg.c | |
parent | b901efe83e212f0c34c769c079e41373da12d723 (diff) | |
download | golang-64d2a7c8945ba05af859901f5e248f1befdd8621.tar.gz |
Imported Upstream version 1.2upstream/1.2
Diffstat (limited to 'src/pkg/runtime/alg.c')
-rw-r--r-- | src/pkg/runtime/alg.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/pkg/runtime/alg.c b/src/pkg/runtime/alg.c index a78d9780c..c3a839695 100644 --- a/src/pkg/runtime/alg.c +++ b/src/pkg/runtime/alg.c @@ -4,6 +4,7 @@ #include "runtime.h" #include "type.h" +#include "../../cmd/ld/textflag.h" #define M0 (sizeof(uintptr)==4 ? 2860486313UL : 33054211828000289ULL) #define M1 (sizeof(uintptr)==4 ? 3267000013UL : 23344194077549503ULL) @@ -499,7 +500,7 @@ runtime·hashinit(void) } // func equal(t *Type, x T, y T) (ret bool) -#pragma textflag 7 +#pragma textflag NOSPLIT void runtime·equal(Type *t, ...) { @@ -512,3 +513,29 @@ runtime·equal(Type *t, ...) ret = ROUND(ret, Structrnd); t->alg->equal((bool*)ret, t->size, x, y); } + +// Testing adapters for hash quality tests (see hash_test.go) +void runtime·haveGoodHash(bool res) { + res = use_aeshash; + FLUSH(&res); +} +void runtime·stringHash(String s, uintptr seed, uintptr res) { + runtime·algarray[ASTRING].hash(&seed, sizeof(String), &s); + res = seed; + FLUSH(&res); +} +void runtime·bytesHash(Slice s, uintptr seed, uintptr res) { + runtime·algarray[AMEM].hash(&seed, s.len, s.array); + res = seed; + FLUSH(&res); +} +void runtime·int32Hash(uint32 i, uintptr seed, uintptr res) { + runtime·algarray[AMEM32].hash(&seed, sizeof(uint32), &i); + res = seed; + FLUSH(&res); +} +void runtime·int64Hash(uint64 i, uintptr seed, uintptr res) { + runtime·algarray[AMEM64].hash(&seed, sizeof(uint64), &i); + res = seed; + FLUSH(&res); +} |