57namespace Fnv1aImplementation
155#if !defined(__FNV_H__)
162#define FNV_VERSION "5.0.2"
178#define FNV0_32_INIT ((Fnv1aImplementation::Fnv32_t)0)
194#define FNV1_32_INIT ((Fnv1aImplementation::Fnv32_t)0x811c9dc5)
196#define FNV1_32A_INIT FNV1_32_INIT
203#define HAVE_64BIT_LONG_LONG
210#if defined(HAVE_64BIT_LONG_LONG)
226#if defined(HAVE_64BIT_LONG_LONG)
227#define FNV0_64_INIT ((Fnv1aImplementation::Fnv64_t)0)
229extern const Fnv64_t fnv0_64_init;
230#define FNV0_64_INIT (Fnv1aImplementation::fnv0_64_init)
246#if defined(HAVE_64BIT_LONG_LONG)
247#define FNV1_64_INIT ((Fnv1aImplementation::Fnv64_t)0xcbf29ce484222325ULL)
249#define FNV1A_64_INIT FNV1_64_INIT
251extern const fnv1_64_init;
252extern const Fnv64_t fnv1a_64_init;
253#define FNV1_64_INIT (fnv1_64_init)
255#define FNV1A_64_INIT (fnv1a_64_init)
368#define FNV_32_PRIME ((Fnv1aImplementation::Fnv32_t)0x01000193)
387 unsigned char *bp = (
unsigned char *)buf;
388 unsigned char *be = bp + len;
399#if defined(NO_FNV_GCC_OPTIMIZATION)
402 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
426 unsigned char *s = (
unsigned char *)str;
437#if defined(NO_FNV_GCC_OPTIMIZATION)
440 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
516#if !defined(HAVE_64BIT_LONG_LONG)
517const Fnv64_t fnv1a_64_init = { 0x84222325, 0xcbf29ce4 };
525#if defined(HAVE_64BIT_LONG_LONG)
526#define FNV_64_PRIME ((Fnv1aImplementation::Fnv64_t)0x100000001b3ULL)
528#define FNV_64_PRIME_LOW ((unsigned long)0x1b3)
529#define FNV_64_PRIME_SHIFT (8)
550 unsigned char *bp = (
unsigned char *)buf;
551 unsigned char *be = bp + len;
553#if defined(HAVE_64BIT_LONG_LONG)
563#if defined(NO_FNV_GCC_OPTIMIZATION)
566 hval += (hval << 1) + (hval << 4) + (hval << 5) +
567 (hval << 7) + (hval << 8) + (hval << 40);
573 unsigned long val[4];
574 unsigned long tmp[4];
579 val[0] = hval.w32[0];
580 val[1] = (val[0] >> 16);
582 val[2] = hval.w32[1];
583 val[3] = (val[2] >> 16);
592 val[0] ^= (
unsigned long)*bp++;
606 tmp[0] = val[0] * FNV_64_PRIME_LOW;
607 tmp[1] = val[1] * FNV_64_PRIME_LOW;
608 tmp[2] = val[2] * FNV_64_PRIME_LOW;
609 tmp[3] = val[3] * FNV_64_PRIME_LOW;
611 tmp[2] += val[0] << FNV_64_PRIME_SHIFT;
612 tmp[3] += val[1] << FNV_64_PRIME_SHIFT;
614 tmp[1] += (tmp[0] >> 16);
615 val[0] = tmp[0] & 0xffff;
616 tmp[2] += (tmp[1] >> 16);
617 val[1] = tmp[1] & 0xffff;
618 val[3] = tmp[3] + (tmp[2] >> 16);
619 val[2] = tmp[2] & 0xffff;
630 hval.w32[1] = ((val[3]<<16) | val[2]);
631 hval.w32[0] = ((val[1]<<16) | val[0]);
655 unsigned char *s = (
unsigned char *)str;
657#if defined(HAVE_64BIT_LONG_LONG)
668#if defined(NO_FNV_GCC_OPTIMIZATION)
671 hval += (hval << 1) + (hval << 4) + (hval << 5) +
672 (hval << 7) + (hval << 8) + (hval << 40);
678 unsigned long val[4];
679 unsigned long tmp[4];
684 val[0] = hval.w32[0];
685 val[1] = (val[0] >> 16);
687 val[2] = hval.w32[1];
688 val[3] = (val[2] >> 16);
710 tmp[0] = val[0] * FNV_64_PRIME_LOW;
711 tmp[1] = val[1] * FNV_64_PRIME_LOW;
712 tmp[2] = val[2] * FNV_64_PRIME_LOW;
713 tmp[3] = val[3] * FNV_64_PRIME_LOW;
715 tmp[2] += val[0] << FNV_64_PRIME_SHIFT;
716 tmp[3] += val[1] << FNV_64_PRIME_SHIFT;
718 tmp[1] += (tmp[0] >> 16);
719 val[0] = tmp[0] & 0xffff;
720 tmp[2] += (tmp[1] >> 16);
721 val[1] = tmp[1] & 0xffff;
722 val[3] = tmp[3] + (tmp[2] >> 16);
723 val[2] = tmp[2] & 0xffff;
729 val[0] ^= (
unsigned long)(*s++);
735 hval.w32[1] = ((val[3]<<16) | val[2]);
736 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.