replace PY_LONG_LONG with long long

This commit is contained in:
Benjamin Peterson 2016-09-06 10:46:49 -07:00
parent 45c7514de4
commit af580dff4a
29 changed files with 222 additions and 234 deletions

View File

@ -85,12 +85,12 @@ PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG); PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long);
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG); PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long);
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *); PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *);
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *); PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *);
PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *); PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *);
PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *); PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int); PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API

View File

@ -156,8 +156,8 @@ typedef unsigned long Py_uintptr_t;
typedef long Py_intptr_t; typedef long Py_intptr_t;
#elif SIZEOF_VOID_P <= SIZEOF_LONG_LONG #elif SIZEOF_VOID_P <= SIZEOF_LONG_LONG
typedef unsigned PY_LONG_LONG Py_uintptr_t; typedef unsigned long long Py_uintptr_t;
typedef PY_LONG_LONG Py_intptr_t; typedef long long Py_intptr_t;
#else #else
# error "Python needs a typedef for Py_uintptr_t in pyport.h." # error "Python needs a typedef for Py_uintptr_t in pyport.h."

View File

@ -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 module exposes a higher-level API, with timeouts expressed in seconds
and floating-point numbers allowed. 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 #define PY_TIMEOUT_MAX PY_LLONG_MAX
/* In the NT API, the timeout is a DWORD and is expressed in milliseconds */ /* In the NT API, the timeout is a DWORD and is expressed in milliseconds */

View File

@ -78,7 +78,7 @@ PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds);
((_PyTime_t)(seconds) * (1000 * 1000 * 1000)) ((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
/* Create a timestamp from a number of nanoseconds. */ /* 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. /* Convert a number of seconds (Python float or int) to a timetamp.
Raise an exception and return -1 on error, return 0 on success. */ Raise an exception and return -1 on error, return 0 on success. */

View File

@ -22,7 +22,6 @@
#define assert(op) /* empty */ #define assert(op) /* empty */
typedef int sdigit; typedef int sdigit;
typedef long Py_ssize_t; typedef long Py_ssize_t;
typedef long long PY_LONG_LONG;
typedef unsigned short wchar_t; typedef unsigned short wchar_t;
typedef struct {} PyObject; typedef struct {} PyObject;
typedef struct {} grammar; typedef struct {} grammar;
@ -63,7 +62,7 @@ PyObject *PyLong_FromLong(long ival)
return NULL; return NULL;
} }
PyObject *PyLong_FromLongLong(PY_LONG_LONG ival) PyObject *PyLong_FromLongLong(long long ival)
{ {
return PyLong_FromLong((long)ival); return PyLong_FromLong((long)ival);
} }

View File

