Skip to content

Commit 47ff073

Browse files
committed
more PY_LONG_LONG to long long
1 parent c71ec8a commit 47ff073

File tree

19 files changed

+81
-281
lines changed

19 files changed

+81
-281
lines changed

Doc/c-api/arg.rst

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,12 @@ Numbers
265265
Convert a Python integer to a C :c:type:`unsigned long` without
266266
overflow checking.
267267

268-
``L`` (:class:`int`) [PY_LONG_LONG]
269-
Convert a Python integer to a C :c:type:`long long`. This format is only
270-
available on platforms that support :c:type:`long long` (or :c:type:`_int64` on
271-
Windows).
268+
``L`` (:class:`int`) [long long]
269+
Convert a Python integer to a C :c:type:`long long`.
272270

273-
``K`` (:class:`int`) [unsigned PY_LONG_LONG]
271+
``K`` (:class:`int`) [unsigned long long]
274272
Convert a Python integer to a C :c:type:`unsigned long long`
275-
without overflow checking. This format is only available on platforms that
276-
support :c:type:`unsigned long long` (or :c:type:`unsigned _int64` on Windows).
273+
without overflow checking.
277274

278275
``n`` (:class:`int`) [Py_ssize_t]
279276
Convert a Python integer to a C :c:type:`Py_ssize_t`.
@@ -594,15 +591,11 @@ Building values
594591
``k`` (:class:`int`) [unsigned long]
595592
Convert a C :c:type:`unsigned long` to a Python integer object.
596593
597-
``L`` (:class:`int`) [PY_LONG_LONG]
598-
Convert a C :c:type:`long long` to a Python integer object. Only available
599-
on platforms that support :c:type:`long long` (or :c:type:`_int64` on
600-
Windows).
594+
``L`` (:class:`int`) [long long]
595+
Convert a C :c:type:`long long` to a Python integer object.
601596
602-
``K`` (:class:`int`) [unsigned PY_LONG_LONG]
603-
Convert a C :c:type:`unsigned long long` to a Python integer object. Only
604-
available on platforms that support :c:type:`unsigned long long` (or
605-
:c:type:`unsigned _int64` on Windows).
597+
``K`` (:class:`int`) [unsigned long long]
598+
Convert a C :c:type:`unsigned long long` to a Python integer object.
606599
607600
``n`` (:class:`int`) [Py_ssize_t]
608601
Convert a C :c:type:`Py_ssize_t` to a Python integer.

Doc/c-api/long.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ All integers are implemented as "long" integer objects of arbitrary size.
6262
*NULL* on failure.
6363
6464
65-
.. c:function:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v)
65+
.. c:function:: PyObject* PyLong_FromLongLong(long long v)
6666
6767
Return a new :c:type:`PyLongObject` object from a C :c:type:`long long`, or *NULL*
6868
on failure.
6969
7070
71-
.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v)
71+
.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned long long v)
7272
7373
Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long long`,
7474
or *NULL* on failure.
@@ -148,7 +148,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
148148
occurs set *\*overflow* to ``0`` and return ``-1`` as usual.
149149
150150
151-
.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *obj)
151+
.. c:function:: long long PyLong_AsLongLong(PyObject *obj)
152152
153153
.. index::
154154
single: OverflowError (built-in exception)
@@ -161,7 +161,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
161161
:c:type:`long`.
162162
163163
164-
.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
164+
.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
165165
166166
Return a C :c:type:`long long` representation of *obj*. If *obj* is not an
167167
instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method
@@ -210,16 +210,16 @@ All integers are implemented as "long" integer objects of arbitrary size.
210210
:c:type:`size_t`.
211211
212212
213-
.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
213+
.. c:function:: unsigned long long PyLong_AsUnsignedLongLong(PyObject *pylong)
214214
215215
.. index::
216216
single: OverflowError (built-in exception)
217217
218-
Return a C :c:type:`unsigned PY_LONG_LONG` representation of *pylong*.
219-
*pylong* must be an instance of :c:type:`PyLongObject`.
218+
Return a C :c:type:`unsigned long long` representation of *pylong*. *pylong*
219+
must be an instance of :c:type:`PyLongObject`.
220220
221221
Raise :exc:`OverflowError` if the value of *pylong* is out of range for an
222-
:c:type:`unsigned PY_LONG_LONG`.
222+
:c:type:`unsigned long long`.
223223
224224
.. versionchanged:: 3.1
225225
A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`.
@@ -235,7 +235,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
235235
return the reduction of that value modulo :const:`ULONG_MAX + 1`.
236236
237237
238-
.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *obj)
238+
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
239239
240240
Return a C :c:type:`unsigned long long` representation of *obj*. If *obj*
241241
is not an instance of :c:type:`PyLongObject`, first call its :meth:`__int__`

