X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fhash.c;h=41ad1bf2fc96ba8a9d041ef8a1281176cf1e1819;hb=697e62f61b0b1f970c940a09b3be66c328d55a6e;hp=f7aa9163363a85386fee596d8c5f115006a9df61;hpb=e368cad8ecf6dbf272b2a3775b2e3e5e2dc6a5cf;p=sliver-openvswitch.git diff --git a/lib/hash.c b/lib/hash.c index f7aa91633..41ad1bf2f 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -102,3 +102,18 @@ hash_bytes(const void *p_, size_t n, uint32_t basis) return c; } + +/* Returns the hash of the 'n' 32-bit words at 'p', starting from 'basis'. + * 'p' must be properly aligned. */ +uint32_t +mhash_words(const uint32_t p[], size_t n_words, uint32_t basis) +{ + uint32_t hash; + size_t i; + + hash = basis; + for (i = 0; i < n_words; i++) { + hash = mhash_add(hash, p[i]); + } + return mhash_finish(hash, n_words); +}