pyo3_ffi/cpython/
longintrepr.rs1use crate::{PyObject, Py_ssize_t};
2use core::ffi::{c_int, c_void};
3
4use crate::Py_uintptr_t;
5
6#[derive(Copy, Clone)]
17#[repr(C)]
18pub struct PyLongLayout {
19 pub bits_per_digit: u8,
20 pub digit_size: u8,
21 pub digits_order: i8,
22 pub digit_endianness: i8,
23}
24
25extern_libpython! {
26 pub fn PyLong_GetNativeLayout() -> *const PyLongLayout;
27}
28
29#[repr(C)]
30pub struct PyLongExport {
31 pub value: i64,
32 pub negative: u8,
33 pub ndigits: Py_ssize_t,
34 pub digits: *const c_void,
35 _reserved: Py_uintptr_t,
36}
37
38extern_libpython! {
39 pub fn PyLong_Export(obj: *mut PyObject, export_long: *mut PyLongExport) -> c_int;
40 pub fn PyLong_FreeExport(export_long: *mut PyLongExport);
41}
42
43opaque_struct!(pub PyLongWriter);
44
45extern_libpython! {
46 pub fn PyLongWriter_Create(
47 negative: c_int,
48 ndigits: Py_ssize_t,
49 digits: *mut *mut c_void,
50 ) -> *mut PyLongWriter;
51
52 pub fn PyLongWriter_Finish(writer: *mut PyLongWriter) -> *mut PyObject;
53
54 pub fn PyLongWriter_Discard(writer: *mut PyLongWriter);
55}