http://www.isthe.com/chongo/tech/comp/fnv/index.html
*/
-unsigned hash32(const void *data, unsigned size, unsigned bits)
+UInt32 hash32(const void *data, unsigned size, unsigned bits)
{
if(bits==0 || bits>32)
throw invalid_argument("hash32");
return result;
}
-HashValue64 hash64(const void *data, unsigned size, unsigned bits)
+UInt64 hash64(const void *data, unsigned size, unsigned bits)
{
if(bits==0 || bits>64)
throw invalid_argument("hash64");
- static const HashValue64 prime = 1099511628211ULL;
- static const HashValue64 offset = 14695981039346656037ULL;
+ static const UInt64 prime = 1099511628211ULL;
+ static const UInt64 offset = 14695981039346656037ULL;
- HashValue64 result = offset;
+ UInt64 result = offset;
for(unsigned i=0; i<size; ++i)
result = (result^*(reinterpret_cast<const unsigned char *>(data)+i))*prime;
#define MSP_CORE_HASH_H_
#include <string>
+#include "inttypes.h"
namespace Msp {
-#ifdef MSVC
-typedef __uint64 HashValue64;
-#else
-typedef unsigned long long HashValue64;
-#endif
-
/**
Computes a 32-bit Fowler-Noll-Vo (FNV-1a) hash. The number of bits can be
limited to less than 32, in which case XOR-folding is used to reduce the hash
size.
*/
-unsigned hash32(const void *, unsigned, unsigned = 32);
+UInt32 hash32(const void *, unsigned, unsigned = 32);
/**
Convenience function to compute a 32-bit hash of a string.
Computes a 64-bit Fowler-Noll-Vo (FNV-1a) hash. Note that even if bits is
limited to 32 or less, this does not produce the same result as hash32.
*/
-HashValue64 hash64(const void *, unsigned, unsigned = 64);
+UInt64 hash64(const void *, unsigned, unsigned = 64);
/**
Convenience function to compute a 64-bit hash of a string.
*/
-inline HashValue64 hash64(const std::string &s, unsigned b = 64)
+inline UInt64 hash64(const std::string &s, unsigned b = 64)
{ return hash64(s.data(), s.size(), b); }
} // namespace Msp
#ifndef MSP_IO_SEEKABLE_H_
#define MSP_IO_SEEKABLE_H_
+#include <msp/core/inttypes.h>
#include "base.h"
namespace Msp {
class Handle;
-#ifdef MSVC
-typedef __int64 SeekOffset;
-#else
-typedef long long SeekOffset;
-#endif
+typedef Int64 SeekOffset;
enum SeekType
{
#include <cmath>
#include <limits>
+#include <msp/core/inttypes.h>
#include "format.h"
#include "lexicalcast.h"
template<typename T>
struct Temporary<T, true>
{
-#ifdef WIN32
- typedef __int64 Type;
-#else
- typedef unsigned long long Type;
-#endif
+ typedef UInt64 Type;
};
/* Helper to avoid warnings about an unsigned type never being < 0 */
#ifndef MSP_TIME_RAWTIME_H_
#define MSP_TIME_RAWTIME_H_
+#include <msp/core/inttypes.h>
+
namespace Msp {
namespace Time {
-#ifdef MSVC
-typedef __int64 RawTime;
-#else
-typedef long long RawTime;
-#endif
+typedef Int64 RawTime;
} // namespace Time
} // namespace Msp