1 | #[cfg (not(any(Py_LIMITED_API, PyPy)))] |
2 | use crate::pyport::{Py_hash_t, Py_ssize_t}; |
3 | #[cfg (not(any(Py_LIMITED_API, PyPy)))] |
4 | use std::os::raw::{c_char, c_void}; |
5 | |
6 | use std::os::raw::{c_int, c_ulong}; |
7 | |
8 | extern "C" { |
9 | // skipped non-limited _Py_HashDouble |
10 | // skipped non-limited _Py_HashPointer |
11 | // skipped non-limited _Py_HashPointerRaw |
12 | |
13 | #[cfg (not(any(Py_LIMITED_API, PyPy)))] |
14 | pub fn _Py_HashBytes(src: *const c_void, len: Py_ssize_t) -> Py_hash_t; |
15 | } |
16 | |
17 | pub const _PyHASH_MULTIPLIER: c_ulong = 1000003; |
18 | |
19 | // skipped _PyHASH_BITS |
20 | |
21 | // skipped non-limited _Py_HashSecret_t |
22 | |
23 | #[cfg (not(any(Py_LIMITED_API, PyPy)))] |
24 | #[repr (C)] |
25 | #[derive (Copy, Clone)] |
26 | pub struct PyHash_FuncDef { |
27 | pub hash: Option<extern "C" fn(arg1: *const c_void, arg2: Py_ssize_t) -> Py_hash_t>, |
28 | pub name: *const c_char, |
29 | pub hash_bits: c_int, |
30 | pub seed_bits: c_int, |
31 | } |
32 | |
33 | #[cfg (not(any(Py_LIMITED_API, PyPy)))] |
34 | impl Default for PyHash_FuncDef { |
35 | #[inline ] |
36 | fn default() -> Self { |
37 | unsafe { std::mem::zeroed() } |
38 | } |
39 | } |
40 | |
41 | extern "C" { |
42 | #[cfg (not(any(Py_LIMITED_API, PyPy)))] |
43 | pub fn PyHash_GetFuncDef() -> *mut PyHash_FuncDef; |
44 | } |
45 | |
46 | // skipped Py_HASH_CUTOFF |
47 | |
48 | pub const Py_HASH_EXTERNAL: c_int = 0; |
49 | pub const Py_HASH_SIPHASH24: c_int = 1; |
50 | pub const Py_HASH_FNV: c_int = 2; |
51 | |
52 | // skipped Py_HASH_ALGORITHM |
53 | |