ref: e82b10ffb480c85a80af21d016f3f8a30db08156
parent: 518fd3ec8350a010e5ed6490e1106c66af8f4d02
author: cinap_lenrek <[email protected]>
date: Tue Nov 24 06:02:04 EST 2015
disksim: don't assume 4-byte pointers
--- a/sys/src/cmd/aux/disksim.c
+++ b/sys/src/cmd/aux/disksim.c
@@ -20,8 +20,7 @@
{
LOGBLKSZ = 13,
BLKSZ = 1<<LOGBLKSZ, /* 8192 */
- LOGNPTR = LOGBLKSZ-2, /* assume sizeof(void*) == 4 */
- NPTR = 1<<LOGNPTR,
+ NPTR = BLKSZ/sizeof(void*),
};
static uchar zero[BLKSZ];
@@ -251,12 +250,12 @@
addr >>= LOGBLKSZ;
oaddr = addr<<LOGBLKSZ;
- i0 = addr & (NPTR-1);
- addr >>= LOGNPTR;
- i1 = addr & (NPTR-1);
- addr >>= LOGNPTR;
- i2 = addr & (NPTR-1);
- addr >>= LOGNPTR;
+ i0 = addr % NPTR;
+ addr /= NPTR;
+ i1 = addr % NPTR;
+ addr /= NPTR;
+ i2 = addr % NPTR;
+ addr /= NPTR;
assert(addr == 0);
if((p2 = trip.dbl[i2]) == 0){
@@ -633,8 +632,6 @@
file = nil;
quotefmtinstall();
time0 = time(0);
- if(NPTR != BLKSZ/sizeof(void*))
- sysfatal("unexpected pointer size");
ARGBEGIN{
case 'D':