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