1use crate::object::*;
2use crate::pyport::Py_ssize_t;
3use libc::size_t;
4#[cfg(not(Py_LIMITED_API))]
5use std::os::raw::c_uchar;
6use std::os::raw::{c_char, c_double, c_int, c_long, c_longlong, c_ulong, c_ulonglong, c_void};
7use std::ptr::addr_of_mut;
8
9opaque_struct!(PyLongObject);
10
11#[cfg_attr(windows, link(name = "pythonXY"))]
12extern "C" {
13 #[cfg_attr(PyPy, link_name = "PyPyLong_Type")]
14 pub static mut PyLong_Type: PyTypeObject;
15}
16
17#[inline]
18pub unsafe fn PyLong_Check(op: *mut PyObject) -> c_int {
19 PyType_FastSubclass(t:Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
20}
21
22#[inline]
23pub unsafe fn PyLong_CheckExact(op: *mut PyObject) -> c_int {
24 (Py_TYPE(ob:op) == addr_of_mut!(PyLong_Type)) as c_int
25}
26
27extern "C" {
28 #[cfg_attr(PyPy, link_name = "PyPyLong_FromLong")]
29 pub fn PyLong_FromLong(arg1: c_long) -> *mut PyObject;
30 #[cfg_attr(PyPy, link_name = "PyPyLong_FromUnsignedLong")]
31 pub fn PyLong_FromUnsignedLong(arg1: c_ulong) -> *mut PyObject;
32 #[cfg_attr(PyPy, link_name = "PyPyLong_FromSize_t")]
33 pub fn PyLong_FromSize_t(arg1: size_t) -> *mut PyObject;
34 #[cfg_attr(PyPy, link_name = "PyPyLong_FromSsize_t")]
35 pub fn PyLong_FromSsize_t(arg1: Py_ssize_t) -> *mut PyObject;
36 #[cfg_attr(PyPy, link_name = "PyPyLong_FromDouble")]
37 pub fn PyLong_FromDouble(arg1: c_double) -> *mut PyObject;
38 #[cfg_attr(PyPy, link_name = "PyPyLong_AsLong")]
39 pub fn PyLong_AsLong(arg1: *mut PyObject) -> c_long;
40 #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongAndOverflow")]
41 pub fn PyLong_AsLongAndOverflow(arg1: *mut PyObject, arg2: *mut c_int) -> c_long;
42 #[cfg_attr(PyPy, link_name = "PyPyLong_AsSsize_t")]
43 pub fn PyLong_AsSsize_t(arg1: *mut PyObject) -> Py_ssize_t;
44 #[cfg_attr(PyPy, link_name = "PyPyLong_AsSize_t")]
45 pub fn PyLong_AsSize_t(arg1: *mut PyObject) -> size_t;
46 #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLong")]
47 pub fn PyLong_AsUnsignedLong(arg1: *mut PyObject) -> c_ulong;
48 #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongMask")]
49 pub fn PyLong_AsUnsignedLongMask(arg1: *mut PyObject) -> c_ulong;
50 // skipped non-limited _PyLong_AsInt
51 pub fn PyLong_GetInfo() -> *mut PyObject;
52 // skipped PyLong_AS_LONG
53
54 // skipped PyLong_FromPid
55 // skipped PyLong_AsPid
56 // skipped _Py_PARSE_INTPTR
57 // skipped _Py_PARSE_UINTPTR
58
59 // skipped non-limited _PyLong_UnsignedShort_Converter
60 // skipped non-limited _PyLong_UnsignedInt_Converter
61 // skipped non-limited _PyLong_UnsignedLong_Converter
62 // skipped non-limited _PyLong_UnsignedLongLong_Converter
63 // skipped non-limited _PyLong_Size_t_Converter
64
65 // skipped non-limited _PyLong_DigitValue
66 // skipped non-limited _PyLong_Frexp
67
68 #[cfg_attr(PyPy, link_name = "PyPyLong_AsDouble")]
69 pub fn PyLong_AsDouble(arg1: *mut PyObject) -> c_double;
70 #[cfg_attr(PyPy, link_name = "PyPyLong_FromVoidPtr")]
71 pub fn PyLong_FromVoidPtr(arg1: *mut c_void) -> *mut PyObject;
72 #[cfg_attr(PyPy, link_name = "PyPyLong_AsVoidPtr")]
73 pub fn PyLong_AsVoidPtr(arg1: *mut PyObject) -> *mut c_void;
74 #[cfg_attr(PyPy, link_name = "PyPyLong_FromLongLong")]
75 pub fn PyLong_FromLongLong(arg1: c_longlong) -> *mut PyObject;
76 #[cfg_attr(PyPy, link_name = "PyPyLong_FromUnsignedLongLong")]
77 pub fn PyLong_FromUnsignedLongLong(arg1: c_ulonglong) -> *mut PyObject;
78 #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongLong")]
79 pub fn PyLong_AsLongLong(arg1: *mut PyObject) -> c_longlong;
80 #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongLong")]
81 pub fn PyLong_AsUnsignedLongLong(arg1: *mut PyObject) -> c_ulonglong;
82 #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongLongMask")]
83 pub fn PyLong_AsUnsignedLongLongMask(arg1: *mut PyObject) -> c_ulonglong;
84 #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongLongAndOverflow")]
85 pub fn PyLong_AsLongLongAndOverflow(arg1: *mut PyObject, arg2: *mut c_int) -> c_longlong;
86 #[cfg_attr(PyPy, link_name = "PyPyLong_FromString")]
87 pub fn PyLong_FromString(
88 arg1: *const c_char,
89 arg2: *mut *mut c_char,
90 arg3: c_int,
91 ) -> *mut PyObject;
92}
93// skipped non-limited PyLong_FromUnicodeObject
94// skipped non-limited _PyLong_FromBytes
95
96#[cfg(not(Py_LIMITED_API))]
97extern "C" {
98 // skipped non-limited _PyLong_Sign
99
100 #[cfg_attr(PyPy, link_name = "_PyPyLong_NumBits")]
101 pub fn _PyLong_NumBits(obj: *mut PyObject) -> size_t;
102
103 // skipped _PyLong_DivmodNear
104
105 #[cfg_attr(PyPy, link_name = "_PyPyLong_FromByteArray")]
106 pub fn _PyLong_FromByteArray(
107 bytes: *const c_uchar,
108 n: size_t,
109 little_endian: c_int,
110 is_signed: c_int,
111 ) -> *mut PyObject;
112
113 #[cfg_attr(PyPy, link_name = "_PyPyLong_AsByteArrayO")]
114 pub fn _PyLong_AsByteArray(
115 v: *mut PyLongObject,
116 bytes: *mut c_uchar,
117 n: size_t,
118 little_endian: c_int,
119 is_signed: c_int,
120 ) -> c_int;
121}
122
123// skipped non-limited _PyLong_Format
124// skipped non-limited _PyLong_FormatWriter
125// skipped non-limited _PyLong_FormatBytesWriter
126// skipped non-limited _PyLong_FormatAdvancedWriter
127
128extern "C" {
129 pub fn PyOS_strtoul(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulong;
130 pub fn PyOS_strtol(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_long;
131}
132
133// skipped non-limited _PyLong_GCD
134// skipped non-limited _PyLong_Rshift
135// skipped non-limited _PyLong_Lshift
136