@ -4198,20 +4198,20 @@ typedef struct tm *(*TM_FUNC)(const time_t *timer);
/* As of version 2015f max fold in IANA database is /* As of version 2015f max fold in IANA database is
* 23 hours at 1969-09-30 13:00:00 in Kwajalein. */ * 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 */ /* 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, utc_to_seconds(int year, int month, int day,
int hour, int minute, int second) 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; return ((ordinal * 24 + hour) * 60 + minute) * 60 + second;
} }
static PY_LONG_LONG static long long
local(PY_LONG_LONG u) local(long long u)
{ {
struct tm local_time; struct tm local_time;
time_t t; 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); second = Py_MIN(59, tm->tm_sec);
if (tzinfo == Py_None && f == localtime) { 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, result_seconds = utc_to_seconds(year, month, day,
hour, minute, second); hour, minute, second);
@ -5115,14 +5115,14 @@ local_timezone(PyDateTime_DateTime *utc_time)
return local_timezone_from_timestamp(timestamp); return local_timezone_from_timestamp(timestamp);
} }
static PY_LONG_LONG static long long
local_to_seconds(int year, int month, int day, local_to_seconds(int year, int month, int day,
int hour, int minute, int second, int fold); int hour, int minute, int second, int fold);
static PyObject * static PyObject *
local_timezone_from_local(PyDateTime_DateTime *local_dt) local_timezone_from_local(PyDateTime_DateTime *local_dt)
{ {
PY_LONG_LONG seconds; long long seconds;
time_t timestamp; time_t timestamp;
seconds = local_to_seconds(GET_YEAR(local_dt), seconds = local_to_seconds(GET_YEAR(local_dt),
GET_MONTH(local_dt), GET_MONTH(local_dt),
@ -5256,11 +5256,11 @@ datetime_timetuple(PyDateTime_DateTime *self)
dstflag); dstflag);
} }
static PY_LONG_LONG static long long
local_to_seconds(int year, int month, int day, local_to_seconds(int year, int month, int day,
int hour, int minute, int second, int fold) 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); t = utc_to_seconds(year, month, day, hour, minute, second);
/* Our goal is to solve t = local(u) for u. */ /* Our goal is to solve t = local(u) for u. */
lt = local(t); lt = local(t);
@ -5320,7 +5320,7 @@ datetime_timestamp(PyDateTime_DateTime *self)
Py_DECREF(delta); Py_DECREF(delta);
} }
else { else {
PY_LONG_LONG seconds; long long seconds;
seconds = local_to_seconds(GET_YEAR(self), seconds = local_to_seconds(GET_YEAR(self),
GET_MONTH(self), GET_MONTH(self),
GET_DAY(self), GET_DAY(self),

View File

@ -8,7 +8,7 @@
#include <windows.h> #include <windows.h>
static PY_LONG_LONG static long long
hpTimer(void) hpTimer(void)
{ {
LARGE_INTEGER li; LARGE_INTEGER li;
@ -35,11 +35,11 @@ hpTimerUnit(void)
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/times.h> #include <sys/times.h>
static PY_LONG_LONG static long long
hpTimer(void) hpTimer(void)
{ {
struct timeval tv; struct timeval tv;
PY_LONG_LONG ret; long long ret;
#ifdef GETTIMEOFDAY_NO_TZ #ifdef GETTIMEOFDAY_NO_TZ
gettimeofday(&tv); gettimeofday(&tv);
#else #else
@ -66,8 +66,8 @@ struct _ProfilerEntry;
/* represents a function called from another function */ /* represents a function called from another function */
typedef struct _ProfilerSubEntry { typedef struct _ProfilerSubEntry {
rotating_node_t header; rotating_node_t header;
PY_LONG_LONG tt; long long tt;
PY_LONG_LONG it; long long it;
long callcount; long callcount;
long recursivecallcount; long recursivecallcount;
long recursionLevel; long recursionLevel;
@ -77,8 +77,8 @@ typedef struct _ProfilerSubEntry {
typedef struct _ProfilerEntry { typedef struct _ProfilerEntry {
rotating_node_t header; rotating_node_t header;
PyObject *userObj; /* PyCodeObject, or a descriptive str for builtins */ PyObject *userObj; /* PyCodeObject, or a descriptive str for builtins */
PY_LONG_LONG tt; /* total time in this entry */ long long tt; /* total time in this entry */
PY_LONG_LONG it; /* inline time in this entry (not in subcalls) */ long long it; /* inline time in this entry (not in subcalls) */
long callcount; /* how many times this was called */ long callcount; /* how many times this was called */
long recursivecallcount; /* how many times called recursively */ long recursivecallcount; /* how many times called recursively */
long recursionLevel; long recursionLevel;
@ -86,8 +86,8 @@ typedef struct _ProfilerEntry {
} ProfilerEntry; } ProfilerEntry;
typedef struct _ProfilerContext { typedef struct _ProfilerContext {
PY_LONG_LONG t0; long long t0;
PY_LONG_LONG subt; long long subt;
struct _ProfilerContext *previous; struct _ProfilerContext *previous;
ProfilerEntry *ctxEntry; ProfilerEntry *ctxEntry;
} ProfilerContext; } ProfilerContext;
@ -117,9 +117,9 @@ static PyTypeObject PyProfiler_Type;
#define DOUBLE_TIMER_PRECISION 4294967296.0 #define DOUBLE_TIMER_PRECISION 4294967296.0
static PyObject *empty_tuple; 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); PyObject *o = PyObject_Call(pObj->externalTimer, empty_tuple, NULL);
if (o == NULL) { if (o == NULL) {
PyErr_WriteUnraisable(pObj->externalTimer); PyErr_WriteUnraisable(pObj->externalTimer);
@ -132,11 +132,11 @@ static PY_LONG_LONG CallExternalTimer(ProfilerObject *pObj)
} }
else { else {
/* interpret the result as a double measured in seconds. /* 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 */ we convert it to a large integer */
double val = PyFloat_AsDouble(o); double val = PyFloat_AsDouble(o);
/* error handling delayed to the code below */ /* 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); Py_DECREF(o);
if (PyErr_Occurred()) { if (PyErr_Occurred()) {
@ -338,8 +338,8 @@ initContext(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
static void static void
Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry) Stop(ProfilerObject *pObj, ProfilerContext *self, ProfilerEntry *entry)
{ {
PY_LONG_LONG tt = CALL_TIMER(pObj) - self->t0; long long tt = CALL_TIMER(pObj) - self->t0;
PY_LONG_LONG it = tt - self->subt; long long it = tt - self->subt;
if (self->previous) if (self->previous)
self->previous->subt += tt; self->previous->subt += tt;
pObj->currentProfilerContext = self->previous; pObj->currentProfilerContext = self->previous;

View File

@ -18,12 +18,6 @@
#include <lzma.h> #include <lzma.h>
#ifndef PY_LONG_LONG
#error "This module requires PY_LONG_LONG to be defined"
#endif
#ifdef WITH_THREAD #ifdef WITH_THREAD
#define ACQUIRE_LOCK(obj) do { \ #define ACQUIRE_LOCK(obj) do { \
if (!PyThread_acquire_lock((obj)->lock, 0)) { \ 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 uint32_t - the "I" (unsigned int) specifier is the right size, but
silently ignores overflows on conversion. 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. size, but like "I" it silently ignores overflows on conversion.
lzma_mode and lzma_match_finder - these are enumeration types, and 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 \ static int \
FUNCNAME(PyObject *obj, void *ptr) \ FUNCNAME(PyObject *obj, void *ptr) \
{ \ { \
unsigned PY_LONG_LONG val; \ unsigned long long val; \
\ \
val = PyLong_AsUnsignedLongLong(obj); \ val = PyLong_AsUnsignedLongLong(obj); \
if (PyErr_Occurred()) \ if (PyErr_Occurred()) \
return 0; \ return 0; \
if ((unsigned PY_LONG_LONG)(TYPE)val != val) { \ if ((unsigned long long)(TYPE)val != val) { \
PyErr_SetString(PyExc_OverflowError, \ PyErr_SetString(PyExc_OverflowError, \
"Value too large for " #TYPE " type"); \ "Value too large for " #TYPE " type"); \
return 0; \ return 0; \
@ -398,7 +392,7 @@ parse_filter_chain_spec(lzma_filter filters[], PyObject *filterspecs)
Python-level filter specifiers (represented as dicts). */ Python-level filter specifiers (represented as dicts). */
static int 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; int status;
PyObject *value_object; PyObject *value_object;
@ -1441,7 +1435,7 @@ static PyModuleDef _lzmamodule = {
/* Some of our constants are more than 32 bits wide, so PyModule_AddIntConstant /* Some of our constants are more than 32 bits wide, so PyModule_AddIntConstant
would not work correctly on platforms with 32-bit longs. */ would not work correctly on platforms with 32-bit longs. */
static int 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); PyObject *o = PyLong_FromLongLong(value);
if (o == NULL) if (o == NULL)

View File

@ -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; /* We can't support q and Q in native mode unless the compiler does;
in std mode, they're 8 bytes on all platforms. */ in std mode, they're 8 bytes on all platforms. */
typedef struct { char c; PY_LONG_LONG x; } s_long_long; typedef struct { char c; long long x; } s_long_long;
#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) #define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(long long))
#ifdef HAVE_C99_BOOL #ifdef HAVE_C99_BOOL
#define BOOL_TYPE _Bool #define BOOL_TYPE _Bool
@ -165,9 +165,9 @@ get_ulong(PyObject *v, unsigned long *p)
/* Same, but handling native long long. */ /* Same, but handling native long long. */
static int 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); v = get_pylong(v);
if (v == NULL) if (v == NULL)
@ -175,7 +175,7 @@ get_longlong(PyObject *v, PY_LONG_LONG *p)
assert(PyLong_Check(v)); assert(PyLong_Check(v));
x = PyLong_AsLongLong(v); x = PyLong_AsLongLong(v);
Py_DECREF(v); Py_DECREF(v);
if (x == (PY_LONG_LONG)-1 && PyErr_Occurred()) { if (x == (long long)-1 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_OverflowError)) if (PyErr_ExceptionMatches(PyExc_OverflowError))
PyErr_SetString(StructError, PyErr_SetString(StructError,
"argument out of range"); "argument out of range");
@ -188,9 +188,9 @@ get_longlong(PyObject *v, PY_LONG_LONG *p)
/* Same, but handling native unsigned long long. */ /* Same, but handling native unsigned long long. */
static int 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); v = get_pylong(v);
if (v == NULL) if (v == NULL)
@ -198,7 +198,7 @@ get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p)
assert(PyLong_Check(v)); assert(PyLong_Check(v));
x = PyLong_AsUnsignedLongLong(v); x = PyLong_AsUnsignedLongLong(v);
Py_DECREF(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)) if (PyErr_ExceptionMatches(PyExc_OverflowError))
PyErr_SetString(StructError, PyErr_SetString(StructError,
"argument out of range"); "argument out of range");
@ -460,20 +460,20 @@ nu_size_t(const char *p, const formatdef *f)
static PyObject * static PyObject *
nu_longlong(const char *p, const formatdef *f) nu_longlong(const char *p, const formatdef *f)
{ {
PY_LONG_LONG x; long long x;
memcpy((char *)&x, p, sizeof x); memcpy((char *)&x, p, sizeof x);
if (x >= LONG_MIN && x <= LONG_MAX) 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); return PyLong_FromLongLong(x);
} }
static PyObject * static PyObject *
nu_ulonglong(const char *p, const formatdef *f) nu_ulonglong(const char *p, const formatdef *f)
{ {
unsigned PY_LONG_LONG x; unsigned long long x;
memcpy((char *)&x, p, sizeof x); memcpy((char *)&x, p, sizeof x);
if (x <= LONG_MAX) 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); return PyLong_FromUnsignedLongLong(x);
} }
@ -673,7 +673,7 @@ np_size_t(char *p, PyObject *v, const formatdef *f)
static int static int
np_longlong(char *p, PyObject *v, const formatdef *f) np_longlong(char *p, PyObject *v, const formatdef *f)
{ {
PY_LONG_LONG x; long long x;
if (get_longlong(v, &x) < 0) if (get_longlong(v, &x) < 0)
return -1; return -1;
memcpy(p, (char *)&x, sizeof x); memcpy(p, (char *)&x, sizeof x);
@ -683,7 +683,7 @@ np_longlong(char *p, PyObject *v, const formatdef *f)
static int static int
np_ulonglong(char *p, PyObject *v, const formatdef *f) np_ulonglong(char *p, PyObject *v, const formatdef *f)
{ {
unsigned PY_LONG_LONG x; unsigned long long x;
if (get_ulonglong(v, &x) < 0) if (get_ulonglong(v, &x) < 0)
return -1; return -1;
memcpy(p, (char *)&x, sizeof x); memcpy(p, (char *)&x, sizeof x);
@ -772,8 +772,8 @@ static const formatdef native_table[] = {
{'L', sizeof(long), LONG_ALIGN, nu_ulong, np_ulong}, {'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_ssize_t, np_ssize_t},
{'N', sizeof(size_t), SIZE_T_ALIGN, nu_size_t, np_size_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(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_ulonglong,np_ulonglong},
{'?', sizeof(BOOL_TYPE), BOOL_ALIGN, nu_bool, np_bool}, {'?', sizeof(BOOL_TYPE), BOOL_ALIGN, nu_bool, np_bool},
{'e', sizeof(short), SHORT_ALIGN, nu_halffloat, np_halffloat}, {'e', sizeof(short), SHORT_ALIGN, nu_halffloat, np_halffloat},
{'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float}, {'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float},
@ -816,7 +816,7 @@ bu_uint(const char *p, const formatdef *f)
static PyObject * static PyObject *
bu_longlong(const char *p, const formatdef *f) bu_longlong(const char *p, const formatdef *f)
{ {
PY_LONG_LONG x = 0; long long x = 0;
Py_ssize_t i = f->size; Py_ssize_t i = f->size;
const unsigned char *bytes = (const unsigned char *)p; const unsigned char *bytes = (const unsigned char *)p;
do { do {
@ -824,23 +824,23 @@ bu_longlong(const char *p, const formatdef *f)
} while (--i > 0); } while (--i > 0);
/* Extend the sign bit. */ /* Extend the sign bit. */
if (SIZEOF_LONG_LONG > f->size) 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) 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); return PyLong_FromLongLong(x);
} }
static PyObject * static PyObject *
bu_ulonglong(const char *p, const formatdef *f) 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; Py_ssize_t i = f->size;
const unsigned char *bytes = (const unsigned char *)p; const unsigned char *bytes = (const unsigned char *)p;
do { do {
x = (x<<8) | *bytes++; x = (x<<8) | *bytes++;
} while (--i > 0); } while (--i > 0);
if (x <= LONG_MAX) 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); return PyLong_FromUnsignedLongLong(x);
} }
@ -1043,7 +1043,7 @@ lu_uint(const char *p, const formatdef *f)
static PyObject * static PyObject *
lu_longlong(const char *p, const formatdef *f) lu_longlong(const char *p, const formatdef *f)
{ {
PY_LONG_LONG x = 0; long long x = 0;
Py_ssize_t i = f->size; Py_ssize_t i = f->size;
const unsigned char *bytes = (const unsigned char *)p; const unsigned char *bytes = (const unsigned char *)p;
do { do {
@ -1051,23 +1051,23 @@ lu_longlong(const char *p, const formatdef *f)
} while (i > 0); } while (i > 0);
/* Extend the sign bit. */ /* Extend the sign bit. */
if (SIZEOF_LONG_LONG > f->size) 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) 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); return PyLong_FromLongLong(x);
} }
static PyObject * static PyObject *
lu_ulonglong(const char *p, const formatdef *f) 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; Py_ssize_t i = f->size;
const unsigned char *bytes = (const unsigned char *)p; const unsigned char *bytes = (const unsigned char *)p;
do { do {
x = (x<<8) | bytes[--i]; x = (x<<8) | bytes[--i];
} while (i > 0); } while (i > 0);
if (x <= LONG_MAX) 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); return PyLong_FromUnsignedLongLong(x);
} }

View File

@ -60,7 +60,7 @@ test_config(PyObject *self)
CHECK_SIZEOF(SIZEOF_LONG, long); CHECK_SIZEOF(SIZEOF_LONG, long);
CHECK_SIZEOF(SIZEOF_VOID_P, void*); CHECK_SIZEOF(SIZEOF_VOID_P, void*);
CHECK_SIZEOF(SIZEOF_TIME_T, time_t); 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 #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. Note that the meat of the test is contained in testcapi_long.h.
This is revolting, but delicate code duplication is worse: "almost 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 dependence on type names makes it impossible to use a parameterized
function. A giant macro would be even worse than this. A C++ template function. A giant macro would be even worse than this. A C++ template
would be perfect. would be perfect.
@ -407,7 +407,7 @@ raise_test_longlong_error(const char* msg)
} }
#define TESTNAME test_longlong_api_inner #define TESTNAME test_longlong_api_inner
#define TYPENAME PY_LONG_LONG #define TYPENAME long long
#define F_S_TO_PY PyLong_FromLongLong #define F_S_TO_PY PyLong_FromLongLong
#define F_PY_TO_S PyLong_AsLongLong #define F_PY_TO_S PyLong_AsLongLong
#define F_U_TO_PY PyLong_FromUnsignedLongLong #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 /* 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. concentrate on proper handling of overflow.
*/ */
@ -602,7 +602,7 @@ static PyObject *
test_long_long_and_overflow(PyObject *self) test_long_long_and_overflow(PyObject *self)
{ {
PyObject *num, *one, *temp; PyObject *num, *one, *temp;
PY_LONG_LONG value; long long value;
int overflow; int overflow;
/* Test that overflow is set properly for a large value. */ /* Test that overflow is set properly for a large value. */
@ -820,7 +820,7 @@ test_long_as_double(PyObject *self)
return Py_None; 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 for both long and int arguments. The test may leak a little memory if
it fails. it fails.
*/ */
@ -828,7 +828,7 @@ static PyObject *
test_L_code(PyObject *self) test_L_code(PyObject *self)
{ {
PyObject *tuple, *num; PyObject *tuple, *num;
PY_LONG_LONG value; long long value;
tuple = PyTuple_New(1); tuple = PyTuple_New(1);
if (tuple == NULL) if (tuple == NULL)
@ -1133,7 +1133,7 @@ getargs_p(PyObject *self, PyObject *args)
static PyObject * static PyObject *
getargs_L(PyObject *self, PyObject *args) getargs_L(PyObject *self, PyObject *args)
{ {
PY_LONG_LONG value; long long value;
if (!PyArg_ParseTuple(args, "L", &value)) if (!PyArg_ParseTuple(args, "L", &value))
return NULL; return NULL;
return PyLong_FromLongLong(value); return PyLong_FromLongLong(value);
@ -1142,7 +1142,7 @@ getargs_L(PyObject *self, PyObject *args)
static PyObject * static PyObject *
getargs_K(PyObject *self, PyObject *args) getargs_K(PyObject *self, PyObject *args)
{ {
unsigned PY_LONG_LONG value; unsigned long long value;
if (!PyArg_ParseTuple(args, "K", &value)) if (!PyArg_ParseTuple(args, "K", &value))
return NULL; return NULL;
return PyLong_FromUnsignedLongLong(value); return PyLong_FromUnsignedLongLong(value);
@ -2271,8 +2271,8 @@ test_string_from_format(PyObject *self, PyObject *args)
CHECK_1_FORMAT("%zu", size_t); CHECK_1_FORMAT("%zu", size_t);
/* "%lld" and "%llu" support added in Python 2.7. */ /* "%lld" and "%llu" support added in Python 2.7. */
CHECK_1_FORMAT("%llu", unsigned PY_LONG_LONG); CHECK_1_FORMAT("%llu", unsigned long long);
CHECK_1_FORMAT("%lld", PY_LONG_LONG); CHECK_1_FORMAT("%lld", long long);
Py_RETURN_NONE; Py_RETURN_NONE;
@ -3696,7 +3696,7 @@ test_pytime_fromsecondsobject(PyObject *self, PyObject *args)
static PyObject * static PyObject *
test_pytime_assecondsdouble(PyObject *self, PyObject *args) test_pytime_assecondsdouble(PyObject *self, PyObject *args)
{ {
PY_LONG_LONG ns; long long ns;
_PyTime_t ts; _PyTime_t ts;
double d; double d;
@ -3710,7 +3710,7 @@ test_pytime_assecondsdouble(PyObject *self, PyObject *args)
static PyObject * static PyObject *
test_PyTime_AsTimeval(PyObject *self, PyObject *args) test_PyTime_AsTimeval(PyObject *self, PyObject *args)
{ {
PY_LONG_LONG ns; long long ns;
int round; int round;
_PyTime_t t; _PyTime_t t;
struct timeval tv; struct timeval tv;
@ -3724,7 +3724,7 @@ test_PyTime_AsTimeval(PyObject *self, PyObject *args)
if (_PyTime_AsTimeval(t, &tv, round) < 0) if (_PyTime_AsTimeval(t, &tv, round) < 0)
return NULL; return NULL;
seconds = PyLong_FromLong((PY_LONG_LONG)tv.tv_sec); seconds = PyLong_FromLong((long long)tv.tv_sec);
if (seconds == NULL) if (seconds == NULL)
return NULL; return NULL;
return Py_BuildValue("Nl", seconds, tv.tv_usec); return Py_BuildValue("Nl", seconds, tv.tv_usec);
@ -3734,7 +3734,7 @@ test_PyTime_AsTimeval(PyObject *self, PyObject *args)
static PyObject * static PyObject *
test_PyTime_AsTimespec(PyObject *self, PyObject *args) test_PyTime_AsTimespec(PyObject *self, PyObject *args)
{ {
PY_LONG_LONG ns; long long ns;
_PyTime_t t; _PyTime_t t;
struct timespec ts; struct timespec ts;
@ -3750,7 +3750,7 @@ test_PyTime_AsTimespec(PyObject *self, PyObject *args)
static PyObject * static PyObject *
test_PyTime_AsMilliseconds(PyObject *self, PyObject *args) test_PyTime_AsMilliseconds(PyObject *self, PyObject *args)
{ {
PY_LONG_LONG ns; long long ns;
int round; int round;
_PyTime_t t, ms; _PyTime_t t, ms;
@ -3768,7 +3768,7 @@ test_PyTime_AsMilliseconds(PyObject *self, PyObject *args)
static PyObject * static PyObject *
test_PyTime_AsMicroseconds(PyObject *self, PyObject *args) test_PyTime_AsMicroseconds(PyObject *self, PyObject *args)
{ {
PY_LONG_LONG ns; long long ns;
int round; int round;
_PyTime_t t, ms; _PyTime_t t, ms;
@ -4141,8 +4141,8 @@ typedef struct {
float float_member; float float_member;
double double_member; double double_member;
char inplace_member[6]; char inplace_member[6];
PY_LONG_LONG longlong_member; long long longlong_member;
unsigned PY_LONG_LONG ulonglong_member; unsigned long long ulonglong_member;
} all_structmembers; } all_structmembers;
typedef struct { typedef struct {

View File

@ -141,7 +141,7 @@ struct addrinfo {
* RFC 2553: protocol-independent placeholder for socket addresses * RFC 2553: protocol-independent placeholder for socket addresses
*/ */
#define _SS_MAXSIZE 128 #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_PAD1SIZE (_SS_ALIGNSIZE - sizeof(u_char) * 2)
#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \ #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(u_char) * 2 - \
_SS_PAD1SIZE - _SS_ALIGNSIZE) _SS_PAD1SIZE - _SS_ALIGNSIZE)
@ -154,7 +154,7 @@ struct sockaddr_storage {
unsigned short ss_family; /* address family */ unsigned short ss_family; /* address family */
#endif /* HAVE_SOCKADDR_SA_LEN */ #endif /* HAVE_SOCKADDR_SA_LEN */
char __ss_pad1[_SS_PAD1SIZE]; 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]; char __ss_pad2[_SS_PAD2SIZE];
}; };
#endif /* !HAVE_SOCKADDR_STORAGE */ #endif /* !HAVE_SOCKADDR_STORAGE */

View File

@ -421,17 +421,17 @@ LL_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
static PyObject * static PyObject *
q_getitem(arrayobject *ap, Py_ssize_t i) 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 static int
q_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) 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)) if (!PyArg_Parse(v, "L;array item must be integer", &x))
return -1; return -1;
if (i >= 0) if (i >= 0)
((PY_LONG_LONG *)ap->ob_item)[i] = x; ((long long *)ap->ob_item)[i] = x;
return 0; return 0;
} }
@ -439,20 +439,20 @@ static PyObject *
QQ_getitem(arrayobject *ap, Py_ssize_t i) QQ_getitem(arrayobject *ap, Py_ssize_t i)
{ {
return PyLong_FromUnsignedLongLong( return PyLong_FromUnsignedLongLong(
((unsigned PY_LONG_LONG *)ap->ob_item)[i]); ((unsigned long long *)ap->ob_item)[i]);
} }
static int static int
QQ_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v) QQ_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
{ {
unsigned PY_LONG_LONG x; unsigned long long x;
if (PyLong_Check(v)) { if (PyLong_Check(v)) {
x = PyLong_AsUnsignedLongLong(v); x = PyLong_AsUnsignedLongLong(v);
if (x == (unsigned PY_LONG_LONG) -1 && PyErr_Occurred()) if (x == (unsigned long long) -1 && PyErr_Occurred())
return -1; return -1;
} }
else { else {
PY_LONG_LONG y; long long y;
if (!PyArg_Parse(v, "L;array item must be integer", &y)) if (!PyArg_Parse(v, "L;array item must be integer", &y))
return -1; return -1;
if (y < 0) { if (y < 0) {
@ -460,11 +460,11 @@ QQ_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
"unsigned long long is less than minimum"); "unsigned long long is less than minimum");
return -1; return -1;
} }
x = (unsigned PY_LONG_LONG)y; x = (unsigned long long)y;
} }
if (i >= 0) if (i >= 0)
((unsigned PY_LONG_LONG *)ap->ob_item)[i] = x; ((unsigned long long *)ap->ob_item)[i] = x;
return 0; return 0;
} }
@ -518,8 +518,8 @@ static const struct arraydescr descriptors[] = {
{'I', sizeof(int), II_getitem, II_setitem, "I", 1, 0}, {'I', sizeof(int), II_getitem, II_setitem, "I", 1, 0},
{'l', sizeof(long), l_getitem, l_setitem, "l", 1, 1}, {'l', sizeof(long), l_getitem, l_setitem, "l", 1, 1},
{'L', sizeof(long), LL_getitem, LL_setitem, "L", 1, 0}, {'L', sizeof(long), LL_getitem, LL_setitem, "L", 1, 0},
{'q', sizeof(PY_LONG_LONG), q_getitem, q_setitem, "q", 1, 1}, {'q', sizeof(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), QQ_getitem, QQ_setitem, "Q", 1, 0},
{'f', sizeof(float), f_getitem, f_setitem, "f", 0, 0}, {'f', sizeof(float), f_getitem, f_setitem, "f", 0, 0},
{'d', sizeof(double), d_getitem, d_setitem, "d", 0, 0}, {'d', sizeof(double), d_getitem, d_setitem, "d", 0, 0},
{'\0', 0, 0, 0, 0, 0, 0} /* Sentinel */ {'\0', 0, 0, 0, 0, 0, 0} /* Sentinel */
@ -1810,11 +1810,11 @@ typecode_to_mformat_code(char typecode)
is_signed = 0; is_signed = 0;
break; break;
case 'q': case 'q':
intsize = sizeof(PY_LONG_LONG); intsize = sizeof(long long);
is_signed = 1; is_signed = 1;
break; break;
case 'Q': case 'Q':
intsize = sizeof(PY_LONG_LONG); intsize = sizeof(long long);
is_signed = 0; is_signed = 0;
break; break;
default: default:

View File

@ -30,7 +30,7 @@ class MD5Type "MD5object *" "&PyType_Type"
#if SIZEOF_INT == 4 #if SIZEOF_INT == 4
typedef unsigned int MD5_INT32; /* 32-bit integer */ 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 #else
/* not defined. compilation will die. */ /* not defined. compilation will die. */
#endif #endif

View File

@ -93,7 +93,7 @@ typedef struct {
size_t size; size_t size;
size_t pos; /* relative to offset */ size_t pos; /* relative to offset */
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
PY_LONG_LONG offset; long long offset;
#else #else
off_t offset; off_t offset;
#endif #endif
@ -446,7 +446,7 @@ mmap_size_method(mmap_object *self,
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (self->file_handle != INVALID_HANDLE_VALUE) { if (self->file_handle != INVALID_HANDLE_VALUE) {
DWORD low,high; DWORD low,high;
PY_LONG_LONG size; long long size;
low = GetFileSize(self->file_handle, &high); low = GetFileSize(self->file_handle, &high);
if (low == INVALID_FILE_SIZE) { if (low == INVALID_FILE_SIZE) {
/* It might be that the function appears to have failed, /* 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) if (!high && low < LONG_MAX)
return PyLong_FromLong((long)low); return PyLong_FromLong((long)low);
size = (((PY_LONG_LONG)high)<<32) + low; size = (((long long)high)<<32) + low;
return PyLong_FromLongLong(size); return PyLong_FromLongLong(size);
} else { } else {
return PyLong_FromSsize_t(self->size); 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 /* 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 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 * static PyObject *
@ -1267,7 +1267,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
mmap_object *m_obj; mmap_object *m_obj;
PyObject *map_size_obj = NULL; PyObject *map_size_obj = NULL;
Py_ssize_t map_size; 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_hi; /* upper 32 bits of offset */
DWORD off_lo; /* lower 32 bits of offset */ DWORD off_lo; /* lower 32 bits of offset */
DWORD size_hi; /* upper 32 bits of size */ 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); return PyErr_SetFromWindowsErr(dwErr);
} }
size = (((PY_LONG_LONG) high) << 32) + low; size = (((long long) high) << 32) + low;
if (size == 0) { if (size == 0) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"cannot mmap an empty file"); "cannot mmap an empty file");

View File

@ -1108,7 +1108,7 @@ dir_fd_and_follow_symlinks_invalid(const char *function_name, int dir_fd,
} }
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
typedef PY_LONG_LONG Py_off_t; typedef long long Py_off_t;
#else #else
typedef off_t Py_off_t; typedef off_t Py_off_t;
#endif #endif
@ -2073,7 +2073,7 @@ _pystat_fromstructstat(STRUCT_STAT *st)
PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode)); PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode));
#ifdef HAVE_LARGEFILE_SUPPORT #ifdef HAVE_LARGEFILE_SUPPORT
PyStructSequence_SET_ITEM(v, 1, PyStructSequence_SET_ITEM(v, 1,
PyLong_FromLongLong((PY_LONG_LONG)st->st_ino)); PyLong_FromLongLong((long long)st->st_ino));
#else #else
PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino)); PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino));
#endif #endif
@ -2092,7 +2092,7 @@ _pystat_fromstructstat(STRUCT_STAT *st)
#endif #endif
#ifdef HAVE_LARGEFILE_SUPPORT #ifdef HAVE_LARGEFILE_SUPPORT
PyStructSequence_SET_ITEM(v, 6, PyStructSequence_SET_ITEM(v, 6,
PyLong_FromLongLong((PY_LONG_LONG)st->st_size)); PyLong_FromLongLong((long long)st->st_size));
#else #else
PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong(st->st_size)); PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong(st->st_size));
#endif #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, 0, PyLong_FromLong((long) st.f_bsize));
PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize)); PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize));
PyStructSequence_SET_ITEM(v, 2, 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, 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, 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, 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, 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, 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, 8, PyLong_FromLong((long) st.f_flag));
PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax));
#endif #endif
@ -11763,10 +11763,10 @@ DirEntry_inode(DirEntry *self)
self->win32_file_index = stat.st_ino; self->win32_file_index = stat.st_ino;
self->got_file_index = 1; 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 */ #else /* POSIX */
#ifdef HAVE_LARGEFILE_SUPPORT #ifdef HAVE_LARGEFILE_SUPPORT
return PyLong_FromLongLong((PY_LONG_LONG)self->d_ino); return PyLong_FromLongLong((long long)self->d_ino);
#else #else
return PyLong_FromLong((long)self->d_ino); return PyLong_FromLong((long)self->d_ino);
#endif #endif

