handle last action with nop
[c11tester.git] / hashfunction.cc
1 #include "hashfunction.h"
2
3 /**
4  * Hash function for 64-bit integers
5  * https://gist.github.com/badboy/6267743#64-bit-to-32-bit-hash-functions
6  */
7 unsigned int int64_hash(uint64_t key) {
8         key = (~key) + (key << 18);     // key = (key << 18) - key - 1;
9         key = key ^ (key >> 31);
10         key = key * 21; // key = (key + (key << 2)) + (key << 4);
11         key = key ^ (key >> 11);
12         key = key + (key << 6);
13         key = key ^ (key >> 22);
14         return (unsigned int) key;
15 }