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