[Python-checkins] CVS: python/dist/src/Modules structmodule.c,2.41,2.42
Tim Peters
tim_one@users.sourceforge.net
Sun, 08 Apr 2001 16:39:40 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv2102/python/dist/src/Modules
Modified Files:
structmodule.c
Log Message:
Repair portability of sign extension when reading signed ints on boxes
where sizeof(long)==8. This *was* broken on boxes where signed right
shifts didn't sign-extend, but not elsewhere. Unfortunately, apart
from the Cray T3E I don't know of such a box, and Guido has so far
refused to buy me any Cray machines for home Python testing <wink>.
More immediately interesting would be if someone could please test
this on *any* sizeof(long)==8 box, to make sure I didn't break it.
Index: structmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/structmodule.c,v
retrieving revision 2.41
retrieving revision 2.42
diff -C2 -r2.41 -r2.42
*** structmodule.c 2000/09/26 05:46:01 2.41
--- structmodule.c 2001/04/08 23:39:38 2.42
***************
*** 654,662 ****
x = (x<<8) | (*p++ & 0xFF);
} while (--i > 0);
! i = 8*(sizeof(long) - f->size);
! if (i) {
! x <<= i;
! x >>= i;
! }
return PyInt_FromLong(x);
}
--- 654,660 ----
x = (x<<8) | (*p++ & 0xFF);
} while (--i > 0);
! /* Extend the sign bit. */
! if (SIZEOF_LONG > f->size)
! x |= -(x & (1L << (8*f->size - 1)));
return PyInt_FromLong(x);
}
***************
*** 768,776 ****
x = (x<<8) | (p[--i] & 0xFF);
} while (i > 0);
! i = 8*(sizeof(long) - f->size);
! if (i) {
! x <<= i;
! x >>= i;
! }
return PyInt_FromLong(x);
}
--- 766,772 ----
x = (x<<8) | (p[--i] & 0xFF);
} while (i > 0);
! /* Extend the sign bit. */
! if (SIZEOF_LONG > f->size)
! x |= -(x & (1L << (8*f->size - 1)));
return PyInt_FromLong(x);
}