| #ifndef Py_HASH_H
|
|
|
| #define Py_HASH_H
|
| #ifdef __cplusplus
|
| extern "C" {
|
| #endif
|
|
|
|
|
| #ifndef Py_LIMITED_API
|
| PyAPI_FUNC(Py_hash_t) _Py_HashDouble(PyObject *, double);
|
| PyAPI_FUNC(Py_hash_t) _Py_HashPointer(const void*);
|
|
|
| PyAPI_FUNC(Py_hash_t) _Py_HashPointerRaw(const void*);
|
| PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void*, Py_ssize_t);
|
| #endif
|
|
|
|
|
| #define _PyHASH_MULTIPLIER 1000003UL
|
|
|
| |
| |
|
|
|
|
| #if SIZEOF_VOID_P >= 8
|
| # define _PyHASH_BITS 61
|
| #else
|
| # define _PyHASH_BITS 31
|
| #endif
|
|
|
| #define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1)
|
| #define _PyHASH_INF 314159
|
| #define _PyHASH_IMAG _PyHASH_MULTIPLIER
|
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef Py_LIMITED_API
|
| typedef union {
|
|
|
| unsigned char uc[24];
|
|
|
| struct {
|
| Py_hash_t prefix;
|
| Py_hash_t suffix;
|
| } fnv;
|
|
|
| struct {
|
| uint64_t k0;
|
| uint64_t k1;
|
| } siphash;
|
|
|
| struct {
|
| unsigned char padding[16];
|
| Py_hash_t suffix;
|
| } djbx33a;
|
| struct {
|
| unsigned char padding[16];
|
| Py_hash_t hashsalt;
|
| } expat;
|
| } _Py_HashSecret_t;
|
| PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret;
|
|
|
| #ifdef Py_DEBUG
|
| PyAPI_DATA(int) _Py_HashSecret_Initialized;
|
| #endif
|
|
|
|
|
|
|
| typedef struct {
|
| Py_hash_t (*const hash)(const void *, Py_ssize_t);
|
| const char *name;
|
| const int hash_bits;
|
| const int seed_bits;
|
| } PyHash_FuncDef;
|
|
|
| PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
|
| #endif
|
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #ifndef Py_HASH_CUTOFF
|
| # define Py_HASH_CUTOFF 0
|
| #elif (Py_HASH_CUTOFF > 7 || Py_HASH_CUTOFF < 0)
|
| # error Py_HASH_CUTOFF must in range 0...7.
|
| #endif
|
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #define Py_HASH_EXTERNAL 0
|
| #define Py_HASH_SIPHASH24 1
|
| #define Py_HASH_FNV 2
|
| #define Py_HASH_SIPHASH13 3
|
|
|
| #ifndef Py_HASH_ALGORITHM
|
| # ifndef HAVE_ALIGNED_REQUIRED
|
| # define Py_HASH_ALGORITHM Py_HASH_SIPHASH13
|
| # else
|
| # define Py_HASH_ALGORITHM Py_HASH_FNV
|
| # endif
|
| #endif
|
|
|
| #ifdef __cplusplus
|
| }
|
| #endif
|
|
|
| #endif
|
|
|