libgo patch committed: Copy hash code from Go 1.7 runtime

Ian Lance Taylor iant@golang.org
Fri Dec 9 22:00:00 GMT 2016


On Fri, Dec 9, 2016 at 2:09 AM, Sebastian Huber
<sebastian.huber@embedded-brains.de> wrote:
> On 08/12/16 17:37, Ian Lance Taylor wrote:
>>
>> +// For gccgo, use go:linkname to rename compiler-called functions to
>> +// themselves, so that the compiler will export them.
>> +//
>> +//go:linkname memhash runtime.memhash
>> +
>> +const (
>> +       // Constants for multiplication: four random odd 64-bit numbers.
>> +       m1 = 16877499708836156737
>> +       m2 = 2820277070424839065
>> +       m3 = 9497967016996688599
>> +       m4 = 15839092249703872147
>> +)
>
>
> Out of curiosity, how did you generate these numbers?

I just copied them from the master gc library (in this case from
https://golang.org/src/runtime/hash64.go).  I asked Keith Randall, who
wrote the original version, and he said he simply generated them
randomly.  He said "I believe I used python's
random.randrange(2**64)|1."

Ian



More information about the Gcc-patches mailing list