mirror of https://github.com/python/cpython
more PY_LONG_LONG to long long
This commit is contained in:
parent
c71ec8aef3
commit
47ff0734b8
|
@ -265,15 +265,12 @@ Numbers
|
|||
Convert a Python integer to a C :c:type:`unsigned long` without
|
||||
overflow checking.
|
||||
|
||||
``L`` (:class:`int`) [PY_LONG_LONG]
|
||||
Convert a Python integer to a C :c:type:`long long`. This format is only
|
||||
available on platforms that support :c:type:`long long` (or :c:type:`_int64` on
|
||||
Windows).
|
||||
``L`` (:class:`int`) [long long]
|
||||
Convert a Python integer to a C :c:type:`long long`.
|
||||
|
||||
``K`` (:class:`int`) [unsigned PY_LONG_LONG]
|
||||
``K`` (:class:`int`) [unsigned long long]
|
||||
Convert a Python integer to a C :c:type:`unsigned long long`
|
||||
without overflow checking. This format is only available on platforms that
|
||||
support :c:type:`unsigned long long` (or :c:type:`unsigned _int64` on Windows).
|
||||
without overflow checking.
|
||||
|
||||
``n`` (:class:`int`) [Py_ssize_t]
|
||||
Convert a Python integer to a C :c:type:`Py_ssize_t`.
|
||||
|
@ -594,15 +591,11 @@ Building values
|
|||
``k`` (:class:`int`) [unsigned long]
|
||||
Convert a C :c:type:`unsigned long` to a Python integer object.
|
||||
|
||||
``L`` (:class:`int`) [PY_LONG_LONG]
|
||||
Convert a C :c:type:`long long` to a Python integer object. Only available
|
||||
on platforms that support :c:type:`long long` (or :c:type:`_int64` on
|
||||
Windows).
|
||||
``L`` (:class:`int`) [long long]
|
||||
Convert a C :c:type:`long long` to a Python integer object.
|
||||
|
||||
``K`` (:class:`int`) [unsigned PY_LONG_LONG]
|
||||
Convert a C :c:type:`unsigned long long` to a Python integer object. Only
|
||||
available on platforms that support :c:type:`unsigned long long` (or
|
||||
:c:type:`unsigned _int64` on Windows).
|
||||
``K`` (:class:`int`) [unsigned long long]
|
||||
Convert a C :c:type:`unsigned long long` to a Python integer object.
|
||||
|
||||
``n`` (:class:`int`) [Py_ssize_t]
|
||||
Convert a C :c:type:`Py_ssize_t` to a Python integer.
|
||||
|
|
|
@ -62,13 +62,13 @@ All integers are implemented as "long" integer objects of arbitrary size.
|
|||
*NULL* on failure.
|
||||
|
||||
|
||||
.. c:function:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v)
|
||||
.. c:function:: PyObject* PyLong_FromLongLong(long long v)
|
||||
|
||||
Return a new :c:type:`PyLongObject` object from a C :c:type:`long long`, or *NULL*
|
||||
on failure.
|
||||
|
||||
|
||||
.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v)
|
||||
.. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned long long v)
|
||||
|
||||
Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long long`,
|
||||
or *NULL* on failure.
|
||||
|
@ -148,7 +148,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
|
|||
occurs set *\*overflow* to ``0`` and return ``-1`` as usual.
|
||||
|
||||
|
||||
.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *obj)
|
||||
.. c:function:: long long PyLong_AsLongLong(PyObject *obj)
|
||||
|
||||
.. index::
|
||||
single: OverflowError (built-in exception)
|
||||
|
@ -161,7 +161,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
|
|||
:c:type:`long`.
|
||||
|
||||
|
||||
.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
|
||||
.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
|
||||
|
||||
Return a C :c:type:`long long` representation of *obj*. If *obj* is not an
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method
|
||||
|
@ -210,16 +210,16 @@ All integers are implemented as "long" integer objects of arbitrary size.
|
|||
:c:type:`size_t`.
|
||||
|
||||
|
||||
.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
|
||||
.. c:function:: unsigned long long PyLong_AsUnsignedLongLong(PyObject *pylong)
|
||||
|
||||
.. index::
|
||||
single: OverflowError (built-in exception)
|
||||
|
||||
Return a C :c:type:`unsigned PY_LONG_LONG` representation of *pylong*.
|
||||
*pylong* must be an instance of :c:type:`PyLongObject`.
|
||||
Return a C :c:type:`unsigned long long` representation of *pylong*. *pylong*
|
||||
must be an instance of :c:type:`PyLongObject`.
|
||||
|
||||
Raise :exc:`OverflowError` if the value of *pylong* is out of range for an
|
||||
:c:type:`unsigned PY_LONG_LONG`.
|
||||
:c:type:`unsigned long long`.
|
||||
|
||||
.. versionchanged:: 3.1
|
||||
A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`.
|
||||
|
@ -235,7 +235,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
|
|||
return the reduction of that value modulo :const:`ULONG_MAX + 1`.
|
||||
|
||||
|
||||
.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *obj)
|
||||
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
|
||||
|
||||
Return a C :c:type:`unsigned long long` representation of *obj*. If *obj*
|
||||
is not an instance of :c:type:`PyLongObject`, first call its :meth:`__int__`
|
||||
|
|
|
@ -440,7 +440,6 @@ APIs:
|
|||
.. % because not all compilers support the %z width modifier -- we fake it
|
||||
.. % when necessary via interpolating PY_FORMAT_SIZE_T.
|
||||
.. % Similar comments apply to the %ll width modifier and
|
||||
.. % PY_FORMAT_LONG_LONG.
|
||||
|
||||
.. tabularcolumns:: |l|l|L|
|
||||
|
||||
|
|
|
@ -39,27 +39,10 @@ Used in: Py_SAFE_DOWNCAST
|
|||
|
||||
#ifndef PY_LONG_LONG
|
||||
#define PY_LONG_LONG long long
|
||||
#if defined(LLONG_MAX)
|
||||
/* If LLONG_MAX is defined in limits.h, use that. */
|
||||
#define PY_LLONG_MIN LLONG_MIN
|
||||
#define PY_LLONG_MAX LLONG_MAX
|
||||
#define PY_ULLONG_MAX ULLONG_MAX
|
||||
#elif defined(__LONG_LONG_MAX__)
|
||||
/* Otherwise, if GCC has a builtin define, use that. (Definition of
|
||||
* PY_LLONG_MIN assumes two's complement with no trap representation.) */
|
||||
#define PY_LLONG_MAX __LONG_LONG_MAX__
|
||||
#define PY_LLONG_MIN (-PY_LLONG_MAX - 1)
|
||||
#define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1)
|
||||
#elif defined(SIZEOF_LONG_LONG)
|
||||
/* Otherwise compute from SIZEOF_LONG_LONG, assuming two's complement, no
|
||||
padding bits, and no trap representation. Note: PY_ULLONG_MAX was
|
||||
previously #defined as (~0ULL) here; but that'll give the wrong value in a
|
||||
preprocessor expression on systems where long long != intmax_t. */
|
||||
#define PY_LLONG_MAX \
|
||||
(1 + 2 * ((Py_LL(1) << (CHAR_BIT * SIZEOF_LONG_LONG - 2)) - 1))
|
||||
#define PY_LLONG_MIN (-PY_LLONG_MAX - 1)
|
||||
#define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1)
|
||||
#endif /* LLONG_MAX */
|
||||
#endif
|
||||
|
||||
#define PY_UINT32_T uint32_t
|
||||
|
@ -159,19 +142,6 @@ typedef int Py_ssize_clean_t;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for
|
||||
* the long long type instead of the size_t type. The "high level" Python format
|
||||
* functions listed above will interpret "lld" or "llu" correctly on
|
||||
* all platforms.
|
||||
*/
|
||||
#ifndef PY_FORMAT_LONG_LONG
|
||||
# ifdef MS_WINDOWS
|
||||
# define PY_FORMAT_LONG_LONG "I64"
|
||||
# else
|
||||
# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Py_LOCAL can be used instead of static to get the fastest possible calling
|
||||
* convention for functions that are local to a given module.
|
||||
*
|
||||
|
|
|
@ -5,10 +5,6 @@ from test import support
|
|||
# Skip this test if the _testcapi module isn't available.
|
||||
support.import_module('_testcapi')
|
||||
from _testcapi import getargs_keywords, getargs_keyword_only
|
||||
try:
|
||||
from _testcapi import getargs_L, getargs_K
|
||||
except ImportError:
|
||||
getargs_L = None # PY_LONG_LONG not available
|
||||
|
||||
# > How about the following counterproposal. This also changes some of
|
||||
# > the other format codes to be a little more regular.
|
||||
|
@ -309,7 +305,6 @@ class Signed_TestCase(unittest.TestCase):
|
|||
self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
|
||||
|
||||
|
||||
@unittest.skipIf(getargs_L is None, 'PY_LONG_LONG is not available')
|
||||
class LongLong_TestCase(unittest.TestCase):
|
||||
def test_L(self):
|
||||
from _testcapi import getargs_L
|
||||
|
|
|
@ -100,7 +100,7 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
|||
Py_buffer buf;
|
||||
|
||||
unsigned long leaf_size = 0;
|
||||
unsigned PY_LONG_LONG node_offset = 0;
|
||||
unsigned long long node_offset = 0;
|
||||
|
||||
self = new_BLAKE2bObject(type);
|
||||
if (self == NULL) {
|
||||
|
@ -170,7 +170,7 @@ py_blake2b_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
|||
|
||||
if (node_offset_obj != NULL) {
|
||||
node_offset = PyLong_AsUnsignedLongLong(node_offset_obj);
|
||||
if (node_offset == (unsigned PY_LONG_LONG) -1 && PyErr_Occurred()) {
|
||||
if (node_offset == (unsigned long long) -1 && PyErr_Occurred()) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
|||
Py_buffer buf;
|
||||
|
||||
unsigned long leaf_size = 0;
|
||||
unsigned PY_LONG_LONG node_offset = 0;
|
||||
unsigned long long node_offset = 0;
|
||||
|
||||
self = new_BLAKE2sObject(type);
|
||||
if (self == NULL) {
|
||||
|
@ -170,7 +170,7 @@ py_blake2s_new_impl(PyTypeObject *type, PyObject *data, int digest_size,
|
|||
|
||||
if (node_offset_obj != NULL) {
|
||||
node_offset = PyLong_AsUnsignedLongLong(node_offset_obj);
|
||||
if (node_offset == (unsigned PY_LONG_LONG) -1 && PyErr_Occurred()) {
|
||||
if (node_offset == (unsigned long long) -1 && PyErr_Occurred()) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,15 +233,15 @@ EXPORT(int) _testfunc_callback_with_pointer(int (*func)(int *))
|
|||
return (*func)(table);
|
||||
}
|
||||
|
||||
EXPORT(PY_LONG_LONG) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
|
||||
double d, PY_LONG_LONG q)
|
||||
EXPORT(long long) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
|
||||
double d, long long q)
|
||||
{
|
||||
return (PY_LONG_LONG)(b + h + i + l + f + d + q);
|
||||
return (long long)(b + h + i + l + f + d + q);
|
||||
}
|
||||
|
||||
EXPORT(PY_LONG_LONG) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
|
||||
EXPORT(long long) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
|
||||
{
|
||||
return (PY_LONG_LONG)(b + h + i + l + f + d);
|
||||
return (long long)(b + h + i + l + f + d);
|
||||
}
|
||||
|
||||
EXPORT(int) _testfunc_callback_i_if(int value, int (*func)(int))
|
||||
|
@ -254,10 +254,10 @@ EXPORT(int) _testfunc_callback_i_if(int value, int (*func)(int))
|
|||
return sum;
|
||||
}
|
||||
|
||||
EXPORT(PY_LONG_LONG) _testfunc_callback_q_qf(PY_LONG_LONG value,
|
||||
PY_LONG_LONG (*func)(PY_LONG_LONG))
|
||||
EXPORT(long long) _testfunc_callback_q_qf(long long value,
|
||||
long long (*func)(long long))
|
||||
{
|
||||
PY_LONG_LONG sum = 0;
|
||||
long long sum = 0;
|
||||
|
||||
while (value != 0) {
|
||||
sum += func(value);
|
||||
|
@ -381,8 +381,8 @@ EXPORT(void) _py_func(void)
|
|||
{
|
||||
}
|
||||
|
||||
EXPORT(PY_LONG_LONG) last_tf_arg_s;
|
||||
EXPORT(unsigned PY_LONG_LONG) last_tf_arg_u;
|
||||
EXPORT(long long) last_tf_arg_s;
|
||||
EXPORT(unsigned long long) last_tf_arg_u;
|
||||
|
||||
struct BITS {
|
||||
int A: 1, B:2, C:3, D:4, E: 5, F: 6, G: 7, H: 8, I: 9;
|
||||
|
@ -445,8 +445,8 @@ static PyMethodDef module_methods[] = {
|
|||
{ NULL, NULL, 0, NULL},
|
||||
};
|
||||
|
||||
#define S last_tf_arg_s = (PY_LONG_LONG)c
|
||||
#define U last_tf_arg_u = (unsigned PY_LONG_LONG)c
|
||||
#define S last_tf_arg_s = (long long)c
|
||||
#define U last_tf_arg_u = (unsigned long long)c
|
||||
|
||||
EXPORT(signed char) tf_b(signed char c) { S; return c/3; }
|
||||
EXPORT(unsigned char) tf_B(unsigned char c) { U; return c/3; }
|
||||
|
@ -456,8 +456,8 @@ EXPORT(int) tf_i(int c) { S; return c/3; }
|
|||
EXPORT(unsigned int) tf_I(unsigned int c) { U; return c/3; }
|
||||
EXPORT(long) tf_l(long c) { S; return c/3; }
|
||||
EXPORT(unsigned long) tf_L(unsigned long c) { U; return c/3; }
|
||||
EXPORT(PY_LONG_LONG) tf_q(PY_LONG_LONG c) { S; return c/3; }
|
||||
EXPORT(unsigned PY_LONG_LONG) tf_Q(unsigned PY_LONG_LONG c) { U; return c/3; }
|
||||
EXPORT(long long) tf_q(long long c) { S; return c/3; }
|
||||
EXPORT(unsigned long long) tf_Q(unsigned long long c) { U; return c/3; }
|
||||
EXPORT(float) tf_f(float c) { S; return c/3; }
|
||||
EXPORT(double) tf_d(double c) { S; return c/3; }
|
||||
EXPORT(long double) tf_D(long double c) { S; return c/3; }
|
||||
|
@ -471,8 +471,8 @@ EXPORT(int) __stdcall s_tf_i(int c) { S; return c/3; }
|
|||
EXPORT(unsigned int) __stdcall s_tf_I(unsigned int c) { U; return c/3; }
|
||||
EXPORT(long) __stdcall s_tf_l(long c) { S; return c/3; }
|
||||
EXPORT(unsigned long) __stdcall s_tf_L(unsigned long c) { U; return c/3; }
|
||||
EXPORT(PY_LONG_LONG) __stdcall s_tf_q(PY_LONG_LONG c) { S; return c/3; }
|
||||
EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_Q(unsigned PY_LONG_LONG c) { U; return c/3; }
|
||||
EXPORT(long long) __stdcall s_tf_q(long long c) { S; return c/3; }
|
||||
EXPORT(unsigned long long) __stdcall s_tf_Q(unsigned long long c) { U; return c/3; }
|
||||
EXPORT(float) __stdcall s_tf_f(float c) { S; return c/3; }
|
||||
EXPORT(double) __stdcall s_tf_d(double c) { S; return c/3; }
|
||||
EXPORT(long double) __stdcall s_tf_D(long double c) { S; return c/3; }
|
||||
|
@ -487,8 +487,8 @@ EXPORT(int) tf_bi(signed char x, int c) { S; return c/3; }
|
|||
EXPORT(unsigned int) tf_bI(signed char x, unsigned int c) { U; return c/3; }
|
||||
EXPORT(long) tf_bl(signed char x, long c) { S; return c/3; }
|
||||
EXPORT(unsigned long) tf_bL(signed char x, unsigned long c) { U; return c/3; }
|
||||
EXPORT(PY_LONG_LONG) tf_bq(signed char x, PY_LONG_LONG c) { S; return c/3; }
|
||||
EXPORT(unsigned PY_LONG_LONG) tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
|
||||
EXPORT(long long) tf_bq(signed char x, long long c) { S; return c/3; }
|
||||
EXPORT(unsigned long long) tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
|
||||
EXPORT(float) tf_bf(signed char x, float c) { S; return c/3; }
|
||||
EXPORT(double) tf_bd(signed char x, double c) { S; return c/3; }
|
||||
EXPORT(long double) tf_bD(signed char x, long double c) { S; return c/3; }
|
||||
|
@ -503,8 +503,8 @@ EXPORT(int) __stdcall s_tf_bi(signed char x, int c) { S; return c/3; }
|
|||
EXPORT(unsigned int) __stdcall s_tf_bI(signed char x, unsigned int c) { U; return c/3; }
|
||||
EXPORT(long) __stdcall s_tf_bl(signed char x, long c) { S; return c/3; }
|
||||
EXPORT(unsigned long) __stdcall s_tf_bL(signed char x, unsigned long c) { U; return c/3; }
|
||||
EXPORT(PY_LONG_LONG) __stdcall s_tf_bq(signed char x, PY_LONG_LONG c) { S; return c/3; }
|
||||
EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
|
||||
EXPORT(long long) __stdcall s_tf_bq(signed char x, long long c) { S; return c/3; }
|
||||
EXPORT(unsigned long long) __stdcall s_tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
|
||||
EXPORT(float) __stdcall s_tf_bf(signed char x, float c) { S; return c/3; }
|
||||
EXPORT(double) __stdcall s_tf_bd(signed char x, double c) { S; return c/3; }
|
||||
EXPORT(long double) __stdcall s_tf_bD(signed char x, long double c) { S; return c/3; }
|
||||
|
|
|
@ -591,7 +591,7 @@ union result {
|
|||
short h;
|
||||
int i;
|
||||
long l;
|
||||
PY_LONG_LONG q;
|
||||
long long q;
|
||||
long double D;
|
||||
double d;
|
||||
float f;
|
||||
|
|
|
@ -382,9 +382,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;
|
||||
if (PyFloat_Check(v)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"int expected instead of float");
|
||||
|
@ -400,16 +400,16 @@ 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;
|
||||
if (PyFloat_Check(v)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"int expected instead of float");
|
||||
return -1;
|
||||
}
|
||||
x = PyLong_AsUnsignedLongLongMask(v);
|
||||
if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())
|
||||
if (x == (unsigned long long)-1 && PyErr_Occurred())
|
||||
return -1;
|
||||
*p = x;
|
||||
return 0;
|
||||
|
@ -879,12 +879,12 @@ L_get_sw(void *ptr, Py_ssize_t size)
|
|||
static PyObject *
|
||||
q_set(void *ptr, PyObject *value, Py_ssize_t size)
|
||||
{
|
||||
PY_LONG_LONG val;
|
||||
PY_LONG_LONG x;
|
||||
long long val;
|
||||
long long x;
|
||||
if (get_longlong(value, &val) < 0)
|
||||
return NULL;
|
||||
memcpy(&x, ptr, sizeof(x));
|
||||
x = SET(PY_LONG_LONG, x, val, size);
|
||||
x = SET(long long, x, val, size);
|
||||
memcpy(ptr, &x, sizeof(x));
|
||||
_RET(value);
|
||||
}
|
||||
|
@ -892,13 +892,13 @@ q_set(void *ptr, PyObject *value, Py_ssize_t size)
|
|||
static PyObject *
|
||||
q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
|
||||
{
|
||||
PY_LONG_LONG val;
|
||||
PY_LONG_LONG field;
|
||||
long long val;
|
||||
long long field;
|
||||
if (get_longlong(value, &val) < 0)
|
||||
return NULL;
|
||||
memcpy(&field, ptr, sizeof(field));
|
||||
field = SWAP_8(field);
|
||||
field = SET(PY_LONG_LONG, field, val, size);
|
||||
field = SET(long long, field, val, size);
|
||||
field = SWAP_8(field);
|
||||
memcpy(ptr, &field, sizeof(field));
|
||||
_RET(value);
|
||||
|
@ -907,7 +907,7 @@ q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
|
|||
static PyObject *
|
||||
q_get(void *ptr, Py_ssize_t size)
|
||||
{
|
||||
PY_LONG_LONG val;
|
||||
long long val;
|
||||
memcpy(&val, ptr, sizeof(val));
|
||||
GET_BITFIELD(val, size);
|
||||
return PyLong_FromLongLong(val);
|
||||
|
@ -916,7 +916,7 @@ q_get(void *ptr, Py_ssize_t size)
|
|||
static PyObject *
|
||||
q_get_sw(void *ptr, Py_ssize_t size)
|
||||
{
|
||||
PY_LONG_LONG val;
|
||||
long long val;
|
||||
memcpy(&val, ptr, sizeof(val));
|
||||
val = SWAP_8(val);
|
||||
GET_BITFIELD(val, size);
|
||||
|
@ -926,12 +926,12 @@ q_get_sw(void *ptr, Py_ssize_t size)
|
|||
static PyObject *
|
||||
Q_set(void *ptr, PyObject *value, Py_ssize_t size)
|
||||
{
|
||||
unsigned PY_LONG_LONG val;
|
||||
unsigned PY_LONG_LONG x;
|
||||
unsigned long long val;
|
||||
unsigned long long x;
|
||||
if (get_ulonglong(value, &val) < 0)
|
||||
return NULL;
|
||||
memcpy(&x, ptr, sizeof(x));
|
||||
x = SET(PY_LONG_LONG, x, val, size);
|
||||
x = SET(long long, x, val, size);
|
||||
memcpy(ptr, &x, sizeof(x));
|
||||
_RET(value);
|
||||
}
|
||||
|
@ -939,13 +939,13 @@ Q_set(void *ptr, PyObject *value, Py_ssize_t size)
|
|||
static PyObject *
|
||||
Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
|
||||
{
|
||||
unsigned PY_LONG_LONG val;
|
||||
unsigned PY_LONG_LONG field;
|
||||
unsigned long long val;
|
||||
unsigned long long field;
|
||||
if (get_ulonglong(value, &val) < 0)
|
||||
return NULL;
|
||||
memcpy(&field, ptr, sizeof(field));
|
||||
field = SWAP_8(field);
|
||||
field = SET(unsigned PY_LONG_LONG, field, val, size);
|
||||
field = SET(unsigned long long, field, val, size);
|
||||
field = SWAP_8(field);
|
||||
memcpy(ptr, &field, sizeof(field));
|
||||
_RET(value);
|
||||
|
@ -954,7 +954,7 @@ Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
|
|||
static PyObject *
|
||||
Q_get(void *ptr, Py_ssize_t size)
|
||||
{
|
||||
unsigned PY_LONG_LONG val;
|
||||
unsigned long long val;
|
||||
memcpy(&val, ptr, sizeof(val));
|
||||
GET_BITFIELD(val, size);
|
||||
return PyLong_FromUnsignedLongLong(val);
|
||||
|
@ -963,7 +963,7 @@ Q_get(void *ptr, Py_ssize_t size)
|
|||
static PyObject *
|
||||
Q_get_sw(void *ptr, Py_ssize_t size)
|
||||
{
|
||||
unsigned PY_LONG_LONG val;
|
||||
unsigned long long val;
|
||||
memcpy(&val, ptr, sizeof(val));
|
||||
val = SWAP_8(val);
|
||||
GET_BITFIELD(val, size);
|
||||
|
@ -1477,7 +1477,7 @@ P_set(void *ptr, PyObject *value, Py_ssize_t size)
|
|||
v = (void *)PyLong_AsUnsignedLongMask(value);
|
||||
#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
|
||||
v = (void *)PyLong_AsUnsignedLongLongMask(value);
|
||||
#endif
|
||||
|
@ -1617,8 +1617,8 @@ typedef struct { char c; wchar_t *x; } s_wchar_p;
|
|||
#endif
|
||||
*/
|
||||
|
||||
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))
|
||||
|
||||
/* from ffi.h:
|
||||
typedef struct _ffi_type
|
||||
|
|
|
@ -301,7 +301,7 @@ struct tagPyCArgObject {
|
|||
short h;
|
||||
int i;
|
||||
long l;
|
||||
PY_LONG_LONG q;
|
||||
long long q;
|
||||
long double D;
|
||||
double d;
|
||||
float f;
|
||||
|
|
|
@ -85,12 +85,12 @@ extern int _PyIO_trap_eintr(void);
|
|||
#ifdef MS_WINDOWS
|
||||
|
||||
/* Windows uses long long for offsets */
|
||||
typedef PY_LONG_LONG Py_off_t;
|
||||
typedef long long Py_off_t;
|
||||
# define PyLong_AsOff_t PyLong_AsLongLong
|
||||
# define PyLong_FromOff_t PyLong_FromLongLong
|
||||
# define PY_OFF_T_MAX PY_LLONG_MAX
|
||||
# define PY_OFF_T_MIN PY_LLONG_MIN
|
||||
# define PY_OFF_T_COMPAT PY_LONG_LONG /* type compatible with off_t */
|
||||
# define PY_OFF_T_MAX LLONG_MAX
|
||||
# define PY_OFF_T_MIN LLONG_MIN
|
||||
# define PY_OFF_T_COMPAT long long /* type compatible with off_t */
|
||||
# define PY_PRIdOFF "lld" /* format to use for that type */
|
||||
|
||||
#else
|
||||
|
@ -107,9 +107,9 @@ typedef off_t Py_off_t;
|
|||
#elif (SIZEOF_OFF_T == SIZEOF_LONG_LONG)
|
||||
# define PyLong_AsOff_t PyLong_AsLongLong
|
||||
# define PyLong_FromOff_t PyLong_FromLongLong
|
||||
# define PY_OFF_T_MAX PY_LLONG_MAX
|
||||
# define PY_OFF_T_MIN PY_LLONG_MIN
|
||||
# define PY_OFF_T_COMPAT PY_LONG_LONG
|
||||
# define PY_OFF_T_MAX LLONG_MAX
|
||||
# define PY_OFF_T_MIN LLONG_MIN
|
||||
# define PY_OFF_T_COMPAT long long
|
||||
# define PY_PRIdOFF "lld"
|
||||
#elif (SIZEOF_OFF_T == SIZEOF_LONG)
|
||||
# define PyLong_AsOff_t PyLong_AsLong
|
||||
|
|
|
@ -531,7 +531,7 @@ _io_IncrementalNewlineDecoder_getstate_impl(nldecoder_object *self)
|
|||
/*[clinic end generated code: output=f0d2c9c136f4e0d0 input=f8ff101825e32e7f]*/
|
||||
{
|
||||
PyObject *buffer;
|
||||
unsigned PY_LONG_LONG flag;
|
||||
unsigned long long flag;
|
||||
|
||||
if (self->decoder != Py_None) {
|
||||
PyObject *state = PyObject_CallMethodObjArgs(self->decoder,
|
||||
|
@ -567,7 +567,7 @@ _io_IncrementalNewlineDecoder_setstate(nldecoder_object *self,
|
|||
/*[clinic end generated code: output=c10c622508b576cb input=c53fb505a76dbbe2]*/
|
||||
{
|
||||
PyObject *buffer;
|
||||
unsigned PY_LONG_LONG flag;
|
||||
unsigned long long flag;
|
||||
|
||||
if (!PyArg_ParseTuple(state, "OK", &buffer, &flag))
|
||||
return NULL;
|
||||
|
|
|
@ -130,7 +130,7 @@ sqlite_int64
|
|||
_pysqlite_long_as_int64(PyObject * py_val)
|
||||
{
|
||||
int overflow;
|
||||
PY_LONG_LONG value = PyLong_AsLongLongAndOverflow(py_val, &overflow);
|
||||
long long value = PyLong_AsLongLongAndOverflow(py_val, &overflow);
|
||||
if (value == -1 && PyErr_Occurred())
|
||||
return -1;
|
||||
if (!overflow) {
|
||||
|
|
|
@ -2680,7 +2680,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
|
|||
len = sprintf(buffer, "%lu",
|
||||
va_arg(*vargs, unsigned long));
|
||||
else if (longlongflag)
|
||||
len = sprintf(buffer, "%" PY_FORMAT_LONG_LONG "u",
|
||||
len = sprintf(buffer, "%llu",
|
||||
va_arg(*vargs, unsigned long long));
|
||||
else if (size_tflag)
|
||||
len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "u",
|
||||
|
@ -2697,7 +2697,7 @@ unicode_fromformat_arg(_PyUnicodeWriter *writer,
|
|||
len = sprintf(buffer, "%li",
|
||||
va_arg(*vargs, long));
|
||||
else if (longlongflag)
|
||||
len = sprintf(buffer, "%" PY_FORMAT_LONG_LONG "i",
|
||||
len = sprintf(buffer, "%lli",
|
||||
va_arg(*vargs, long long));
|
||||
else if (size_tflag)
|
||||
len = sprintf(buffer, "%" PY_FORMAT_SIZE_T "i",
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
||||
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
dnl serial 11 (pkg-config-0.29)
|
||||
dnl serial 11 (pkg-config-0.29.1)
|
||||
dnl
|
||||
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
||||
|
@ -55,7 +55,7 @@ dnl
|
|||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29])
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.1])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
|
|
|
@ -15729,99 +15729,6 @@ $as_echo "#define HAVE_DEV_PTC 1" >>confdefs.h
|
|||
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for %lld and %llu printf() format support" >&5
|
||||
$as_echo_n "checking for %lld and %llu printf() format support... " >&6; }
|
||||
if ${ac_cv_have_long_long_format+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then :
|
||||
ac_cv_have_long_long_format="cross -- assuming no"
|
||||
if test x$GCC = xyes; then
|
||||
save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Werror -Wformat"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
char *buffer;
|
||||
sprintf(buffer, "%lld", (long long)123);
|
||||
sprintf(buffer, "%lld", (long long)-123);
|
||||
sprintf(buffer, "%llu", (unsigned long long)123);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ac_cv_have_long_long_format=yes
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
CFLAGS=$save_CFLAGS
|
||||
fi
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
if (sprintf(buffer, "%lld", (long long)123) < 0)
|
||||
return 1;
|
||||
if (strcmp(buffer, "123"))
|
||||
return 1;
|
||||
|
||||
if (sprintf(buffer, "%lld", (long long)-123) < 0)
|
||||
return 1;
|
||||
if (strcmp(buffer, "-123"))
|
||||
return 1;
|
||||
|
||||
if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
|
||||
return 1;
|
||||
if (strcmp(buffer, "123"))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_ACEOF
|
||||
if ac_fn_c_try_run "$LINENO"; then :
|
||||
ac_cv_have_long_long_format=yes
|
||||
else
|
||||
ac_cv_have_long_long_format=no
|
||||
fi
|
||||
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
||||
conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_long_long_format" >&5
|
||||
$as_echo "$ac_cv_have_long_long_format" >&6; }
|
||||
|
||||
if test "$ac_cv_have_long_long_format" = yes
|
||||
then
|
||||
|
||||
$as_echo "#define PY_FORMAT_LONG_LONG \"ll\"" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
if test $ac_sys_system = Darwin
|
||||
then
|
||||
LIBS="$LIBS -framework CoreFoundation"
|
||||
|
|
61
configure.ac
61
configure.ac
|
@ -4938,67 +4938,6 @@ if test "x$ac_cv_file__dev_ptc" = xyes; then
|
|||
[Define to 1 if you have the /dev/ptc device file.])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for %lld and %llu printf() format support)
|
||||
AC_CACHE_VAL(ac_cv_have_long_long_format,
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([[[
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
char buffer[256];
|
||||
|
||||
if (sprintf(buffer, "%lld", (long long)123) < 0)
|
||||
return 1;
|
||||
if (strcmp(buffer, "123"))
|
||||
return 1;
|
||||
|
||||
if (sprintf(buffer, "%lld", (long long)-123) < 0)
|
||||
return 1;
|
||||
if (strcmp(buffer, "-123"))
|
||||
return 1;
|
||||
|
||||
if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
|
||||
return 1;
|
||||
if (strcmp(buffer, "123"))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
]]])],
|
||||
[ac_cv_have_long_long_format=yes],
|
||||
[ac_cv_have_long_long_format=no],
|
||||
[ac_cv_have_long_long_format="cross -- assuming no"
|
||||
if test x$GCC = xyes; then
|
||||
save_CFLAGS=$CFLAGS
|
||||
CFLAGS="$CFLAGS -Werror -Wformat"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
]], [[
|
||||
char *buffer;
|
||||
sprintf(buffer, "%lld", (long long)123);
|
||||
sprintf(buffer, "%lld", (long long)-123);
|
||||
sprintf(buffer, "%llu", (unsigned long long)123);
|
||||
]])],
|
||||
ac_cv_have_long_long_format=yes
|
||||
)
|
||||
CFLAGS=$save_CFLAGS
|
||||
fi])
|
||||
)
|
||||
AC_MSG_RESULT($ac_cv_have_long_long_format)
|
||||
|
||||
if test "$ac_cv_have_long_long_format" = yes
|
||||
then
|
||||
AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
|
||||
[Define to printf format modifier for long long type])
|
||||
fi
|
||||
|
||||
if test $ac_sys_system = Darwin
|
||||
then
|
||||
LIBS="$LIBS -framework CoreFoundation"
|
||||
|
|
|
@ -1241,9 +1241,6 @@
|
|||
/* Define as the preferred size in bits of long digits */
|
||||
#undef PYLONG_BITS_IN_DIGIT
|
||||
|
||||
/* Define to printf format modifier for long long type */
|
||||
#undef PY_FORMAT_LONG_LONG
|
||||
|
||||
/* Define to printf format modifier for Py_ssize_t */
|
||||
#undef PY_FORMAT_SIZE_T
|
||||
|
||||
|
|
Loading…
Reference in New Issue