diff options
author | van Hauser <vh@thc.org> | 2020-06-29 18:19:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 18:19:35 +0200 |
commit | 8f1b78f49e8efef8ec089230d732cdee7b37fa9a (patch) | |
tree | 4cb5e6e59f24f488e58fbb1aced2dbc0e6550c15 /include/hash.h | |
parent | 12bdefe00e38cdc3dd8cb028eeac325ab2e94e16 (diff) | |
parent | 3a0c91b86205bfebb8ec7e62a2e7b0bfcec2e407 (diff) | |
download | afl++-8f1b78f49e8efef8ec089230d732cdee7b37fa9a.tar.gz |
Merge pull request #426 from AFLplusplus/dev
Dev
Diffstat (limited to 'include/hash.h')
-rw-r--r-- | include/hash.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/include/hash.h b/include/hash.h index cec51eac..9319ab95 100644 --- a/include/hash.h +++ b/include/hash.h @@ -30,11 +30,18 @@ #include "types.h" -#ifdef __x86_64__ +u32 hash32(u8 *key, u32 len, u32 seed); +u64 hash64(u8 *key, u32 len, u64 seed); - #define ROL64(_x, _r) ((((u64)(_x)) << (_r)) | (((u64)(_x)) >> (64 - (_r)))) +#if 0 -static inline u32 hash32(const void *key, u32 len, u32 seed) { +The following code is disabled because xxh3 is 30% faster + + #ifdef __x86_64__ + + #define ROL64(_x, _r) ((((u64)(_x)) << (_r)) | (((u64)(_x)) >> (64 - (_r)))) + +static inline u32 hash32(u8 *key, u32 len, u32 seed) { const u64 *data = (u64 *)key; u64 h1 = seed ^ len; @@ -65,9 +72,9 @@ static inline u32 hash32(const void *key, u32 len, u32 seed) { } -#else + #else - #define ROL32(_x, _r) ((((u32)(_x)) << (_r)) | (((u32)(_x)) >> (32 - (_r)))) + #define ROL32(_x, _r) ((((u32)(_x)) << (_r)) | (((u32)(_x)) >> (32 - (_r)))) static inline u32 hash32(const void *key, u32 len, u32 seed) { @@ -100,7 +107,8 @@ static inline u32 hash32(const void *key, u32 len, u32 seed) { } -#endif /* ^__x86_64__ */ + #endif /* ^__x86_64__ */ +#endif #endif /* !_HAVE_HASH_H */ |