Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up ffi from pyframe to pyhash #1763

Merged
merged 1 commit into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/ffi/pyframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ opaque_struct!(PyFrameObject);
extern "C" {
pub fn PyFrame_GetLineNumber(f: *mut PyFrameObject) -> c_int;
}
// skipped PyFrame_GetLineNumber
davidhewitt marked this conversation as resolved.
Show resolved Hide resolved
// skipped PyFrame_GetCode
34 changes: 31 additions & 3 deletions src/ffi/pyhash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
#[cfg(not(Py_LIMITED_API))]
use crate::ffi::pyport::{Py_hash_t, Py_ssize_t};
use std::os::raw::{c_char, c_int, c_void};
#[cfg(not(Py_LIMITED_API))]
use std::os::raw::{c_char, c_void};

use std::os::raw::{c_int, c_ulong};

extern "C" {
// skipped non-limited _Py_HashDouble
// skipped non-limited _Py_HashPointer
// skipped non-limited _Py_HashPointerRaw

#[cfg(not(any(Py_LIMITED_API, PyPy)))]
pub fn _Py_HashBytes(src: *const c_void, len: Py_ssize_t) -> Py_hash_t;
}

pub const _PyHASH_MULTIPLIER: c_ulong = 1000003;

// skipped _PyHASH_BITS

// skipped non-limited _Py_HashSecret_t

#[cfg(not(Py_LIMITED_API))]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyHash_FuncDef {
Expand All @@ -10,6 +30,7 @@ pub struct PyHash_FuncDef {
pub seed_bits: c_int,
}

#[cfg(not(Py_LIMITED_API))]
impl Default for PyHash_FuncDef {
#[inline]
fn default() -> Self {
Expand All @@ -18,7 +39,14 @@ impl Default for PyHash_FuncDef {
}

extern "C" {
#[cfg(not(any(Py_LIMITED_API, PyPy)))]
pub fn PyHash_GetFuncDef() -> *mut PyHash_FuncDef;
#[cfg(not(PyPy))]
pub fn _Py_HashBytes(src: *const c_void, len: Py_ssize_t) -> Py_hash_t;
}

// skipped Py_HASH_CUTOFF

pub const Py_HASH_EXTERNAL: c_int = 0;
pub const Py_HASH_SIPHASH24: c_int = 1;
pub const Py_HASH_FNV: c_int = 2;

// skipped Py_HASH_ALGORITHM