Commits

Kristjan Valur Jonsson  committed e7db211

Fix 64 bit compiler warnings in the stackless module.

  • Participants
  • Parent commits 1840e0d
  • Branches release25-maint

Comments (0)

Files changed (6)

File Stackless/module/channelobject.c

 	PyObject *lis;
 	int flags, balance;
 	int dir;
-	int i, n;
+	Py_ssize_t i, n;
 
 	if (!PyArg_ParseTuple(args, "iiO!:channel",
 			      &balance,

File Stackless/module/flextype.c

 	}
 }
 
-static int
-find_size(PyObject * bases, int size)
+static Py_ssize_t
+find_size(PyObject * bases, Py_ssize_t size)
 {
-	int i, n = PyTuple_GET_SIZE(bases);
+	Py_ssize_t i, n = PyTuple_GET_SIZE(bases);
 
 	for (i=0; i<n; ++i) {
 		PyObject *op = PyTuple_GET_ITEM(bases, i);
-		int sz = op->ob_type->tp_basicsize;
+		Py_ssize_t sz = op->ob_type->tp_basicsize;
 		if (sz > size)
 			size = sz;
 	}
         PyObject *name, *bases, *dict;
 	static char *kwlist[] = {"name", "bases", "dict", 0};
 	PyFlexTypeObject *type;
-	int basicsize = meta->tp_basicsize;
-	int type_size = basicsize;
+	Py_ssize_t basicsize = meta->tp_basicsize;
+	Py_ssize_t type_size = basicsize;
 
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "SO!O!:type", kwlist,
 					 &name,
 	   size_t type_size, PyCMethodDef *ml)
 {
         PyObject *args = Py_BuildValue("(s(O)O)", typename, base, dict);
-	int basicsize = meta->tp_basicsize;
+	Py_ssize_t basicsize = meta->tp_basicsize;
 	PyFlexTypeObject *type;
 
         assert(type_size >= (size_t) meta->tp_basicsize);

File Stackless/module/stacklessmodule.c

 {
 	PyObject *op, *max = Py_None;
 	PyObject *refchain;
-	int ref_total = _Py_RefTotal;
-	int computed_total = 0;
+	Py_ssize_t ref_total = _Py_RefTotal;
+	Py_ssize_t computed_total = 0;
 
 	refchain = PyTuple_New(0)->_ob_next; /* None doesn't work in 2.2 */
 	Py_DECREF(refchain->_ob_prev);
 		max = op;
 		computed_total += op->ob_refcnt;
 	}
-	return Py_BuildValue("(Oiii)", max, max->ob_refcnt, ref_total,
+	return Py_BuildValue("(Onnn)", max, max->ob_refcnt, ref_total,
 			     computed_total);
 }
 
 
 	for (; p->type != NULL; p++) {
 		PyTypeObject *t = p->type;
-		int ind = p->offset & MFLAG_IND;
-		int ofs = p->offset - ind;
+		size_t ind = p->offset & MFLAG_IND;
+		size_t ofs = p->offset - ind;
 
 		if (ind)
 			t = *((PyTypeObject **)t);

File Stackless/module/taskletobject.c

 	PyObject *tempval, *lis;
 	int flags, nesting_level;
 	PyFrameObject *f;
-	int i, nframes;
+	Py_ssize_t i, nframes;
+	int j;
 
 	if (!PyArg_ParseTuple(args, "iOiO!:tasklet",
 			      &flags, 
 	 * they can leave their blocked flag in place because the
 	 * channel would have set it.
 	 */
-	i = t->flags.blocked;
+	j = t->flags.blocked;
 	*(int *)&t->flags = flags;
 	if (t->next == NULL) {
 		t->flags.blocked = 0;
 	} else {
-		t->flags.blocked = i;
+		t->flags.blocked = j;
 	}
 
 	/* t->nesting_level = nesting_level;

File Stackless/pickling/prickelpit.c

  */
 
 PyObject *
-slp_into_tuple_with_nulls(PyObject **start, int length)
+slp_into_tuple_with_nulls(PyObject **start, Py_ssize_t length)
 {
 	PyObject *res = PyTuple_New(length+1);
 	PyObject *nulls = PyTuple_New(0);
-	int i, nullcount = 0;
+	Py_ssize_t i, nullcount = 0;
 	if (res == NULL)
 		return NULL;
 	for (i=0; i<length; ++i) {
 		PyObject *ob = start[i];
 		if (ob == NULL) {
 			/* store None, and add the position to nulls */
-			PyObject *pos = PyInt_FromLong(i);
+			PyObject *pos = PyInt_FromSsize_t(i);
 			if (pos == NULL)
 				return NULL;
 			ob = Py_None;
 	return res;
 }
 
-int
+Py_ssize_t
 slp_from_tuple_with_nulls(PyObject **start, PyObject *tup)
 {
-	int i, length = PyTuple_GET_SIZE(tup)-1;
+	Py_ssize_t i, length = PyTuple_GET_SIZE(tup)-1;
 	PyObject *nulls;
 	if (length < 0) return 0;
 
 	PyObject *exec_name = NULL;
 	PyFrame_ExecFunc *good_func, *bad_func;
 	int valid, have_locals;
+	Py_ssize_t tmp;
 
 	if (is_wrong_type(f->ob_type)) return NULL;
 
 	}
 
 	if (PyTuple_Check(localsplus_as_tuple)) {
-		int space =  f->f_code->co_stacksize + (f->f_valuestack - f->f_localsplus);
+		Py_ssize_t space =  f->f_code->co_stacksize + (f->f_valuestack - f->f_localsplus);
 
 		if (PyTuple_GET_SIZE(localsplus_as_tuple)-1 > space) {
 			PyErr_SetString(PyExc_ValueError, "invalid localsplus for frame");
 
 	f->f_lasti = f_lasti;
 	f->f_lineno = f_lineno;
-	f->f_iblock = PyTuple_GET_SIZE(blockstack_as_tuple);
+	tmp = PyTuple_GET_SIZE(blockstack_as_tuple);
+	f->f_iblock = Py_SAFE_DOWNCAST(tmp, Py_ssize_t, int);
 	if (f->f_iblock < 0 || f->f_iblock > CO_MAXBLOCKS) {
 		PyErr_SetString(PyExc_ValueError, "invalid blockstack for frame");
 		goto err_exit;

File Stackless/pickling/prickelpit.h

 
 /* pickling of arrays with nulls */
 
-PyAPI_FUNC(PyObject *) slp_into_tuple_with_nulls(PyObject **start, int length);
+PyAPI_FUNC(PyObject *) slp_into_tuple_with_nulls(PyObject **start, Py_ssize_t length);
 /* creates a tuple of length+1 with the first element holding null markers */
 
-PyAPI_FUNC(int) slp_from_tuple_with_nulls(PyObject **start, PyObject *tup);
+PyAPI_FUNC(Py_ssize_t) slp_from_tuple_with_nulls(PyObject **start, PyObject *tup);
 /* loads data from a tuple where the first element holds null markers.
    return value is the number of elements (length-1)
  */