Skip to content

Commit af580df

Browse files
committed
replace PY_LONG_LONG with long long
1 parent 45c7514 commit af580df

29 files changed

+222
-234
lines changed

Include/longobject.h

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

88-
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG);
89-
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG);
90-
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *);
91-
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *);
92-
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *);
93-
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
88+
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long);
89+
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long);
90+
PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *);
91+
PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *);
92+
PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *);
93+
PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
9494

9595
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
9696
#ifndef Py_LIMITED_API

Include/pyport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ typedef unsigned long Py_uintptr_t;
156156
typedef long Py_intptr_t;
157157

158158
#elif SIZEOF_VOID_P <= SIZEOF_LONG_LONG
159-
typedef unsigned PY_LONG_LONG Py_uintptr_t;
160-
typedef PY_LONG_LONG Py_intptr_t;
159+
typedef unsigned long long Py_uintptr_t;
160+
typedef long long Py_intptr_t;
161161

162162
#else
163163
# error "Python needs a typedef for Py_uintptr_t in pyport.h."

Include/pythread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ 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-
#define PY_TIMEOUT_T PY_LONG_LONG
40+
#define PY_TIMEOUT_T long long
4141
#define PY_TIMEOUT_MAX PY_LLONG_MAX
4242

4343
/* In the NT API, the timeout is a DWORD and is expressed in milliseconds */

