require a long long data type (closes #27961) · pythoncapi/cpython@ed4aa83 · GitHub
Skip to content

Commit ed4aa83

Browse files
committed
require a long long data type (closes python#27961)
1 parent b3b0767 commit ed4aa83

32 files changed

Lines changed: 156 additions & 442 deletions

Doc/c-api/unicode.rst

Lines changed: 0 additions & 5 deletions

Include/longobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
8585
PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
8686
PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
8787

88-
#ifdef HAVE_LONG_LONG
8988
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG);
9089
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG);
9190
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *);
9291
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
9392
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
9493
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
95-
#endif /* HAVE_LONG_LONG */
9694

9795
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
9896
#ifndef Py_LIMITED_API

Include/pyport.h

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ HAVE_UINTPTR_T
3535
Meaning: The C9X type uintptr_t is supported by the compiler
3636
Used in: Py_uintptr_t
3737
38-
HAVE_LONG_LONG
39-
Meaning: The compiler supports the C type "long long"
40-
Used in: PY_LONG_LONG
41-
4238
**************************************************************************/
4339

4440
/* typedefs for some C9X-defined synonyms for integral types.
@@ -53,7 +49,6 @@ Used in: PY_LONG_LONG
5349
* integral synonyms. Only define the ones we actually need.
5450
*/
5551

56-
#ifdef HAVE_LONG_LONG
5752
#ifndef PY_LONG_LONG
5853
#define PY_LONG_LONG long long
5954
#if defined(LLONG_MAX)
@@ -78,7 +73,6 @@ Used in: PY_LONG_LONG
7873
#define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1)
7974
#endif /* LLONG_MAX */
8075
#endif
81-
#endif /* HAVE_LONG_LONG */
8276

8377
/* a build with 30-bit digits for Python integers needs an exact-width
8478
* 32-bit unsigned integer type to store those digits. (We could just use
@@ -161,7 +155,7 @@ typedef int Py_intptr_t;
161155
typedef unsigned long Py_uintptr_t;
162156
typedef long Py_intptr_t;
163157

164-
#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG)
158+
#elif SIZEOF_VOID_P <= SIZEOF_LONG_LONG
165159
typedef unsigned PY_LONG_LONG Py_uintptr_t;
166160
typedef PY_LONG_LONG Py_intptr_t;
167161

@@ -248,19 +242,16 @@ typedef int Py_ssize_clean_t;
248242
#endif
249243

250244
/* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for
251-
* the long long type instead of the size_t type. It's only available
252-
* when HAVE_LONG_LONG is defined. The "high level" Python format
245+
* the long long type instead of the size_t type. The "high level" Python format
253246
* functions listed above will interpret "lld" or "llu" correctly on
254247
* all platforms.
255248
*/
256-
#ifdef HAVE_LONG_LONG
257-
# ifndef PY_FORMAT_LONG_LONG
258-
# ifdef MS_WINDOWS
259-
# define PY_FORMAT_LONG_LONG "I64"
260-
# else
261-
# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG"
262-
# endif
263-
# endif
249+
#ifndef PY_FORMAT_LONG_LONG
250+
# ifdef MS_WINDOWS
251+
# define PY_FORMAT_LONG_LONG "I64"
252+
# else
253+
# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG"
254+
# endif
264255
#endif
265256

266257
/* Py_LOCAL can be used instead of static to get the fastest possible calling

Include/pythread.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,8 @@ PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
3737
module exposes a higher-level API, with timeouts expressed in seconds
3838
and floating-point numbers allowed.
3939
*/
40-
#if defined(HAVE_LONG_LONG)
4140
#define PY_TIMEOUT_T PY_LONG_LONG
4241
#define PY_TIMEOUT_MAX PY_LLONG_MAX
43-
#else
44-
#define PY_TIMEOUT_T long
45-
#define PY_TIMEOUT_MAX LONG_MAX
46-
#endif
4742

4843
/* In the NT API, the timeout is a DWORD and is expressed in milliseconds */
4944
#if defined (NT_THREADS)

