X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=flowspec-xdp;a=blobdiff_plain;f=siphash.h;h=298a3a2dd626470915f21c7fe39fa0f0d56e827d;hp=4c2ec7aa3d2db82582c978a7a27729475faa18d9;hb=HEAD;hpb=e7e5b2c8192b715dcfb574051c8d098c8360d746 diff --git a/siphash.h b/siphash.h index 4c2ec7a..298a3a2 100644 --- a/siphash.h +++ b/siphash.h @@ -140,3 +140,15 @@ static inline uint64_t siphash(const void *in, const size_t inlen, const uint8_t b = v0 ^ v1 ^ v2 ^ v3; return b; } + +#include "rand.h" +static uint64_t siphash_uint64_t(const uint64_t in) { + return siphash(&in, sizeof(uint64_t), COMPILE_TIME_RAND); +} +__attribute__((always_inline)) +static inline uint64_t siphash_uint32_t(const uint32_t in) { + return siphash_uint64_t(in); +} +static uint64_t siphash_uint128_t(const __uint128_t in) { + return siphash(&in, sizeof(__uint128_t), COMPILE_TIME_RAND); +}