123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- #ifndef Py_HASH_H
- #define Py_HASH_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifndef Py_LIMITED_API
- PyAPI_FUNC(Py_hash_t) _Py_HashDouble(double);
- PyAPI_FUNC(Py_hash_t) _Py_HashPointer(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_NAN 0
- #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;
- #ifdef PY_UINT64_T
-
- struct {
- PY_UINT64_T k0;
- PY_UINT64_T k1;
- } siphash;
- #endif
-
- 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;
- #endif
- #ifdef Py_DEBUG
- PyAPI_DATA(int) _Py_HashSecret_Initialized;
- #endif
- #ifndef Py_LIMITED_API
- 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
- #ifndef Py_HASH_ALGORITHM
- # if (defined(PY_UINT64_T) && defined(PY_UINT32_T) \
- && !defined(HAVE_ALIGNED_REQUIRED))
- # define Py_HASH_ALGORITHM Py_HASH_SIPHASH24
- # else
- # define Py_HASH_ALGORITHM Py_HASH_FNV
- # endif
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|