code: 9ferno

Download patch

ref: 916fe767404498e0108f7b1d3fd0994ae19913f3
parent: 7c22230886134121893f02ee283da85f3a6807e6
author: 9ferno <gophone2015@gmail.com>
date: Tue Sep 7 22:47:44 EDT 2021

ulong pointers bug fixed

--- a/appl/cmd/disk/kfs64.b
+++ b/appl/cmd/disk/kfs64.b
@@ -3581,6 +3581,13 @@
 #
 # kfs check, could be a separate module if that seemed important
 #
+# check() kicks off the fsck() on the root directory
+# fsck() walks through each child file and directory
+#	and marks every block and qid that are being used
+#	in amap and qmap. If the child is a directory, then fsck()
+#	descends into it and fsck()'s each child.
+#	if a bit has already been marked, then we have a duplicate
+#	if a block number is <= fstart and >= fsize, then bad
 
 MAXDEPTH: con 100;
 MAXNAME: con 4000;
@@ -3602,8 +3609,8 @@
 Check: adt {
 	dev:	ref Device;
 
-	amap:	ref Map;
-	qmap:	ref Map;
+	amap:	ref Map;	# bit map of all blocks
+	qmap:	ref Map;	# bit map of max qid used + 100
 
 	name:	string;
 	nfiles:	big;
--- a/libinterp/dec.c
+++ b/libinterp/dec.c
@@ -4,7 +4,7 @@
 #include "isa.h"
 #include "interp.h"
 
-#define DIND(reg, xxx) (uchar*)((*(ulong*)(R.reg+R.PC->xxx.i.f))+R.PC->xxx.i.s)
+#define DIND(reg, xxx) (uchar*)((*(uintptr*)(R.reg+R.PC->xxx.i.f))+R.PC->xxx.i.s)
 static void
 D00(void)
 {
--- a/libinterp/xec.c
+++ b/libinterp/xec.c
@@ -215,12 +215,12 @@
 }
 OP(indx)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indx a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indx a %p a->len %zd i %zd\n", a, a->len, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*a->t->size);
@@ -227,12 +227,12 @@
 }
 OP(indw)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indw a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indw a %p a->len %zd i %zd\n", a, a->len, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*sizeof(WORD));
@@ -239,12 +239,12 @@
 }
 OP(indf)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indf a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indf a %p a->len %zd i %zd\n", a, a->len, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*sizeof(REAL));
@@ -251,12 +251,12 @@
 }
 OP(indl)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indl a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indl a %p a->len %zd i %zd\n", a, a->len, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*sizeof(LONG));
@@ -263,12 +263,12 @@
 }
 OP(indb)
 {
-	ulong i;
+	uintptr i;
 	Array *a;
 
 	a = A(s);
 	i = W(d);
-	DP("indb a %p a->len %lld i %ld\n", a, a->len, i);
+	DP("indb a %p a->len %zd a->data 0x%p i %zd\n", a, a->len, a->data, i);
 	if(a == H || i >= a->len)
 		error(exBounds);
 	W(m) = (WORD)(a->data+i*sizeof(BYTE));
--- a/os/port/alloc.c
+++ b/os/port/alloc.c
@@ -18,7 +18,7 @@
 	char*	name;
 	int	pnum;
 	uintptr	maxsize;
-	int	quanta;
+	intptr	quanta;
 	int	chunk;
 	uintptr	ressize;
 	uintptr	cursize;
@@ -29,8 +29,8 @@
 	Bhdr*	chain;
 	uintptr	nalloc;
 	uintptr	nfree;
-	int	nbrk;
-	int	lastfree;
+	intptr	nbrk;
+	intptr	lastfree;
 	int	warn;
 	void	(*move)(void*, void*);
 };
@@ -955,7 +955,7 @@
 	char *fmsg, *msg;
 	uintptr fsz;
 
-	SET(fsz, fmsg);
+	SET(fsz, fmsg, nb);
 	for (p = &table.pool[0]; p < &table.pool[nelem(table.pool)]; p++) {
 		ilock(&p->l);
 		for (bc = p->chain; bc != nil; bc = bc->clink) {
--- a/os/port/devcons.c
+++ b/os/port/devcons.c
@@ -457,7 +457,7 @@
 
 	if(size > 64) size = 64;
 
-	snprint(tmp, sizeof(tmp), "%*.0lud ", size, val);
+	snprint(tmp, sizeof(tmp), "%*.0ld ", size, val);
 	if(off >= size)
 		return 0;
 	if(off+n > size)