Doc/c-api/unicode.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ APIs:
440440
.. % because not all compilers support the %z width modifier -- we fake it
441441
.. % when necessary via interpolating PY_FORMAT_SIZE_T.
442442
.. % Similar comments apply to the %ll width modifier and
443-
.. % PY_FORMAT_LONG_LONG.
444443
445444
.. tabularcolumns:: |l|l|L|
446445

Include/pyport.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,10 @@ Used in: Py_SAFE_DOWNCAST
3939

4040
#ifndef PY_LONG_LONG
4141
#define PY_LONG_LONG long long
42-
#if defined(LLONG_MAX)
4342
/* If LLONG_MAX is defined in limits.h, use that. */
4443
#define PY_LLONG_MIN LLONG_MIN
4544
#define PY_LLONG_MAX LLONG_MAX
4645
#define PY_ULLONG_MAX ULLONG_MAX
47-
#elif defined(__LONG_LONG_MAX__)
48-
/* Otherwise, if GCC has a builtin define, use that. (Definition of
49-
* PY_LLONG_MIN assumes two's complement with no trap representation.) */
50-
#define PY_LLONG_MAX __LONG_LONG_MAX__
51-
#define PY_LLONG_MIN (-PY_LLONG_MAX - 1)
52-
#define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1)
53-
#elif defined(SIZEOF_LONG_LONG)
54-
/* Otherwise compute from SIZEOF_LONG_LONG, assuming two's complement, no
55-
padding bits, and no trap representation. Note: PY_ULLONG_MAX was
56-
previously #defined as (~0ULL) here; but that'll give the wrong value in a
57-
preprocessor expression on systems where long long != intmax_t. */
58-
#define PY_LLONG_MAX \
59-
(1 + 2 * ((Py_LL(1) << (CHAR_BIT * SIZEOF_LONG_LONG - 2)) - 1))
60-
#define PY_LLONG_MIN (-PY_LLONG_MAX - 1)
61-
#define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1)
62-
#endif /* LLONG_MAX */
6346
#endif
6447

6548
#define PY_UINT32_T uint32_t
@@ -159,19 +142,6 @@ typedef int Py_ssize_clean_t;
159142
# endif
160143
#endif
161144

