diff options
| author | Ben Pfaff <blp@nicira.com> | 2009-10-14 17:03:55 -0700 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2009-11-04 15:00:30 -0800 |
| commit | cce1d8bd8e326c93579a6ff5d037fe3a60a39f86 (patch) | |
| tree | de57bab2a0360bce07d96e35347751765bf0c1bc /lib/hash.c | |
| parent | 0064467516248fb3b28bdbd7d0f4e54b861627cf (diff) | |
| download | openvswitch-cce1d8bd8e326c93579a6ff5d037fe3a60a39f86.tar.gz | |
hash: Implement hash function for "double" values.
This will be used by the configuration database, which can store real
numbers.
Diffstat (limited to 'lib/hash.c')
| -rw-r--r-- | lib/hash.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/hash.c b/lib/hash.c index f1daa6ba7..63b4784fc 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -52,6 +52,21 @@ hash_words(const uint32_t *p, size_t n, uint32_t basis) return c; } +/* Returns the hash of the pair of aligned 32-bit words at 'p', starting from + * 'basis'. */ +uint32_t +hash_2words(const uint32_t *p, uint32_t basis) +{ + uint32_t a, b, c; + + a = b = c = 0xdeadbeef + (2 << 2) + basis; + b += p[1]; + a += p[0]; + HASH_FINAL(a, b, c); + + return c; +} + /* Returns the hash of the 'n' bytes at 'p', starting from 'basis'. */ uint32_t hash_bytes(const void *p_, size_t n, uint32_t basis) |
