17db96d56Sopenharmony_ci#ifndef Py_CPYTHON_LONGOBJECT_H
27db96d56Sopenharmony_ci#  error "this header file must not be included directly"
37db96d56Sopenharmony_ci#endif
47db96d56Sopenharmony_ci
57db96d56Sopenharmony_ciPyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
67db96d56Sopenharmony_ci
77db96d56Sopenharmony_ciPyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *);
87db96d56Sopenharmony_ciPyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *);
97db96d56Sopenharmony_ciPyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *);
107db96d56Sopenharmony_ciPyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *);
117db96d56Sopenharmony_ciPyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
127db96d56Sopenharmony_ci
137db96d56Sopenharmony_ci/* _PyLong_Frexp returns a double x and an exponent e such that the
147db96d56Sopenharmony_ci   true value is approximately equal to x * 2**e.  e is >= 0.  x is
157db96d56Sopenharmony_ci   0.0 if and only if the input is 0 (in which case, e and x are both
167db96d56Sopenharmony_ci   zeroes); otherwise, 0.5 <= abs(x) < 1.0.  On overflow, which is
177db96d56Sopenharmony_ci   possible if the number of bits doesn't fit into a Py_ssize_t, sets
187db96d56Sopenharmony_ci   OverflowError and returns -1.0 for x, 0 for e. */
197db96d56Sopenharmony_ciPyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
207db96d56Sopenharmony_ci
217db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
227db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int);
237db96d56Sopenharmony_ci
247db96d56Sopenharmony_ci/* _PyLong_Sign.  Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
257db96d56Sopenharmony_ci   v must not be NULL, and must be a normalized long.
267db96d56Sopenharmony_ci   There are no error cases.
277db96d56Sopenharmony_ci*/
287db96d56Sopenharmony_ciPyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
297db96d56Sopenharmony_ci
307db96d56Sopenharmony_ci/* _PyLong_NumBits.  Return the number of bits needed to represent the
317db96d56Sopenharmony_ci   absolute value of a long.  For example, this returns 1 for 1 and -1, 2
327db96d56Sopenharmony_ci   for 2 and -2, and 2 for 3 and -3.  It returns 0 for 0.
337db96d56Sopenharmony_ci   v must not be NULL, and must be a normalized long.
347db96d56Sopenharmony_ci   (size_t)-1 is returned and OverflowError set if the true result doesn't
357db96d56Sopenharmony_ci   fit in a size_t.
367db96d56Sopenharmony_ci*/
377db96d56Sopenharmony_ciPyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
387db96d56Sopenharmony_ci
397db96d56Sopenharmony_ci/* _PyLong_DivmodNear.  Given integers a and b, compute the nearest
407db96d56Sopenharmony_ci   integer q to the exact quotient a / b, rounding to the nearest even integer
417db96d56Sopenharmony_ci   in the case of a tie.  Return (q, r), where r = a - q*b.  The remainder r
427db96d56Sopenharmony_ci   will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
437db96d56Sopenharmony_ci   even.
447db96d56Sopenharmony_ci*/
457db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *);
467db96d56Sopenharmony_ci
477db96d56Sopenharmony_ci/* _PyLong_FromByteArray:  View the n unsigned bytes as a binary integer in
487db96d56Sopenharmony_ci   base 256, and return a Python int with the same numeric value.
497db96d56Sopenharmony_ci   If n is 0, the integer is 0.  Else:
507db96d56Sopenharmony_ci   If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB;
517db96d56Sopenharmony_ci   else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the
527db96d56Sopenharmony_ci   LSB.
537db96d56Sopenharmony_ci   If is_signed is 0/false, view the bytes as a non-negative integer.
547db96d56Sopenharmony_ci   If is_signed is 1/true, view the bytes as a 2's-complement integer,
557db96d56Sopenharmony_ci   non-negative if bit 0x80 of the MSB is clear, negative if set.
567db96d56Sopenharmony_ci   Error returns:
577db96d56Sopenharmony_ci   + Return NULL with the appropriate exception set if there's not
587db96d56Sopenharmony_ci     enough memory to create the Python int.
597db96d56Sopenharmony_ci*/
607db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
617db96d56Sopenharmony_ci    const unsigned char* bytes, size_t n,
627db96d56Sopenharmony_ci    int little_endian, int is_signed);
637db96d56Sopenharmony_ci
647db96d56Sopenharmony_ci/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long
657db96d56Sopenharmony_ci   v to a base-256 integer, stored in array bytes.  Normally return 0,
667db96d56Sopenharmony_ci   return -1 on error.
677db96d56Sopenharmony_ci   If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at
687db96d56Sopenharmony_ci   bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and
697db96d56Sopenharmony_ci   the LSB at bytes[n-1].
707db96d56Sopenharmony_ci   If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes
717db96d56Sopenharmony_ci   are filled and there's nothing special about bit 0x80 of the MSB.
727db96d56Sopenharmony_ci   If is_signed is 1/true, bytes is filled with the 2's-complement
737db96d56Sopenharmony_ci   representation of v's value.  Bit 0x80 of the MSB is the sign bit.
747db96d56Sopenharmony_ci   Error returns (-1):
757db96d56Sopenharmony_ci   + is_signed is 0 and v < 0.  TypeError is set in this case, and bytes
767db96d56Sopenharmony_ci     isn't altered.
777db96d56Sopenharmony_ci   + n isn't big enough to hold the full mathematical value of v.  For
787db96d56Sopenharmony_ci     example, if is_signed is 0 and there are more digits in the v than
797db96d56Sopenharmony_ci     fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of
807db96d56Sopenharmony_ci     being large enough to hold a sign bit.  OverflowError is set in this
817db96d56Sopenharmony_ci     case, but bytes holds the least-significant n bytes of the true value.
827db96d56Sopenharmony_ci*/
837db96d56Sopenharmony_ciPyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
847db96d56Sopenharmony_ci    unsigned char* bytes, size_t n,
857db96d56Sopenharmony_ci    int little_endian, int is_signed);
867db96d56Sopenharmony_ci
877db96d56Sopenharmony_ci/* _PyLong_Format: Convert the long to a string object with given base,
887db96d56Sopenharmony_ci   appending a base prefix of 0[box] if base is 2, 8 or 16. */
897db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *obj, int base);
907db96d56Sopenharmony_ci
917db96d56Sopenharmony_ci/* For use by the gcd function in mathmodule.c */
927db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
937db96d56Sopenharmony_ci
947db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) _PyLong_Rshift(PyObject *, size_t);
957db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) _PyLong_Lshift(PyObject *, size_t);
96