pyo3_ffi/
pyhash.rs

1#[cfg(not(any(Py_LIMITED_API, PyPy)))]
2use crate::pyport::{Py_hash_t, Py_ssize_t};
3#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
4use std::os::raw::c_char;
5#[cfg(not(any(Py_LIMITED_API, PyPy)))]
6use std::os::raw::c_void;
7
8use std::os::raw::{c_int, c_ulong};
9
10extern "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
19pub 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)]
28pub 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)))]
36impl Default for PyHash_FuncDef {
37    #[inline]
38    fn default() -> Self {
39        unsafe { std::mem::zeroed() }
40    }
41}
42
43extern "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
50pub const Py_HASH_EXTERNAL: c_int = 0;
51pub const Py_HASH_SIPHASH24: c_int = 1;
52pub const Py_HASH_FNV: c_int = 2;
53
54// skipped Py_HASH_ALGORITHM