(root)/
Python-3.12.0/
Include/
longobject.h
       1  #ifndef Py_LONGOBJECT_H
       2  #define Py_LONGOBJECT_H
       3  #ifdef __cplusplus
       4  extern "C" {
       5  #endif
       6  
       7  
       8  /* Long (arbitrary precision) integer object interface */
       9  
      10  PyAPI_DATA(PyTypeObject) PyLong_Type;
      11  
      12  #define PyLong_Check(op) \
      13          PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
      14  #define PyLong_CheckExact(op) Py_IS_TYPE((op), &PyLong_Type)
      15  
      16  PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
      17  PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
      18  PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
      19  PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
      20  PyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
      21  PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
      22  PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *);
      23  PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *);
      24  PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
      25  PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
      26  PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
      27  PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
      28  
      29  /* It may be useful in the future. I've added it in the PyInt -> PyLong
      30     cleanup to keep the extra information. [CH] */
      31  #define PyLong_AS_LONG(op) PyLong_AsLong(op)
      32  
      33  /* Issue #1983: pid_t can be longer than a C long on some systems */
      34  #if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT
      35  #define _Py_PARSE_PID "i"
      36  #define PyLong_FromPid PyLong_FromLong
      37  #define PyLong_AsPid PyLong_AsLong
      38  #elif SIZEOF_PID_T == SIZEOF_LONG
      39  #define _Py_PARSE_PID "l"
      40  #define PyLong_FromPid PyLong_FromLong
      41  #define PyLong_AsPid PyLong_AsLong
      42  #elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG
      43  #define _Py_PARSE_PID "L"
      44  #define PyLong_FromPid PyLong_FromLongLong
      45  #define PyLong_AsPid PyLong_AsLongLong
      46  #else
      47  #error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)"
      48  #endif /* SIZEOF_PID_T */
      49  
      50  #if SIZEOF_VOID_P == SIZEOF_INT
      51  #  define _Py_PARSE_INTPTR "i"
      52  #  define _Py_PARSE_UINTPTR "I"
      53  #elif SIZEOF_VOID_P == SIZEOF_LONG
      54  #  define _Py_PARSE_INTPTR "l"
      55  #  define _Py_PARSE_UINTPTR "k"
      56  #elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
      57  #  define _Py_PARSE_INTPTR "L"
      58  #  define _Py_PARSE_UINTPTR "K"
      59  #else
      60  #  error "void* different in size from int, long and long long"
      61  #endif /* SIZEOF_VOID_P */
      62  
      63  PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
      64  PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
      65  PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
      66  
      67  PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long);
      68  PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long);
      69  PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *);
      70  PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *);
      71  PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *);
      72  PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
      73  
      74  PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
      75  
      76  /* These aren't really part of the int object, but they're handy. The
      77     functions are in Python/mystrtoul.c.
      78   */
      79  PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
      80  PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
      81  
      82  #ifndef Py_LIMITED_API
      83  #  define Py_CPYTHON_LONGOBJECT_H
      84  #  include "cpython/longobject.h"
      85  #  undef Py_CPYTHON_LONGOBJECT_H
      86  #endif
      87  
      88  #ifdef __cplusplus
      89  }
      90  #endif
      91  #endif /* !Py_LONGOBJECT_H */