|
|
|||
File indexing completed on 2025-11-19 09:50:54
0001 #ifndef Py_HASH_H 0002 #define Py_HASH_H 0003 #ifdef __cplusplus 0004 extern "C" { 0005 #endif 0006 0007 /* Cutoff for small string DJBX33A optimization in range [1, cutoff). 0008 * 0009 * About 50% of the strings in a typical Python application are smaller than 0010 * 6 to 7 chars. However DJBX33A is vulnerable to hash collision attacks. 0011 * NEVER use DJBX33A for long strings! 0012 * 0013 * A Py_HASH_CUTOFF of 0 disables small string optimization. 32 bit platforms 0014 * should use a smaller cutoff because it is easier to create colliding 0015 * strings. A cutoff of 7 on 64bit platforms and 5 on 32bit platforms should 0016 * provide a decent safety margin. 0017 */ 0018 #ifndef Py_HASH_CUTOFF 0019 # define Py_HASH_CUTOFF 0 0020 #elif (Py_HASH_CUTOFF > 7 || Py_HASH_CUTOFF < 0) 0021 # error Py_HASH_CUTOFF must in range 0...7. 0022 #endif /* Py_HASH_CUTOFF */ 0023 0024 0025 /* Hash algorithm selection 0026 * 0027 * The values for Py_HASH_* are hard-coded in the 0028 * configure script. 0029 * 0030 * - FNV and SIPHASH* are available on all platforms and architectures. 0031 * - With EXTERNAL embedders can provide an alternative implementation with:: 0032 * 0033 * PyHash_FuncDef PyHash_Func = {...}; 0034 * 0035 * XXX: Figure out __declspec() for extern PyHash_FuncDef. 0036 */ 0037 #define Py_HASH_EXTERNAL 0 0038 #define Py_HASH_SIPHASH24 1 0039 #define Py_HASH_FNV 2 0040 #define Py_HASH_SIPHASH13 3 0041 0042 #ifndef Py_HASH_ALGORITHM 0043 # ifndef HAVE_ALIGNED_REQUIRED 0044 # define Py_HASH_ALGORITHM Py_HASH_SIPHASH13 0045 # else 0046 # define Py_HASH_ALGORITHM Py_HASH_FNV 0047 # endif /* uint64_t && uint32_t && aligned */ 0048 #endif /* Py_HASH_ALGORITHM */ 0049 0050 #ifndef Py_LIMITED_API 0051 # define Py_CPYTHON_HASH_H 0052 # include "cpython/pyhash.h" 0053 # undef Py_CPYTHON_HASH_H 0054 #endif 0055 0056 #ifdef __cplusplus 0057 } 0058 #endif 0059 #endif // !Py_HASH_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|