annotate Include/longobject.h @ 84007:dbfbdf2b5c19 3.3

Fix #17967: For ftp urls CWD to target instead of hopping to each directory towards target. This fixes a bug where target is accessible, but parent directories are restricted.
author Senthil Kumaran <senthil@uthcode.com>
date Sat, 01 Jun 2013 08:27:06 -0700
parents 8f10c9eae183
children ecc8512b427d d67467ff2ed5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
1 #ifndef Py_LONGOBJECT_H
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
2 #define Py_LONGOBJECT_H
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
3 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
4 extern "C" {
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
5 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
6
230
7ba9612058a4 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
7ba9612058a4 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 /* Long (arbitrary precision) integer object interface */
7ba9612058a4 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2058
diff changeset
10 typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
614
11e86270ed0d Added typedef for longobject and declarations for long_{format,scan}.
Guido van Rossum <guido@python.org>
parents: 255
diff changeset
11
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
12 PyAPI_DATA(PyTypeObject) PyLong_Type;
230
7ba9612058a4 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
40909
f2f0b41f270d Merged revisions 53875-53911 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 40626
diff changeset
14 #define PyLong_Check(op) \
72504
950678c769e6 Clean up a few tabs that went in with PEP393.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 72475
diff changeset
15 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
16 #define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type)
230
7ba9612058a4 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
18 PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
19 PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
40626
4aee3f672f77 Merged the int/long unification branch, by very crude means (sorry Thomas!).
Guido van Rossum <guido@python.org>
parents: 38301
diff changeset
20 PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
4aee3f672f77 Merged the int/long unification branch, by very crude means (sorry Thomas!).
Guido van Rossum <guido@python.org>
parents: 38301
diff changeset
21 PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
22 PyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
23 PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
44158
81e0c0e2a8c1 Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
Martin v. Löwis <martin@v.loewis.de>
parents: 44107
diff changeset
24 PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *);
40966
140f3524027f I assume this was supposed to be Py_ssize_t since there are no uses of plain ssize_t.
Neal Norwitz <nnorwitz@gmail.com>
parents: 40909
diff changeset
25 PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *);
40626
4aee3f672f77 Merged the int/long unification branch, by very crude means (sorry Thomas!).
Guido van Rossum <guido@python.org>
parents: 38301
diff changeset
26 PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
27 PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
28652
28a2975514cd SF # 595026: support for masks in getargs.c.
Thomas Heller <theller@ctypes.org>
parents: 28437
diff changeset
28 PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
81587
974ace29ee2d Issue #15989: Fix several occurrences of integer overflow
Serhiy Storchaka <storchaka@gmail.com>
parents: 68257
diff changeset
29 #ifndef Py_LIMITED_API
974ace29ee2d Issue #15989: Fix several occurrences of integer overflow
Serhiy Storchaka <storchaka@gmail.com>
parents: 68257
diff changeset
30 PyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
974ace29ee2d Issue #15989: Fix several occurrences of integer overflow
Serhiy Storchaka <storchaka@gmail.com>
parents: 68257
diff changeset
31 #endif
52215
bb5de24a343f Issue #4258: Make it possible to use 30-bit digits for PyLongs:
Mark Dickinson <dickinsm@gmail.com>
parents: 50656
diff changeset
32 PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
19671
7df300d284c6 Introduce new private API function _PyLong_AsScaledDouble. Not used yet,
Tim Peters <tim.peters@gmail.com>
parents: 19550
diff changeset
33
44099
f324631462a2 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents: 43881
diff changeset
34 /* It may be useful in the future. I've added it in the PyInt -> PyLong
f324631462a2 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents: 43881
diff changeset
35 cleanup to keep the extra information. [CH] */
f324631462a2 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents: 43881
diff changeset
36 #define PyLong_AS_LONG(op) PyLong_AsLong(op)
f324631462a2 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h
Christian Heimes <christian@cheimes.de>
parents: 43881
diff changeset
37
59605
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
38 /* Issue #1983: pid_t can be longer than a C long on some systems */
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
39 #if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT
59625
8f1993b866f7 Change PARSE_PID to _Py_PARSE_PID (cleanup for r78946).
Gregory P. Smith <greg@mad-scientist.com>
parents: 59605
diff changeset
40 #define _Py_PARSE_PID "i"
59605
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
41 #define PyLong_FromPid PyLong_FromLong
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
42 #define PyLong_AsPid PyLong_AsLong
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
43 #elif SIZEOF_PID_T == SIZEOF_LONG
59625
8f1993b866f7 Change PARSE_PID to _Py_PARSE_PID (cleanup for r78946).
Gregory P. Smith <greg@mad-scientist.com>
parents: 59605
diff changeset
44 #define _Py_PARSE_PID "l"
59605
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
45 #define PyLong_FromPid PyLong_FromLong
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
46 #define PyLong_AsPid PyLong_AsLong
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
47 #elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG
59625
8f1993b866f7 Change PARSE_PID to _Py_PARSE_PID (cleanup for r78946).
Gregory P. Smith <greg@mad-scientist.com>
parents: 59605
diff changeset
48 #define _Py_PARSE_PID "L"
59605
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
49 #define PyLong_FromPid PyLong_FromLongLong
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
50 #define PyLong_AsPid PyLong_AsLongLong
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
51 #else
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
52 #error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)"
768722b2ae0a * Replaces the internals of the subprocess module from fork through exec on
Gregory P. Smith <greg@mad-scientist.com>
parents: 58582
diff changeset
53 #endif /* SIZEOF_PID_T */
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 33540
diff changeset
54
62558
ec0fd5a6bb45 Issue #9089: Remove references to intobject.c and intobject.h from comments.
Mark Dickinson <dickinsm@gmail.com>
parents: 62154
diff changeset
55 /* Used by Python/mystrtoul.c. */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64301
diff changeset
56 #ifndef Py_LIMITED_API
50656
c7c344b63ecc Reduce the size of the _PyLong_DigitValue table.
Raymond Hettinger <python@rcn.com>
parents: 47393
diff changeset
57 PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64301
diff changeset
58 #endif
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 33540
diff changeset
59
58088
46d60e5ff103 Merged revisions 77234 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 52215
diff changeset
60 /* _PyLong_Frexp returns a double x and an exponent e such that the
46d60e5ff103 Merged revisions 77234 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 52215
diff changeset
61 true value is approximately equal to x * 2**e. e is >= 0. x is
46d60e5ff103 Merged revisions 77234 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 52215
diff changeset
62 0.0 if and only if the input is 0 (in which case, e and x are both
46d60e5ff103 Merged revisions 77234 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 52215
diff changeset
63 zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is
46d60e5ff103 Merged revisions 77234 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 52215
diff changeset
64 possible if the number of bits doesn't fit into a Py_ssize_t, sets
46d60e5ff103 Merged revisions 77234 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 52215
diff changeset
65 OverflowError and returns -1.0 for x, 0 for e. */
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64301
diff changeset
66 #ifndef Py_LIMITED_API
58088
46d60e5ff103 Merged revisions 77234 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 52215
diff changeset
67 PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64301
diff changeset
68 #endif
19671
7df300d284c6 Introduce new private API function _PyLong_AsScaledDouble. Not used yet,
Tim Peters <tim.peters@gmail.com>
parents: 19550
diff changeset
69
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
70 PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
71 PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
72 PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
614
11e86270ed0d Added typedef for longobject and declarations for long_{format,scan}.
Guido van Rossum <guido@python.org>
parents: 255
diff changeset
73
8822
bd47ee068b83 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 4870
diff changeset
74 #ifdef HAVE_LONG_LONG
28437
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27549
diff changeset
75 PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG);
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27549
diff changeset
76 PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG);
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27549
diff changeset
77 PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *);
871da703e4c0 Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.
Martin v. Löwis <martin@v.loewis.de>
parents: 27549
diff changeset
78 PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
28652
28a2975514cd SF # 595026: support for masks in getargs.c.
Thomas Heller <theller@ctypes.org>
parents: 28437
diff changeset
79 PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
58582
5893ef9a9b84 Merged revisions 77842 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 58088
diff changeset
80 PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
9044
d437b6683e24 Patch by Mark Hammond to support 64-bit ints on MS platforms.
Guido van Rossum <guido@python.org>
parents: 8822
diff changeset
81 #endif /* HAVE_LONG_LONG */
8822
bd47ee068b83 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 4870
diff changeset
82
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
83 PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64301
diff changeset
84 #ifndef Py_LIMITED_API
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 33540
diff changeset
85 PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
72475
8beaa9a37387 Implement PEP 393.
Martin v. Löwis <martin@v.loewis.de>
parents: 68257
diff changeset
86 PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64301
diff changeset
87 #endif
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
88
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64301
diff changeset
89 #ifndef Py_LIMITED_API
27549
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
90 /* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
91 v must not be NULL, and must be a normalized long.
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
92 There are no error cases.
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
93 */
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
94 PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
95
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
96
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
97 /* _PyLong_NumBits. Return the number of bits needed to represent the
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
98 absolute value of a long. For example, this returns 1 for 1 and -1, 2
7fcdeeb16ec0 _PyLong_NumBits(): The definition of this was too specific to the quirky
Tim Peters <tim.peters@gmail.com>
parents: 27487
diff changeset
99 for 2 and -2, and 2 for 3 and -3. It returns 0 for 0.
27487
0904d878b8f1 Added new private API function _PyLong_NumBits. This will be used at the
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
100 v must not be NULL, and must be a normalized long.
0904d878b8f1 Added new private API function _PyLong_NumBits. This will be used at the
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
101 (size_t)-1 is returned and OverflowError set if the true result doesn't
0904d878b8f1 Added new private API function _PyLong_NumBits. This will be used at the
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
102 fit in a size_t.
0904d878b8f1 Added new private API function _PyLong_NumBits. This will be used at the
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
103 */
0904d878b8f1 Added new private API function _PyLong_NumBits. This will be used at the
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
104 PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
0904d878b8f1 Added new private API function _PyLong_NumBits. This will be used at the
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
105
62154
0d9347934cc5 Fix naming inconsistency.
Mark Dickinson <dickinsm@gmail.com>
parents: 61924
diff changeset
106 /* _PyLong_DivmodNear. Given integers a and b, compute the nearest
61924
81a580d947ef Issue #8817: Expose round-to-nearest variant of divmod in _PyLong_Divmod_Near
Mark Dickinson <dickinsm@gmail.com>
parents: 59625
diff changeset
107 integer q to the exact quotient a / b, rounding to the nearest even integer
81a580d947ef Issue #8817: Expose round-to-nearest variant of divmod in _PyLong_Divmod_Near
Mark Dickinson <dickinsm@gmail.com>
parents: 59625
diff changeset
108 in the case of a tie. Return (q, r), where r = a - q*b. The remainder r
81a580d947ef Issue #8817: Expose round-to-nearest variant of divmod in _PyLong_Divmod_Near
Mark Dickinson <dickinsm@gmail.com>
parents: 59625
diff changeset
109 will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
81a580d947ef Issue #8817: Expose round-to-nearest variant of divmod in _PyLong_Divmod_Near
Mark Dickinson <dickinsm@gmail.com>
parents: 59625
diff changeset
110 even.
81a580d947ef Issue #8817: Expose round-to-nearest variant of divmod in _PyLong_Divmod_Near
Mark Dickinson <dickinsm@gmail.com>
parents: 59625
diff changeset
111 */
62154
0d9347934cc5 Fix naming inconsistency.
Mark Dickinson <dickinsm@gmail.com>
parents: 61924
diff changeset
112 PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *);
61924
81a580d947ef Issue #8817: Expose round-to-nearest variant of divmod in _PyLong_Divmod_Near
Mark Dickinson <dickinsm@gmail.com>
parents: 59625
diff changeset
113
18082
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
114 /* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
115 base 256, and return a Python long with the same numeric value.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
116 If n is 0, the integer is 0. Else:
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
117 If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB;
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
118 else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
119 LSB.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
120 If is_signed is 0/false, view the bytes as a non-negative integer.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
121 If is_signed is 1/true, view the bytes as a 2's-complement integer,
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
122 non-negative if bit 0x80 of the MSB is clear, negative if set.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
123 Error returns:
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
124 + Return NULL with the appropriate exception set if there's not
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
125 enough memory to create the Python long.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
126 */
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
127 PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
72504
950678c769e6 Clean up a few tabs that went in with PEP393.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 72475
diff changeset
128 const unsigned char* bytes, size_t n,
950678c769e6 Clean up a few tabs that went in with PEP393.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 72475
diff changeset
129 int little_endian, int is_signed);
18082
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
130
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
131 /* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
132 v to a base-256 integer, stored in array bytes. Normally return 0,
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
133 return -1 on error.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
134 If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
135 bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
136 the LSB at bytes[n-1].
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
137 If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
138 are filled and there's nothing special about bit 0x80 of the MSB.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
139 If is_signed is 1/true, bytes is filled with the 2's-complement
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
140 representation of v's value. Bit 0x80 of the MSB is the sign bit.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
141 Error returns (-1):
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
142 + is_signed is 0 and v < 0. TypeError is set in this case, and bytes
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
143 isn't altered.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
144 + n isn't big enough to hold the full mathematical value of v. For
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
145 example, if is_signed is 0 and there are more digits in the v than
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
146 fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
147 being large enough to hold a sign bit. OverflowError is set in this
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
148 case, but bytes holds the least-signficant n bytes of the true value.
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
149 */
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 24210
diff changeset
150 PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
72504
950678c769e6 Clean up a few tabs that went in with PEP393.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 72475
diff changeset
151 unsigned char* bytes, size_t n,
950678c769e6 Clean up a few tabs that went in with PEP393.
Ezio Melotti <ezio.melotti@gmail.com>
parents: 72475
diff changeset
152 int little_endian, int is_signed);
18082
dd09f11fa40d Two new private longobject API functions,
Tim Peters <tim.peters@gmail.com>
parents: 14869
diff changeset
153
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41587
diff changeset
154
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41587
diff changeset
155 /* _PyLong_Format: Convert the long to a string object with given base,
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41587
diff changeset
156 appending a base prefix of 0[box] if base is 2, 8 or 16. */
77223
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
157 PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *obj, int base);
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
158
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
159 PyAPI_FUNC(int) _PyLong_FormatWriter(
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
160 _PyUnicodeWriter *writer,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
161 PyObject *obj,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
162 int base,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
163 int alternate);
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41587
diff changeset
164
47393
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 44366
diff changeset
165 /* Format the object based on the format_spec, as defined in PEP 3101
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 44366
diff changeset
166 (Advanced String Formatting). */
77223
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
167 PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter(
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
168 _PyUnicodeWriter *writer,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
169 PyObject *obj,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
170 PyObject *format_spec,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
171 Py_ssize_t start,
22b56b0b8619 Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args)
Victor Stinner <victor.stinner@gmail.com>
parents: 72504
diff changeset
172 Py_ssize_t end);
66664
62b61abd02b8 Merge branches/pep-0384.
Martin v. Löwis <martin@v.loewis.de>
parents: 64301
diff changeset
173 #endif /* Py_LIMITED_API */
47393
0da27fdf0192 Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents: 44366
diff changeset
174
44107
4e1d6491367c I've moved the remains of PyInt_ to the longobject.h header file and removed the inclusing of intobject.h from Python.h. Now the intobject.h exists only to provide some aliases for porters from Python 2.x.
Christian Heimes <christian@cheimes.de>
parents: 44099
diff changeset
175 /* These aren't really part of the long object, but they're handy. The
4e1d6491367c I've moved the remains of PyInt_ to the longobject.h header file and removed the inclusing of intobject.h from Python.h. Now the intobject.h exists only to provide some aliases for porters from Python 2.x.
Christian Heimes <christian@cheimes.de>
parents: 44099
diff changeset
176 functions are in Python/mystrtoul.c.
4e1d6491367c I've moved the remains of PyInt_ to the longobject.h header file and removed the inclusing of intobject.h from Python.h. Now the intobject.h exists only to provide some aliases for porters from Python 2.x.
Christian Heimes <christian@cheimes.de>
parents: 44099
diff changeset
177 */
4e1d6491367c I've moved the remains of PyInt_ to the longobject.h header file and removed the inclusing of intobject.h from Python.h. Now the intobject.h exists only to provide some aliases for porters from Python 2.x.
Christian Heimes <christian@cheimes.de>
parents: 44099
diff changeset
178 PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int);
4e1d6491367c I've moved the remains of PyInt_ to the longobject.h header file and removed the inclusing of intobject.h from Python.h. Now the intobject.h exists only to provide some aliases for porters from Python 2.x.
Christian Heimes <christian@cheimes.de>
parents: 44099
diff changeset
179 PyAPI_FUNC(long) PyOS_strtol(char *, char **, int);
4e1d6491367c I've moved the remains of PyInt_ to the longobject.h header file and removed the inclusing of intobject.h from Python.h. Now the intobject.h exists only to provide some aliases for porters from Python 2.x.
Christian Heimes <christian@cheimes.de>
parents: 44099
diff changeset
180
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
181 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
182 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
183 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
184 #endif /* !Py_LONGOBJECT_H */