Include/structmember.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ typedef struct PyMemberDef {
4949
#define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError
5050
when the value is NULL, instead of
5151
converting to None. */
52-
#ifdef HAVE_LONG_LONG
5352
#define T_LONGLONG 17
5453
#define T_ULONGLONG 18
55-
#endif /* HAVE_LONG_LONG */
5654

5755
#define T_PYSSIZET 19 /* Py_ssize_t */
5856
#define T_NONE 20 /* Value is always None */

Lib/test/test_struct.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,10 @@
1616
def iter_integer_formats(byteorders=byteorders):
1717
for code in integer_codes:
1818
for byteorder in byteorders:
19-
if (byteorder in ('', '@') and code in ('q', 'Q') and
20-
not HAVE_LONG_LONG):
21-
continue
2219
if (byteorder not in ('', '@') and code in ('n', 'N')):
2320
continue
2421
yield code, byteorder
2522

26-
# Native 'q' packing isn't available on systems that don't have the C
27-
# long long type.
28-
try:
29-
struct.pack('q', 5)
30-
except struct.error:
31-
HAVE_LONG_LONG = False
32-
else:
33-
HAVE_LONG_LONG = True
34-
3523
def string_reverse(s):
3624
return s[::-1]
3725

@@ -159,9 +147,7 @@ def test_calcsize(self):
159147
self.assertEqual(size, expected_size[code])
160148

161149
# native integer sizes
162-
native_pairs = 'bB', 'hH', 'iI', 'lL', 'nN'
163-
if HAVE_LONG_LONG:
164-
native_pairs += 'qQ',
150+
native_pairs = 'bB', 'hH', 'iI', 'lL', 'nN', 'qQ'
165151
for format_pair in native_pairs:
166152
for byteorder in '', '@':
167153
signed_size = struct.calcsize(byteorder + format_pair[0])
@@ -174,9 +160,8 @@ def test_calcsize(self):
174160
self.assertLessEqual(4, struct.calcsize('l'))
175161
self.assertLessEqual(struct.calcsize('h'), struct.calcsize('i'))
176162
self.assertLessEqual(struct.calcsize('i'), struct.calcsize('l'))
177-
if HAVE_LONG_LONG:
178-
self.assertLessEqual(8, struct.calcsize('q'))
179-
self.assertLessEqual(struct.calcsize('l'), struct.calcsize('q'))
163+
self.assertLessEqual(8, struct.calcsize('q'))
164+
self.assertLessEqual(struct.calcsize('l'), struct.calcsize('q'))
180165
self.assertGreaterEqual(struct.calcsize('n'), struct.calcsize('i'))
181166
self.assertGreaterEqual(struct.calcsize('n'), struct.calcsize('P'))
182167

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.6.0 beta 1
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #27961?: Require platforms to support ``long long``. Python hasn't
14+
compiled without ``long long`` for years, so this is basically a formality.
15+
1316
- Issue #27355: Removed support for Windows CE. It was never finished,
1417
and Windows CE is no longer a relevant platform for Python.
1518

Modules/_ctypes/_ctypes_test.c

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

236-
#ifdef HAVE_LONG_LONG
237236
EXPORT(PY_LONG_LONG) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
238237
double d, PY_LONG_LONG q)
239238
{
@@ -267,8 +266,6 @@ EXPORT(PY_LONG_LONG) _testfunc_callback_q_qf(PY_LONG_LONG value,
267266
return sum;
268267
}
269268

270-
#endif
271-
272269
typedef struct {
273270
char *name;
274271
char *value;

Modules/_ctypes/callproc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@ PyCArg_repr(PyCArgObject *self)
474474
self->tag, self->value.l);
475475
break;
476476

477-
#ifdef HAVE_LONG_LONG
478477
case 'q':
479478
case 'Q':
480479
sprintf(buffer,
@@ -485,7 +484,6 @@ PyCArg_repr(PyCArgObject *self)
485484
#endif
486485
self->tag, self->value.q);
487486
break;
488-
#endif
489487
case 'd':
490488
sprintf(buffer, "<cparam '%c' (%f)>",
491489
self->tag, self->value.d);
@@ -593,9 +591,7 @@ union result {
593591
short h;
594592
int i;
595593
long l;
596-
#ifdef HAVE_LONG_LONG
597594
PY_LONG_LONG q;
598-
#endif
599595
long double D;
600596
double d;
601597
float f;

Modules/_ctypes/cfield.c

Lines changed: 1 addition & 13 deletions

0 commit comments

Comments
 (0)