mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
gopack: work around gcc bug in hash function
Fixes #48. (this time for sure!) R=r, r1 https://golang.org/cl/152088
This commit is contained in:
parent
0c83f23d44
commit
8b95720918
1 changed files with 10 additions and 3 deletions
|
|
@ -784,9 +784,16 @@ hashstr(char *name)
|
|||
h = 0;
|
||||
for(cp = name; *cp; h += *cp++)
|
||||
h *= 1119;
|
||||
if(h < 0)
|
||||
h = ~h;
|
||||
return h;
|
||||
|
||||
// the code used to say
|
||||
// if(h < 0)
|
||||
// h = ~h;
|
||||
// but on gcc 4.3 with -O2 on some systems,
|
||||
// the if(h < 0) gets compiled away as not possible.
|
||||
// use a mask instead, leaving plenty of bits but
|
||||
// definitely not the sign bit.
|
||||
|
||||
return h & 0xfffffff;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue