Branch data Line data Source code
1 : : // This file is a part of Julia. License is MIT: https://julialang.org/license 2 : : 3 : : #ifndef JL_HASHING_H 4 : : #define JL_HASHING_H 5 : : 6 : : #include "utils.h" 7 : : #include "dtypes.h" 8 : : #include "analyzer_annotations.h" 9 : : 10 : : #ifdef __cplusplus 11 : : extern "C" { 12 : : #endif 13 : : 14 : : uint_t nextipow2(uint_t i) JL_NOTSAFEPOINT; 15 : : uint32_t int32hash(uint32_t a) JL_NOTSAFEPOINT; 16 : : uint64_t int64hash(uint64_t key) JL_NOTSAFEPOINT; 17 : : uint32_t int64to32hash(uint64_t key) JL_NOTSAFEPOINT; 18 : : #ifdef _P64 19 : : #define inthash int64hash 20 : : #else 21 : : #define inthash int32hash 22 : : #endif 23 : : JL_DLLEXPORT uint64_t memhash(const char *buf, size_t n) JL_NOTSAFEPOINT; 24 : : JL_DLLEXPORT uint64_t memhash_seed(const char *buf, size_t n, uint32_t seed) JL_NOTSAFEPOINT; 25 : : JL_DLLEXPORT uint32_t memhash32(const char *buf, size_t n) JL_NOTSAFEPOINT; 26 : : JL_DLLEXPORT uint32_t memhash32_seed(const char *buf, size_t n, uint32_t seed) JL_NOTSAFEPOINT; 27 : : 28 : : #ifdef _P64 29 : 2377196088 : STATIC_INLINE uint64_t bitmix(uint64_t a, uint64_t b) JL_NOTSAFEPOINT 30 : : { 31 : 2377196088 : return int64hash(a^bswap_64(b)); 32 : : } 33 : : #else 34 : : STATIC_INLINE uint32_t bitmix(uint32_t a, uint32_t b) JL_NOTSAFEPOINT 35 : : { 36 : : return int64to32hash((((uint64_t)a) << 32) | (uint64_t)b); 37 : : } 38 : : #endif 39 : : #define bitmix(a, b) (bitmix)((uintptr_t)(a), (uintptr_t)(b)) 40 : : 41 : : #ifdef __cplusplus 42 : : } 43 : : #endif 44 : : 45 : : #endif