HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_XXHash.h
Go to the documentation of this file.
1 /*
2  xxHash - Extremely Fast Hash algorithm
3  Header File
4  Copyright (C) 2012-2016, Yann Collet.
5 
6  BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are
10  met:
11 
12  * Redistributions of source code must retain the above copyright
13  notice, this list of conditions and the following disclaimer.
14  * Redistributions in binary form must reproduce the above
15  copyright notice, this list of conditions and the following disclaimer
16  in the documentation and/or other materials provided with the
17  distribution.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31  You can contact the author at :
32  - xxHash source repository : https://github.com/Cyan4973/xxHash
33 
34  All modifications by SideFX are tagged with a comment "// SideFX ..."
35 */
36 
37 /* Notice extracted from xxHash homepage :
38 
39 xxHash is an extremely fast Hash algorithm, running at RAM speed limits.
40 It also successfully passes all tests from the SMHasher suite.
41 
42 Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz)
43 
44 Name Speed Q.Score Author
45 xxHash 5.4 GB/s 10
46 CrapWow 3.2 GB/s 2 Andrew
47 MumurHash 3a 2.7 GB/s 10 Austin Appleby
48 SpookyHash 2.0 GB/s 10 Bob Jenkins
49 SBox 1.4 GB/s 9 Bret Mulvey
50 Lookup3 1.2 GB/s 9 Bob Jenkins
51 SuperFastHash 1.2 GB/s 1 Paul Hsieh
52 CityHash64 1.05 GB/s 10 Pike & Alakuijala
53 FNV 0.55 GB/s 5 Fowler, Noll, Vo
54 CRC32 0.43 GB/s 9
55 MD5-32 0.33 GB/s 10 Ronald L. Rivest
56 SHA1-32 0.28 GB/s 10
57 
58 Q.Score is a measure of quality of the hash function.
59 It depends on successfully passing SMHasher test set.
60 10 is a perfect score.
61 
62 A 64-bit version, named XXH64, is available since r35.
63 It offers much better speed, but for 64-bit applications only.
64 Name Speed on 64 bits Speed on 32 bits
65 XXH64 13.8 GB/s 1.9 GB/s
66 XXH32 6.8 GB/s 6.0 GB/s
67 */
68 
69 #ifndef XXHASH_H_5627135585666179
70 #define XXHASH_H_5627135585666179 1
71 
72 #if defined (__cplusplus)
73 extern "C" {
74 #endif
75 
76 
77 /* ****************************
78 * Definitions
79 ******************************/
80 #include <stddef.h> /* size_t */
81 typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
82 
83 
84 /* ****************************
85  * API modifier
86  ******************************/
87 /** XXH_INLINE_ALL (and XXH_PRIVATE_API)
88  * This build macro includes xxhash functions in `static` mode
89  * in order to inline them, and remove their symbol from the public list.
90  * Inlining offers great performance improvement on small keys,
91  * and dramatic ones when length is expressed as a compile-time constant.
92  * See https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html .
93  * Methodology :
94  * #define XXH_INLINE_ALL
95  * #include "xxhash.h"
96  * `xxhash.c` is automatically included.
97  * It's not useful to compile and link it as a separate object.
98  */
99 #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
100 # ifndef XXH_STATIC_LINKING_ONLY
101 # define XXH_STATIC_LINKING_ONLY
102 # endif
103 # if defined(__GNUC__)
104 # define XXH_PUBLIC_API static __inline __attribute__((unused))
105 # elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
106 # define XXH_PUBLIC_API static inline
107 # elif defined(_MSC_VER)
108 # define XXH_PUBLIC_API static __inline
109 # else
110  /* this version may generate warnings for unused static functions */
111 # define XXH_PUBLIC_API static
112 # endif
113 #else
114 # if defined(WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT))
115 # ifdef XXH_EXPORT
116 # define XXH_PUBLIC_API __declspec(dllexport)
117 # elif XXH_IMPORT
118 # define XXH_PUBLIC_API __declspec(dllimport)
119 # endif
120 # else
121 # define XXH_PUBLIC_API /* do nothing */
122 # endif
123 #endif /* XXH_INLINE_ALL || XXH_PRIVATE_API */
124 
125 /*! XXH_NAMESPACE, aka Namespace Emulation :
126  *
127  * If you want to include _and expose_ xxHash functions from within your own library,
128  * but also want to avoid symbol collisions with other libraries which may also include xxHash,
129  *
130  * you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library
131  * with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values).
132  *
133  * Note that no change is required within the calling program as long as it includes `xxhash.h` :
134  * regular symbol name will be automatically translated by this header.
135  */
136 
137 #include "UT_API.h" // SideFX modification
138 #undef XXH_PUBLIC_API // SideFX modification
139 #define XXH_PUBLIC_API UT_API // SideFX modification
140 #define XXH_NAMESPACE UT_ // SideFX modification
141 
142 #ifdef XXH_NAMESPACE
143 # define XXH_CAT(A,B) A##B
144 # define XXH_NAME2(A,B) XXH_CAT(A,B)
145 # define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber)
146 # define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
147 # define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState)
148 # define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState)
149 # define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
150 # define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
151 # define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
152 # define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState)
153 # define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash)
154 # define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical)
155 # define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64)
156 # define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState)
157 # define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState)
158 # define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset)
159 # define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update)
160 # define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest)
161 # define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState)
162 # define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash)
163 # define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical)
164 #endif
165 
166 
167 /* *************************************
168 * Version
169 ***************************************/
170 #define XXH_VERSION_MAJOR 0
171 #define XXH_VERSION_MINOR 7
172 #define XXH_VERSION_RELEASE 1
173 #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
174 XXH_PUBLIC_API unsigned XXH_versionNumber (void);
175 
176 
177 /*-**********************************************************************
178 * 32-bit hash
179 ************************************************************************/
180 #if !defined (__VMS) \
181  && (defined (__cplusplus) \
182  || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
183 # include <stdint.h>
184  typedef uint32_t XXH32_hash_t;
185 #else
186  typedef unsigned int XXH32_hash_t;
187 #endif
188 
189 /*! XXH32() :
190  Calculate the 32-bit hash of sequence "length" bytes stored at memory address "input".
191  The memory between input & input+length must be valid (allocated and read-accessible).
192  "seed" can be used to alter the result predictably.
193  Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s */
194 XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed);
195 
196 /*====== Streaming ======*/
197 typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */
200 XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dst_state, const XXH32_state_t* src_state);
201 
202 XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned int seed);
203 XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length);
204 XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr);
205 
206 /*
207  * Streaming functions generate the xxHash of an input provided in multiple segments.
208  * Note that, for small input, they are slower than single-call functions, due to state management.
209  * For small inputs, prefer `XXH32()` and `XXH64()`, which are better optimized.
210  *
211  * XXH state must first be allocated, using XXH*_createState() .
212  *
213  * Start a new hash by initializing state with a seed, using XXH*_reset().
214  *
215  * Then, feed the hash state by calling XXH*_update() as many times as necessary.
216  * The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
217  *
218  * Finally, a hash value can be produced anytime, by using XXH*_digest().
219  * This function returns the nn-bits hash as an int or long long.
220  *
221  * It's still possible to continue inserting input into the hash state after a digest,
222  * and generate some new hashes later on, by calling again XXH*_digest().
223  *
224  * When done, free XXH state space if it was allocated dynamically.
225  */
226 
227 /*====== Canonical representation ======*/
228 
229 typedef struct { unsigned char digest[4]; } XXH32_canonical_t;
232 
233 /* Default result type for XXH functions are primitive unsigned 32 and 64 bits.
234  * The canonical representation uses human-readable write convention, aka big-endian (large digits first).
235  * These functions allow transformation of hash result into and from its canonical format.
236  * This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
237  */
238 
239 
240 #ifndef XXH_NO_LONG_LONG
241 /*-**********************************************************************
242 * 64-bit hash
243 ************************************************************************/
244 #if !defined (__VMS) \
245  && (defined (__cplusplus) \
246  || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
247 # include <stdint.h>
248  typedef uint64_t XXH64_hash_t;
249 #else
250  typedef unsigned long long XXH64_hash_t;
251 #endif
252 
253 /*! XXH64() :
254  Calculate the 64-bit hash of sequence of length "len" stored at memory address "input".
255  "seed" can be used to alter the result predictably.
256  This function runs faster on 64-bit systems, but slower on 32-bit systems (see benchmark).
257 */
258 XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed);
259 
260 /*====== Streaming ======*/
261 typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */
264 XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dst_state, const XXH64_state_t* src_state);
265 
266 XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed);
267 XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length);
268 XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr);
269 
270 /*====== Canonical representation ======*/
271 typedef struct { unsigned char digest[8]; } XXH64_canonical_t;
274 
275 
276 #endif /* XXH_NO_LONG_LONG */
277 
278 
279 
280 #ifdef XXH_STATIC_LINKING_ONLY
281 
282 /* ================================================================================================
283  This section contains declarations which are not guaranteed to remain stable.
284  They may change in future versions, becoming incompatible with a different version of the library.
285  These declarations should only be used with static linking.
286  Never use them in association with dynamic linking !
287 =================================================================================================== */
288 
289 /* These definitions are only present to allow
290  * static allocation of XXH state, on stack or in a struct for example.
291  * Never **ever** use members directly. */
292 
293 struct XXH32_state_s {
294  XXH32_hash_t total_len_32;
295  XXH32_hash_t large_len;
296  XXH32_hash_t v1;
297  XXH32_hash_t v2;
298  XXH32_hash_t v3;
299  XXH32_hash_t v4;
300  XXH32_hash_t mem32[4];
301  XXH32_hash_t memsize;
302  XXH32_hash_t reserved; /* never read nor write, might be removed in a future version */
303 }; /* typedef'd to XXH32_state_t */
304 
305 #ifndef XXH_NO_LONG_LONG /* remove 64-bit support */
306 struct XXH64_state_s {
307  XXH64_hash_t total_len;
308  XXH64_hash_t v1;
309  XXH64_hash_t v2;
310  XXH64_hash_t v3;
311  XXH64_hash_t v4;
312  XXH64_hash_t mem64[4];
313  XXH32_hash_t memsize;
314  XXH32_hash_t reserved[2]; /* never read nor write, might be removed in a future version */
315 }; /* typedef'd to XXH64_state_t */
316 #endif /* XXH_NO_LONG_LONG */
317 
318 
319 /*-**********************************************************************
320 * XXH3
321 * New experimental hash
322 ************************************************************************/
323 #ifndef XXH_NO_LONG_LONG
324 
325 
326 /* ============================================
327  * XXH3 is a new hash algorithm,
328  * featuring improved speed performance for both small and large inputs.
329  * See full speed analysis at : http://fastcompression.blogspot.com/2019/03/presenting-xxh3.html
330  * In general, expect XXH3 to run about ~2x faster on large inputs,
331  * and >3x faster on small ones, though exact differences depend on platform.
332  *
333  * The algorithm is portable, will generate the same hash on all platforms.
334  * It benefits greatly from vectorization units, but does not require it.
335  *
336  * XXH3 offers 2 variants, _64bits and _128bits.
337  * When only 64 bits are needed, prefer calling the _64bits variant :
338  * it reduces the amount of mixing, resulting in faster speed on small inputs.
339  * It's also generally simpler to manipulate a scalar return type than a struct.
340  *
341  * The XXH3 algorithm is still considered experimental.
342  * Produced results can still change between versions.
343  * For example, results produced by v0.7.1 are not comparable with results from v0.7.0 .
344  * It's nonetheless possible to use XXH3 for ephemeral data (local sessions),
345  * but avoid storing values in long-term storage for later re-use.
346  *
347  * The API supports one-shot hashing, streaming mode, and custom secrets.
348  *
349  * There are still a number of opened questions that community can influence during the experimental period.
350  * I'm trying to list a few of them below, though don't consider this list as complete.
351  *
352  * - 128-bits output type : currently defined as a structure of two 64-bits fields.
353  * That's because 128-bit values do not exist in C standard.
354  * Note that it means that, at byte level, result is not identical depending on endianess.
355  * However, at field level, they are identical on all platforms.
356  * The canonical representation solves the issue of identical byte-level representation across platforms,
357  * which is necessary for serialization.
358  * Would there be a better representation for a 128-bit hash result ?
359  * Are the names of the inner 64-bit fields important ? Should they be changed ?
360  *
361  * - Seed type for 128-bits variant : currently, it's a single 64-bit value, like the 64-bit variant.
362  * It could be argued that it's more logical to offer a 128-bit seed input parameter for a 128-bit hash.
363  * But 128-bit seed is more difficult to use, since it requires to pass a structure instead of a scalar value.
364  * Such a variant could either replace current one, or become an additional one.
365  * Farmhash, for example, offers both variants (the 128-bits seed variant is called `doubleSeed`).
366  * If both 64-bit and 128-bit seeds are possible, which variant should be called XXH128 ?
367  *
368  * - Result for len==0 : Currently, the result of hashing a zero-length input is `0`.
369  * It seems okay as a return value when using all "default" secret and seed (it used to be a request for XXH32/XXH64).
370  * But is it still fine to return `0` when secret or seed are non-default ?
371  * Are there use cases which could depend on generating a different hash result for zero-length input when the secret is different ?
372  */
373 
374 #ifdef XXH_NAMESPACE
375 # define XXH3_64bits XXH_NAME2(XXH_NAMESPACE, XXH3_64bits)
376 # define XXH3_64bits_withSecret XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_withSecret)
377 # define XXH3_64bits_withSeed XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_withSeed)
378 
379 # define XXH3_createState XXH_NAME2(XXH_NAMESPACE, XXH3_createState)
380 # define XXH3_freeState XXH_NAME2(XXH_NAMESPACE, XXH3_freeState)
381 # define XXH3_copyState XXH_NAME2(XXH_NAMESPACE, XXH3_copyState)
382 
383 # define XXH3_64bits_reset XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_reset)
384 # define XXH3_64bits_reset_withSeed XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_reset_withSeed)
385 # define XXH3_64bits_reset_withSecret XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_reset_withSecret)
386 # define XXH3_64bits_update XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_update)
387 # define XXH3_64bits_digest XXH_NAME2(XXH_NAMESPACE, XXH3_64bits_digest)
388 #endif
389 
390 /* XXH3_64bits() :
391  * default 64-bit variant, using default secret and default seed of 0.
392  * It's the fastest variant. */
393 XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(const void* data, size_t len);
394 
395 /* XXH3_64bits_withSecret() :
396  * It's possible to provide any blob of bytes as a "secret" to generate the hash.
397  * This makes it more difficult for an external actor to prepare an intentional collision.
398  * The secret *must* be large enough (>= XXH3_SECRET_SIZE_MIN).
399  * It should consist of random bytes.
400  * Avoid repeating same character, or sequences of bytes,
401  * and especially avoid swathes of \0.
402  * Failure to respect these conditions will result in a poor quality hash.
403  */
404 #define XXH3_SECRET_SIZE_MIN 136
405 XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize);
406 
407 /* XXH3_64bits_withSeed() :
408  * This variant generates on the fly a custom secret,
409  * based on the default secret, altered using the `seed` value.
410  * While this operation is decently fast, note that it's not completely free.
411  * note : seed==0 produces same results as XXH3_64bits() */
412 XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(const void* data, size_t len, XXH64_hash_t seed);
413 
414 
415 /* streaming 64-bit */
416 
417 #if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11+ */
418 # include <stdalign.h>
419 # define XXH_ALIGN(n) alignas(n)
420 #elif defined(__GNUC__)
421 # define XXH_ALIGN(n) __attribute__ ((aligned(n)))
422 #elif defined(_MSC_VER)
423 # define XXH_ALIGN(n) __declspec(align(n))
424 #else
425 # define XXH_ALIGN(n) /* disabled */
426 #endif
427 
428 typedef struct XXH3_state_s XXH3_state_t;
429 
430 #define XXH3_SECRET_DEFAULT_SIZE 192 /* minimum XXH3_SECRET_SIZE_MIN */
431 #define XXH3_INTERNALBUFFER_SIZE 256
432 struct XXH3_state_s {
433  XXH_ALIGN(64) XXH64_hash_t acc[8];
434  XXH_ALIGN(64) char customSecret[XXH3_SECRET_DEFAULT_SIZE]; /* used to store a custom secret generated from the seed. Makes state larger. Design might change */
435  XXH_ALIGN(64) char buffer[XXH3_INTERNALBUFFER_SIZE];
436  const void* secret;
437  XXH32_hash_t bufferedSize;
438  XXH32_hash_t nbStripesPerBlock;
439  XXH32_hash_t nbStripesSoFar;
440  XXH32_hash_t reserved32;
441  XXH32_hash_t reserved32_2;
442  XXH32_hash_t secretLimit;
443  XXH64_hash_t totalLen;
444  XXH64_hash_t seed;
445  XXH64_hash_t reserved64;
446 }; /* typedef'd to XXH3_state_t */
447 
448 /* Streaming requires state maintenance.
449  * This operation costs memory and cpu.
450  * As a consequence, streaming is slower than one-shot hashing.
451  * For better performance, prefer using one-shot functions whenever possible. */
452 
453 XXH_PUBLIC_API XXH3_state_t* XXH3_createState(void);
454 XXH_PUBLIC_API XXH_errorcode XXH3_freeState(XXH3_state_t* statePtr);
455 XXH_PUBLIC_API void XXH3_copyState(XXH3_state_t* dst_state, const XXH3_state_t* src_state);
456 
457 
458 /* XXH3_64bits_reset() :
459  * initialize with default parameters.
460  * result will be equivalent to `XXH3_64bits()`. */
461 XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset(XXH3_state_t* statePtr);
462 /* XXH3_64bits_reset_withSeed() :
463  * generate a custom secret from `seed`, and store it into state.
464  * digest will be equivalent to `XXH3_64bits_withSeed()`. */
465 XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed);
466 /* XXH3_64bits_reset_withSecret() :
467  * `secret` is referenced, and must outlive the hash streaming session.
468  * secretSize must be >= XXH3_SECRET_SIZE_MIN.
469  */
470 XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize);
471 
472 XXH_PUBLIC_API XXH_errorcode XXH3_64bits_update (XXH3_state_t* statePtr, const void* input, size_t length);
473 XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* statePtr);
474 
475 
476 /* 128-bit */
477 
478 #ifdef XXH_NAMESPACE
479 # define XXH128 XXH_NAME2(XXH_NAMESPACE, XXH128)
480 # define XXH3_128bits XXH_NAME2(XXH_NAMESPACE, XXH3_128bits)
481 # define XXH3_128bits_withSeed XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_withSeed)
482 # define XXH3_128bits_withSecret XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_withSecret)
483 
484 # define XXH3_128bits_reset XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_reset)
485 # define XXH3_128bits_reset_withSeed XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_reset_withSeed)
486 # define XXH3_128bits_reset_withSecret XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_reset_withSecret)
487 # define XXH3_128bits_update XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_update)
488 # define XXH3_128bits_digest XXH_NAME2(XXH_NAMESPACE, XXH3_128bits_digest)
489 
490 # define XXH128_isEqual XXH_NAME2(XXH_NAMESPACE, XXH128_isEqual)
491 # define XXH128_cmp XXH_NAME2(XXH_NAMESPACE, XXH128_cmp)
492 # define XXH128_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH128_canonicalFromHash)
493 # define XXH128_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH128_hashFromCanonical)
494 #endif
495 
496 typedef struct {
497  XXH64_hash_t low64;
498  XXH64_hash_t high64;
499 } XXH128_hash_t;
500 
501 XXH_PUBLIC_API XXH128_hash_t XXH128(const void* data, size_t len, XXH64_hash_t seed);
502 XXH_PUBLIC_API XXH128_hash_t XXH3_128bits(const void* data, size_t len);
503 XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSeed(const void* data, size_t len, XXH64_hash_t seed); /* == XXH128() */
504 XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize);
505 
506 XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset(XXH3_state_t* statePtr);
507 XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed);
508 XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize);
509 
510 XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update (XXH3_state_t* statePtr, const void* input, size_t length);
511 XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* statePtr);
512 
513 
514 /* Note : for better performance, following functions should be inlined,
515  * using XXH_INLINE_ALL */
516 
517 /* return : 1 is equal, 0 if different */
518 XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2);
519 
520 /* This comparator is compatible with stdlib's qsort().
521  * return : >0 if *h128_1 > *h128_2
522  * <0 if *h128_1 < *h128_2
523  * =0 if *h128_1 == *h128_2 */
524 XXH_PUBLIC_API int XXH128_cmp(const void* h128_1, const void* h128_2);
525 
526 
527 /*====== Canonical representation ======*/
528 typedef struct { unsigned char digest[16]; } XXH128_canonical_t;
529 XXH_PUBLIC_API void XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash);
530 XXH_PUBLIC_API XXH128_hash_t XXH128_hashFromCanonical(const XXH128_canonical_t* src);
531 
532 
533 #endif /* XXH_NO_LONG_LONG */
534 
535 
536 /*-**********************************************************************
537 * XXH_INLINE_ALL
538 ************************************************************************/
539 #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
540 # include "xxhash.c" /* include xxhash function bodies as `static`, for inlining */
541 #endif
542 
543 
544 
545 #endif /* XXH_STATIC_LINKING_ONLY */
546 
547 
548 #if defined (__cplusplus)
549 }
550 #endif
551 
552 #endif /* XXHASH_H_5627135585666179 */
unsigned long long XXH64_hash_t
Definition: UT_XXHash.h:250
#define XXH64
Definition: UT_XXHash.h:155
XXH_errorcode
Definition: UT_XXHash.h:81
GLenum GLenum GLenum input
Definition: glew.h:14162
#define XXH64_reset
Definition: UT_XXHash.h:158
#define XXH64_hashFromCanonical
Definition: UT_XXHash.h:163
#define XXH32_hashFromCanonical
Definition: UT_XXHash.h:154
GLenum src
Definition: glcorearb.h:1793
#define XXH64_createState
Definition: UT_XXHash.h:156
#define XXH64_freeState
Definition: UT_XXHash.h:157
Definition: core.h:760
#define XXH64_copyState
Definition: UT_XXHash.h:161
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
GLenum GLsizei len
Definition: glew.h:7782
#define XXH_PUBLIC_API
Definition: UT_XXHash.h:139
struct XXH64_state_s XXH64_state_t
Definition: UT_XXHash.h:261
#define XXH32_createState
Definition: UT_XXHash.h:147
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:819
#define XXH64_canonicalFromHash
Definition: UT_XXHash.h:162
#define XXH32_update
Definition: UT_XXHash.h:150
#define XXH64_update
Definition: UT_XXHash.h:159
struct XXH32_state_s XXH32_state_t
Definition: UT_XXHash.h:197
#define XXH32_freeState
Definition: UT_XXHash.h:148
unsigned int XXH32_hash_t
Definition: UT_XXHash.h:186
#define XXH_versionNumber
Definition: UT_XXHash.h:145
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
#define XXH32_digest
Definition: UT_XXHash.h:151
#define XXH32_canonicalFromHash
Definition: UT_XXHash.h:153
#define XXH32
Definition: UT_XXHash.h:146
#define XXH32_reset
Definition: UT_XXHash.h:149
#define XXH64_digest
Definition: UT_XXHash.h:160
#define const
Definition: zconf.h:214
GLfloat GLfloat v1
Definition: glcorearb.h:817
GLenum GLenum dst
Definition: glcorearb.h:1793
#define XXH32_copyState
Definition: UT_XXHash.h:152
Definition: format.h:895