unsigned int x;
memcpy((char *)&x, p, sizeof x);
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x <= INT_MAX)
+ if (x <= LONG_MAX)
return PyInt_FromLong((long)x);
#endif
return PyLong_FromUnsignedLong((unsigned long)x);
unsigned long x;
memcpy((char *)&x, p, sizeof x);
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x <= INT_MAX)
+ if (x <= LONG_MAX)
return PyInt_FromLong((long)x);
#endif
return PyLong_FromUnsignedLong(x);
PY_LONG_LONG x;
memcpy((char *)&x, p, sizeof x);
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x >= INT_MIN && x <= INT_MAX)
+ if (x >= LONG_MIN && x <= LONG_MAX)
return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long));
#endif
return PyLong_FromLongLong(x);
unsigned PY_LONG_LONG x;
memcpy((char *)&x, p, sizeof x);
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x <= INT_MAX)
+ if (x <= LONG_MAX)
return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long));
#endif
return PyLong_FromUnsignedLongLong(x);
x = (x<<8) | (*p++ & 0xFF);
} while (--i > 0);
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x <= INT_MAX)
+ if (x <= LONG_MAX)
return PyInt_FromLong((long)x);
#else
if (SIZEOF_LONG > f->size)
if (SIZEOF_LONG_LONG > f->size)
x |= -(x & (1L << (8 * f->size - 1)));
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x >= INT_MIN && x <= INT_MAX)
+ if (x >= LONG_MIN && x <= LONG_MAX)
return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long));
#endif
return PyLong_FromLongLong(x);
x = (x<<8) | (*p++ & 0xFF);
} while (--i > 0);
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x <= INT_MAX)
+ if (x <= LONG_MAX)
return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long));
#endif
return PyLong_FromUnsignedLongLong(x);
x = (x<<8) | (p[--i] & 0xFF);
} while (i > 0);
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x <= INT_MAX)
+ if (x <= LONG_MAX)
return PyInt_FromLong((long)x);
#else
if (SIZEOF_LONG > f->size)
if (SIZEOF_LONG_LONG > f->size)
x |= -(x & (1L << (8 * f->size - 1)));
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x >= INT_MIN && x <= INT_MAX)
+ if (x >= LONG_MIN && x <= LONG_MAX)
return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long));
#endif
return PyLong_FromLongLong(x);
x = (x<<8) | (p[--i] & 0xFF);
} while (i > 0);
#ifdef PY_USE_INT_WHEN_POSSIBLE
- if (x <= INT_MAX)
+ if (x <= LONG_MAX)
return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long));
#endif
return PyLong_FromUnsignedLongLong(x);
if (PyType_Ready(&PyStructType) < 0)
return;
+
/* Add some symbolic constants to the module */
if (StructError == NULL) {
StructError = PyErr_NewException("struct.error", NULL, NULL);
if (StructError == NULL)
return;
}
+
Py_INCREF(StructError);
PyModule_AddObject(m, "error", StructError);
+
Py_INCREF((PyObject*)&PyStructType);
PyModule_AddObject(m, "Struct", (PyObject*)&PyStructType);
}