FarmTest.cc 833 B

1234567891011121314151617181920
  1. /* We have conflicting uint128_t types in Types.h (Blob<128>) and farmhash.h */
  2. #undef FARMHASH_UINT128_T_DEFINED
  3. #include "farmhash.h"
  4. void FarmHash32_test ( const void * key, int len, uint32_t seed, void * out ) {
  5. using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
  6. *(uint32_t*)out = Hash32WithSeed((const char *)key,(size_t)len,seed);
  7. }
  8. void FarmHash64_test ( const void * key, int len, uint32_t seed, void * out ) {
  9. using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
  10. *(uint64_t*)out = Hash64WithSeed((const char *)key,(size_t)len,(uint64_t)seed);
  11. }
  12. void FarmHash128_test ( const void * key, int len, uint32_t seed, void * out ) {
  13. using namespace NAMESPACE_FOR_HASH_FUNCTIONS;
  14. uint128_t s((uint64_t)seed, (uint64_t)0UL);
  15. uint128_t result = Hash128WithSeed((const char *)key, (size_t)len, s);
  16. memcpy(out, &result, 128/8);
  17. }