/usr/include/gmsh/Hash.h is in libgmsh-dev 3.0.6+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | // Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
#ifndef _HASH_H_
#define _HASH_H_
//--FNV hashing parameters
#if defined(HAVE_64BIT_SIZE_T)
#define FNV_PRIME 1099511628211UL
#define FNV_OFFSET_BASIS 14695981039346656037UL
#else
#define FNV_PRIME 16777619UL
#define FNV_OFFSET_BASIS 2166136261UL
#endif
//--Hash FNV1a implemented via for loop. "key" has size "len" bytes.
inline size_t hash_FNV1a(const void *const key, const int len)
{
const unsigned char *p = static_cast<const unsigned char*>(key);
size_t hash = FNV_OFFSET_BASIS;
for(int n = len; n--; ) hash = (hash^static_cast<size_t>(*p++))*FNV_PRIME;
return hash;
}
//--Hash FNV1a implemented via template-metaprogramming loop. This should be
//--used if the length N is known at compile time. "key" has size "N" bytes.
//--Use the entry point HashFNV1a<N>::eval(key).
template <int N> struct Hash1FNV1a {
static size_t eval(size_t hash, const unsigned char *p)
{
return Hash1FNV1a<N-1>::eval((hash^static_cast<size_t>(*p))*FNV_PRIME, p+1);
}
};
template <> struct Hash1FNV1a<1> {
static size_t eval(size_t hash, const unsigned char *p)
{
return (hash^static_cast<size_t>(*p))*FNV_PRIME;
}
};
// Entry point
template <int N> struct HashFNV1a {
static size_t eval(const void *const key)
{
size_t hash = FNV_OFFSET_BASIS;
return Hash1FNV1a<N>::eval(hash, static_cast<const unsigned char*>(key));
}
};
#endif
|