pyo3_ffi/cpython/
pyhash.rs1#[cfg(Py_3_14)]
2use crate::Py_ssize_t;
3#[cfg(Py_3_13)]
4use crate::{PyObject, Py_hash_t};
5#[cfg(any(Py_3_13, not(PyPy)))]
6use std::os::raw::c_void;
7#[cfg(not(PyPy))]
8use std::os::raw::{c_char, c_int};
9
10#[cfg(not(PyPy))]
11#[repr(C)]
12#[derive(Copy, Clone)]
13pub struct PyHash_FuncDef {
14 pub hash:
15 Option<extern "C" fn(arg1: *const c_void, arg2: crate::Py_ssize_t) -> crate::Py_hash_t>,
16 pub name: *const c_char,
17 pub hash_bits: c_int,
18 pub seed_bits: c_int,
19}
20
21#[cfg(not(PyPy))]
22impl Default for PyHash_FuncDef {
23 #[inline]
24 fn default() -> Self {
25 unsafe { std::mem::zeroed() }
26 }
27}
28
29extern "C" {
30 #[cfg(not(PyPy))]
31 pub fn PyHash_GetFuncDef() -> *mut PyHash_FuncDef;
32 #[cfg(Py_3_13)]
33 pub fn Py_HashPointer(ptr: *const c_void) -> Py_hash_t;
34 #[cfg(Py_3_13)]
35 pub fn PyObject_GenericHash(obj: *mut PyObject) -> Py_hash_t;
36 #[cfg(Py_3_14)]
37 pub fn Py_HashBuffer(ptr: *const c_void, len: Py_ssize_t) -> Py_hash_t;
38}