File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 33
33
// FNV is provided primarily for backward compatibility.
34
34
35
35
#include < bits/hash_bytes.h>
36
+ #include < type_traits>
37
+
38
+ #ifdef __AVR__
39
+ #include < util/crc16.h>
40
+ #endif
36
41
37
42
namespace
38
43
{
@@ -174,7 +179,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
174
179
}
175
180
return hash;
176
181
}
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
+ }
177
193
194
+ size_t
195
+ _Fnv_hash_bytes (const void * ptr, size_t len, size_t seed)
196
+ { return _Hash_bytes (ptr, len, seed); }
178
197
#else
179
198
180
199
// Dummy hash implementation for unusual sizeof(size_t).
You can’t perform that action at this time.
0 commit comments