View File

@ -137,8 +137,8 @@ rlimit2py(struct rlimit rl)
{ {
if (sizeof(rl.rlim_cur) > sizeof(long)) { if (sizeof(rl.rlim_cur) > sizeof(long)) {
return Py_BuildValue("LL", return Py_BuildValue("LL",
(PY_LONG_LONG) rl.rlim_cur, (long long) rl.rlim_cur,
(PY_LONG_LONG) rl.rlim_max); (long long) rl.rlim_max);
} }
return Py_BuildValue("ll", (long) rl.rlim_cur, (long) rl.rlim_max); return Py_BuildValue("ll", (long) rl.rlim_cur, (long) rl.rlim_max);
} }
@ -437,7 +437,7 @@ PyInit_resource(void)
#endif #endif
if (sizeof(RLIM_INFINITY) > sizeof(long)) { if (sizeof(RLIM_INFINITY) > sizeof(long)) {
v = PyLong_FromLongLong((PY_LONG_LONG) RLIM_INFINITY); v = PyLong_FromLongLong((long long) RLIM_INFINITY);
} else } else
{ {
v = PyLong_FromLong((long) RLIM_INFINITY); v = PyLong_FromLong((long) RLIM_INFINITY);

View File

@ -30,7 +30,7 @@ class SHA1Type "SHA1object *" "&PyType_Type"
#if SIZEOF_INT == 4 #if SIZEOF_INT == 4
typedef unsigned int SHA1_INT32; /* 32-bit integer */ 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 #else
/* not defined. compilation will die. */ /* not defined. compilation will die. */
#endif #endif

View File

@ -27,15 +27,13 @@ class SHA512Type "SHAobject *" "&PyType_Type"
[clinic start generated code]*/ [clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=81a3ccde92bcfe8d]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=81a3ccde92bcfe8d]*/
#ifdef PY_LONG_LONG /* If no PY_LONG_LONG, don't compile anything! */
/* Some useful types */ /* Some useful types */
typedef unsigned char SHA_BYTE; typedef unsigned char SHA_BYTE;
#if SIZEOF_INT == 4 #if SIZEOF_INT == 4
typedef unsigned int SHA_INT32; /* 32-bit integer */ 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 #else
/* not defined. compilation will die. */ /* not defined. compilation will die. */
#endif #endif
@ -121,12 +119,12 @@ static void SHAcopy(SHAobject *src, SHAobject *dest)
/* Various logical functions */ /* Various logical functions */
#define ROR64(x, y) \ #define ROR64(x, y) \
( ((((x) & Py_ULL(0xFFFFFFFFFFFFFFFF))>>((unsigned PY_LONG_LONG)(y) & 63)) | \ ( ((((x) & Py_ULL(0xFFFFFFFFFFFFFFFF))>>((unsigned long long)(y) & 63)) | \
((x)<<((unsigned PY_LONG_LONG)(64-((y) & 63))))) & Py_ULL(0xFFFFFFFFFFFFFFFF)) ((x)<<((unsigned long long)(64-((y) & 63))))) & Py_ULL(0xFFFFFFFFFFFFFFFF))
#define Ch(x,y,z) (z ^ (x & (y ^ z))) #define Ch(x,y,z) (z ^ (x & (y ^ z)))
#define Maj(x,y,z) (((x | y) & z) | (x & y)) #define Maj(x,y,z) (((x | y) & z) | (x & y))
#define S(x, n) ROR64((x),(n)) #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 Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39))
#define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41)) #define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41))
#define Gamma0(x) (S(x, 1) ^ S(x, 8) ^ R(x, 7)) #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); PyModule_AddObject(m, "SHA512Type", (PyObject *)&SHA512type);
return m; return m;
} }
#endif

