HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hash.h
Go to the documentation of this file.
1 /*
2  Copyright 2008 Larry Gritz and the other authors and contributors.
3  All Rights Reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8  * Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13  * Neither the name of the software's owners nor the names of its
14  contributors may be used to endorse or promote products derived from
15  this software without specific prior written permission.
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28  (This is the Modified BSD License)
29 */
30 
31 // clang-format off
32 
33 /// \file
34 ///
35 /// Wrapper so that hash_map and hash_set mean what we want regardless
36 /// of the compiler.
37 ///
38 
39 #pragma once
40 
41 #include <cassert>
42 #include <cstdint>
43 #include <cstdlib>
44 #include <cstring>
45 #include <unordered_map>
46 #include <utility>
47 #include <vector>
48 
49 #include <OpenImageIO/span.h>
50 #include <OpenImageIO/export.h>
51 #include <OpenImageIO/fmath.h>
54 
55 
56 
58 
59 using std::hash;
60 using std::unordered_map;
61 
62 namespace fasthash {
63 
64 /* The MIT License
65  Copyright (C) 2012 Zilong Tan (eric.zltan@gmail.com)
66  Permission is hereby granted, free of charge, to any person
67  obtaining a copy of this software and associated documentation
68  files (the "Software"), to deal in the Software without
69  restriction, including without limitation the rights to use, copy,
70  modify, merge, publish, distribute, sublicense, and/or sell copies
71  of the Software, and to permit persons to whom the Software is
72  furnished to do so, subject to the following conditions:
73  The above copyright notice and this permission notice shall be
74  included in all copies or substantial portions of the Software.
75  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
76  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
77  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
78  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
79  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
80  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
81  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
82  SOFTWARE.
83 */
84 
85 // Compression function for Merkle-Damgard construction.
86 // This function is generated using the framework provided.
87 static inline uint64_t mix(uint64_t h) {
88  h ^= h >> 23;
89  h *= 0x2127599bf4325c37ULL;
90  h ^= h >> 47;
91  return h;
92 }
93 
94 inline uint64_t fasthash64(const void *buf, size_t len, uint64_t seed)
95 {
96  const uint64_t m = 0x880355f21e6d1965ULL;
97  const uint64_t *pos = (const uint64_t *)buf;
98  const uint64_t *end = pos + (len / 8);
99  const unsigned char *pos2;
100  uint64_t h = seed ^ (len * m);
101  uint64_t v;
102 
103  while (pos != end) {
104  v = *pos++;
105  h ^= mix(v);
106  h *= m;
107  }
108 
109  pos2 = (const unsigned char*)pos;
110  v = 0;
111 
112  switch (len & 7) {
113  case 7: v ^= (uint64_t)pos2[6] << 48;
114  case 6: v ^= (uint64_t)pos2[5] << 40;
115  case 5: v ^= (uint64_t)pos2[4] << 32;
116  case 4: v ^= (uint64_t)pos2[3] << 24;
117  case 3: v ^= (uint64_t)pos2[2] << 16;
118  case 2: v ^= (uint64_t)pos2[1] << 8;
119  case 1: v ^= (uint64_t)pos2[0];
120  h ^= mix(v);
121  h *= m;
122  }
123 
124  return mix(h);
125 }
126 
127 // simplified version for hashing just a few ints
128 inline uint64_t fasthash64(const std::initializer_list<uint64_t> buf) {
129  const uint64_t m = 0x880355f21e6d1965ULL;
130  uint64_t h = (buf.size() * sizeof(uint64_t)) * m;
131  for (const uint64_t v : buf) {
132  h ^= mix(v);
133  h *= m;
134  }
135  return mix(h);
136 }
137 
138 } // namespace fasthash
139 
140 
141 namespace xxhash {
142 
143 // xxhash: http://code.google.com/p/xxhash/
144 // It's BSD licensed.
145 
146 unsigned int OIIO_API XXH32 (const void* input, size_t length,
147  unsigned seed=1771);
148 unsigned long long OIIO_API XXH64 (const void* input, size_t length,
149  unsigned long long seed=1771);
150 
151 inline size_t xxhash (const void* input, size_t length, size_t seed=1771)
152 {
153  return size_t (XXH64 (input, length, (unsigned long long)seed));
154 }
155 
156 template <typename Str>
157 inline size_t xxhash (const Str& s, size_t seed=1771) {
158  assert(sizeof(s[0]) == 1);
159  return xxhash (s.data(), s.length(), seed);
160 }
161 
162 } // end namespace xxhash
163 
164 
165 
166 
167 namespace bjhash {
168 
169 // Bob Jenkins "lookup3" hashes: http://burtleburtle.net/bob/c/lookup3.c
170 // It's in the public domain.
171 
172 // Mix up the bits of a, b, and c (changing their values in place).
173 inline OIIO_HOSTDEVICE void bjmix (uint32_t &a, uint32_t &b, uint32_t &c)
174 {
175  a -= c; a ^= rotl32(c, 4); c += b;
176  b -= a; b ^= rotl32(a, 6); a += c;
177  c -= b; c ^= rotl32(b, 8); b += a;
178  a -= c; a ^= rotl32(c,16); c += b;
179  b -= a; b ^= rotl32(a,19); a += c;
180  c -= b; c ^= rotl32(b, 4); b += a;
181 }
182 
183 // Mix up and combine the bits of a, b, and c (doesn't change them, but
184 // returns a hash of those three original values). 21 ops
185 inline OIIO_HOSTDEVICE uint32_t bjfinal (uint32_t a, uint32_t b, uint32_t c=0xdeadbeef)
186 {
187  c ^= b; c -= rotl32(b,14);
188  a ^= c; a -= rotl32(c,11);
189  b ^= a; b -= rotl32(a,25);
190  c ^= b; c -= rotl32(b,16);
191  a ^= c; a -= rotl32(c,4);
192  b ^= a; b -= rotl32(a,14);
193  c ^= b; c -= rotl32(b,24);
194  return c;
195 }
196 
197 // Mix up 4 64-bit inputs (non-destructively), and return a 64 bit hash.
198 // Adapted from http://burtleburtle.net/bob/c/SpookyV2.h 33 ops
199 inline uint64_t bjfinal64 (uint64_t h0, uint64_t h1, uint64_t h2, uint64_t h3)
200 {
201  h3 ^= h2; h2 = rotl64(h2,15); h3 += h2;
202  h0 ^= h3; h3 = rotl64(h3,52); h0 += h3;
203  h1 ^= h0; h0 = rotl64(h0,26); h1 += h0;
204  h2 ^= h1; h1 = rotl64(h1,51); h2 += h1;
205  h3 ^= h2; h2 = rotl64(h2,28); h3 += h2;
206  h0 ^= h3; h3 = rotl64(h3,9); h0 += h3;
207  h1 ^= h0; h0 = rotl64(h0,47); h1 += h0;
208  h2 ^= h1; h1 = rotl64(h1,54); h2 += h1;
209  h3 ^= h2; h2 = rotl64(h2,32); h3 += h2;
210  h0 ^= h3; h3 = rotl64(h3,25); h0 += h3;
211  h1 ^= h0; h0 = rotl64(h0,63); h1 += h0;
212  return h1;
213 }
214 
215 // Standard "lookup3" hash, arbitrary length in bytes.
216 uint32_t OIIO_API hashlittle (const void *key, size_t length,
217  uint32_t seed=1771);
218 
219 // Hash an array of 32 bit words -- faster than hashlittle if you know
220 // it's a whole number of 4-byte words.
221 uint32_t OIIO_API hashword (const uint32_t *key, size_t nwords,
222  uint32_t seed=1771);
223 
224 // Hash a string without pre-known length. We use the Jenkins
225 // one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function),
226 // which seems to be a good speed/quality/requirements compromise.
227 inline size_t
228 strhash (const char *s)
229 {
230  if (! s) return 0;
231  unsigned int h = 0;
232  while (*s) {
233  h += (unsigned char)(*s);
234  h += h << 10;
235  h ^= h >> 6;
236  ++s;
237  }
238  h += h << 3;
239  h ^= h >> 11;
240  h += h << 15;
241  return h;
242 }
243 
244 
245 // Hash a string_view. We use the Jenkins
246 // one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function),
247 // which seems to be a good speed/quality/requirements compromise.
248 inline size_t
250 {
251  size_t len = s.length();
252  if (! len) return 0;
253  unsigned int h = 0;
254  for (size_t i = 0; i < len; ++i) {
255  h += (unsigned char)(s[i]);
256  h += h << 10;
257  h ^= h >> 6;
258  }
259  h += h << 3;
260  h ^= h >> 11;
261  h += h << 15;
262  return h;
263 }
264 
265 } // end namespace bjhash
266 
267 
268 namespace murmur {
269 
270 // These functions were lifted from the public domain Murmurhash3. We
271 // don't bother using Murmurhash -- in my tests, it was slower than
272 // xxhash in all cases, and comparable to bjhash. But these two fmix
273 // functions are useful for scrambling the bits of a single 32 or 64 bit
274 // value.
275 
276 inline uint32_t fmix (uint32_t h)
277 {
278  h ^= h >> 16;
279  h *= 0x85ebca6b;
280  h ^= h >> 13;
281  h *= 0xc2b2ae35;
282  h ^= h >> 16;
283  return h;
284 }
285 
286 inline uint64_t fmix (uint64_t k)
287 {
288  k ^= k >> 33;
289  k *= 0xff51afd7ed558ccdULL;
290  k ^= k >> 33;
291  k *= 0xc4ceb9fe1a85ec53ULL;
292  k ^= k >> 33;
293  return k;
294 }
295 
296 } // end namespace murmur
297 
298 
299 
300 namespace farmhash {
301 
302 // Copyright (c) 2014 Google, Inc.
303 // http://code.google.com/p/farmhash/
304 // See OpenImageIO's hashes.cpp for the MIT license for this code.
305 
306 
307 #if defined(FARMHASH_UINT128_T_DEFINED)
308 inline uint64_t Uint128Low64(const uint128_t x) {
309  return static_cast<uint64_t>(x);
310 }
311 inline uint64_t Uint128High64(const uint128_t x) {
312  return static_cast<uint64_t>(x >> 64);
313 }
314 inline uint128_t Uint128(uint64_t lo, uint64_t hi) {
315  return lo + (((uint128_t)hi) << 64);
316 }
317 #else
318 typedef std::pair<uint64_t, uint64_t> uint128_t;
319 inline uint64_t Uint128Low64(const uint128_t x) { return x.first; }
320 inline uint64_t Uint128High64(const uint128_t x) { return x.second; }
321 inline uint128_t Uint128(uint64_t lo, uint64_t hi) { return uint128_t(lo, hi); }
322 #endif
323 
324 
325 // BASIC STRING HASHING
326 
327 // Hash function for a byte array.
328 // May change from time to time, may differ on different platforms, may differ
329 // depending on NDEBUG.
330 size_t OIIO_API Hash(const char* s, size_t len);
331 
332 // Hash function for a byte array. Most useful in 32-bit binaries.
333 // May change from time to time, may differ on different platforms, may differ
334 // depending on NDEBUG.
335 uint32_t OIIO_API Hash32(const char* s, size_t len);
336 
337 // Hash function for a byte array. For convenience, a 32-bit seed is also
338 // hashed into the result.
339 // May change from time to time, may differ on different platforms, may differ
340 // depending on NDEBUG.
341 uint32_t OIIO_API Hash32WithSeed(const char* s, size_t len, uint32_t seed);
342 
343 // Hash 128 input bits down to 64 bits of output.
344 // Hash function for a byte array.
345 // May change from time to time, may differ on different platforms, may differ
346 // depending on NDEBUG.
347 uint64_t OIIO_API Hash64(const char* s, size_t len);
348 
349 // Hash function for a byte array. For convenience, a 64-bit seed is also
350 // hashed into the result.
351 // May change from time to time, may differ on different platforms, may differ
352 // depending on NDEBUG.
353 uint64_t OIIO_API Hash64WithSeed(const char* s, size_t len, uint64_t seed);
354 
355 // Hash function for a byte array. For convenience, two seeds are also
356 // hashed into the result.
357 // May change from time to time, may differ on different platforms, may differ
358 // depending on NDEBUG.
359 uint64_t OIIO_API Hash64WithSeeds(const char* s, size_t len,
360  uint64_t seed0, uint64_t seed1);
361 
362 // Hash function for a byte array.
363 // May change from time to time, may differ on different platforms, may differ
364 // depending on NDEBUG.
365 uint128_t OIIO_API Hash128(const char* s, size_t len);
366 
367 // Hash function for a byte array. For convenience, a 128-bit seed is also
368 // hashed into the result.
369 // May change from time to time, may differ on different platforms, may differ
370 // depending on NDEBUG.
371 uint128_t OIIO_API Hash128WithSeed(const char* s, size_t len, uint128_t seed);
372 
373 // BASIC NON-STRING HASHING
374 
375 // This is intended to be a reasonably good hash function.
376 // May change from time to time, may differ on different platforms, may differ
377 // depending on NDEBUG.
378 inline uint64_t Hash128to64(uint128_t x) {
379  // Murmur-inspired hashing.
380  const uint64_t kMul = 0x9ddfea08eb382d69ULL;
381  uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
382  a ^= (a >> 47);
383  uint64_t b = (Uint128High64(x) ^ a) * kMul;
384  b ^= (b >> 47);
385  b *= kMul;
386  return b;
387 }
388 
389 // FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
390 
391 // Fingerprint function for a byte array. Most useful in 32-bit binaries.
392 uint32_t OIIO_API Fingerprint32(const char* s, size_t len);
393 
394 // Fingerprint function for a byte array.
395 uint64_t OIIO_API Fingerprint64(const char* s, size_t len);
396 
397 // Fingerprint function for a byte array.
398 uint128_t OIIO_API Fingerprint128(const char* s, size_t len);
399 
400 // This is intended to be a good fingerprinting primitive.
401 // See below for more overloads.
402 inline uint64_t Fingerprint(uint128_t x) {
403  // Murmur-inspired hashing.
404  const uint64_t kMul = 0x9ddfea08eb382d69ULL;
405  uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
406  a ^= (a >> 47);
407  uint64_t b = (Uint128High64(x) ^ a) * kMul;
408  b ^= (b >> 44);
409  b *= kMul;
410  b ^= (b >> 41);
411  b *= kMul;
412  return b;
413 }
414 
415 // This is intended to be a good fingerprinting primitive.
416 inline uint64_t Fingerprint(uint64_t x) {
417  // Murmur-inspired hashing.
418  const uint64_t kMul = 0x9ddfea08eb382d69ULL;
419  uint64_t b = x * kMul;
420  b ^= (b >> 44);
421  b *= kMul;
422  b ^= (b >> 41);
423  b *= kMul;
424  return b;
425 }
426 
427 #ifndef FARMHASH_NO_CXX_STRING
428 
429 // Convenience functions to hash or fingerprint C++ strings.
430 // These require that Str::data() return a pointer to the first char
431 // (as a const char*) and that Str::length() return the string's length;
432 // they work with std::string, for example.
433 
434 // Hash function for a byte array.
435 // May change from time to time, may differ on different platforms, may differ
436 // depending on NDEBUG.
437 template <typename Str>
438 inline size_t Hash(const Str& s) {
439  assert(sizeof(s[0]) == 1);
440  return Hash(s.data(), s.length());
441 }
442 
443 // Hash function for a byte array. Most useful in 32-bit binaries.
444 // May change from time to time, may differ on different platforms, may differ
445 // depending on NDEBUG.
446 template <typename Str>
447 inline uint32_t Hash32(const Str& s) {
448  assert(sizeof(s[0]) == 1);
449  return Hash32(s.data(), s.length());
450 }
451 
452 // Hash function for a byte array. For convenience, a 32-bit seed is also
453 // hashed into the result.
454 // May change from time to time, may differ on different platforms, may differ
455 // depending on NDEBUG.
456 template <typename Str>
457 inline uint32_t Hash32WithSeed(const Str& s, uint32_t seed) {
458  assert(sizeof(s[0]) == 1);
459  return Hash32WithSeed(s.data(), s.length(), seed);
460 }
461 
462 // Hash 128 input bits down to 64 bits of output.
463 // Hash function for a byte array.
464 // May change from time to time, may differ on different platforms, may differ
465 // depending on NDEBUG.
466 template <typename Str>
467 inline uint64_t Hash64(const Str& s) {
468  assert(sizeof(s[0]) == 1);
469  return Hash64(s.data(), s.length());
470 }
471 
472 // Hash function for a byte array. For convenience, a 64-bit seed is also
473 // hashed into the result.
474 // May change from time to time, may differ on different platforms, may differ
475 // depending on NDEBUG.
476 template <typename Str>
477 inline uint64_t Hash64WithSeed(const Str& s, uint64_t seed) {
478  assert(sizeof(s[0]) == 1);
479  return Hash64WithSeed(s.data(), s.length(), seed);
480 }
481 
482 // Hash function for a byte array. For convenience, two seeds are also
483 // hashed into the result.
484 // May change from time to time, may differ on different platforms, may differ
485 // depending on NDEBUG.
486 template <typename Str>
487 inline uint64_t Hash64WithSeeds(const Str& s, uint64_t seed0, uint64_t seed1) {
488  assert(sizeof(s[0]) == 1);
489  return Hash64WithSeeds(s.data(), s.length(), seed0, seed1);
490 }
491 
492 // Hash function for a byte array.
493 // May change from time to time, may differ on different platforms, may differ
494 // depending on NDEBUG.
495 template <typename Str>
496 inline uint128_t Hash128(const Str& s) {
497  assert(sizeof(s[0]) == 1);
498  return Hash128(s.data(), s.length());
499 }
500 
501 // Hash function for a byte array. For convenience, a 128-bit seed is also
502 // hashed into the result.
503 // May change from time to time, may differ on different platforms, may differ
504 // depending on NDEBUG.
505 template <typename Str>
506 inline uint128_t Hash128WithSeed(const Str& s, uint128_t seed) {
507  assert(sizeof(s[0]) == 1);
508  return Hash128(s.data(), s.length(), seed);
509 }
510 
511 // FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
512 
513 // Fingerprint function for a byte array. Most useful in 32-bit binaries.
514 template <typename Str>
515 inline uint32_t Fingerprint32(const Str& s) {
516  assert(sizeof(s[0]) == 1);
517  return Fingerprint32(s.data(), s.length());
518 }
519 
520 // Fingerprint 128 input bits down to 64 bits of output.
521 // Fingerprint function for a byte array.
522 template <typename Str>
523 inline uint64_t Fingerprint64(const Str& s) {
524  assert(sizeof(s[0]) == 1);
525  return Fingerprint64(s.data(), s.length());
526 }
527 
528 // Fingerprint function for a byte array.
529 template <typename Str>
530 inline uint128_t Fingerprint128(const Str& s) {
531  assert(sizeof(s[0]) == 1);
532  return Fingerprint128(s.data(), s.length());
533 }
534 
535 #endif
536 
537 } // namespace farmhash
538 
539 
540 
541 
542 class CSHA1; // opaque forward declaration
543 
544 
545 /// Class that encapsulates SHA-1 hashing, a crypticographic-strength
546 /// 160-bit hash function. It's not as fast as our other hashing
547 /// methods, but has an extremely low chance of having collisions.
548 class OIIO_API SHA1 {
549 public:
550  /// Create SHA1, optionally read data
551  SHA1 (const void *data=NULL, size_t size=0);
552  ~SHA1 ();
553 
554  /// Append more data
555  void append (const void *data, size_t size);
556 
557  /// Append more data from a span, without thinking about sizes.
558  template<class T> void append (span<T> v) {
559  append (v.data(), v.size()*sizeof(T));
560  }
561 
562  /// Type for storing the raw bits of the hash
563  struct Hash {
564  unsigned char hash[20];
565  };
566 
567  /// Get the digest and store it in Hash h.
568  void gethash (Hash &h);
569 
570  /// Get the digest and store it in h (must point to enough storage
571  /// to accommodate 20 bytes).
572  void gethash (void *h) { gethash (*(Hash *)h); }
573 
574  /// Return the digest as a hex string
575  std::string digest ();
576 
577  /// Roll the whole thing into one functor, return the string digest.
578  static std::string digest (const void *data, size_t size) {
579  SHA1 s (data, size); return s.digest();
580  }
581 
582 private:
583  CSHA1 *m_csha1;
584  bool m_final;
585 };
586 
587 
GLdouble s
Definition: glew.h:1390
GLenum GLenum GLenum input
Definition: glew.h:13879
GLsizeiptr size
Definition: glew.h:1681
constexpr index_type size() const noexcept
Definition: span.h:148
void gethash(void *h)
Definition: hash.h:572
uint128_t OIIO_API Hash128WithSeed(const char *s, size_t len, uint128_t seed)
OIIO_HOSTDEVICE uint32_t bjfinal(uint32_t a, uint32_t b, uint32_t c=0xdeadbeef)
Definition: hash.h:185
size_t xxhash(const Str &s, size_t seed=1771)
Definition: hash.h:157
size_t strhash(const char *s)
Definition: hash.h:228
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
uint128_t Uint128(uint64_t lo, uint64_t hi)
Definition: hash.h:321
Definition: span.h:47
uint64_t Uint128Low64(const uint128_t x)
Definition: hash.h:319
uint32_t OIIO_API hashlittle(const void *key, size_t length, uint32_t seed=1771)
Type for storing the raw bits of the hash.
Definition: hash.h:563
uint64_t Fingerprint(uint128_t x)
Definition: hash.h:402
const GLdouble * m
Definition: glew.h:9124
const GLdouble * v
Definition: glew.h:1391
unsigned long long OIIO_API XXH64(const void *input, size_t length, unsigned long long seed=1771)
uint64_t Hash128to64(uint128_t x)
Definition: hash.h:378
uint64_t OIIO_API Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1)
size_t OIIO_API Hash(const char *s, size_t len)
size_t xxhash(const void *input, size_t length, size_t seed=1771)
Definition: hash.h:151
unsigned int OIIO_API XXH32(const void *input, size_t length, unsigned seed=1771)
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
std::string digest()
Return the digest as a hex string.
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
uint64_t bjfinal64(uint64_t h0, uint64_t h1, uint64_t h2, uint64_t h3)
Definition: hash.h:199
GLuint GLuint end
Definition: glew.h:1253
uint64_t fasthash64(const void *buf, size_t len, uint64_t seed)
Definition: hash.h:94
const GLfloat * c
Definition: glew.h:16296
GLuint GLsizei GLsizei * length
Definition: glew.h:1825
uint64_t Uint128High64(const uint128_t x)
Definition: hash.h:320
Definition: hash.h:548
#define OIIO_HOSTDEVICE
Definition: platform.h:348
OIIO_HOSTDEVICE void bjmix(uint32_t &a, uint32_t &b, uint32_t &c)
Definition: hash.h:173
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
OIIO_FORCEINLINE OIIO_HOSTDEVICE uint32_t rotl32(uint32_t x, int k)
Bitwise circular rotation left by k bits (for 32 bit unsigned integers)
Definition: fmath.h:200
uint64_t OIIO_API Hash64(const char *s, size_t len)
uint32_t OIIO_API Fingerprint32(const char *s, size_t len)
uint128_t OIIO_API Hash128(const char *s, size_t len)
uint32_t fmix(uint32_t h)
Definition: hash.h:276
uint64_t OIIO_API Fingerprint64(const char *s, size_t len)
void append(span< T > v)
Append more data from a span, without thinking about sizes.
Definition: hash.h:558
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
GLsizei const GLchar *const * string
Definition: glew.h:1844
uint64_t OIIO_API Hash64WithSeed(const char *s, size_t len, uint64_t seed)
size_type length() const
Definition: string_view.h:162
static std::string digest(const void *data, size_t size)
Roll the whole thing into one functor, return the string digest.
Definition: hash.h:578
Definition: SHA1.h:159
uint32_t OIIO_API hashword(const uint32_t *key, size_t nwords, uint32_t seed=1771)
#define OIIO_NAMESPACE_END
Definition: oiioversion.h:66
OIIO_FORCEINLINE OIIO_HOSTDEVICE uint64_t rotl64(uint64_t x, int k)
Bitwise circular rotation left by k bits (for 64 bit unsigned integers)
Definition: fmath.h:211
GLenum GLuint GLsizei const GLchar * buf
Definition: glew.h:2580
uint32_t OIIO_API Hash32WithSeed(const char *s, size_t len, uint32_t seed)
constexpr pointer data() const noexcept
Definition: span.h:152
uint32_t OIIO_API Hash32(const char *s, size_t len)
std::pair< uint64_t, uint64_t > uint128_t
Definition: hash.h:318
GLenum GLsizei len
Definition: glew.h:7752
#define OIIO_NAMESPACE_BEGIN
Definition: oiioversion.h:65
#define OIIO_API
Definition: export.h:91
uint128_t OIIO_API Fingerprint128(const char *s, size_t len)