X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fhash.c;h=63b4784fc0add651896913fed79783386c46e96c;hb=a0bc29a541fc7dc6e20137d5558e2094d614e6ab;hp=f1daa6ba782389a956cd5ae508927546d637f3b0;hpb=34e63086edddcae06d7c1a4fa84fec0861e50758;p=openvswitch diff --git a/lib/hash.c b/lib/hash.c index f1daa6ba..63b4784f 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)