Include/pytime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds);
7878
((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
7979

8080
/* Create a timestamp from a number of nanoseconds. */
81-
PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(PY_LONG_LONG ns);
81+
PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(long long ns);
8282

8383
/* Convert a number of seconds (Python float or int) to a timetamp.
8484
Raise an exception and return -1 on error, return 0 on success. */

Misc/coverity_model.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#define assert(op) /* empty */
2323
typedef int sdigit;
2424
typedef long Py_ssize_t;
25-
typedef long long PY_LONG_LONG;
2625
typedef unsigned short wchar_t;
2726
typedef struct {} PyObject;
2827
typedef struct {} grammar;
@@ -63,7 +62,7 @@ PyObject *PyLong_FromLong(long ival)
6362
return NULL;
6463
}
6564

66-
PyObject *PyLong_FromLongLong(PY_LONG_LONG ival)
65+
PyObject *PyLong_FromLongLong(long long ival)
6766
{
6867
return PyLong_FromLong((long)ival);
6968
}

Modules/_datetimemodule.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4198,20 +4198,20 @@ typedef struct tm *(*TM_FUNC)(const time_t *timer);
41984198

41994199
/* As of version 2015f max fold in IANA database is
42004200
* 23 hours at 1969-09-30 13:00:00 in Kwajalein. */
4201-
static PY_LONG_LONG max_fold_seconds = 24 * 3600;
4201+
static long long max_fold_seconds = 24 * 3600;
42024202
/* NB: date(1970,1,1).toordinal() == 719163 */
4203-
static PY_LONG_LONG epoch = Py_LL(719163) * 24 * 60 * 60;
4203+
static long long epoch = Py_LL(719163) * 24 * 60 * 60;
42044204

4205-
static PY_LONG_LONG
4205+
static long long
42064206
utc_to_seconds(int year, int month, int day,
42074207
int hour, int minute, int second)
42084208
{
4209-
PY_LONG_LONG ordinal = ymd_to_ord(year, month, day);
4209+
long long ordinal = ymd_to_ord(year, month, day);
42104210
return ((ordinal * 24 + hour) * 60 + minute) * 60 + second;
42114211
}
42124212

4213-
static PY_LONG_LONG
4214-
local(PY_LONG_LONG u)
4213+
static long long
4214+
local(long long u)
42154215
{
42164216
struct tm local_time;
42174217
time_t t;
@@ -4269,7 +4269,7 @@ datetime_from_timet_and_us(PyObject *cls, TM_FUNC f, time_t timet, int us,
42694269
second = Py_MIN(59, tm->tm_sec);
42704270

42714271
if (tzinfo == Py_None && f == localtime) {
4272-
PY_LONG_LONG probe_seconds, result_seconds, transition;
4272+
long long probe_seconds, result_seconds, transition;
42734273

42744274
result_seconds = utc_to_seconds(year, month, day,
42754275
hour, minute, second);
@@ -5115,14 +5115,14 @@ local_timezone(PyDateTime_DateTime *utc_time)
51155115
return local_timezone_from_timestamp(timestamp);
51165116
}
51175117

5118-
static PY_LONG_LONG
5118+
static long long
51195119
local_to_seconds(int year, int month, int day,
51205120
int hour, int minute, int second, int fold);
51215121

51225122
static PyObject *
51235123
local_timezone_from_local(PyDateTime_DateTime *local_dt)
51245124
{
5125-
PY_LONG_LONG seconds;
5125+
long long seconds;
51265126
time_t timestamp;
51275127
seconds = local_to_seconds(GET_YEAR(local_dt),
51285128
GET_MONTH(local_dt),
@@ -5256,11 +5256,11 @@ datetime_timetuple(PyDateTime_DateTime *self)
52565256
dstflag);
52575257
}
52585258

5259-
static PY_LONG_LONG
5259+
static long long
52605260
local_to_seconds(int year, int month, int day,
52615261
int hour, int minute, int second, int fold)
52625262
{
5263-
PY_LONG_LONG t, a, b, u1, u2, t1, t2, lt;
5263+
long long t, a, b, u1, u2, t1, t2, lt;
52645264
t = utc_to_seconds(year, month, day, hour, minute, second);
52655265
/* Our goal is to solve t = local(u) for u. */
52665266
lt = local(t);
@@ -5320,7 +5320,7 @@ datetime_timestamp(PyDateTime_DateTime *self)
53205320
Py_DECREF(delta);
53215321
}
53225322
else {
5323-
PY_LONG_LONG seconds;
5323+
long long seconds;
53245324
seconds = local_to_seconds(GET_YEAR(self),
53255325
GET_MONTH(self),
53265326
GET_DAY(self),

Modules/_lsprof.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <windows.h>
1010

11-
static PY_LONG_LONG
11+
static long long
1212
hpTimer(void)
1313
{
1414
LARGE_INTEGER li;
@@ -35,11 +35,11 @@ hpTimerUnit(void)
3535
#include <sys/resource.h>
3636
#include <sys/times.h>
3737

38-
static PY_LONG_LONG
38+
static long long
3939
hpTimer(void)
4040
{
4141
struct timeval tv;
42-
PY_LONG_LONG ret;
42+
long long ret;
4343
#ifdef GETTIMEOFDAY_NO_TZ
4444
gettimeofday(&tv);
4545
#else
@@ -66,8 +66,8 @@ struct _ProfilerEntry;
6666
/* represents a function called from another function */
6767
typedef struct _ProfilerSubEntry {
6868
rotating_node_t header;
69-
PY_LONG_LONG tt;
70-
PY_LONG_LONG it;
69+
long long tt;
70+
long long it;
7171
long callcount;
7272
long recursivecallcount;
7373
long recursionLevel;
@@ -77,17 +77,17 @@ typedef struct _ProfilerSubEntry {
7777
typedef struct _ProfilerEntry {
7878
rotating_node_t header;
7979
PyObject *userObj; /* PyCodeObject, or a descriptive str for builtins */
80-
PY_LONG_LONG tt; /* total time in this entry */
81-
PY_LONG_LONG it; /* inline time in this entry (not in subcalls) */
80+
long long tt; /* total time in this entry */
81+
long long it; /* inline time in this entry (not in subcalls) */
8282
long callcount; /* how many times this was called */
8383
long recursivecallcount; /* how many times called recursively */
8484
long recursionLevel;
8585
rotating_node_t *calls;
8686
} ProfilerEntry;
8787

8888
typedef struct _ProfilerContext {
89-
PY_LONG_LONG t0;
90-
PY_LONG_LONG subt;
89+
long long t0;
90+
long long subt;
9191
struct _ProfilerContext *previous;
9292
ProfilerEntry *ctxEntry;
9393
} ProfilerContext;
@@ -117,9 +117,9 @@ static PyTypeObject PyProfiler_Type;
117117
#define DOUBLE_TIMER_PRECISION 4294967296.0
118118
static PyObject *empty_tuple;
119119

120-
static PY_LONG_LONG CallExternalTimer(ProfilerObject *pObj)
120+
static long long CallExternalTimer(ProfilerObject *pObj)
121121
{
122-
PY_LONG_LONG result;
122+
long long result;
123123
PyObject *o = PyObject_Call(pObj->externalTimer, empty_tuple, NULL);
124124
if (o == NULL) {
125125
PyErr_WriteUnraisable(pObj->externalTimer);
@@ -132,11 +132,11 @@ static PY_LONG_LONG CallExternalTimer(ProfilerObject *pObj)
132132
}
133133
else {
134134
/* interpret the result as a double measured in seconds.
135-
As the profiler works with PY_LONG_LONG internally
135+
As the profiler works with long long internally
136136
we convert it to a large integer */
137137
double val = PyFloat_AsDouble(o);
138138
/* error handling delayed to the code below */
139-
result = (PY_LONG_LONG) (val * DOUBLE_TIMER_PRECISION);
139+
result = (long long) (val * DOUBLE_TIMER_PRECISION);
140140
}
141141
Py_DECREF(o);
142142
if (PyErr_Occurred()) {
@@ -338,8 +338,8 @@ initContext(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
338338
static void
339339
Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
340340
{
341-
PY_LONG_LONG tt = CALL_TIMER(pObj) - self->t0;
342-
PY_LONG_LONG it = tt - self->subt;
341+
long long tt = CALL_TIMER(pObj) - self->t0;
342+
long long it = tt - self->subt;
343343
if (self->previous)
344344
self->previous->subt += tt;
345345
pObj->currentProfilerContext = self->previous;

Modules/_lzmamodule.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818

1919
#include <lzma.h>
2020

21-
22-
#ifndef PY_LONG_LONG
23-
#error "This module requires PY_LONG_LONG to be defined"
24-
#endif
25-
26-
2721
#ifdef WITH_THREAD
2822
#define ACQUIRE_LOCK(obj) do { \
2923
if (!PyThread_acquire_lock((obj)->lock, 0)) { \
@@ -163,7 +157,7 @@ grow_buffer(PyObject **buf, Py_ssize_t max_length)
163157
uint32_t - the "I" (unsigned int) specifier is the right size, but
164158
silently ignores overflows on conversion.
165159
166-
lzma_vli - the "K" (unsigned PY_LONG_LONG) specifier is the right
160+
lzma_vli - the "K" (unsigned long long) specifier is the right
167161
size, but like "I" it silently ignores overflows on conversion.
168162
169163
lzma_mode and lzma_match_finder - these are enumeration types, and
@@ -176,12 +170,12 @@ grow_buffer(PyObject **buf, Py_ssize_t max_length)
176170
static int \
177171
FUNCNAME(PyObject *obj, void *ptr) \
178172
{ \
179-
unsigned PY_LONG_LONG val; \
173+
unsigned long long val; \
180174
\
181175
val = PyLong_AsUnsignedLongLong(obj); \
182176
if (PyErr_Occurred()) \
183177
return 0; \
184-
if ((unsigned PY_LONG_LONG)(TYPE)val != val) { \
178+
if ((unsigned long long)(TYPE)val != val) { \
185179
PyErr_SetString(PyExc_OverflowError, \
186180
"Value too large for " #TYPE " type"); \
187181
return 0; \
@@ -398,7 +392,7 @@ parse_filter_chain_spec(lzma_filter filters[], PyObject *filterspecs)
398392
Python-level filter specifiers (represented as dicts). */
399393

400394
static int
401-
spec_add_field(PyObject *spec, _Py_Identifier *key, unsigned PY_LONG_LONG value)
395+
spec_add_field(PyObject *spec, _Py_Identifier *key, unsigned long long value)
402396
{
403397
int status;
404398
PyObject *value_object;
@@ -1441,7 +1435,7 @@ static PyModuleDef _lzmamodule = {
14411435
/* Some of our constants are more than 32 bits wide, so PyModule_AddIntConstant
14421436
would not work correctly on platforms with 32-bit longs. */
14431437
static int
1444-
module_add_int_constant(PyObject *m, const char *name, PY_LONG_LONG value)
1438+
module_add_int_constant(PyObject *m, const char *name, long long value)
14451439
{
14461440
PyObject *o = PyLong_FromLongLong(value);
14471441
if (o == NULL)

0 commit comments

Comments
 (0)