162-
/* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for
163-
* the long long type instead of the size_t type. The "high level" Python format
164-
* functions listed above will interpret "lld" or "llu" correctly on
165-
* all platforms.
166-
*/
167-
#ifndef PY_FORMAT_LONG_LONG
168-
# ifdef MS_WINDOWS
169-
# define PY_FORMAT_LONG_LONG "I64"
170-
# else
171-
# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG"
172-
# endif
173-
#endif
174-
175145
/* Py_LOCAL can be used instead of static to get the fastest possible calling
176146
* convention for functions that are local to a given module.
177147
*

Lib/test/test_getargs2.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
# Skip this test if the _testcapi module isn't available.
66
support.import_module('_testcapi')
77
from _testcapi import getargs_keywords, getargs_keyword_only
8-
try:
9-
from _testcapi import getargs_L, getargs_K
10-
except ImportError:
11-
getargs_L = None # PY_LONG_LONG not available
128

139
# > How about the following counterproposal. This also changes some of
1410
# > the other format codes to be a little more regular.
@@ -309,7 +305,6 @@ def test_n(self):
309305
self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
310306

311307

312-
@unittest.skipIf(getargs_L is None, 'PY_LONG_LONG is not available')
313308
class LongLong_TestCase(unittest.TestCase):
314309
def test_L(self):
315310
from _testcapi import getargs_L

Modules/_blake2/blake2b_impl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
100100
Py_buffer buf;
101101

102102
unsigned long leaf_size = 0;
103-
unsigned PY_LONG_LONG node_offset = 0;
103+
unsigned long long node_offset = 0;
104104

105105
self = new_BLAKE2bObject(type);
106106
if (self == NULL) {
@@ -170,7 +170,7 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
170170

171171
if (node_offset_obj != NULL) {
172172
node_offset = PyLong_AsUnsignedLongLong(node_offset_obj);
173-
if (node_offset == (unsigned PY_LONG_LONG) -1 && PyErr_Occurred()) {
173+
if (node_offset == (unsigned long long) -1 && PyErr_Occurred()) {
174174
goto error;
175175
}
176176
}

Modules/_blake2/blake2s_impl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
100100
Py_buffer buf;
101101

102102
unsigned long leaf_size = 0;
103-
unsigned PY_LONG_LONG node_offset = 0;
103+
unsigned long long node_offset = 0;
104104

105105
self = new_BLAKE2sObject(type);
106106
if (self == NULL) {
@@ -170,7 +170,7 @@ py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
170170

171171
if (node_offset_obj != NULL) {
172172
node_offset = PyLong_AsUnsignedLongLong(node_offset_obj);
173-
if (node_offset == (unsigned PY_LONG_LONG) -1 && PyErr_Occurred()) {
173+
if (node_offset == (unsigned long long) -1 && PyErr_Occurred()) {
174174
goto error;
175175
}
176176
}

Modules/_ctypes/_ctypes_test.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,15 @@ EXPORT(int) _testfunc_callback_with_pointer(int (*func)(int *))
233233
return (*func)(table);
234234
}
235235

236-
EXPORT(PY_LONG_LONG) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
237-
double d, PY_LONG_LONG q)
236+
EXPORT(long long) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
237+
double d, long long q)
238238
{
239-
return (PY_LONG_LONG)(b + h + i + l + f + d + q);
239+
return (long long)(b + h + i + l + f + d + q);
240240
}
241241

242-
EXPORT(PY_LONG_LONG) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
242+
EXPORT(long long) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
243243
{
244-
return (PY_LONG_LONG)(b + h + i + l + f + d);
244+
return (long long)(b + h + i + l + f + d);
245245
}
246246

247247
EXPORT(int) _testfunc_callback_i_if(int value, int (*func)(int))
@@ -254,10 +254,10 @@ EXPORT(int) _testfunc_callback_i_if(int value, int (*func)(int))
254254
return sum;
255255
}
256256

257-
EXPORT(PY_LONG_LONG) _testfunc_callback_q_qf(PY_LONG_LONG value,
258-
PY_LONG_LONG (*func)(PY_LONG_LONG))
257+
EXPORT(long long) _testfunc_callback_q_qf(long long value,
258+
long long (*func)(long long))
259259
{
260-
PY_LONG_LONG sum = 0;
260+
long long sum = 0;
261261

262262
while (value != 0) {
263263
sum += func(value);
@@ -381,8 +381,8 @@ EXPORT(void) _py_func(void)
381381
{
382382
}
383383

384-
EXPORT(PY_LONG_LONG) last_tf_arg_s;
385-
EXPORT(unsigned PY_LONG_LONG) last_tf_arg_u;
384+
EXPORT(long long) last_tf_arg_s;
385+
EXPORT(unsigned long long) last_tf_arg_u;
386386

387387
struct BITS {
388388
int A: 1, B:2, C:3, D:4, E: 5, F: 6, G: 7, H: 8, I: 9;
@@ -445,8 +445,8 @@ static PyMethodDef module_methods[] = {
445445
{ NULL, NULL, 0, NULL},
446446
};
447447

448-
#define S last_tf_arg_s = (PY_LONG_LONG)c
449-
#define U last_tf_arg_u = (unsigned PY_LONG_LONG)c
448+
#define S last_tf_arg_s = (long long)c
449+
#define U last_tf_arg_u = (unsigned long long)c
450450

451451
EXPORT(signed char) tf_b(signed char c) { S; return c/3; }
452452
EXPORT(unsigned char) tf_B(unsigned char c) { U; return c/3; }
@@ -456,8 +456,8 @@ EXPORT(int) tf_i(int c) { S; return c/3; }
456456
EXPORT(unsigned int) tf_I(unsigned int c) { U; return c/3; }
457457
EXPORT(long) tf_l(long c) { S; return c/3; }
458458
EXPORT(unsigned long) tf_L(unsigned long c) { U; return c/3; }
459-
EXPORT(PY_LONG_LONG) tf_q(PY_LONG_LONG c) { S; return c/3; }
460-
EXPORT(unsigned PY_LONG_LONG) tf_Q(unsigned PY_LONG_LONG c) { U; return c/3; }
459+
EXPORT(long long) tf_q(long long c) { S; return c/3; }
460+
EXPORT(unsigned long long) tf_Q(unsigned long long c) { U; return c/3; }
461461
EXPORT(float) tf_f(float c) { S; return c/3; }
462462
EXPORT(double) tf_d(double c) { S; return c/3; }
463463
EXPORT(long double) tf_D(long double c) { S; return c/3; }
@@ -471,8 +471,8 @@ EXPORT(int) __stdcall s_tf_i(int c) { S; return c/3; }
471471
EXPORT(unsigned int) __stdcall s_tf_I(unsigned int c) { U; return c/3; }
472472
EXPORT(long) __stdcall s_tf_l(long c) { S; return c/3; }
473473
EXPORT(unsigned long) __stdcall s_tf_L(unsigned long c) { U; return c/3; }
474-
EXPORT(PY_LONG_LONG) __stdcall s_tf_q(PY_LONG_LONG c) { S; return c/3; }
475-
EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_Q(unsigned PY_LONG_LONG c) { U; return c/3; }
474+
EXPORT(long long) __stdcall s_tf_q(long long c) { S; return c/3; }
475+
EXPORT(unsigned long long) __stdcall s_tf_Q(unsigned long long c) { U; return c/3; }
476476
EXPORT(float) __stdcall s_tf_f(float c) { S; return c/3; }
477477
EXPORT(double) __stdcall s_tf_d(double c) { S; return c/3; }
478478
EXPORT(long double) __stdcall s_tf_D(long double c) { S; return c/3; }
@@ -487,8 +487,8 @@ EXPORT(int) tf_bi(signed char x, int c) { S; return c/3; }
487487
EXPORT(unsigned int) tf_bI(signed char x, unsigned int c) { U; return c/3; }
488488
EXPORT(long) tf_bl(signed char x, long c) { S; return c/3; }
489489
EXPORT(unsigned long) tf_bL(signed char x, unsigned long c) { U; return c/3; }
490-
EXPORT(PY_LONG_LONG) tf_bq(signed char x, PY_LONG_LONG c) { S; return c/3; }
491-
EXPORT(unsigned PY_LONG_LONG) tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
490+
EXPORT(long long) tf_bq(signed char x, long long c) { S; return c/3; }
491+
EXPORT(unsigned long long) tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
492492
EXPORT(float) tf_bf(signed char x, float c) { S; return c/3; }
493493
EXPORT(double) tf_bd(signed char x, double c) { S; return c/3; }
494494
EXPORT(long double) tf_bD(signed char x, long double c) { S; return c/3; }
@@ -503,8 +503,8 @@ EXPORT(int) __stdcall s_tf_bi(signed char x, int c) { S; return c/3; }
503503
EXPORT(unsigned int) __stdcall s_tf_bI(signed char x, unsigned int c) { U; return c/3; }
504504
EXPORT(long) __stdcall s_tf_bl(signed char x, long c) { S; return c/3; }
505505
EXPORT(unsigned long) __stdcall s_tf_bL(signed char x, unsigned long c) { U; return c/3; }
506-
EXPORT(PY_LONG_LONG) __stdcall s_tf_bq(signed char x, PY_LONG_LONG c) { S; return c/3; }
507-
EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
506+
EXPORT(long long) __stdcall s_tf_bq(signed char x, long long c) { S; return c/3; }
507+
EXPORT(unsigned long long) __stdcall s_tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
508508
EXPORT(float) __stdcall s_tf_bf(signed char x, float c) { S; return c/3; }
509509
EXPORT(double) __stdcall s_tf_bd(signed char x, double c) { S; return c/3; }
510510
EXPORT(long double) __stdcall s_tf_bD(signed char x, long double c) { S; return c/3; }

Modules/_ctypes/callproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ union result {
591591
short h;
592592
int i;
593593
long l;
594-
PY_LONG_LONG q;
594+
long long q;
595595
long double D;
596596
double d;
597597
float f;

0 commit comments

Comments
 (0)