From af580dff4af3cb812cdd7a229a4a65059b3bc1ee Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 6 Sep 2016 10:46:49 -0700 Subject: [PATCH] replace PY_LONG_LONG with long long --- Include/longobject.h | 12 +++--- Include/pyport.h | 4 +- Include/pythread.h | 2 +- Include/pytime.h | 2 +- Misc/coverity_model.c | 3 +- Modules/_datetimemodule.c | 24 ++++++------ Modules/_lsprof.c | 30 +++++++-------- Modules/_lzmamodule.c | 16 +++----- Modules/_struct.c | 52 ++++++++++++------------- Modules/_testcapimodule.c | 38 +++++++++---------- Modules/addrinfo.h | 4 +- Modules/arraymodule.c | 26 ++++++------- Modules/md5module.c | 2 +- Modules/mmapmodule.c | 12 +++--- Modules/posixmodule.c | 22 +++++------ Modules/resource.c | 6 +-- Modules/sha1module.c | 2 +- Modules/sha512module.c | 12 ++---- Objects/longobject.c | 80 +++++++++++++++++++-------------------- Objects/memoryobject.c | 34 ++++++++--------- Objects/rangeobject.c | 2 +- Objects/unicodeobject.c | 4 +- PC/pyconfig.h | 5 +-- Python/condvar.h | 6 +-- Python/getargs.c | 16 ++++---- Python/modsupport.c | 4 +- Python/pytime.c | 18 ++++----- Python/structmember.c | 16 ++++---- Python/thread_nt.h | 2 +- 29 files changed, 222 insertions(+), 234 deletions(-) diff --git a/Include/longobject.h b/Include/longobject.h index 6237001313e..2957f1612cd 100644 --- a/Include/longobject.h +++ b/Include/longobject.h @@ -85,12 +85,12 @@ PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); -PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG); -PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG); -PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *); -PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *); -PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *); -PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *); +PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long); +PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *); +PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *); +PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *); +PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *); PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int); #ifndef Py_LIMITED_API diff --git a/Include/pyport.h b/Include/pyport.h index b9aa70bcf3f..3d5233eb39b 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -156,8 +156,8 @@ typedef unsigned long Py_uintptr_t; typedef long Py_intptr_t; #elif SIZEOF_VOID_P <= SIZEOF_LONG_LONG -typedef unsigned PY_LONG_LONG Py_uintptr_t; -typedef PY_LONG_LONG Py_intptr_t; +typedef unsigned long long Py_uintptr_t; +typedef long long Py_intptr_t; #else # error "Python needs a typedef for Py_uintptr_t in pyport.h." diff --git a/Include/pythread.h b/Include/pythread.h index 6f3d08d3b85..459a5d516c4 100644 --- a/Include/pythread.h +++ b/Include/pythread.h @@ -37,7 +37,7 @@ PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); module exposes a higher-level API, with timeouts expressed in seconds and floating-point numbers allowed. */ -#define PY_TIMEOUT_T PY_LONG_LONG +#define PY_TIMEOUT_T long long #define PY_TIMEOUT_MAX PY_LLONG_MAX /* In the NT API, the timeout is a DWORD and is expressed in milliseconds */ diff --git a/Include/pytime.h b/Include/pytime.h index 98612e13078..859321b34d0 100644 --- a/Include/pytime.h +++ b/Include/pytime.h @@ -78,7 +78,7 @@ PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds); ((_PyTime_t)(seconds) * (1000 * 1000 * 1000)) /* Create a timestamp from a number of nanoseconds. */ -PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(PY_LONG_LONG ns); +PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(long long ns); /* Convert a number of seconds (Python float or int) to a timetamp. Raise an exception and return -1 on error, return 0 on success. */ diff --git a/Misc/coverity_model.c b/Misc/coverity_model.c index 089513a9b58..d17c6073d28 100644 --- a/Misc/coverity_model.c +++ b/Misc/coverity_model.c @@ -22,7 +22,6 @@ #define assert(op) /* empty */ typedef int sdigit; typedef long Py_ssize_t; -typedef long long PY_LONG_LONG; typedef unsigned short wchar_t; typedef struct {} PyObject; typedef struct {} grammar; @@ -63,7 +62,7 @@ PyObject *PyLong_FromLong(long ival) return NULL; } -PyObject *PyLong_FromLongLong(PY_LONG_LONG ival) +PyObject *PyLong_FromLongLong(long long ival) { return PyLong_FromLong((long)ival); } diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index b48dc2dff32..6597cb7ad57 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -4198,20 +4198,20 @@ typedef struct tm *(*TM_FUNC)(const time_t *timer); /* As of version 2015f max fold in IANA database is * 23 hours at 1969-09-30 13:00:00 in Kwajalein. */ -static PY_LONG_LONG max_fold_seconds = 24 * 3600; +static long long max_fold_seconds = 24 * 3600; /* NB: date(1970,1,1).toordinal() == 719163 */ -static PY_LONG_LONG epoch = Py_LL(719163) * 24 * 60 * 60; +static long long epoch = Py_LL(719163) * 24 * 60 * 60; -static PY_LONG_LONG +static long long utc_to_seconds(int year, int month, int day, int hour, int minute, int second) { - PY_LONG_LONG ordinal = ymd_to_ord(year, month, day); + long long ordinal = ymd_to_ord(year, month, day); return ((ordinal * 24 + hour) * 60 + minute) * 60 + second; } -static PY_LONG_LONG -local(PY_LONG_LONG u) +static long long +local(long long u) { struct tm local_time; time_t t; @@ -4269,7 +4269,7 @@ datetime_from_timet_and_us(PyObject *cls, TM_FUNC f, time_t timet, int us, second = Py_MIN(59, tm->tm_sec); if (tzinfo == Py_None && f == localtime) { - PY_LONG_LONG probe_seconds, result_seconds, transition; + long long probe_seconds, result_seconds, transition; result_seconds = utc_to_seconds(year, month, day, hour, minute, second); @@ -5115,14 +5115,14 @@ local_timezone(PyDateTime_DateTime *utc_time) return local_timezone_from_timestamp(timestamp); } -static PY_LONG_LONG +static long long local_to_seconds(int year, int month, int day, int hour, int minute, int second, int fold); static PyObject * local_timezone_from_local(PyDateTime_DateTime *local_dt) { - PY_LONG_LONG seconds; + long long seconds; time_t timestamp; seconds = local_to_seconds(GET_YEAR(local_dt), GET_MONTH(local_dt), @@ -5256,11 +5256,11 @@ datetime_timetuple(PyDateTime_DateTime *self) dstflag); } -static PY_LONG_LONG +static long long local_to_seconds(int year, int month, int day, int hour, int minute, int second, int fold) { - PY_LONG_LONG t, a, b, u1, u2, t1, t2, lt; + long long t, a, b, u1, u2, t1, t2, lt; t = utc_to_seconds(year, month, day, hour, minute, second); /* Our goal is to solve t = local(u) for u. */ lt = local(t); @@ -5320,7 +5320,7 @@ datetime_timestamp(PyDateTime_DateTime *self) Py_DECREF(delta); } else { - PY_LONG_LONG seconds; + long long seconds; seconds = local_to_seconds(GET_YEAR(self), GET_MONTH(self), GET_DAY(self), diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 788d9064e93..dc3f8ab2fac 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -8,7 +8,7 @@ #include -static PY_LONG_LONG +static long long hpTimer(void) { LARGE_INTEGER li; @@ -35,11 +35,11 @@ hpTimerUnit(void) #include #include -static PY_LONG_LONG +static long long hpTimer(void) { struct timeval tv; - PY_LONG_LONG ret; + long long ret; #ifdef GETTIMEOFDAY_NO_TZ gettimeofday(&tv); #else @@ -66,8 +66,8 @@ struct _ProfilerEntry; /* represents a function called from another function */ typedef struct _ProfilerSubEntry { rotating_node_t header; - PY_LONG_LONG tt; - PY_LONG_LONG it; + long long tt; + long long it; long callcount; long recursivecallcount; long recursionLevel; @@ -77,8 +77,8 @@ typedef struct _ProfilerSubEntry { typedef struct _ProfilerEntry { rotating_node_t header; PyObject *userObj; /* PyCodeObject, or a descriptive str for builtins */ - PY_LONG_LONG tt; /* total time in this entry */ - PY_LONG_LONG it; /* inline time in this entry (not in subcalls) */ + long long tt; /* total time in this entry */ + long long it; /* inline time in this entry (not in subcalls) */ long callcount; /* how many times this was called */ long recursivecallcount; /* how many times called recursively */ long recursionLevel; @@ -86,8 +86,8 @@ typedef struct _ProfilerEntry { } ProfilerEntry; typedef struct _ProfilerContext { - PY_LONG_LONG t0; - PY_LONG_LONG subt; + long long t0; + long long subt; struct _ProfilerContext *previous; ProfilerEntry *ctxEntry; } ProfilerContext; @@ -117,9 +117,9 @@ static PyTypeObject PyProfiler_Type; #define DOUBLE_TIMER_PRECISION 4294967296.0 static PyObject *empty_tuple; -static PY_LONG_LONG CallExternalTimer(ProfilerObject *pObj) +static long long CallExternalTimer(ProfilerObject *pObj) { - PY_LONG_LONG result; + long long result; PyObject *o = PyObject_Call(pObj->externalTimer, empty_tuple, NULL); if (o == NULL) { PyErr_WriteUnraisable(pObj->externalTimer); @@ -132,11 +132,11 @@ static PY_LONG_LONG CallExternalTimer(ProfilerObject *pObj) } else { /* interpret the result as a double measured in seconds. - As the profiler works with PY_LONG_LONG internally + As the profiler works with long long internally we convert it to a large integer */ double val = PyFloat_AsDouble(o); /* error handling delayed to the code below */ - result = (PY_LONG_LONG) (val * DOUBLE_TIMER_PRECISION); + result = (long long) (val * DOUBLE_TIMER_PRECISION); } Py_DECREF(o); if (PyErr_Occurred()) { @@ -338,8 +338,8 @@ initContext(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry) static void Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry) { - PY_LONG_LONG tt = CALL_TIMER(pObj) - self->t0; - PY_LONG_LONG it = tt - self->subt; + long long tt = CALL_TIMER(pObj) - self->t0; + long long it = tt - self->subt; if (self->previous) self->previous->subt += tt; pObj->currentProfilerContext = self->previous; diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c index ce4e17fc861..5e158fd07de 100644 --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -18,12 +18,6 @@ #include - -#ifndef PY_LONG_LONG -#error "This module requires PY_LONG_LONG to be defined" -#endif - - #ifdef WITH_THREAD #define ACQUIRE_LOCK(obj) do { \ if (!PyThread_acquire_lock((obj)->lock, 0)) { \ @@ -163,7 +157,7 @@ grow_buffer(PyObject **buf, Py_ssize_t max_length) uint32_t - the "I" (unsigned int) specifier is the right size, but silently ignores overflows on conversion. - lzma_vli - the "K" (unsigned PY_LONG_LONG) specifier is the right + lzma_vli - the "K" (unsigned long long) specifier is the right size, but like "I" it silently ignores overflows on conversion. lzma_mode and lzma_match_finder - these are enumeration types, and @@ -176,12 +170,12 @@ grow_buffer(PyObject **buf, Py_ssize_t max_length) static int \ FUNCNAME(PyObject *obj, void *ptr) \ { \ - unsigned PY_LONG_LONG val; \ + unsigned long long val; \ \ val = PyLong_AsUnsignedLongLong(obj); \ if (PyErr_Occurred()) \ return 0; \ - if ((unsigned PY_LONG_LONG)(TYPE)val != val) { \ + if ((unsigned long long)(TYPE)val != val) { \ PyErr_SetString(PyExc_OverflowError, \ "Value too large for " #TYPE " type"); \ return 0; \ @@ -398,7 +392,7 @@ parse_filter_chain_spec(lzma_filter filters[], PyObject *filterspecs) Python-level filter specifiers (represented as dicts). */ static int -spec_add_field(PyObject *spec, _Py_Identifier *key, unsigned PY_LONG_LONG value) +spec_add_field(PyObject *spec, _Py_Identifier *key, unsigned long long value) { int status; PyObject *value_object; @@ -1441,7 +1435,7 @@ static PyModuleDef _lzmamodule = { /* Some of our constants are more than 32 bits wide, so PyModule_AddIntConstant would not work correctly on platforms with 32-bit longs. */ static int -module_add_int_constant(PyObject *m, const char *name, PY_LONG_LONG value) +module_add_int_constant(PyObject *m, const char *name, long long value) { PyObject *o = PyLong_FromLongLong(value); if (o == NULL) diff --git a/Modules/_struct.c b/Modules/_struct.c index ba60ba6133c..a601f03ce75 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -71,8 +71,8 @@ typedef struct { char c; size_t x; } st_size_t; /* We can't support q and Q in native mode unless the compiler does; in std mode, they're 8 bytes on all platforms. */ -typedef struct { char c; PY_LONG_LONG x; } s_long_long; -#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) +typedef struct { char c; long long x; } s_long_long; +#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(long long)) #ifdef HAVE_C99_BOOL #define BOOL_TYPE _Bool @@ -165,9 +165,9 @@ get_ulong(PyObject *v, unsigned long *p) /* Same, but handling native long long. */ static int -get_longlong(PyObject *v, PY_LONG_LONG *p) +get_longlong(PyObject *v, long long *p) { - PY_LONG_LONG x; + long long x; v = get_pylong(v); if (v == NULL) @@ -175,7 +175,7 @@ get_longlong(PyObject *v, PY_LONG_LONG *p) assert(PyLong_Check(v)); x = PyLong_AsLongLong(v); Py_DECREF(v); - if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) { + if (x == (long long)-1 && PyErr_Occurred()) { if (PyErr_ExceptionMatches(PyExc_OverflowError)) PyErr_SetString(StructError, "argument out of range"); @@ -188,9 +188,9 @@ get_longlong(PyObject *v, PY_LONG_LONG *p) /* Same, but handling native unsigned long long. */ static int -get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) +get_ulonglong(PyObject *v, unsigned long long *p) { - unsigned PY_LONG_LONG x; + unsigned long long x; v = get_pylong(v); if (v == NULL) @@ -198,7 +198,7 @@ get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) assert(PyLong_Check(v)); x = PyLong_AsUnsignedLongLong(v); Py_DECREF(v); - if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) { + if (x == (unsigned long long)-1 && PyErr_Occurred()) { if (PyErr_ExceptionMatches(PyExc_OverflowError)) PyErr_SetString(StructError, "argument out of range"); @@ -460,20 +460,20 @@ nu_size_t(const char *p, const formatdef *f) static PyObject * nu_longlong(const char *p, const formatdef *f) { - PY_LONG_LONG x; + long long x; memcpy((char *)&x, p, sizeof x); if (x >= LONG_MIN && x <= LONG_MAX) - return PyLong_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, long long, long)); return PyLong_FromLongLong(x); } static PyObject * nu_ulonglong(const char *p, const formatdef *f) { - unsigned PY_LONG_LONG x; + unsigned long long x; memcpy((char *)&x, p, sizeof x); if (x <= LONG_MAX) - return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned long long, long)); return PyLong_FromUnsignedLongLong(x); } @@ -673,7 +673,7 @@ np_size_t(char *p, PyObject *v, const formatdef *f) static int np_longlong(char *p, PyObject *v, const formatdef *f) { - PY_LONG_LONG x; + long long x; if (get_longlong(v, &x) < 0) return -1; memcpy(p, (char *)&x, sizeof x); @@ -683,7 +683,7 @@ np_longlong(char *p, PyObject *v, const formatdef *f) static int np_ulonglong(char *p, PyObject *v, const formatdef *f) { - unsigned PY_LONG_LONG x; + unsigned long long x; if (get_ulonglong(v, &x) < 0) return -1; memcpy(p, (char *)&x, sizeof x); @@ -772,8 +772,8 @@ static const formatdef native_table[] = { {'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, {'n', sizeof(size_t), SIZE_T_ALIGN, nu_ssize_t, np_ssize_t}, {'N', sizeof(size_t), SIZE_T_ALIGN, nu_size_t, np_size_t}, - {'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong}, - {'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, + {'q', sizeof(long long), LONG_LONG_ALIGN, nu_longlong, np_longlong}, + {'Q', sizeof(long long), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong}, {'?', sizeof(BOOL_TYPE), BOOL_ALIGN, nu_bool, np_bool}, {'e', sizeof(short), SHORT_ALIGN, nu_halffloat, np_halffloat}, {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, @@ -816,7 +816,7 @@ bu_uint(const char *p, const formatdef *f) static PyObject * bu_longlong(const char *p, const formatdef *f) { - PY_LONG_LONG x = 0; + long long x = 0; Py_ssize_t i = f->size; const unsigned char *bytes = (const unsigned char *)p; do { @@ -824,23 +824,23 @@ bu_longlong(const char *p, const formatdef *f) } while (--i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) - x |= -(x & ((PY_LONG_LONG)1 << ((8 * f->size) - 1))); + x |= -(x & ((long long)1 << ((8 * f->size) - 1))); if (x >= LONG_MIN && x <= LONG_MAX) - return PyLong_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, long long, long)); return PyLong_FromLongLong(x); } static PyObject * bu_ulonglong(const char *p, const formatdef *f) { - unsigned PY_LONG_LONG x = 0; + unsigned long long x = 0; Py_ssize_t i = f->size; const unsigned char *bytes = (const unsigned char *)p; do { x = (x<<8) | *bytes++; } while (--i > 0); if (x <= LONG_MAX) - return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned long long, long)); return PyLong_FromUnsignedLongLong(x); } @@ -1043,7 +1043,7 @@ lu_uint(const char *p, const formatdef *f) static PyObject * lu_longlong(const char *p, const formatdef *f) { - PY_LONG_LONG x = 0; + long long x = 0; Py_ssize_t i = f->size; const unsigned char *bytes = (const unsigned char *)p; do { @@ -1051,23 +1051,23 @@ lu_longlong(const char *p, const formatdef *f) } while (i > 0); /* Extend the sign bit. */ if (SIZEOF_LONG_LONG > f->size) - x |= -(x & ((PY_LONG_LONG)1 << ((8 * f->size) - 1))); + x |= -(x & ((long long)1 << ((8 * f->size) - 1))); if (x >= LONG_MIN && x <= LONG_MAX) - return PyLong_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, long long, long)); return PyLong_FromLongLong(x); } static PyObject * lu_ulonglong(const char *p, const formatdef *f) { - unsigned PY_LONG_LONG x = 0; + unsigned long long x = 0; Py_ssize_t i = f->size; const unsigned char *bytes = (const unsigned char *)p; do { x = (x<<8) | bytes[--i]; } while (i > 0); if (x <= LONG_MAX) - return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned long long, long)); return PyLong_FromUnsignedLongLong(x); } diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 2fb5a14c5f7..e9a0f128856 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -60,7 +60,7 @@ test_config(PyObject *self) CHECK_SIZEOF(SIZEOF_LONG, long); CHECK_SIZEOF(SIZEOF_VOID_P, void*); CHECK_SIZEOF(SIZEOF_TIME_T, time_t); - CHECK_SIZEOF(SIZEOF_LONG_LONG, PY_LONG_LONG); + CHECK_SIZEOF(SIZEOF_LONG_LONG, long long); #undef CHECK_SIZEOF @@ -360,7 +360,7 @@ test_lazy_hash_inheritance(PyObject* self) Note that the meat of the test is contained in testcapi_long.h. This is revolting, but delicate code duplication is worse: "almost - exactly the same" code is needed to test PY_LONG_LONG, but the ubiquitous + exactly the same" code is needed to test long long, but the ubiquitous dependence on type names makes it impossible to use a parameterized function. A giant macro would be even worse than this. A C++ template would be perfect. @@ -407,7 +407,7 @@ raise_test_longlong_error(const char* msg) } #define TESTNAME test_longlong_api_inner -#define TYPENAME PY_LONG_LONG +#define TYPENAME long long #define F_S_TO_PY PyLong_FromLongLong #define F_PY_TO_S PyLong_AsLongLong #define F_U_TO_PY PyLong_FromUnsignedLongLong @@ -594,7 +594,7 @@ test_long_and_overflow(PyObject *self) } /* Test the PyLong_AsLongLongAndOverflow API. General conversion to - PY_LONG_LONG is tested by test_long_api_inner. This test will + long long is tested by test_long_api_inner. This test will concentrate on proper handling of overflow. */ @@ -602,7 +602,7 @@ static PyObject * test_long_long_and_overflow(PyObject *self) { PyObject *num, *one, *temp; - PY_LONG_LONG value; + long long value; int overflow; /* Test that overflow is set properly for a large value. */ @@ -820,7 +820,7 @@ test_long_as_double(PyObject *self) return Py_None; } -/* Test the L code for PyArg_ParseTuple. This should deliver a PY_LONG_LONG +/* Test the L code for PyArg_ParseTuple. This should deliver a long long for both long and int arguments. The test may leak a little memory if it fails. */ @@ -828,7 +828,7 @@ static PyObject * test_L_code(PyObject *self) { PyObject *tuple, *num; - PY_LONG_LONG value; + long long value; tuple = PyTuple_New(1); if (tuple == NULL) @@ -1133,7 +1133,7 @@ getargs_p(PyObject *self, PyObject *args) static PyObject * getargs_L(PyObject *self, PyObject *args) { - PY_LONG_LONG value; + long long value; if (!PyArg_ParseTuple(args, "L", &value)) return NULL; return PyLong_FromLongLong(value); @@ -1142,7 +1142,7 @@ getargs_L(PyObject *self, PyObject *args) static PyObject * getargs_K(PyObject *self, PyObject *args) { - unsigned PY_LONG_LONG value; + unsigned long long value; if (!PyArg_ParseTuple(args, "K", &value)) return NULL; return PyLong_FromUnsignedLongLong(value); @@ -2271,8 +2271,8 @@ test_string_from_format(PyObject *self, PyObject *args) CHECK_1_FORMAT("%zu", size_t); /* "%lld" and "%llu" support added in Python 2.7. */ - CHECK_1_FORMAT("%llu", unsigned PY_LONG_LONG); - CHECK_1_FORMAT("%lld", PY_LONG_LONG); + CHECK_1_FORMAT("%llu", unsigned long long); + CHECK_1_FORMAT("%lld", long long); Py_RETURN_NONE; @@ -3696,7 +3696,7 @@ test_pytime_fromsecondsobject(PyObject *self, PyObject *args) static PyObject * test_pytime_assecondsdouble(PyObject *self, PyObject *args) { - PY_LONG_LONG ns; + long long ns; _PyTime_t ts; double d; @@ -3710,7 +3710,7 @@ test_pytime_assecondsdouble(PyObject *self, PyObject *args) static PyObject * test_PyTime_AsTimeval(PyObject *self, PyObject *args) { - PY_LONG_LONG ns; + long long ns; int round; _PyTime_t t; struct timeval tv; @@ -3724,7 +3724,7 @@ test_PyTime_AsTimeval(PyObject *self, PyObject *args) if (_PyTime_AsTimeval(t, &tv, round) < 0) return NULL; - seconds = PyLong_FromLong((PY_LONG_LONG)tv.tv_sec); + seconds = PyLong_FromLong((long long)tv.tv_sec); if (seconds == NULL) return NULL; return Py_BuildValue("Nl", seconds, tv.tv_usec); @@ -3734,7 +3734,7 @@ test_PyTime_AsTimeval(PyObject *self, PyObject *args) static PyObject * test_PyTime_AsTimespec(PyObject *self, PyObject *args) { - PY_LONG_LONG ns; + long long ns; _PyTime_t t; struct timespec ts; @@ -3750,7 +3750,7 @@ test_PyTime_AsTimespec(PyObject *self, PyObject *args) static PyObject * test_PyTime_AsMilliseconds(PyObject *self, PyObject *args) { - PY_LONG_LONG ns; + long long ns; int round; _PyTime_t t, ms; @@ -3768,7 +3768,7 @@ test_PyTime_AsMilliseconds(PyObject *self, PyObject *args) static PyObject * test_PyTime_AsMicroseconds(PyObject *self, PyObject *args) { - PY_LONG_LONG ns; + long long ns; int round; _PyTime_t t, ms; @@ -4141,8 +4141,8 @@ typedef struct { float float_member; double double_member; char inplace_member[6]; - PY_LONG_LONG longlong_member; - unsigned PY_LONG_LONG ulonglong_member; + long long longlong_member; + unsigned long long ulonglong_member; } all_structmembers; typedef struct { diff --git a/Modules/addrinfo.h b/Modules/addrinfo.h index 20f76506419..c3c86248dd4 100644 --- a/Modules/addrinfo.h +++ b/Modules/addrinfo.h @@ -141,7 +141,7 @@ struct addrinfo { * RFC 2553: protocol-independent placeholder for socket addresses */ #define _SS_MAXSIZE 128 -#define _SS_ALIGNSIZE (sizeof(PY_LONG_LONG)) +#define _SS_ALIGNSIZE (sizeof(long long)) #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2) #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \ _SS_PAD1SIZE - _SS_ALIGNSIZE) @@ -154,7 +154,7 @@ struct sockaddr_storage { unsigned short ss_family; /* address family */ #endif /* HAVE_SOCKADDR_SA_LEN */ char __ss_pad1[_SS_PAD1SIZE]; - PY_LONG_LONG __ss_align; /* force desired structure storage alignment */ + long long __ss_align; /* force desired structure storage alignment */ char __ss_pad2[_SS_PAD2SIZE]; }; #endif /* !HAVE_SOCKADDR_STORAGE */ diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index 8637cb52b10..86a58d9170b 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -421,17 +421,17 @@ LL_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) static PyObject * q_getitem(arrayobject *ap, Py_ssize_t i) { - return PyLong_FromLongLong(((PY_LONG_LONG *)ap->ob_item)[i]); + return PyLong_FromLongLong(((long long *)ap->ob_item)[i]); } static int q_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) { - PY_LONG_LONG x; + long long x; if (!PyArg_Parse(v, "L;array item must be integer", &x)) return -1; if (i >= 0) - ((PY_LONG_LONG *)ap->ob_item)[i] = x; + ((long long *)ap->ob_item)[i] = x; return 0; } @@ -439,20 +439,20 @@ static PyObject * QQ_getitem(arrayobject *ap, Py_ssize_t i) { return PyLong_FromUnsignedLongLong( - ((unsigned PY_LONG_LONG *)ap->ob_item)[i]); + ((unsigned long long *)ap->ob_item)[i]); } static int QQ_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) { - unsigned PY_LONG_LONG x; + unsigned long long x; if (PyLong_Check(v)) { x = PyLong_AsUnsignedLongLong(v); - if (x == (unsigned PY_LONG_LONG) -1 && PyErr_Occurred()) + if (x == (unsigned long long) -1 && PyErr_Occurred()) return -1; } else { - PY_LONG_LONG y; + long long y; if (!PyArg_Parse(v, "L;array item must be integer", &y)) return -1; if (y < 0) { @@ -460,11 +460,11 @@ QQ_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) "unsigned long long is less than minimum"); return -1; } - x = (unsigned PY_LONG_LONG)y; + x = (unsigned long long)y; } if (i >= 0) - ((unsigned PY_LONG_LONG *)ap->ob_item)[i] = x; + ((unsigned long long *)ap->ob_item)[i] = x; return 0; } @@ -518,8 +518,8 @@ static const struct arraydescr descriptors[] = { {'I', sizeof(int), II_getitem, II_setitem, "I", 1, 0}, {'l', sizeof(long), l_getitem, l_setitem, "l", 1, 1}, {'L', sizeof(long), LL_getitem, LL_setitem, "L", 1, 0}, - {'q', sizeof(PY_LONG_LONG), q_getitem, q_setitem, "q", 1, 1}, - {'Q', sizeof(PY_LONG_LONG), QQ_getitem, QQ_setitem, "Q", 1, 0}, + {'q', sizeof(long long), q_getitem, q_setitem, "q", 1, 1}, + {'Q', sizeof(long long), QQ_getitem, QQ_setitem, "Q", 1, 0}, {'f', sizeof(float), f_getitem, f_setitem, "f", 0, 0}, {'d', sizeof(double), d_getitem, d_setitem, "d", 0, 0}, {'\0', 0, 0, 0, 0, 0, 0} /* Sentinel */ @@ -1810,11 +1810,11 @@ typecode_to_mformat_code(char typecode) is_signed = 0; break; case 'q': - intsize = sizeof(PY_LONG_LONG); + intsize = sizeof(long long); is_signed = 1; break; case 'Q': - intsize = sizeof(PY_LONG_LONG); + intsize = sizeof(long long); is_signed = 0; break; default: diff --git a/Modules/md5module.c b/Modules/md5module.c index f94acc75130..04bc06e4b78 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -30,7 +30,7 @@ class MD5Type "MD5object *" "&PyType_Type" #if SIZEOF_INT == 4 typedef unsigned int MD5_INT32; /* 32-bit integer */ -typedef PY_LONG_LONG MD5_INT64; /* 64-bit integer */ +typedef long long MD5_INT64; /* 64-bit integer */ #else /* not defined. compilation will die. */ #endif diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 50cec2498d8..b0015a5756f 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -93,7 +93,7 @@ typedef struct { size_t size; size_t pos; /* relative to offset */ #ifdef MS_WINDOWS - PY_LONG_LONG offset; + long long offset; #else off_t offset; #endif @@ -446,7 +446,7 @@ mmap_size_method(mmap_object *self, #ifdef MS_WINDOWS if (self->file_handle != INVALID_HANDLE_VALUE) { DWORD low,high; - PY_LONG_LONG size; + long long size; low = GetFileSize(self->file_handle, &high); if (low == INVALID_FILE_SIZE) { /* It might be that the function appears to have failed, @@ -457,7 +457,7 @@ mmap_size_method(mmap_object *self, } if (!high && low < LONG_MAX) return PyLong_FromLong((long)low); - size = (((PY_LONG_LONG)high)<<32) + low; + size = (((long long)high)<<32) + low; return PyLong_FromLongLong(size); } else { return PyLong_FromSsize_t(self->size); @@ -1258,7 +1258,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) /* A note on sizes and offsets: while the actual map size must hold in a Py_ssize_t, both the total file size and the start offset can be longer - than a Py_ssize_t, so we use PY_LONG_LONG which is always 64-bit. + than a Py_ssize_t, so we use long long which is always 64-bit. */ static PyObject * @@ -1267,7 +1267,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) mmap_object *m_obj; PyObject *map_size_obj = NULL; Py_ssize_t map_size; - PY_LONG_LONG offset = 0, size; + long long offset = 0, size; DWORD off_hi; /* upper 32 bits of offset */ DWORD off_lo; /* lower 32 bits of offset */ DWORD size_hi; /* upper 32 bits of size */ @@ -1379,7 +1379,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) return PyErr_SetFromWindowsErr(dwErr); } - size = (((PY_LONG_LONG) high) << 32) + low; + size = (((long long) high) << 32) + low; if (size == 0) { PyErr_SetString(PyExc_ValueError, "cannot mmap an empty file"); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 21d91b03df6..df295c25b66 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1108,7 +1108,7 @@ dir_fd_and_follow_symlinks_invalid(const char *function_name, int dir_fd, } #ifdef MS_WINDOWS - typedef PY_LONG_LONG Py_off_t; + typedef long long Py_off_t; #else typedef off_t Py_off_t; #endif @@ -2073,7 +2073,7 @@ _pystat_fromstructstat(STRUCT_STAT *st) PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode)); #ifdef HAVE_LARGEFILE_SUPPORT PyStructSequence_SET_ITEM(v, 1, - PyLong_FromLongLong((PY_LONG_LONG)st->st_ino)); + PyLong_FromLongLong((long long)st->st_ino)); #else PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino)); #endif @@ -2092,7 +2092,7 @@ _pystat_fromstructstat(STRUCT_STAT *st) #endif #ifdef HAVE_LARGEFILE_SUPPORT PyStructSequence_SET_ITEM(v, 6, - PyLong_FromLongLong((PY_LONG_LONG)st->st_size)); + PyLong_FromLongLong((long long)st->st_size)); #else PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong(st->st_size)); #endif @@ -9420,17 +9420,17 @@ _pystatvfs_fromstructstatvfs(struct statvfs st) { PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long) st.f_bsize)); PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize)); PyStructSequence_SET_ITEM(v, 2, - PyLong_FromLongLong((PY_LONG_LONG) st.f_blocks)); + PyLong_FromLongLong((long long) st.f_blocks)); PyStructSequence_SET_ITEM(v, 3, - PyLong_FromLongLong((PY_LONG_LONG) st.f_bfree)); + PyLong_FromLongLong((long long) st.f_bfree)); PyStructSequence_SET_ITEM(v, 4, - PyLong_FromLongLong((PY_LONG_LONG) st.f_bavail)); + PyLong_FromLongLong((long long) st.f_bavail)); PyStructSequence_SET_ITEM(v, 5, - PyLong_FromLongLong((PY_LONG_LONG) st.f_files)); + PyLong_FromLongLong((long long) st.f_files)); PyStructSequence_SET_ITEM(v, 6, - PyLong_FromLongLong((PY_LONG_LONG) st.f_ffree)); + PyLong_FromLongLong((long long) st.f_ffree)); PyStructSequence_SET_ITEM(v, 7, - PyLong_FromLongLong((PY_LONG_LONG) st.f_favail)); + PyLong_FromLongLong((long long) st.f_favail)); PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag)); PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); #endif @@ -11763,10 +11763,10 @@ DirEntry_inode(DirEntry *self) self->win32_file_index = stat.st_ino; self->got_file_index = 1; } - return PyLong_FromLongLong((PY_LONG_LONG)self->win32_file_index); + return PyLong_FromLongLong((long long)self->win32_file_index); #else /* POSIX */ #ifdef HAVE_LARGEFILE_SUPPORT - return PyLong_FromLongLong((PY_LONG_LONG)self->d_ino); + return PyLong_FromLongLong((long long)self->d_ino); #else return PyLong_FromLong((long)self->d_ino); #endif diff --git a/Modules/resource.c b/Modules/resource.c index bbe8aefef1b..6702b7a7c4c 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -137,8 +137,8 @@ rlimit2py(struct rlimit rl) { if (sizeof(rl.rlim_cur) > sizeof(long)) { return Py_BuildValue("LL", - (PY_LONG_LONG) rl.rlim_cur, - (PY_LONG_LONG) rl.rlim_max); + (long long) rl.rlim_cur, + (long long) rl.rlim_max); } return Py_BuildValue("ll", (long) rl.rlim_cur, (long) rl.rlim_max); } @@ -437,7 +437,7 @@ PyInit_resource(void) #endif if (sizeof(RLIM_INFINITY) > sizeof(long)) { - v = PyLong_FromLongLong((PY_LONG_LONG) RLIM_INFINITY); + v = PyLong_FromLongLong((long long) RLIM_INFINITY); } else { v = PyLong_FromLong((long) RLIM_INFINITY); diff --git a/Modules/sha1module.c b/Modules/sha1module.c index 6cb32ed69c1..d5065ce1349 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -30,7 +30,7 @@ class SHA1Type "SHA1object *" "&PyType_Type" #if SIZEOF_INT == 4 typedef unsigned int SHA1_INT32; /* 32-bit integer */ -typedef PY_LONG_LONG SHA1_INT64; /* 64-bit integer */ +typedef long long SHA1_INT64; /* 64-bit integer */ #else /* not defined. compilation will die. */ #endif diff --git a/Modules/sha512module.c b/Modules/sha512module.c index f9ff0eaf2df..f5f9e18768a 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -27,15 +27,13 @@ class SHA512Type "SHAobject *" "&PyType_Type" [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=81a3ccde92bcfe8d]*/ -#ifdef PY_LONG_LONG /* If no PY_LONG_LONG, don't compile anything! */ - /* Some useful types */ typedef unsigned char SHA_BYTE; #if SIZEOF_INT == 4 typedef unsigned int SHA_INT32; /* 32-bit integer */ -typedef unsigned PY_LONG_LONG SHA_INT64; /* 64-bit integer */ +typedef unsigned long long SHA_INT64; /* 64-bit integer */ #else /* not defined. compilation will die. */ #endif @@ -121,12 +119,12 @@ static void SHAcopy(SHAobject *src, SHAobject *dest) /* Various logical functions */ #define ROR64(x, y) \ - ( ((((x) & Py_ULL(0xFFFFFFFFFFFFFFFF))>>((unsigned PY_LONG_LONG)(y) & 63)) | \ - ((x)<<((unsigned PY_LONG_LONG)(64-((y) & 63))))) & Py_ULL(0xFFFFFFFFFFFFFFFF)) + ( ((((x) & Py_ULL(0xFFFFFFFFFFFFFFFF))>>((unsigned long long)(y) & 63)) | \ + ((x)<<((unsigned long long)(64-((y) & 63))))) & Py_ULL(0xFFFFFFFFFFFFFFFF)) #define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Maj(x,y,z) (((x | y) & z) | (x & y)) #define S(x, n) ROR64((x),(n)) -#define R(x, n) (((x) & Py_ULL(0xFFFFFFFFFFFFFFFF)) >> ((unsigned PY_LONG_LONG)n)) +#define R(x, n) (((x) & Py_ULL(0xFFFFFFFFFFFFFFFF)) >> ((unsigned long long)n)) #define Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39)) #define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41)) #define Gamma0(x) (S(x, 1) ^ S(x, 8) ^ R(x, 7)) @@ -803,5 +801,3 @@ PyInit__sha512(void) PyModule_AddObject(m, "SHA512Type", (PyObject *)&SHA512type); return m; } - -#endif diff --git a/Objects/longobject.c b/Objects/longobject.c index 150953b05d7..6c8fe22d866 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -993,9 +993,9 @@ PyLong_FromVoidPtr(void *p) #else #if SIZEOF_LONG_LONG < SIZEOF_VOID_P -# error "PyLong_FromVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" +# error "PyLong_FromVoidPtr: sizeof(long long) < sizeof(void*)" #endif - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)(Py_uintptr_t)p); + return PyLong_FromUnsignedLongLong((unsigned long long)(Py_uintptr_t)p); #endif /* SIZEOF_VOID_P <= SIZEOF_LONG */ } @@ -1015,9 +1015,9 @@ PyLong_AsVoidPtr(PyObject *vv) #else #if SIZEOF_LONG_LONG < SIZEOF_VOID_P -# error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" +# error "PyLong_AsVoidPtr: sizeof(long long) < sizeof(void*)" #endif - PY_LONG_LONG x; + long long x; if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0) x = PyLong_AsLongLong(vv); @@ -1031,20 +1031,20 @@ PyLong_AsVoidPtr(PyObject *vv) return (void *)x; } -/* Initial PY_LONG_LONG support by Chris Herborth (chrish@qnx.com), later +/* Initial long long support by Chris Herborth (chrish@qnx.com), later * rewritten to use the newer PyLong_{As,From}ByteArray API. */ -#define PY_ABS_LLONG_MIN (0-(unsigned PY_LONG_LONG)PY_LLONG_MIN) +#define PY_ABS_LLONG_MIN (0-(unsigned long long)PY_LLONG_MIN) -/* Create a new int object from a C PY_LONG_LONG int. */ +/* Create a new int object from a C long long int. */ PyObject * -PyLong_FromLongLong(PY_LONG_LONG ival) +PyLong_FromLongLong(long long ival) { PyLongObject *v; - unsigned PY_LONG_LONG abs_ival; - unsigned PY_LONG_LONG t; /* unsigned so >> doesn't propagate sign bit */ + unsigned long long abs_ival; + unsigned long long t; /* unsigned so >> doesn't propagate sign bit */ int ndigits = 0; int negative = 0; @@ -1052,11 +1052,11 @@ PyLong_FromLongLong(PY_LONG_LONG ival) if (ival < 0) { /* avoid signed overflow on negation; see comments in PyLong_FromLong above. */ - abs_ival = (unsigned PY_LONG_LONG)(-1-ival) + 1; + abs_ival = (unsigned long long)(-1-ival) + 1; negative = 1; } else { - abs_ival = (unsigned PY_LONG_LONG)ival; + abs_ival = (unsigned long long)ival; } /* Count the number of Python digits. @@ -1081,19 +1081,19 @@ PyLong_FromLongLong(PY_LONG_LONG ival) return (PyObject *)v; } -/* Create a new int object from a C unsigned PY_LONG_LONG int. */ +/* Create a new int object from a C unsigned long long int. */ PyObject * -PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival) +PyLong_FromUnsignedLongLong(unsigned long long ival) { PyLongObject *v; - unsigned PY_LONG_LONG t; + unsigned long long t; int ndigits = 0; if (ival < PyLong_BASE) return PyLong_FromLong((long)ival); /* Count the number of Python digits. */ - t = (unsigned PY_LONG_LONG)ival; + t = (unsigned long long)ival; while (t) { ++ndigits; t >>= PyLong_SHIFT; @@ -1182,11 +1182,11 @@ PyLong_FromSize_t(size_t ival) /* Get a C long long int from an int object or any object that has an __int__ method. Return -1 and set an error if overflow occurs. */ -PY_LONG_LONG +long long PyLong_AsLongLong(PyObject *vv) { PyLongObject *v; - PY_LONG_LONG bytes; + long long bytes; int res; int do_decref = 0; /* if nb_int was called */ @@ -1224,30 +1224,30 @@ PyLong_AsLongLong(PyObject *vv) Py_DECREF(v); } - /* Plan 9 can't handle PY_LONG_LONG in ? : expressions */ + /* Plan 9 can't handle long long in ? : expressions */ if (res < 0) - return (PY_LONG_LONG)-1; + return (long long)-1; else return bytes; } -/* Get a C unsigned PY_LONG_LONG int from an int object. +/* Get a C unsigned long long int from an int object. Return -1 and set an error if overflow occurs. */ -unsigned PY_LONG_LONG +unsigned long long PyLong_AsUnsignedLongLong(PyObject *vv) { PyLongObject *v; - unsigned PY_LONG_LONG bytes; + unsigned long long bytes; int res; if (vv == NULL) { PyErr_BadInternalCall(); - return (unsigned PY_LONG_LONG)-1; + return (unsigned long long)-1; } if (!PyLong_Check(vv)) { PyErr_SetString(PyExc_TypeError, "an integer is required"); - return (unsigned PY_LONG_LONG)-1; + return (unsigned long long)-1; } v = (PyLongObject*)vv; @@ -1259,9 +1259,9 @@ PyLong_AsUnsignedLongLong(PyObject *vv) res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes, SIZEOF_LONG_LONG, PY_LITTLE_ENDIAN, 0); - /* Plan 9 can't handle PY_LONG_LONG in ? : expressions */ + /* Plan 9 can't handle long long in ? : expressions */ if (res < 0) - return (unsigned PY_LONG_LONG)res; + return (unsigned long long)res; else return bytes; } @@ -1269,11 +1269,11 @@ PyLong_AsUnsignedLongLong(PyObject *vv) /* Get a C unsigned long int from an int object, ignoring the high bits. Returns -1 and sets an error condition if an error occurs. */ -static unsigned PY_LONG_LONG +static unsigned long long _PyLong_AsUnsignedLongLongMask(PyObject *vv) { PyLongObject *v; - unsigned PY_LONG_LONG x; + unsigned long long x; Py_ssize_t i; int sign; @@ -1299,11 +1299,11 @@ _PyLong_AsUnsignedLongLongMask(PyObject *vv) return x * sign; } -unsigned PY_LONG_LONG +unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *op) { PyLongObject *lo; - unsigned PY_LONG_LONG val; + unsigned long long val; if (op == NULL) { PyErr_BadInternalCall(); @@ -1316,7 +1316,7 @@ PyLong_AsUnsignedLongLongMask(PyObject *op) lo = _PyLong_FromNbInt(op); if (lo == NULL) - return (unsigned PY_LONG_LONG)-1; + return (unsigned long long)-1; val = _PyLong_AsUnsignedLongLongMask((PyObject *)lo); Py_DECREF(lo); @@ -1333,13 +1333,13 @@ PyLong_AsUnsignedLongLongMask(PyObject *op) In this case *overflow will be 0. */ -PY_LONG_LONG +long long PyLong_AsLongLongAndOverflow(PyObject *vv, int *overflow) { /* This version by Tim Peters */ PyLongObject *v; - unsigned PY_LONG_LONG x, prev; - PY_LONG_LONG res; + unsigned long long x, prev; + long long res; Py_ssize_t i; int sign; int do_decref = 0; /* if nb_int was called */ @@ -1391,8 +1391,8 @@ PyLong_AsLongLongAndOverflow(PyObject *vv, int *overflow) /* Haven't lost any bits, but casting to long requires extra * care (see comment above). */ - if (x <= (unsigned PY_LONG_LONG)PY_LLONG_MAX) { - res = (PY_LONG_LONG)x * sign; + if (x <= (unsigned long long)PY_LLONG_MAX) { + res = (long long)x * sign; } else if (sign < 0 && x == PY_ABS_LLONG_MIN) { res = PY_LLONG_MIN; @@ -3481,7 +3481,7 @@ long_mul(PyLongObject *a, PyLongObject *b) /* fast path for single-digit multiplication */ if (Py_ABS(Py_SIZE(a)) <= 1 && Py_ABS(Py_SIZE(b)) <= 1) { stwodigits v = (stwodigits)(MEDIUM_VALUE(a)) * MEDIUM_VALUE(b); - return PyLong_FromLongLong((PY_LONG_LONG)v); + return PyLong_FromLongLong((long long)v); } z = k_mul(a, b); @@ -4650,7 +4650,7 @@ simple: /* a fits into a long, so b must too */ x = PyLong_AsLong((PyObject *)a); y = PyLong_AsLong((PyObject *)b); -#elif defined(PY_LONG_LONG) && PY_LLONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT +#elif defined(long long) && PY_LLONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT x = PyLong_AsLongLong((PyObject *)a); y = PyLong_AsLongLong((PyObject *)b); #else @@ -4669,7 +4669,7 @@ simple: } #if LONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT return PyLong_FromLong(x); -#elif defined(PY_LONG_LONG) && PY_LLONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT +#elif defined(long long) && PY_LLONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT return PyLong_FromLongLong(x); #else # error "_PyLong_GCD" diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index adf3ec62dab..07402d2e868 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1111,7 +1111,7 @@ get_native_fmtchar(char *result, const char *fmt) case 'h': case 'H': size = sizeof(short); break; case 'i': case 'I': size = sizeof(int); break; case 'l': case 'L': size = sizeof(long); break; - case 'q': case 'Q': size = sizeof(PY_LONG_LONG); break; + case 'q': case 'Q': size = sizeof(long long); break; case 'n': case 'N': size = sizeof(Py_ssize_t); break; case 'f': size = sizeof(float); break; case 'd': size = sizeof(double); break; @@ -1577,11 +1577,11 @@ pylong_as_lu(PyObject *item) return lu; } -static PY_LONG_LONG +static long long pylong_as_lld(PyObject *item) { PyObject *tmp; - PY_LONG_LONG lld; + long long lld; tmp = PyNumber_Index(item); if (tmp == NULL) @@ -1592,15 +1592,15 @@ pylong_as_lld(PyObject *item) return lld; } -static unsigned PY_LONG_LONG +static unsigned long long pylong_as_llu(PyObject *item) { PyObject *tmp; - unsigned PY_LONG_LONG llu; + unsigned long long llu; tmp = PyNumber_Index(item); if (tmp == NULL) - return (unsigned PY_LONG_LONG)-1; + return (unsigned long long)-1; llu = PyLong_AsUnsignedLongLong(tmp); Py_DECREF(tmp); @@ -1653,10 +1653,10 @@ pylong_as_zu(PyObject *item) Py_LOCAL_INLINE(PyObject *) unpack_single(const char *ptr, const char *fmt) { - unsigned PY_LONG_LONG llu; + unsigned long long llu; unsigned long lu; size_t zu; - PY_LONG_LONG lld; + long long lld; long ld; Py_ssize_t zd; double d; @@ -1685,8 +1685,8 @@ unpack_single(const char *ptr, const char *fmt) case 'L': UNPACK_SINGLE(lu, ptr, unsigned long); goto convert_lu; /* native 64-bit */ - case 'q': UNPACK_SINGLE(lld, ptr, PY_LONG_LONG); goto convert_lld; - case 'Q': UNPACK_SINGLE(llu, ptr, unsigned PY_LONG_LONG); goto convert_llu; + case 'q': UNPACK_SINGLE(lld, ptr, long long); goto convert_lld; + case 'Q': UNPACK_SINGLE(llu, ptr, unsigned long long); goto convert_llu; /* ssize_t and size_t */ case 'n': UNPACK_SINGLE(zd, ptr, Py_ssize_t); goto convert_zd; @@ -1747,10 +1747,10 @@ err_format: static int pack_single(char *ptr, PyObject *item, const char *fmt) { - unsigned PY_LONG_LONG llu; + unsigned long long llu; unsigned long lu; size_t zu; - PY_LONG_LONG lld; + long long lld; long ld; Py_ssize_t zd; double d; @@ -1802,13 +1802,13 @@ pack_single(char *ptr, PyObject *item, const char *fmt) lld = pylong_as_lld(item); if (lld == -1 && PyErr_Occurred()) goto err_occurred; - PACK_SINGLE(ptr, lld, PY_LONG_LONG); + PACK_SINGLE(ptr, lld, long long); break; case 'Q': llu = pylong_as_llu(item); - if (llu == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) + if (llu == (unsigned long long)-1 && PyErr_Occurred()) goto err_occurred; - PACK_SINGLE(ptr, llu, unsigned PY_LONG_LONG); + PACK_SINGLE(ptr, llu, unsigned long long); break; /* ssize_t and size_t */ @@ -2646,8 +2646,8 @@ unpack_cmp(const char *p, const char *q, char fmt, case 'L': CMP_SINGLE(p, q, unsigned long); return equal; /* native 64-bit */ - case 'q': CMP_SINGLE(p, q, PY_LONG_LONG); return equal; - case 'Q': CMP_SINGLE(p, q, unsigned PY_LONG_LONG); return equal; + case 'q': CMP_SINGLE(p, q, long long); return equal; + case 'Q': CMP_SINGLE(p, q, unsigned long long); return equal; /* ssize_t and size_t */ case 'n': CMP_SINGLE(p, q, Py_ssize_t); return equal; diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 284a1008d24..8e741328073 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -6,7 +6,7 @@ /* Support objects whose length is > PY_SSIZE_T_MAX. This could be sped up for small PyLongs if they fit in a Py_ssize_t. - This only matters on Win64. Though we could use PY_LONG_LONG which + This only matters on Win64. Though we could use long long which would presumably help perf. */ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 7ea1639addf..12d09f06f2d 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2680,7 +2680,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer, va_arg(*vargs, unsigned long)); else if (longlongflag) len = sprintf(buffer, "%" PY_FORMAT_LONG_LONG "u", - va_arg(*vargs, unsigned PY_LONG_LONG)); + va_arg(*vargs, unsigned long long)); else if (size_tflag) len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "u", va_arg(*vargs, size_t)); @@ -2697,7 +2697,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer, va_arg(*vargs, long)); else if (longlongflag) len = sprintf(buffer, "%" PY_FORMAT_LONG_LONG "i", - va_arg(*vargs, PY_LONG_LONG)); + va_arg(*vargs, long long)); else if (size_tflag) len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "i", va_arg(*vargs, Py_ssize_t)); diff --git a/PC/pyconfig.h b/PC/pyconfig.h index 35f8778dbdc..24995f566f2 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -265,7 +265,6 @@ typedef int pid_t; #endif /* 64 bit ints are usually spelt __int64 unless compiler has overridden */ -#define HAVE_LONG_LONG 1 #ifndef PY_LONG_LONG # define PY_LONG_LONG __int64 # define PY_LLONG_MAX _I64_MAX @@ -379,7 +378,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ #ifndef PY_UINT64_T #if SIZEOF_LONG_LONG == 8 #define HAVE_UINT64_T 1 -#define PY_UINT64_T unsigned PY_LONG_LONG +#define PY_UINT64_T unsigned long long #endif #endif @@ -396,7 +395,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ #ifndef PY_INT64_T #if SIZEOF_LONG_LONG == 8 #define HAVE_INT64_T 1 -#define PY_INT64_T PY_LONG_LONG +#define PY_INT64_T long long #endif #endif diff --git a/Python/condvar.h b/Python/condvar.h index ced910fbeaa..9a71b17738f 100644 --- a/Python/condvar.h +++ b/Python/condvar.h @@ -89,7 +89,7 @@ do { /* TODO: add overflow and truncation checks */ \ /* return 0 for success, 1 on timeout, -1 on error */ Py_LOCAL_INLINE(int) -PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, PY_LONG_LONG us) +PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, long long us) { int r; struct timespec ts; @@ -270,7 +270,7 @@ PyCOND_WAIT(PyCOND_T *cv, PyMUTEX_T *cs) } Py_LOCAL_INLINE(int) -PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, PY_LONG_LONG us) +PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, long long us) { return _PyCOND_WAIT_MS(cv, cs, (DWORD)(us/1000)); } @@ -363,7 +363,7 @@ PyCOND_WAIT(PyCOND_T *cv, PyMUTEX_T *cs) * 2 to indicate that we don't know. */ Py_LOCAL_INLINE(int) -PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, PY_LONG_LONG us) +PyCOND_TIMEDWAIT(PyCOND_T *cv, PyMUTEX_T *cs, long long us) { return SleepConditionVariableSRW(cv, cs, (DWORD)(us/1000), 0) ? 2 : -1; } diff --git a/Python/getargs.c b/Python/getargs.c index 008a4346fb8..0854cc45e6a 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -769,13 +769,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, break; } - case 'L': {/* PY_LONG_LONG */ - PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * ); - PY_LONG_LONG ival; + case 'L': {/* long long */ + long long *p = va_arg( *p_va, long long * ); + long long ival; if (float_argument_error(arg)) RETURN_ERR_OCCURRED; ival = PyLong_AsLongLong(arg); - if (ival == (PY_LONG_LONG)-1 && PyErr_Occurred()) + if (ival == (long long)-1 && PyErr_Occurred()) RETURN_ERR_OCCURRED; else *p = ival; @@ -783,8 +783,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, } case 'K': { /* long long sized bitfield */ - unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *); - unsigned PY_LONG_LONG ival; + unsigned long long *p = va_arg(*p_va, unsigned long long *); + unsigned long long ival; if (PyLong_Check(arg)) ival = PyLong_AsUnsignedLongLongMask(arg); else @@ -2086,8 +2086,8 @@ skipitem(const char **p_format, va_list *p_va, int flags) case 'I': /* int sized bitfield */ case 'l': /* long int */ case 'k': /* long int sized bitfield */ - case 'L': /* PY_LONG_LONG */ - case 'K': /* PY_LONG_LONG sized bitfield */ + case 'L': /* long long */ + case 'K': /* long long sized bitfield */ case 'n': /* Py_ssize_t */ case 'f': /* float */ case 'd': /* double */ diff --git a/Python/modsupport.c b/Python/modsupport.c index 37c0ce78648..f3aa91f2b9d 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -261,10 +261,10 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags) } case 'L': - return PyLong_FromLongLong((PY_LONG_LONG)va_arg(*p_va, PY_LONG_LONG)); + return PyLong_FromLongLong((long long)va_arg(*p_va, long long)); case 'K': - return PyLong_FromUnsignedLongLong((PY_LONG_LONG)va_arg(*p_va, unsigned PY_LONG_LONG)); + return PyLong_FromUnsignedLongLong((long long)va_arg(*p_va, unsigned long long)); case 'u': { diff --git a/Python/pytime.c b/Python/pytime.c index 5f166b868a9..02ef8ee7d63 100644 --- a/Python/pytime.c +++ b/Python/pytime.c @@ -39,7 +39,7 @@ time_t _PyLong_AsTime_t(PyObject *obj) { #if SIZEOF_TIME_T == SIZEOF_LONG_LONG - PY_LONG_LONG val; + long long val; val = PyLong_AsLongLong(obj); #else long val; @@ -58,7 +58,7 @@ PyObject * _PyLong_FromTime_t(time_t t) { #if SIZEOF_TIME_T == SIZEOF_LONG_LONG - return PyLong_FromLongLong((PY_LONG_LONG)t); + return PyLong_FromLongLong((long long)t); #else Py_BUILD_ASSERT(sizeof(time_t) <= sizeof(long)); return PyLong_FromLong((long)t); @@ -218,11 +218,11 @@ _PyTime_FromSeconds(int seconds) } _PyTime_t -_PyTime_FromNanoseconds(PY_LONG_LONG ns) +_PyTime_FromNanoseconds(long long ns) { _PyTime_t t; - Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t)); - t = Py_SAFE_DOWNCAST(ns, PY_LONG_LONG, _PyTime_t); + Py_BUILD_ASSERT(sizeof(long long) <= sizeof(_PyTime_t)); + t = Py_SAFE_DOWNCAST(ns, long long, _PyTime_t); return t; } @@ -304,8 +304,8 @@ _PyTime_FromObject(_PyTime_t *t, PyObject *obj, _PyTime_round_t round, return _PyTime_FromFloatObject(t, d, round, unit_to_ns); } else { - PY_LONG_LONG sec; - Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t)); + long long sec; + Py_BUILD_ASSERT(sizeof(long long) <= sizeof(_PyTime_t)); sec = PyLong_AsLongLong(obj); if (sec == -1 && PyErr_Occurred()) { @@ -358,8 +358,8 @@ _PyTime_AsSecondsDouble(_PyTime_t t) PyObject * _PyTime_AsNanosecondsObject(_PyTime_t t) { - Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) >= sizeof(_PyTime_t)); - return PyLong_FromLongLong((PY_LONG_LONG)t); + Py_BUILD_ASSERT(sizeof(long long) >= sizeof(_PyTime_t)); + return PyLong_FromLongLong((long long)t); } static _PyTime_t diff --git a/Python/structmember.c b/Python/structmember.c index c2ddb51e80d..86d4c66ca74 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -75,10 +75,10 @@ PyMember_GetOne(const char *addr, PyMemberDef *l) Py_XINCREF(v); break; case T_LONGLONG: - v = PyLong_FromLongLong(*(PY_LONG_LONG *)addr); + v = PyLong_FromLongLong(*(long long *)addr); break; case T_ULONGLONG: - v = PyLong_FromUnsignedLongLong(*(unsigned PY_LONG_LONG *)addr); + v = PyLong_FromUnsignedLongLong(*(unsigned long long *)addr); break; case T_NONE: v = Py_None; @@ -265,21 +265,21 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) PyErr_SetString(PyExc_TypeError, "readonly attribute"); return -1; case T_LONGLONG:{ - PY_LONG_LONG value; - *(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); + long long value; + *(long long*)addr = value = PyLong_AsLongLong(v); if ((value == -1) && PyErr_Occurred()) return -1; break; } case T_ULONGLONG:{ - unsigned PY_LONG_LONG value; + unsigned long long value; /* ??? PyLong_AsLongLong accepts an int, but PyLong_AsUnsignedLongLong doesn't ??? */ if (PyLong_Check(v)) - *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); + *(unsigned long long*)addr = value = PyLong_AsUnsignedLongLong(v); else - *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsLong(v); - if ((value == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred()) + *(unsigned long long*)addr = value = PyLong_AsLong(v); + if ((value == (unsigned long long)-1) && PyErr_Occurred()) return -1; break; } diff --git a/Python/thread_nt.h b/Python/thread_nt.h index cb0e99596c5..74a6ee80298 100644 --- a/Python/thread_nt.h +++ b/Python/thread_nt.h @@ -77,7 +77,7 @@ EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds) /* wait at least until the target */ DWORD now, target = GetTickCount() + milliseconds; while (mutex->locked) { - if (PyCOND_TIMEDWAIT(&mutex->cv, &mutex->cs, (PY_LONG_LONG)milliseconds*1000) < 0) { + if (PyCOND_TIMEDWAIT(&mutex->cv, &mutex->cs, (long long)milliseconds*1000) < 0) { result = WAIT_FAILED; break; }