1/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
3#ident "$Id$"
4/*======
5This file is part of PerconaFT.
6
7
8Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
9
10 PerconaFT is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License, version 2,
12 as published by the Free Software Foundation.
13
14 PerconaFT is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
21
22----------------------------------------
23
24 PerconaFT is free software: you can redistribute it and/or modify
25 it under the terms of the GNU Affero General Public License, version 3,
26 as published by the Free Software Foundation.
27
28 PerconaFT is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU Affero General Public License for more details.
32
33 You should have received a copy of the GNU Affero General Public License
34 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
35======= */
36
37#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
38
39#pragma once
40
41#include <toku_stdint.h>
42
43// The x1764 hash is
44// $s = \sum_i a_i*17^i$ where $a_i$ is the $i$th 64-bit number (represented in little-endian format)
45// The final 32-bit result is the xor of the high- and low-order bits of s.
46// If any odd bytes numbers are left at the end, they are filled in at the low end.
47
48
49uint32_t toku_x1764_memory (const void *buf, int len);
50// Effect: Compute x1764 on the bytes of buf. Return the 32 bit answer.
51
52uint32_t toku_x1764_memory_simple (const void *buf, int len);
53// Effect: Same as toku_x1764_memory, but not highly optimized (more likely to be correct). Useful for testing the optimized version.
54
55
56// For incrementally computing an x1764, use the following interfaces.
57struct x1764 {
58 uint64_t sum;
59 uint64_t input;
60 int n_input_bytes;
61};
62
63void toku_x1764_init(struct x1764 *l);
64// Effect: Initialize *l.
65
66void toku_x1764_add (struct x1764 *l, const void *vbuf, int len);
67// Effect: Add more bytes to *l.
68
69uint32_t toku_x1764_finish (struct x1764 *l);
70// Effect: Return the final 32-bit result.
71