Now that we have standard (optional) long long support, the long long

support in this module can go.  The patch only deletes code
(PyLong_FromLongLong() and PyLong_AsLongLong()).  By Sjoerd Mullender.
This commit is contained in:
Guido van Rossum 1998-08-31 14:14:09 +00:00
parent 80c7bcf667
commit 164543607c

View File

@ -85,72 +85,6 @@ ErrorHandler(long code, const char *fmt, ...)
#ifdef AL_NO_ELEM /* IRIX 6 */
static PyObject *
PyLong_FromLongLong(long long v)
{
/* XXXX Somewhat complicated way to convert a long long to a PyLong */
PyObject *l = NULL, *lhi, *llo;
int is_negative = 0;
static PyObject *i32; /* 32 as a python long */
if (v < 0) {
is_negative = 1;
v = -v;
}
lhi = PyLong_FromUnsignedLong((unsigned long) ((unsigned long long) v >> 32));
llo = PyLong_FromUnsignedLong((unsigned long) (v & 0xFFFFFFFFLL));
if (i32 == NULL)
i32 = PyLong_FromLong(32L); /* don't decref */
if (PyErr_Occurred())
goto error;
if ((l = PyNumber_Lshift(lhi, i32)) == NULL)
goto error;
Py_DECREF(lhi);
lhi = l;
if ((l = PyNumber_Or(lhi, llo)) == NULL)
goto error;
Py_DECREF(lhi);
Py_DECREF(llo);
if (is_negative) {
if ((lhi = PyNumber_Negative(l)) == NULL)
goto error;
Py_DECREF(l);
l = lhi;
}
return l;
error:
Py_XDECREF(lhi);
Py_XDECREF(llo);
Py_XDECREF(l);
return NULL;
}
static long long
PyLong_AsLongLong(PyObject *v)
{
/* XXXX Somewhat complicated way to convert a PyLong to a long long */
static PyObject *i2_32; /* 2**32 as a python long */
PyObject *lhi, *llo;
long long ihi;
unsigned long long ilo;
if (!PyLong_Check(v)) {
PyErr_BadInternalCall();
return -1;
}
if (i2_32 == NULL)
i2_32 = PyLong_FromLongLong(0x100000000LL); /* don't decref */
if ((v = PyNumber_Divmod(v, i2_32)) == NULL)
return -1;
lhi = PyTuple_GetItem(v, 0);
llo = PyTuple_GetItem(v, 1);
ihi = PyLong_AsLong(lhi);
ilo = PyLong_AsUnsignedLong(llo);
Py_DECREF(v);
return ihi * 0x100000000LL + ilo;
}
static PyObject *
param2python(int resource, int param, ALvalue value, ALparamInfo *pinfo)
{