/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0.If a copy of the MPL was not distributed with this * file, You can obtain one at http ://mozilla.org/MPL/2.0/. */ #pragma once #include #define CAT2(x, y) x##y #define CAT(x, y) CAT2(x, y) // hashes in universally into l (<= num bits in TYPE) bits using odd seed #define MSH(TYPE) \ inline TYPE CAT(TYPE, _msh) (TYPE in, TYPE bits, TYPE seed) { \ return (seed * in) >> ((sizeof( TYPE ) * 8) - bits); \ } // hashes for all of the standard sizes MSH(uint8_t) MSH(uint16_t) MSH(uint32_t) MSH(uint64_t)