File: SpookyV2Test.cpp

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (52 lines) | stat: -rw-r--r-- 1,351 bytes parent folder | download | duplicates (2)
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
#include "SpookyV2.h"

#ifdef __cplusplus
extern "C" {
#endif

void SpookyHash32_with_state_test(const void *key, size_t len, const void *state, void *out) {
  uint64 *state64= (uint64 *)state;
  uint64 s0 = state64[0];
  uint64 s1 = state64[1];
  SpookyHash::Hash128(key, len, &s0, &s1);
  ((uint32 *)out)[0]= (uint32)s0;
}

void SpookyHash64_with_state_test(const void *key, size_t len, const void *state, void *out) {
  uint64 *state64= (uint64 *)state;
  uint64 *out64= (uint64 *)out;
  out64[0] = state64[0];
  uint64 s1 = state64[1];
  SpookyHash::Hash128(key, len, out64, &s1);
}

void SpookyHash128_with_state_test(const void *key, size_t len, const void *state, void *out) {
  uint64 *state64= (uint64 *)state;
  uint64 *out64= (uint64 *)out;
  out64[0] = state64[0];
  out64[1] = state64[1];
  SpookyHash::Hash128(key, len, out64, out64+1);
}

void SpookyHash_seed_state_test(int in_bits, const void *seed, void *state) {
    uint64 *state64= (uint64 *)state;
    if (in_bits == 32) {
        state64[0]= state64[1]= ((uint32*)seed)[0];
    }
    else {
        uint64 *seed64= (uint64 *)seed;
        if (in_bits == 64) {
            state64[0]= state64[1]= seed64[0];
        }
        else
        if (in_bits == 128) {
            state64[0]= seed64[0];
            state64[1]= seed64[1];
        }
    }
}


#ifdef __cplusplus
}
#endif