1*b7893ccfSSadaf Ebrahimi /* 2*b7893ccfSSadaf Ebrahimi xxHash - Extremely Fast Hash algorithm 3*b7893ccfSSadaf Ebrahimi Header File 4*b7893ccfSSadaf Ebrahimi Copyright (C) 2012-2016, Yann Collet. 5*b7893ccfSSadaf Ebrahimi 6*b7893ccfSSadaf Ebrahimi BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 7*b7893ccfSSadaf Ebrahimi 8*b7893ccfSSadaf Ebrahimi Redistribution and use in source and binary forms, with or without 9*b7893ccfSSadaf Ebrahimi modification, are permitted provided that the following conditions are 10*b7893ccfSSadaf Ebrahimi met: 11*b7893ccfSSadaf Ebrahimi 12*b7893ccfSSadaf Ebrahimi * Redistributions of source code must retain the above copyright 13*b7893ccfSSadaf Ebrahimi notice, this list of conditions and the following disclaimer. 14*b7893ccfSSadaf Ebrahimi * Redistributions in binary form must reproduce the above 15*b7893ccfSSadaf Ebrahimi copyright notice, this list of conditions and the following disclaimer 16*b7893ccfSSadaf Ebrahimi in the documentation and/or other materials provided with the 17*b7893ccfSSadaf Ebrahimi distribution. 18*b7893ccfSSadaf Ebrahimi 19*b7893ccfSSadaf Ebrahimi THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20*b7893ccfSSadaf Ebrahimi "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21*b7893ccfSSadaf Ebrahimi LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22*b7893ccfSSadaf Ebrahimi A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23*b7893ccfSSadaf Ebrahimi OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24*b7893ccfSSadaf Ebrahimi SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25*b7893ccfSSadaf Ebrahimi LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26*b7893ccfSSadaf Ebrahimi DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27*b7893ccfSSadaf Ebrahimi THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28*b7893ccfSSadaf Ebrahimi (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29*b7893ccfSSadaf Ebrahimi OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30*b7893ccfSSadaf Ebrahimi 31*b7893ccfSSadaf Ebrahimi You can contact the author at : 32*b7893ccfSSadaf Ebrahimi - xxHash source repository : https://github.com/Cyan4973/xxHash 33*b7893ccfSSadaf Ebrahimi */ 34*b7893ccfSSadaf Ebrahimi 35*b7893ccfSSadaf Ebrahimi /* Notice extracted from xxHash homepage : 36*b7893ccfSSadaf Ebrahimi 37*b7893ccfSSadaf Ebrahimi xxHash is an extremely fast Hash algorithm, running at RAM speed limits. 38*b7893ccfSSadaf Ebrahimi It also successfully passes all tests from the SMHasher suite. 39*b7893ccfSSadaf Ebrahimi 40*b7893ccfSSadaf Ebrahimi Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz) 41*b7893ccfSSadaf Ebrahimi 42*b7893ccfSSadaf Ebrahimi Name Speed Q.Score Author 43*b7893ccfSSadaf Ebrahimi xxHash 5.4 GB/s 10 44*b7893ccfSSadaf Ebrahimi CrapWow 3.2 GB/s 2 Andrew 45*b7893ccfSSadaf Ebrahimi MumurHash 3a 2.7 GB/s 10 Austin Appleby 46*b7893ccfSSadaf Ebrahimi SpookyHash 2.0 GB/s 10 Bob Jenkins 47*b7893ccfSSadaf Ebrahimi SBox 1.4 GB/s 9 Bret Mulvey 48*b7893ccfSSadaf Ebrahimi Lookup3 1.2 GB/s 9 Bob Jenkins 49*b7893ccfSSadaf Ebrahimi SuperFastHash 1.2 GB/s 1 Paul Hsieh 50*b7893ccfSSadaf Ebrahimi CityHash64 1.05 GB/s 10 Pike & Alakuijala 51*b7893ccfSSadaf Ebrahimi FNV 0.55 GB/s 5 Fowler, Noll, Vo 52*b7893ccfSSadaf Ebrahimi CRC32 0.43 GB/s 9 53*b7893ccfSSadaf Ebrahimi MD5-32 0.33 GB/s 10 Ronald L. Rivest 54*b7893ccfSSadaf Ebrahimi SHA1-32 0.28 GB/s 10 55*b7893ccfSSadaf Ebrahimi 56*b7893ccfSSadaf Ebrahimi Q.Score is a measure of quality of the hash function. 57*b7893ccfSSadaf Ebrahimi It depends on successfully passing SMHasher test set. 58*b7893ccfSSadaf Ebrahimi 10 is a perfect score. 59*b7893ccfSSadaf Ebrahimi 60*b7893ccfSSadaf Ebrahimi A 64-bits version, named XXH64, is available since r35. 61*b7893ccfSSadaf Ebrahimi It offers much better speed, but for 64-bits applications only. 62*b7893ccfSSadaf Ebrahimi Name Speed on 64 bits Speed on 32 bits 63*b7893ccfSSadaf Ebrahimi XXH64 13.8 GB/s 1.9 GB/s 64*b7893ccfSSadaf Ebrahimi XXH32 6.8 GB/s 6.0 GB/s 65*b7893ccfSSadaf Ebrahimi */ 66*b7893ccfSSadaf Ebrahimi 67*b7893ccfSSadaf Ebrahimi #ifndef XXHASH_H_5627135585666179 68*b7893ccfSSadaf Ebrahimi #define XXHASH_H_5627135585666179 1 69*b7893ccfSSadaf Ebrahimi 70*b7893ccfSSadaf Ebrahimi #if defined (__cplusplus) 71*b7893ccfSSadaf Ebrahimi extern "C" { 72*b7893ccfSSadaf Ebrahimi #endif 73*b7893ccfSSadaf Ebrahimi 74*b7893ccfSSadaf Ebrahimi 75*b7893ccfSSadaf Ebrahimi /* **************************** 76*b7893ccfSSadaf Ebrahimi * Definitions 77*b7893ccfSSadaf Ebrahimi ******************************/ 78*b7893ccfSSadaf Ebrahimi #include <stddef.h> /* size_t */ 79*b7893ccfSSadaf Ebrahimi typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; 80*b7893ccfSSadaf Ebrahimi 81*b7893ccfSSadaf Ebrahimi 82*b7893ccfSSadaf Ebrahimi /* **************************** 83*b7893ccfSSadaf Ebrahimi * API modifier 84*b7893ccfSSadaf Ebrahimi ******************************/ 85*b7893ccfSSadaf Ebrahimi /** XXH_PRIVATE_API 86*b7893ccfSSadaf Ebrahimi * This is useful to include xxhash functions in `static` mode 87*b7893ccfSSadaf Ebrahimi * in order to inline them, and remove their symbol from the public list. 88*b7893ccfSSadaf Ebrahimi * Methodology : 89*b7893ccfSSadaf Ebrahimi * #define XXH_PRIVATE_API 90*b7893ccfSSadaf Ebrahimi * #include "xxhash.h" 91*b7893ccfSSadaf Ebrahimi * `xxhash.c` is automatically included. 92*b7893ccfSSadaf Ebrahimi * It's not useful to compile and link it as a separate module. 93*b7893ccfSSadaf Ebrahimi */ 94*b7893ccfSSadaf Ebrahimi #ifdef XXH_PRIVATE_API 95*b7893ccfSSadaf Ebrahimi # ifndef XXH_STATIC_LINKING_ONLY 96*b7893ccfSSadaf Ebrahimi # define XXH_STATIC_LINKING_ONLY 97*b7893ccfSSadaf Ebrahimi # endif 98*b7893ccfSSadaf Ebrahimi # if defined(__GNUC__) 99*b7893ccfSSadaf Ebrahimi # define XXH_PUBLIC_API static __inline __attribute__((unused)) 100*b7893ccfSSadaf Ebrahimi # elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) 101*b7893ccfSSadaf Ebrahimi # define XXH_PUBLIC_API static inline 102*b7893ccfSSadaf Ebrahimi # elif defined(_MSC_VER) 103*b7893ccfSSadaf Ebrahimi # define XXH_PUBLIC_API static __inline 104*b7893ccfSSadaf Ebrahimi # else 105*b7893ccfSSadaf Ebrahimi # define XXH_PUBLIC_API static /* this version may generate warnings for unused static functions; disable the relevant warning */ 106*b7893ccfSSadaf Ebrahimi # endif 107*b7893ccfSSadaf Ebrahimi #else 108*b7893ccfSSadaf Ebrahimi # define XXH_PUBLIC_API /* do nothing */ 109*b7893ccfSSadaf Ebrahimi #endif /* XXH_PRIVATE_API */ 110*b7893ccfSSadaf Ebrahimi 111*b7893ccfSSadaf Ebrahimi /*!XXH_NAMESPACE, aka Namespace Emulation : 112*b7893ccfSSadaf Ebrahimi 113*b7893ccfSSadaf Ebrahimi If you want to include _and expose_ xxHash functions from within your own library, 114*b7893ccfSSadaf Ebrahimi but also want to avoid symbol collisions with other libraries which may also include xxHash, 115*b7893ccfSSadaf Ebrahimi 116*b7893ccfSSadaf Ebrahimi you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library 117*b7893ccfSSadaf Ebrahimi with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values). 118*b7893ccfSSadaf Ebrahimi 119*b7893ccfSSadaf Ebrahimi Note that no change is required within the calling program as long as it includes `xxhash.h` : 120*b7893ccfSSadaf Ebrahimi regular symbol name will be automatically translated by this header. 121*b7893ccfSSadaf Ebrahimi */ 122*b7893ccfSSadaf Ebrahimi #ifdef XXH_NAMESPACE 123*b7893ccfSSadaf Ebrahimi # define XXH_CAT(A,B) A##B 124*b7893ccfSSadaf Ebrahimi # define XXH_NAME2(A,B) XXH_CAT(A,B) 125*b7893ccfSSadaf Ebrahimi # define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber) 126*b7893ccfSSadaf Ebrahimi # define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32) 127*b7893ccfSSadaf Ebrahimi # define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState) 128*b7893ccfSSadaf Ebrahimi # define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState) 129*b7893ccfSSadaf Ebrahimi # define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset) 130*b7893ccfSSadaf Ebrahimi # define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update) 131*b7893ccfSSadaf Ebrahimi # define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest) 132*b7893ccfSSadaf Ebrahimi # define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState) 133*b7893ccfSSadaf Ebrahimi # define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash) 134*b7893ccfSSadaf Ebrahimi # define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical) 135*b7893ccfSSadaf Ebrahimi # define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64) 136*b7893ccfSSadaf Ebrahimi # define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState) 137*b7893ccfSSadaf Ebrahimi # define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState) 138*b7893ccfSSadaf Ebrahimi # define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset) 139*b7893ccfSSadaf Ebrahimi # define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update) 140*b7893ccfSSadaf Ebrahimi # define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest) 141*b7893ccfSSadaf Ebrahimi # define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState) 142*b7893ccfSSadaf Ebrahimi # define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash) 143*b7893ccfSSadaf Ebrahimi # define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical) 144*b7893ccfSSadaf Ebrahimi #endif 145*b7893ccfSSadaf Ebrahimi 146*b7893ccfSSadaf Ebrahimi 147*b7893ccfSSadaf Ebrahimi /* ************************************* 148*b7893ccfSSadaf Ebrahimi * Version 149*b7893ccfSSadaf Ebrahimi ***************************************/ 150*b7893ccfSSadaf Ebrahimi #define XXH_VERSION_MAJOR 0 151*b7893ccfSSadaf Ebrahimi #define XXH_VERSION_MINOR 6 152*b7893ccfSSadaf Ebrahimi #define XXH_VERSION_RELEASE 2 153*b7893ccfSSadaf Ebrahimi #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) 154*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API unsigned XXH_versionNumber (void); 155*b7893ccfSSadaf Ebrahimi 156*b7893ccfSSadaf Ebrahimi 157*b7893ccfSSadaf Ebrahimi /*-********************************************************************** 158*b7893ccfSSadaf Ebrahimi * 32-bits hash 159*b7893ccfSSadaf Ebrahimi ************************************************************************/ 160*b7893ccfSSadaf Ebrahimi typedef unsigned int XXH32_hash_t; 161*b7893ccfSSadaf Ebrahimi 162*b7893ccfSSadaf Ebrahimi /*! XXH32() : 163*b7893ccfSSadaf Ebrahimi Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input". 164*b7893ccfSSadaf Ebrahimi The memory between input & input+length must be valid (allocated and read-accessible). 165*b7893ccfSSadaf Ebrahimi "seed" can be used to alter the result predictably. 166*b7893ccfSSadaf Ebrahimi Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s */ 167*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed); 168*b7893ccfSSadaf Ebrahimi 169*b7893ccfSSadaf Ebrahimi /*====== Streaming ======*/ 170*b7893ccfSSadaf Ebrahimi typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */ 171*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void); 172*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr); 173*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dst_state, const XXH32_state_t* src_state); 174*b7893ccfSSadaf Ebrahimi 175*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned int seed); 176*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length); 177*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr); 178*b7893ccfSSadaf Ebrahimi 179*b7893ccfSSadaf Ebrahimi /* 180*b7893ccfSSadaf Ebrahimi These functions generate the xxHash of an input provided in multiple segments. 181*b7893ccfSSadaf Ebrahimi Note that, for small input, they are slower than single-call functions, due to state management. 182*b7893ccfSSadaf Ebrahimi For small input, prefer `XXH32()` and `XXH64()` . 183*b7893ccfSSadaf Ebrahimi 184*b7893ccfSSadaf Ebrahimi XXH state must first be allocated, using XXH*_createState() . 185*b7893ccfSSadaf Ebrahimi 186*b7893ccfSSadaf Ebrahimi Start a new hash by initializing state with a seed, using XXH*_reset(). 187*b7893ccfSSadaf Ebrahimi 188*b7893ccfSSadaf Ebrahimi Then, feed the hash state by calling XXH*_update() as many times as necessary. 189*b7893ccfSSadaf Ebrahimi Obviously, input must be allocated and read accessible. 190*b7893ccfSSadaf Ebrahimi The function returns an error code, with 0 meaning OK, and any other value meaning there is an error. 191*b7893ccfSSadaf Ebrahimi 192*b7893ccfSSadaf Ebrahimi Finally, a hash value can be produced anytime, by using XXH*_digest(). 193*b7893ccfSSadaf Ebrahimi This function returns the nn-bits hash as an int or long long. 194*b7893ccfSSadaf Ebrahimi 195*b7893ccfSSadaf Ebrahimi It's still possible to continue inserting input into the hash state after a digest, 196*b7893ccfSSadaf Ebrahimi and generate some new hashes later on, by calling again XXH*_digest(). 197*b7893ccfSSadaf Ebrahimi 198*b7893ccfSSadaf Ebrahimi When done, free XXH state space if it was allocated dynamically. 199*b7893ccfSSadaf Ebrahimi */ 200*b7893ccfSSadaf Ebrahimi 201*b7893ccfSSadaf Ebrahimi /*====== Canonical representation ======*/ 202*b7893ccfSSadaf Ebrahimi 203*b7893ccfSSadaf Ebrahimi typedef struct { unsigned char digest[4]; } XXH32_canonical_t; 204*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash); 205*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src); 206*b7893ccfSSadaf Ebrahimi 207*b7893ccfSSadaf Ebrahimi /* Default result type for XXH functions are primitive unsigned 32 and 64 bits. 208*b7893ccfSSadaf Ebrahimi * The canonical representation uses human-readable write convention, aka big-endian (large digits first). 209*b7893ccfSSadaf Ebrahimi * These functions allow transformation of hash result into and from its canonical format. 210*b7893ccfSSadaf Ebrahimi * This way, hash values can be written into a file / memory, and remain comparable on different systems and programs. 211*b7893ccfSSadaf Ebrahimi */ 212*b7893ccfSSadaf Ebrahimi 213*b7893ccfSSadaf Ebrahimi 214*b7893ccfSSadaf Ebrahimi #ifndef XXH_NO_LONG_LONG 215*b7893ccfSSadaf Ebrahimi /*-********************************************************************** 216*b7893ccfSSadaf Ebrahimi * 64-bits hash 217*b7893ccfSSadaf Ebrahimi ************************************************************************/ 218*b7893ccfSSadaf Ebrahimi typedef unsigned long long XXH64_hash_t; 219*b7893ccfSSadaf Ebrahimi 220*b7893ccfSSadaf Ebrahimi /*! XXH64() : 221*b7893ccfSSadaf Ebrahimi Calculate the 64-bits hash of sequence of length "len" stored at memory address "input". 222*b7893ccfSSadaf Ebrahimi "seed" can be used to alter the result predictably. 223*b7893ccfSSadaf Ebrahimi This function runs faster on 64-bits systems, but slower on 32-bits systems (see benchmark). 224*b7893ccfSSadaf Ebrahimi */ 225*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed); 226*b7893ccfSSadaf Ebrahimi 227*b7893ccfSSadaf Ebrahimi /*====== Streaming ======*/ 228*b7893ccfSSadaf Ebrahimi typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */ 229*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void); 230*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr); 231*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dst_state, const XXH64_state_t* src_state); 232*b7893ccfSSadaf Ebrahimi 233*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed); 234*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length); 235*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr); 236*b7893ccfSSadaf Ebrahimi 237*b7893ccfSSadaf Ebrahimi /*====== Canonical representation ======*/ 238*b7893ccfSSadaf Ebrahimi typedef struct { unsigned char digest[8]; } XXH64_canonical_t; 239*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash); 240*b7893ccfSSadaf Ebrahimi XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src); 241*b7893ccfSSadaf Ebrahimi #endif /* XXH_NO_LONG_LONG */ 242*b7893ccfSSadaf Ebrahimi 243*b7893ccfSSadaf Ebrahimi 244*b7893ccfSSadaf Ebrahimi #ifdef XXH_STATIC_LINKING_ONLY 245*b7893ccfSSadaf Ebrahimi 246*b7893ccfSSadaf Ebrahimi /* ================================================================================================ 247*b7893ccfSSadaf Ebrahimi This section contains definitions which are not guaranteed to remain stable. 248*b7893ccfSSadaf Ebrahimi They may change in future versions, becoming incompatible with a different version of the library. 249*b7893ccfSSadaf Ebrahimi They shall only be used with static linking. 250*b7893ccfSSadaf Ebrahimi Never use these definitions in association with dynamic linking ! 251*b7893ccfSSadaf Ebrahimi =================================================================================================== */ 252*b7893ccfSSadaf Ebrahimi 253*b7893ccfSSadaf Ebrahimi /* These definitions are only meant to make possible 254*b7893ccfSSadaf Ebrahimi static allocation of XXH state, on stack or in a struct for example. 255*b7893ccfSSadaf Ebrahimi Never use members directly. */ 256*b7893ccfSSadaf Ebrahimi 257*b7893ccfSSadaf Ebrahimi struct XXH32_state_s { 258*b7893ccfSSadaf Ebrahimi unsigned total_len_32; 259*b7893ccfSSadaf Ebrahimi unsigned large_len; 260*b7893ccfSSadaf Ebrahimi unsigned v1; 261*b7893ccfSSadaf Ebrahimi unsigned v2; 262*b7893ccfSSadaf Ebrahimi unsigned v3; 263*b7893ccfSSadaf Ebrahimi unsigned v4; 264*b7893ccfSSadaf Ebrahimi unsigned mem32[4]; /* buffer defined as U32 for alignment */ 265*b7893ccfSSadaf Ebrahimi unsigned memsize; 266*b7893ccfSSadaf Ebrahimi unsigned reserved; /* never read nor write, will be removed in a future version */ 267*b7893ccfSSadaf Ebrahimi }; /* typedef'd to XXH32_state_t */ 268*b7893ccfSSadaf Ebrahimi 269*b7893ccfSSadaf Ebrahimi #ifndef XXH_NO_LONG_LONG /* remove 64-bits support */ 270*b7893ccfSSadaf Ebrahimi struct XXH64_state_s { 271*b7893ccfSSadaf Ebrahimi unsigned long long total_len; 272*b7893ccfSSadaf Ebrahimi unsigned long long v1; 273*b7893ccfSSadaf Ebrahimi unsigned long long v2; 274*b7893ccfSSadaf Ebrahimi unsigned long long v3; 275*b7893ccfSSadaf Ebrahimi unsigned long long v4; 276*b7893ccfSSadaf Ebrahimi unsigned long long mem64[4]; /* buffer defined as U64 for alignment */ 277*b7893ccfSSadaf Ebrahimi unsigned memsize; 278*b7893ccfSSadaf Ebrahimi unsigned reserved[2]; /* never read nor write, will be removed in a future version */ 279*b7893ccfSSadaf Ebrahimi }; /* typedef'd to XXH64_state_t */ 280*b7893ccfSSadaf Ebrahimi #endif 281*b7893ccfSSadaf Ebrahimi 282*b7893ccfSSadaf Ebrahimi #ifdef XXH_PRIVATE_API 283*b7893ccfSSadaf Ebrahimi # include "xxhash.c" /* include xxhash function bodies as `static`, for inlining */ 284*b7893ccfSSadaf Ebrahimi #endif 285*b7893ccfSSadaf Ebrahimi 286*b7893ccfSSadaf Ebrahimi #endif /* XXH_STATIC_LINKING_ONLY */ 287*b7893ccfSSadaf Ebrahimi 288*b7893ccfSSadaf Ebrahimi 289*b7893ccfSSadaf Ebrahimi #if defined (__cplusplus) 290*b7893ccfSSadaf Ebrahimi } 291*b7893ccfSSadaf Ebrahimi #endif 292*b7893ccfSSadaf Ebrahimi 293*b7893ccfSSadaf Ebrahimi #endif /* XXHASH_H_5627135585666179 */ 294