17db96d56Sopenharmony_ci#ifndef Py_LONGOBJECT_H
27db96d56Sopenharmony_ci#define Py_LONGOBJECT_H
37db96d56Sopenharmony_ci#ifdef __cplusplus
47db96d56Sopenharmony_ciextern "C" {
57db96d56Sopenharmony_ci#endif
67db96d56Sopenharmony_ci
77db96d56Sopenharmony_ci
87db96d56Sopenharmony_ci/* Long (arbitrary precision) integer object interface */
97db96d56Sopenharmony_ci
107db96d56Sopenharmony_ciPyAPI_DATA(PyTypeObject) PyLong_Type;
117db96d56Sopenharmony_ci
127db96d56Sopenharmony_ci#define PyLong_Check(op) \
137db96d56Sopenharmony_ci        PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
147db96d56Sopenharmony_ci#define PyLong_CheckExact(op) Py_IS_TYPE(op, &PyLong_Type)
157db96d56Sopenharmony_ci
167db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromLong(long);
177db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
187db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
197db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
207db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
217db96d56Sopenharmony_ciPyAPI_FUNC(long) PyLong_AsLong(PyObject *);
227db96d56Sopenharmony_ciPyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *);
237db96d56Sopenharmony_ciPyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *);
247db96d56Sopenharmony_ciPyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
257db96d56Sopenharmony_ciPyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
267db96d56Sopenharmony_ciPyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
277db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
287db96d56Sopenharmony_ci
297db96d56Sopenharmony_ci/* It may be useful in the future. I've added it in the PyInt -> PyLong
307db96d56Sopenharmony_ci   cleanup to keep the extra information. [CH] */
317db96d56Sopenharmony_ci#define PyLong_AS_LONG(op) PyLong_AsLong(op)
327db96d56Sopenharmony_ci
337db96d56Sopenharmony_ci/* Issue #1983: pid_t can be longer than a C long on some systems */
347db96d56Sopenharmony_ci#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT
357db96d56Sopenharmony_ci#define _Py_PARSE_PID "i"
367db96d56Sopenharmony_ci#define PyLong_FromPid PyLong_FromLong
377db96d56Sopenharmony_ci#define PyLong_AsPid PyLong_AsLong
387db96d56Sopenharmony_ci#elif SIZEOF_PID_T == SIZEOF_LONG
397db96d56Sopenharmony_ci#define _Py_PARSE_PID "l"
407db96d56Sopenharmony_ci#define PyLong_FromPid PyLong_FromLong
417db96d56Sopenharmony_ci#define PyLong_AsPid PyLong_AsLong
427db96d56Sopenharmony_ci#elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG
437db96d56Sopenharmony_ci#define _Py_PARSE_PID "L"
447db96d56Sopenharmony_ci#define PyLong_FromPid PyLong_FromLongLong
457db96d56Sopenharmony_ci#define PyLong_AsPid PyLong_AsLongLong
467db96d56Sopenharmony_ci#else
477db96d56Sopenharmony_ci#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)"
487db96d56Sopenharmony_ci#endif /* SIZEOF_PID_T */
497db96d56Sopenharmony_ci
507db96d56Sopenharmony_ci#if SIZEOF_VOID_P == SIZEOF_INT
517db96d56Sopenharmony_ci#  define _Py_PARSE_INTPTR "i"
527db96d56Sopenharmony_ci#  define _Py_PARSE_UINTPTR "I"
537db96d56Sopenharmony_ci#elif SIZEOF_VOID_P == SIZEOF_LONG
547db96d56Sopenharmony_ci#  define _Py_PARSE_INTPTR "l"
557db96d56Sopenharmony_ci#  define _Py_PARSE_UINTPTR "k"
567db96d56Sopenharmony_ci#elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
577db96d56Sopenharmony_ci#  define _Py_PARSE_INTPTR "L"
587db96d56Sopenharmony_ci#  define _Py_PARSE_UINTPTR "K"
597db96d56Sopenharmony_ci#else
607db96d56Sopenharmony_ci#  error "void* different in size from int, long and long long"
617db96d56Sopenharmony_ci#endif /* SIZEOF_VOID_P */
627db96d56Sopenharmony_ci
637db96d56Sopenharmony_ciPyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
647db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
657db96d56Sopenharmony_ciPyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
667db96d56Sopenharmony_ci
677db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long);
687db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long);
697db96d56Sopenharmony_ciPyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *);
707db96d56Sopenharmony_ciPyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *);
717db96d56Sopenharmony_ciPyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *);
727db96d56Sopenharmony_ciPyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
737db96d56Sopenharmony_ci
747db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
757db96d56Sopenharmony_ci
767db96d56Sopenharmony_ci/* These aren't really part of the int object, but they're handy. The
777db96d56Sopenharmony_ci   functions are in Python/mystrtoul.c.
787db96d56Sopenharmony_ci */
797db96d56Sopenharmony_ciPyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
807db96d56Sopenharmony_ciPyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
817db96d56Sopenharmony_ci
827db96d56Sopenharmony_ci#ifndef Py_LIMITED_API
837db96d56Sopenharmony_ci#  define Py_CPYTHON_LONGOBJECT_H
847db96d56Sopenharmony_ci#  include "cpython/longobject.h"
857db96d56Sopenharmony_ci#  undef Py_CPYTHON_LONGOBJECT_H
867db96d56Sopenharmony_ci#endif
877db96d56Sopenharmony_ci
887db96d56Sopenharmony_ci#ifdef __cplusplus
897db96d56Sopenharmony_ci}
907db96d56Sopenharmony_ci#endif
917db96d56Sopenharmony_ci#endif /* !Py_LONGOBJECT_H */
92