View File

@ -993,9 +993,9 @@ PyLong_FromVoidPtr(void *p)
#else #else
#if SIZEOF_LONG_LONG < SIZEOF_VOID_P #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 #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 */ #endif /* SIZEOF_VOID_P <= SIZEOF_LONG */
} }
@ -1015,9 +1015,9 @@ PyLong_AsVoidPtr(PyObject *vv)
#else #else
#if SIZEOF_LONG_LONG < SIZEOF_VOID_P #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 #endif
PY_LONG_LONG x; long long x;
if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0) if (PyLong_Check(vv) && _PyLong_Sign(vv) < 0)
x = PyLong_AsLongLong(vv); x = PyLong_AsLongLong(vv);
@ -1031,20 +1031,20 @@ PyLong_AsVoidPtr(PyObject *vv)
return (void *)x; 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. * 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 * PyObject *
PyLong_FromLongLong(PY_LONG_LONG ival) PyLong_FromLongLong(long long ival)
{ {
PyLongObject *v; PyLongObject *v;
unsigned PY_LONG_LONG abs_ival; unsigned long long abs_ival;
unsigned PY_LONG_LONG t; /* unsigned so >> doesn't propagate sign bit */ unsigned long long t; /* unsigned so >> doesn't propagate sign bit */
int ndigits = 0; int ndigits = 0;
int negative = 0; int negative = 0;
@ -1052,11 +1052,11 @@ PyLong_FromLongLong(PY_LONG_LONG ival)
if (ival < 0) { if (ival < 0) {
/* avoid signed overflow on negation; see comments /* avoid signed overflow on negation; see comments
in PyLong_FromLong above. */ in PyLong_FromLong above. */
abs_ival = (unsigned PY_LONG_LONG)(-1-ival) + 1; abs_ival = (unsigned long long)(-1-ival) + 1;
negative = 1; negative = 1;
} }
else { else {
abs_ival = (unsigned PY_LONG_LONG)ival; abs_ival = (unsigned long long)ival;
} }
/* Count the number of Python digits. /* Count the number of Python digits.
@ -1081,19 +1081,19 @@ PyLong_FromLongLong(PY_LONG_LONG ival)
return (PyObject *)v; 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 * PyObject *
PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG ival) PyLong_FromUnsignedLongLong(unsigned long long ival)
{ {
PyLongObject *v; PyLongObject *v;
unsigned PY_LONG_LONG t; unsigned long long t;
int ndigits = 0; int ndigits = 0;
if (ival < PyLong_BASE) if (ival < PyLong_BASE)
return PyLong_FromLong((long)ival); return PyLong_FromLong((long)ival);
/* Count the number of Python digits. */ /* Count the number of Python digits. */
t = (unsigned PY_LONG_LONG)ival; t = (unsigned long long)ival;
while (t) { while (t) {
++ndigits; ++ndigits;
t >>= PyLong_SHIFT; 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 /* 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. */ __int__ method. Return -1 and set an error if overflow occurs. */
PY_LONG_LONG long long
PyLong_AsLongLong(PyObject *vv) PyLong_AsLongLong(PyObject *vv)
{ {
PyLongObject *v; PyLongObject *v;
PY_LONG_LONG bytes; long long bytes;
int res; int res;
int do_decref = 0; /* if nb_int was called */ int do_decref = 0; /* if nb_int was called */
@ -1224,30 +1224,30 @@ PyLong_AsLongLong(PyObject *vv)
Py_DECREF(v); 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) if (res < 0)
return (PY_LONG_LONG)-1; return (long long)-1;
else else
return bytes; 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. */ Return -1 and set an error if overflow occurs. */
unsigned PY_LONG_LONG unsigned long long
PyLong_AsUnsignedLongLong(PyObject *vv) PyLong_AsUnsignedLongLong(PyObject *vv)
{ {
PyLongObject *v; PyLongObject *v;
unsigned PY_LONG_LONG bytes; unsigned long long bytes;
int res; int res;
if (vv == NULL) { if (vv == NULL) {
PyErr_BadInternalCall(); PyErr_BadInternalCall();
return (unsigned PY_LONG_LONG)-1; return (unsigned long long)-1;
} }
if (!PyLong_Check(vv)) { if (!PyLong_Check(vv)) {
PyErr_SetString(PyExc_TypeError, "an integer is required"); PyErr_SetString(PyExc_TypeError, "an integer is required");
return (unsigned PY_LONG_LONG)-1; return (unsigned long long)-1;
} }
v = (PyLongObject*)vv; v = (PyLongObject*)vv;
@ -1259,9 +1259,9 @@ PyLong_AsUnsignedLongLong(PyObject *vv)
res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes, res = _PyLong_AsByteArray((PyLongObject *)vv, (unsigned char *)&bytes,
SIZEOF_LONG_LONG, PY_LITTLE_ENDIAN, 0); 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) if (res < 0)
return (unsigned PY_LONG_LONG)res; return (unsigned long long)res;
else else
return bytes; return bytes;
} }
@ -1269,11 +1269,11 @@ PyLong_AsUnsignedLongLong(PyObject *vv)
/* Get a C unsigned long int from an int object, ignoring the high bits. /* 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. */ Returns -1 and sets an error condition if an error occurs. */
static unsigned PY_LONG_LONG static unsigned long long
_PyLong_AsUnsignedLongLongMask(PyObject *vv) _PyLong_AsUnsignedLongLongMask(PyObject *vv)
{ {
PyLongObject *v; PyLongObject *v;
unsigned PY_LONG_LONG x; unsigned long long x;
Py_ssize_t i; Py_ssize_t i;
int sign; int sign;
@ -1299,11 +1299,11 @@ _PyLong_AsUnsignedLongLongMask(PyObject *vv)
return x * sign; return x * sign;
} }
unsigned PY_LONG_LONG unsigned long long
PyLong_AsUnsignedLongLongMask(PyObject *op) PyLong_AsUnsignedLongLongMask(PyObject *op)
{ {
PyLongObject *lo; PyLongObject *lo;
unsigned PY_LONG_LONG val; unsigned long long val;
if (op == NULL) { if (op == NULL) {
PyErr_BadInternalCall(); PyErr_BadInternalCall();
@ -1316,7 +1316,7 @@ PyLong_AsUnsignedLongLongMask(PyObject *op)
lo = _PyLong_FromNbInt(op); lo = _PyLong_FromNbInt(op);
if (lo == NULL) if (lo == NULL)
return (unsigned PY_LONG_LONG)-1; return (unsigned long long)-1;
val = _PyLong_AsUnsignedLongLongMask((PyObject *)lo); val = _PyLong_AsUnsignedLongLongMask((PyObject *)lo);
Py_DECREF(lo); Py_DECREF(lo);
@ -1333,13 +1333,13 @@ PyLong_AsUnsignedLongLongMask(PyObject *op)
In this case *overflow will be 0. In this case *overflow will be 0.
*/ */
PY_LONG_LONG long long
PyLong_AsLongLongAndOverflow(PyObject *vv, int *overflow) PyLong_AsLongLongAndOverflow(PyObject *vv, int *overflow)
{ {
/* This version by Tim Peters */ /* This version by Tim Peters */
PyLongObject *v; PyLongObject *v;
unsigned PY_LONG_LONG x, prev; unsigned long long x, prev;
PY_LONG_LONG res; long long res;
Py_ssize_t i; Py_ssize_t i;
int sign; int sign;
int do_decref = 0; /* if nb_int was called */ 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 /* Haven't lost any bits, but casting to long requires extra
* care (see comment above). * care (see comment above).
*/ */
if (x <= (unsigned PY_LONG_LONG)PY_LLONG_MAX) { if (x <= (unsigned long long)PY_LLONG_MAX) {
res = (PY_LONG_LONG)x * sign; res = (long long)x * sign;
} }
else if (sign < 0 && x == PY_ABS_LLONG_MIN) { else if (sign < 0 && x == PY_ABS_LLONG_MIN) {
res = PY_LLONG_MIN; res = PY_LLONG_MIN;
@ -3481,7 +3481,7 @@ long_mul(PyLongObject *a, PyLongObject *b)
/* fast path for single-digit multiplication */ /* fast path for single-digit multiplication */
if (Py_ABS(Py_SIZE(a)) <= 1 && Py_ABS(Py_SIZE(b)) <= 1) { if (Py_ABS(Py_SIZE(a)) <= 1 && Py_ABS(Py_SIZE(b)) <= 1) {
stwodigits v = (stwodigits)(MEDIUM_VALUE(a)) * MEDIUM_VALUE(b); 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); z = k_mul(a, b);
@ -4650,7 +4650,7 @@ simple:
/* a fits into a long, so b must too */ /* a fits into a long, so b must too */
x = PyLong_AsLong((PyObject *)a); x = PyLong_AsLong((PyObject *)a);
y = PyLong_AsLong((PyObject *)b); 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); x = PyLong_AsLongLong((PyObject *)a);
y = PyLong_AsLongLong((PyObject *)b); y = PyLong_AsLongLong((PyObject *)b);
#else #else
@ -4669,7 +4669,7 @@ simple:
} }
#if LONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT #if LONG_MAX >> PyLong_SHIFT >> PyLong_SHIFT
return PyLong_FromLong(x); 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); return PyLong_FromLongLong(x);
#else #else
# error "_PyLong_GCD" # error "_PyLong_GCD"

View File

@ -1111,7 +1111,7 @@ get_native_fmtchar(char *result, const char *fmt)
case 'h': case 'H': size = sizeof(short); break; case 'h': case 'H': size = sizeof(short); break;
case 'i': case 'I': size = sizeof(int); break; case 'i': case 'I': size = sizeof(int); break;
case 'l': case 'L': size = sizeof(long); 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 'n': case 'N': size = sizeof(Py_ssize_t); break;
case 'f': size = sizeof(float); break; case 'f': size = sizeof(float); break;
case 'd': size = sizeof(double); break; case 'd': size = sizeof(double); break;
@ -1577,11 +1577,11 @@ pylong_as_lu(PyObject *item)
return lu; return lu;
} }
static PY_LONG_LONG static long long
pylong_as_lld(PyObject *item) pylong_as_lld(PyObject *item)
{ {
PyObject *tmp; PyObject *tmp;
PY_LONG_LONG lld; long long lld;
tmp = PyNumber_Index(item); tmp = PyNumber_Index(item);
if (tmp == NULL) if (tmp == NULL)
@ -1592,15 +1592,15 @@ pylong_as_lld(PyObject *item)
return lld; return lld;
} }
static unsigned PY_LONG_LONG static unsigned long long
pylong_as_llu(PyObject *item) pylong_as_llu(PyObject *item)
{ {
PyObject *tmp; PyObject *tmp;
unsigned PY_LONG_LONG llu; unsigned long long llu;
tmp = PyNumber_Index(item); tmp = PyNumber_Index(item);
if (tmp == NULL) if (tmp == NULL)
return (unsigned PY_LONG_LONG)-1; return (unsigned long long)-1;
llu = PyLong_AsUnsignedLongLong(tmp); llu = PyLong_AsUnsignedLongLong(tmp);
Py_DECREF(tmp); Py_DECREF(tmp);
@ -1653,10 +1653,10 @@ pylong_as_zu(PyObject *item)
Py_LOCAL_INLINE(PyObject *) Py_LOCAL_INLINE(PyObject *)
unpack_single(const char *ptr, const char *fmt) unpack_single(const char *ptr, const char *fmt)
{ {
unsigned PY_LONG_LONG llu; unsigned long long llu;
unsigned long lu; unsigned long lu;
size_t zu; size_t zu;
PY_LONG_LONG lld; long long lld;
long ld; long ld;
Py_ssize_t zd; Py_ssize_t zd;
double d; 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; case 'L': UNPACK_SINGLE(lu, ptr, unsigned long); goto convert_lu;
/* native 64-bit */ /* native 64-bit */
case 'q': UNPACK_SINGLE(lld, ptr, PY_LONG_LONG); goto convert_lld; case 'q': UNPACK_SINGLE(lld, ptr, long long); goto convert_lld;
case 'Q': UNPACK_SINGLE(llu, ptr, unsigned PY_LONG_LONG); goto convert_llu; case 'Q': UNPACK_SINGLE(llu, ptr, unsigned long long); goto convert_llu;
/* ssize_t and size_t */ /* ssize_t and size_t */
case 'n': UNPACK_SINGLE(zd, ptr, Py_ssize_t); goto convert_zd; case 'n': UNPACK_SINGLE(zd, ptr, Py_ssize_t); goto convert_zd;
@ -1747,10 +1747,10 @@ err_format:
static int static int
pack_single(char *ptr, PyObject *item, const char *fmt) pack_single(char *ptr, PyObject *item, const char *fmt)
{ {
unsigned PY_LONG_LONG llu; unsigned long long llu;
unsigned long lu; unsigned long lu;
size_t zu; size_t zu;
PY_LONG_LONG lld; long long lld;
long ld; long ld;
Py_ssize_t zd; Py_ssize_t zd;
double d; double d;
@ -1802,13 +1802,13 @@ pack_single(char *ptr, PyObject *item, const char *fmt)
lld = pylong_as_lld(item); lld = pylong_as_lld(item);
if (lld == -1 && PyErr_Occurred()) if (lld == -1 && PyErr_Occurred())
goto err_occurred; goto err_occurred;
PACK_SINGLE(ptr, lld, PY_LONG_LONG); PACK_SINGLE(ptr, lld, long long);
break; break;
case 'Q': case 'Q':
llu = pylong_as_llu(item); 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; goto err_occurred;
PACK_SINGLE(ptr, llu, unsigned PY_LONG_LONG); PACK_SINGLE(ptr, llu, unsigned long long);
break; break;
/* ssize_t and size_t */ /* 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; case 'L': CMP_SINGLE(p, q, unsigned long); return equal;
/* native 64-bit */ /* native 64-bit */
case 'q': CMP_SINGLE(p, q, PY_LONG_LONG); return equal; case 'q': CMP_SINGLE(p, q, long long); return equal;
case 'Q': CMP_SINGLE(p, q, unsigned PY_LONG_LONG); return equal; case 'Q': CMP_SINGLE(p, q, unsigned long long); return equal;
/* ssize_t and size_t */ /* ssize_t and size_t */
case 'n': CMP_SINGLE(p, q, Py_ssize_t); return equal; case 'n': CMP_SINGLE(p, q, Py_ssize_t); return equal;

View File

@ -6,7 +6,7 @@
/* Support objects whose length is > PY_SSIZE_T_MAX. /* 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 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. would presumably help perf.
*/ */

View File

@ -2680,7 +2680,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
va_arg(*vargs, unsigned long)); va_arg(*vargs, unsigned long));
else if (longlongflag) else if (longlongflag)
len = sprintf(buffer, "%" PY_FORMAT_LONG_LONG "u", 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) else if (size_tflag)
len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "u", len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "u",
va_arg(*vargs, size_t)); va_arg(*vargs, size_t));
@ -2697,7 +2697,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
va_arg(*vargs, long)); va_arg(*vargs, long));
else if (longlongflag) else if (longlongflag)
len = sprintf(buffer, "%" PY_FORMAT_LONG_LONG "i", len = sprintf(buffer, "%" PY_FORMAT_LONG_LONG "i",
va_arg(*vargs, PY_LONG_LONG)); va_arg(*vargs, long long));
else if (size_tflag) else if (size_tflag)
len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "i", len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "i",
va_arg(*vargs, Py_ssize_t)); va_arg(*vargs, Py_ssize_t));

View File

@ -265,7 +265,6 @@ typedef int pid_t;
#endif #endif
/* 64 bit ints are usually spelt __int64 unless compiler has overridden */ /* 64 bit ints are usually spelt __int64 unless compiler has overridden */
#define HAVE_LONG_LONG 1
#ifndef PY_LONG_LONG #ifndef PY_LONG_LONG
# define PY_LONG_LONG __int64 # define PY_LONG_LONG __int64
# define PY_LLONG_MAX _I64_MAX # 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 #ifndef PY_UINT64_T
#if SIZEOF_LONG_LONG == 8 #if SIZEOF_LONG_LONG == 8
#define HAVE_UINT64_T 1 #define HAVE_UINT64_T 1
#define PY_UINT64_T unsigned PY_LONG_LONG #define PY_UINT64_T unsigned long long
#endif #endif
#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 #ifndef PY_INT64_T
#if SIZEOF_LONG_LONG == 8 #if SIZEOF_LONG_LONG == 8
#define HAVE_INT64_T 1 #define HAVE_INT64_T 1
#define PY_INT64_T PY_LONG_LONG #define PY_INT64_T long long
#endif #endif
#endif #endif

View File

@ -89,7 +89,7 @@ do { /* TODO: add overflow and truncation checks */ \
/* return 0 for success, 1 on timeout, -1 on error */ /* return 0 for success, 1 on timeout, -1 on error */
Py_LOCAL_INLINE(int) 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; int r;
struct timespec ts; struct timespec ts;
@ -270,7 +270,7 @@ PyCOND_WAIT(PyCOND_T *cv, PyMUTEX_T *cs)
} }
Py_LOCAL_INLINE(int) 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)); 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. * 2 to indicate that we don't know.
*/ */
Py_LOCAL_INLINE(int) 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; return SleepConditionVariableSRW(cv, cs, (DWORD)(us/1000), 0) ? 2 : -1;
} }

