46namespace Fnv1aImplementation
144#if !defined(__FNV_H__)
151#define FNV_VERSION "5.0.2"
167#define FNV0_32_INIT ((Fnv1aImplementation::Fnv32_t)0)
183#define FNV1_32_INIT ((Fnv1aImplementation::Fnv32_t)0x811c9dc5)
185#define FNV1_32A_INIT FNV1_32_INIT
192#define HAVE_64BIT_LONG_LONG
199#if defined(HAVE_64BIT_LONG_LONG)
215#if defined(HAVE_64BIT_LONG_LONG)
216#define FNV0_64_INIT ((Fnv1aImplementation::Fnv64_t)0)
218extern const Fnv64_t fnv0_64_init;
219#define FNV0_64_INIT (Fnv1aImplementation::fnv0_64_init)
235#if defined(HAVE_64BIT_LONG_LONG)
236#define FNV1_64_INIT ((Fnv1aImplementation::Fnv64_t)0xcbf29ce484222325ULL)
238#define FNV1A_64_INIT FNV1_64_INIT
240extern const fnv1_64_init;
241extern const Fnv64_t fnv1a_64_init;
242#define FNV1_64_INIT (fnv1_64_init)
244#define FNV1A_64_INIT (fnv1a_64_init)
357#define FNV_32_PRIME ((Fnv1aImplementation::Fnv32_t)0x01000193)
376 unsigned char *bp = (
unsigned char *)buf;
377 unsigned char *be = bp + len;
388#if defined(NO_FNV_GCC_OPTIMIZATION)
391 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
415 unsigned char *s = (
unsigned char *)str;
426#if defined(NO_FNV_GCC_OPTIMIZATION)
429 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
505#if !defined(HAVE_64BIT_LONG_LONG)
506const Fnv64_t fnv1a_64_init = { 0x84222325, 0xcbf29ce4 };
514#if defined(HAVE_64BIT_LONG_LONG)
515#define FNV_64_PRIME ((Fnv1aImplementation::Fnv64_t)0x100000001b3ULL)
517#define FNV_64_PRIME_LOW ((unsigned long)0x1b3)
518#define FNV_64_PRIME_SHIFT (8)
539 unsigned char *bp = (
unsigned char *)buf;
540 unsigned char *be = bp + len;
542#if defined(HAVE_64BIT_LONG_LONG)
552#if defined(NO_FNV_GCC_OPTIMIZATION)
555 hval += (hval << 1) + (hval << 4) + (hval << 5) +
556 (hval << 7) + (hval << 8) + (hval << 40);
562 unsigned long val[4];
563 unsigned long tmp[4];
568 val[0] = hval.w32[0];
569 val[1] = (val[0] >> 16);
571 val[2] = hval.w32[1];
572 val[3] = (val[2] >> 16);
581 val[0] ^= (
unsigned long)*bp++;
595 tmp[0] = val[0] * FNV_64_PRIME_LOW;
596 tmp[1] = val[1] * FNV_64_PRIME_LOW;
597 tmp[2] = val[2] * FNV_64_PRIME_LOW;
598 tmp[3] = val[3] * FNV_64_PRIME_LOW;
600 tmp[2] += val[0] << FNV_64_PRIME_SHIFT;
601 tmp[3] += val[1] << FNV_64_PRIME_SHIFT;
603 tmp[1] += (tmp[0] >> 16);
604 val[0] = tmp[0] & 0xffff;
605 tmp[2] += (tmp[1] >> 16);
606 val[1] = tmp[1] & 0xffff;
607 val[3] = tmp[3] + (tmp[2] >> 16);
608 val[2] = tmp[2] & 0xffff;
619 hval.w32[1] = ((val[3]<<16) | val[2]);
620 hval.w32[0] = ((val[1]<<16) | val[0]);
644 unsigned char *s = (
unsigned char *)str;
646#if defined(HAVE_64BIT_LONG_LONG)
657#if defined(NO_FNV_GCC_OPTIMIZATION)
660 hval += (hval << 1) + (hval << 4) + (hval << 5) +
661 (hval << 7) + (hval << 8) + (hval << 40);
667 unsigned long val[4];
668 unsigned long tmp[4];
673 val[0] = hval.w32[0];
674 val[1] = (val[0] >> 16);
676 val[2] = hval.w32[1];
677 val[3] = (val[2] >> 16);
699 tmp[0] = val[0] * FNV_64_PRIME_LOW;
700 tmp[1] = val[1] * FNV_64_PRIME_LOW;
701 tmp[2] = val[2] * FNV_64_PRIME_LOW;
702 tmp[3] = val[3] * FNV_64_PRIME_LOW;
704 tmp[2] += val[0] << FNV_64_PRIME_SHIFT;
705 tmp[3] += val[1] << FNV_64_PRIME_SHIFT;
707 tmp[1] += (tmp[0] >> 16);
708 val[0] = tmp[0] & 0xffff;
709 tmp[2] += (tmp[1] >> 16);
710 val[1] = tmp[1] & 0xffff;
711 val[3] = tmp[3] + (tmp[2] >> 16);
712 val[2] = tmp[2] & 0xffff;
718 val[0] ^= (
unsigned long)(*s++);
724 hval.w32[1] = ((val[3]<<16) | val[2]);
725 hval.w32[0] = ((val[1]<<16) | val[0]);
uint32_t m_hash32
Cache last hash value, for incremental hashing.
uint32_t GetHash32(const char *buffer, const size_t size) override
Compute 32-bit hash of a byte buffer.
uint64_t GetHash64(const char *buffer, const size_t size) override
Compute 64-bit hash of a byte buffer.
uint64_t m_hash64
Cache last hash value, for incremental hashing.
void clear() override
Restore initial state.
uint64_t Fnv64_t
64 bit FNV-0 hash
#define FNV1A_64_INIT
64 bit FNV-1 non-zero initial basis
#define FNV1_32A_INIT
32 bit FNV-1 and FNV-1a non-zero initial basis
Fnv32_t fnv_32_str(char *str, Fnv32_t hval)
fnv_32a_str - perform a 32 bit Fowler/Noll/Vo FNV-1a hash on a string
Fnv64_t fnv_64_str(char *str, Fnv64_t hval)
fnv_64a_str - perform a 64 bit Fowler/Noll/Vo FNV-1a hash on a buffer
Fnv32_t fnv_32a_str(char *buf, Fnv32_t hashval)
fnv_32a_str - perform a 32 bit Fowler/Noll/Vo FNV-1a hash on a string
#define FNV_64_PRIME
FNV-1a defines the initial basis to be non-zero.
uint32_t Fnv32_t
32 bit FNV-0 hash type
Fnv64_t fnv_64_buf(void *buf, size_t len, Fnv64_t hval)
fnv_64a_buf - perform a 64 bit Fowler/Noll/Vo FNV-1a hash on a buffer
Fnv64_t fnv_64a_str(char *buf, Fnv64_t hashval)
fnv_64a_str - perform a 64 bit Fowler/Noll/Vo FNV-1a hash on a buffer
Fnv32_t fnv_32_buf(void *buf, size_t len, Fnv32_t hval)
fnv_32a_buf - perform a 32 bit Fowler/Noll/Vo FNV-1a hash on a buffer
#define FNV_32_PRIME
32 bit magic FNV-1a prime
Fnv32_t fnv_32a_buf(void *buf, size_t len, Fnv32_t hashval)
fnv_32a_buf - perform a 32 bit Fowler/Noll/Vo FNV-1a hash on a buffer
Fnv64_t fnv_64a_buf(void *buf, size_t len, Fnv64_t hashval)
fnv_64a_buf - perform a 64 bit Fowler/Noll/Vo FNV-1a hash on a buffer
@ FNV1a_32
FNV-1a 32 bit hash.
@ FNV1_64
FNV-1 64 bit hash.
@ FNV1a_64
FNV-1a 64 bit hash.
@ FNV_NONE
invalid FNV hash type
@ FNV0_64
FNV-0 64 bit hash.
@ FNV0_32
FNV-0 32 bit hash.
@ FNV1_32
FNV-1 32 bit hash.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
ns3::Hash::Function::Fnv1a declaration.
Every class exported by the ns3 library is enclosed in the ns3 namespace.