File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 3333// FNV is provided primarily for backward compatibility.
3434
3535#include < bits/hash_bytes.h>
36+ #include < type_traits>
37+
38+ #ifdef __AVR__
39+ #include < util/crc16.h>
40+ #endif
3641
3742namespace
3843{
@@ -174,7 +179,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
174179 }
175180 return hash;
176181 }
182+ #elif __SIZEOF_SIZE_T__ == 2 && defined(__AVR__)
183+ size_t
184+ _Hash_bytes (const void * ptr, size_t len, size_t seed)
185+ {
186+ static_assert (is_same_v<uint16_t , size_t >);
187+ size_t hash = seed;
188+ const char * cptr = reinterpret_cast <const char *>(ptr);
189+ for (; len; --len)
190+ hash = _crc_ccitt_update (hash, *cptr++);
191+ return hash;
192+ }
177193
194+ size_t
195+ _Fnv_hash_bytes (const void * ptr, size_t len, size_t seed)
196+ { return _Hash_bytes (ptr, len, seed); }
178197#else
179198
180199 // Dummy hash implementation for unusual sizeof(size_t).
You can’t perform that action at this time.
0 commit comments