View File

@ -769,13 +769,13 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
break; break;
} }
case 'L': {/* PY_LONG_LONG */ case 'L': {/* long long */
PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * ); long long *p = va_arg( *p_va, long long * );
PY_LONG_LONG ival; long long ival;
if (float_argument_error(arg)) if (float_argument_error(arg))
RETURN_ERR_OCCURRED; RETURN_ERR_OCCURRED;
ival = PyLong_AsLongLong(arg); ival = PyLong_AsLongLong(arg);
if (ival == (PY_LONG_LONG)-1 && PyErr_Occurred()) if (ival == (long long)-1 && PyErr_Occurred())
RETURN_ERR_OCCURRED; RETURN_ERR_OCCURRED;
else else
*p = ival; *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 */ case 'K': { /* long long sized bitfield */
unsigned PY_LONG_LONG *p = va_arg(*p_va, unsigned PY_LONG_LONG *); unsigned long long *p = va_arg(*p_va, unsigned long long *);
unsigned PY_LONG_LONG ival; unsigned long long ival;
if (PyLong_Check(arg)) if (PyLong_Check(arg))
ival = PyLong_AsUnsignedLongLongMask(arg); ival = PyLong_AsUnsignedLongLongMask(arg);
else else
@ -2086,8 +2086,8 @@ skipitem(const char **p_format, va_list *p_va, int flags)
case 'I': /* int sized bitfield */ case 'I': /* int sized bitfield */
case 'l': /* long int */ case 'l': /* long int */
case 'k': /* long int sized bitfield */ case 'k': /* long int sized bitfield */
case 'L': /* PY_LONG_LONG */ case 'L': /* long long */
case 'K': /* PY_LONG_LONG sized bitfield */ case 'K': /* long long sized bitfield */
case 'n': /* Py_ssize_t */ case 'n': /* Py_ssize_t */
case 'f': /* float */ case 'f': /* float */
case 'd': /* double */ case 'd': /* double */

View File

@ -261,10 +261,10 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
} }
case 'L': 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': 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': case 'u':
{ {

View File

@ -39,7 +39,7 @@ time_t
_PyLong_AsTime_t(PyObject *obj) _PyLong_AsTime_t(PyObject *obj)
{ {
#if SIZEOF_TIME_T == SIZEOF_LONG_LONG #if SIZEOF_TIME_T == SIZEOF_LONG_LONG
PY_LONG_LONG val; long long val;
val = PyLong_AsLongLong(obj); val = PyLong_AsLongLong(obj);
#else #else
long val; long val;
@ -58,7 +58,7 @@ PyObject *
_PyLong_FromTime_t(time_t t) _PyLong_FromTime_t(time_t t)
{ {
#if SIZEOF_TIME_T == SIZEOF_LONG_LONG #if SIZEOF_TIME_T == SIZEOF_LONG_LONG
return PyLong_FromLongLong((PY_LONG_LONG)t); return PyLong_FromLongLong((long long)t);
#else #else
Py_BUILD_ASSERT(sizeof(time_t) <= sizeof(long)); Py_BUILD_ASSERT(sizeof(time_t) <= sizeof(long));
return PyLong_FromLong((long)t); return PyLong_FromLong((long)t);
@ -218,11 +218,11 @@ _PyTime_FromSeconds(int seconds)
} }
_PyTime_t _PyTime_t
_PyTime_FromNanoseconds(PY_LONG_LONG ns) _PyTime_FromNanoseconds(long long ns)
{ {
_PyTime_t t; _PyTime_t t;
Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t)); Py_BUILD_ASSERT(sizeof(long long) <= sizeof(_PyTime_t));
t = Py_SAFE_DOWNCAST(ns, PY_LONG_LONG, _PyTime_t); t = Py_SAFE_DOWNCAST(ns, long long, _PyTime_t);
return 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); return _PyTime_FromFloatObject(t, d, round, unit_to_ns);
} }
else { else {
PY_LONG_LONG sec; long long sec;
Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) <= sizeof(_PyTime_t)); Py_BUILD_ASSERT(sizeof(long long) <= sizeof(_PyTime_t));
sec = PyLong_AsLongLong(obj); sec = PyLong_AsLongLong(obj);
if (sec == -1 && PyErr_Occurred()) { if (sec == -1 && PyErr_Occurred()) {
@ -358,8 +358,8 @@ _PyTime_AsSecondsDouble(_PyTime_t t)
PyObject * PyObject *
_PyTime_AsNanosecondsObject(_PyTime_t t) _PyTime_AsNanosecondsObject(_PyTime_t t)
{ {
Py_BUILD_ASSERT(sizeof(PY_LONG_LONG) >= sizeof(_PyTime_t)); Py_BUILD_ASSERT(sizeof(long long) >= sizeof(_PyTime_t));
return PyLong_FromLongLong((PY_LONG_LONG)t); return PyLong_FromLongLong((long long)t);
} }
static _PyTime_t static _PyTime_t

View File

@ -75,10 +75,10 @@ PyMember_GetOne(const char *addr, PyMemberDef *l)
Py_XINCREF(v); Py_XINCREF(v);
break; break;
case T_LONGLONG: case T_LONGLONG:
v = PyLong_FromLongLong(*(PY_LONG_LONG *)addr); v = PyLong_FromLongLong(*(long long *)addr);
break; break;
case T_ULONGLONG: case T_ULONGLONG:
v = PyLong_FromUnsignedLongLong(*(unsigned PY_LONG_LONG *)addr); v = PyLong_FromUnsignedLongLong(*(unsigned long long *)addr);
break; break;
case T_NONE: case T_NONE:
v = Py_None; v = Py_None;
@ -265,21 +265,21 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
PyErr_SetString(PyExc_TypeError, "readonly attribute"); PyErr_SetString(PyExc_TypeError, "readonly attribute");
return -1; return -1;
case T_LONGLONG:{ case T_LONGLONG:{
PY_LONG_LONG value; long long value;
*(PY_LONG_LONG*)addr = value = PyLong_AsLongLong(v); *(long long*)addr = value = PyLong_AsLongLong(v);
if ((value == -1) && PyErr_Occurred()) if ((value == -1) && PyErr_Occurred())
return -1; return -1;
break; break;
} }
case T_ULONGLONG:{ case T_ULONGLONG:{
unsigned PY_LONG_LONG value; unsigned long long value;
/* ??? PyLong_AsLongLong accepts an int, but PyLong_AsUnsignedLongLong /* ??? PyLong_AsLongLong accepts an int, but PyLong_AsUnsignedLongLong
doesn't ??? */ doesn't ??? */
if (PyLong_Check(v)) if (PyLong_Check(v))
*(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); *(unsigned long long*)addr = value = PyLong_AsUnsignedLongLong(v);
else else
*(unsigned PY_LONG_LONG*)addr = value = PyLong_AsLong(v); *(unsigned long long*)addr = value = PyLong_AsLong(v);
if ((value == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred()) if ((value == (unsigned long long)-1) && PyErr_Occurred())
return -1; return -1;
break; break;
} }

View File

@ -77,7 +77,7 @@ EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds)
/* wait at least until the target */ /* wait at least until the target */
DWORD now, target = GetTickCount() + milliseconds; DWORD now, target = GetTickCount() + milliseconds;
while (mutex->locked) { 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; result = WAIT_FAILED;
break; break;
} }