changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: kernel: get rid of PTR2UINT() and UINT2PTR() macros

changeset 7155: 85c4b38d9a82
parent 7154: 0573cdc3766b
child 7156: 9851d8234792
author: cinap_lenrek@felloff.net
date: Thu, 11 Apr 2019 13:51:38 +0200
files: sys/src/9/bcm/arch.c sys/src/9/bcm/fns.h sys/src/9/bcm/main.c sys/src/9/bcm/mmu.c sys/src/9/bcm/trap.c sys/src/9/bcm/vcore.c sys/src/9/kw/arch.c sys/src/9/kw/fns.h sys/src/9/kw/main.c sys/src/9/kw/mmu.c sys/src/9/kw/syscall.c sys/src/9/kw/trap.c sys/src/9/omap/arch.c sys/src/9/omap/fns.h sys/src/9/omap/main.c sys/src/9/omap/mmu.c sys/src/9/omap/syscall.c sys/src/9/omap/trap.c sys/src/9/port/syscallfmt.c sys/src/9/teg2/arch.c sys/src/9/teg2/fns.h sys/src/9/teg2/main.c sys/src/9/teg2/mmu.c sys/src/9/teg2/syscall.c sys/src/9/teg2/trap.c
description: kernel: get rid of PTR2UINT() and UINT2PTR() macros
     1.1--- a/sys/src/9/bcm/arch.c
     1.2+++ b/sys/src/9/bcm/arch.c
     1.3@@ -24,7 +24,7 @@ setkernur(Ureg* ureg, Proc* p)
     1.4 {
     1.5 	ureg->pc = p->sched.pc;
     1.6 	ureg->sp = p->sched.sp+4;
     1.7-	ureg->r14 = PTR2UINT(sched);
     1.8+	ureg->r14 = (uintptr)sched;
     1.9 }
    1.10 
    1.11 /*
    1.12@@ -95,8 +95,8 @@ linkproc(void)
    1.13 void
    1.14 kprocchild(Proc *p, void (*func)(void*), void *arg)
    1.15 {
    1.16-	p->sched.pc = PTR2UINT(linkproc);
    1.17-	p->sched.sp = PTR2UINT(p->kstack+KSTACK);
    1.18+	p->sched.pc = (uintptr)linkproc;
    1.19+	p->sched.sp = (uintptr)p->kstack+KSTACK;
    1.20 
    1.21 	p->kpfun = func;
    1.22 	p->kparg = arg;
     2.1--- a/sys/src/9/bcm/fns.h
     2.2+++ b/sys/src/9/bcm/fns.h
     2.3@@ -131,14 +131,9 @@ extern void kexit(Ureg*);
     2.4 #define	kmapinval()
     2.5 #define countpagerefs(a, b)
     2.6 
     2.7-#define PTR2UINT(p)	((uintptr)(p))
     2.8-#define UINT2PTR(i)	((void*)(i))
     2.9-
    2.10 #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
    2.11 
    2.12-#define KADDR(pa)	UINT2PTR(KZERO    | ((uintptr)(pa) & ~KSEGM))
    2.13-#define PADDR(va)	PTR2UINT(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
    2.14-#define DMAADDR(va)	PTR2UINT(BUSDRAM  | ((uintptr)(va) & ~KSEGM))
    2.15-#define DMAIO(va)	PTR2UINT(BUSIO    | ((uintptr)(va) & ~VIRTIO))
    2.16+#define KADDR(pa)	((void*)(KZERO | ((uintptr)(pa) & ~KSEGM)))
    2.17+#define PADDR(va)	(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
    2.18 
    2.19 #define MASK(v)	((1UL << (v)) - 1)	/* mask `v' bits wide */
     3.1--- a/sys/src/9/bcm/main.c
     3.2+++ b/sys/src/9/bcm/main.c
     3.3@@ -367,7 +367,7 @@ bootargs(uintptr base)
     3.4 	 * of the argument list checked in syscall.
     3.5 	 */
     3.6 	i = oargblen+1;
     3.7-	p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(Tos) - i));
     3.8+	p = (void*)STACKALIGN(base + BY2PG - sizeof(Tos) - i);
     3.9 	memmove(p, oargb, i);
    3.10 
    3.11 	/*
    3.12@@ -379,7 +379,7 @@ bootargs(uintptr base)
    3.13 	 * not the usual (int argc, char* argv[])
    3.14 	 */
    3.15 	av = (char**)(p - (oargc+1)*sizeof(char*));
    3.16-	ssize = base + BY2PG - PTR2UINT(av);
    3.17+	ssize = base + BY2PG - (uintptr)av;
    3.18 	for(i = 0; i < oargc; i++)
    3.19 		*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
    3.20 	*av = nil;
    3.21@@ -415,8 +415,8 @@ userinit(void)
    3.22 	/*
    3.23 	 * Kernel Stack
    3.24 	 */
    3.25-	p->sched.pc = PTR2UINT(init0);
    3.26-	p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
    3.27+	p->sched.pc = (uintptr)init0;
    3.28+	p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr);
    3.29 	p->sched.sp = STACKALIGN(p->sched.sp);
    3.30 
    3.31 	/*
    3.32@@ -445,7 +445,7 @@ userinit(void)
    3.33 	pg->txtflush = ~0;
    3.34 	segpage(s, pg);
    3.35 	k = kmap(s->map[0]->pages[0]);
    3.36-	memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
    3.37+	memmove((void*)VA(k), initcode, sizeof initcode);
    3.38 	kunmap(k);
    3.39 
    3.40 	ready(p);
    3.41@@ -485,7 +485,7 @@ confinit(void)
    3.42 		conf.mem[0].limit = conf.mem[0].base + memsize;
    3.43 
    3.44 	conf.npage = 0;
    3.45-	pa = PADDR(PGROUND(PTR2UINT(end)));
    3.46+	pa = PADDR(PGROUND((uintptr)end));
    3.47 
    3.48 	/*
    3.49 	 *  we assume that the kernel is at the beginning of one of the
     4.1--- a/sys/src/9/bcm/mmu.c
     4.2+++ b/sys/src/9/bcm/mmu.c
     4.3@@ -91,7 +91,7 @@ mmul2empty(Proc* proc, int clear)
     4.4 	l2 = &proc->mmul2;
     4.5 	for(page = *l2; page != nil; page = page->next){
     4.6 		if(clear)
     4.7-			memset(UINT2PTR(page->va), 0, L2size);
     4.8+			memset((void*)page->va, 0, L2size);
     4.9 		l1[page->daddr] = Fault;
    4.10 		l2 = &page->next;
    4.11 	}
    4.12@@ -241,7 +241,7 @@ putmmu(uintptr va, uintptr pa, Page* pag
    4.13 				m->mmul1hi = L1hi - x;
    4.14 		}
    4.15 	}
    4.16-	pte = UINT2PTR(KADDR(PPN(*l1)));
    4.17+	pte = KADDR(PPN(*l1));
    4.18 
    4.19 	/* protection bits are
    4.20 	 *	PTERONLY|PTEVALID;
    4.21@@ -283,7 +283,7 @@ mmuuncache(void* v, usize size)
    4.22 	 * Uncache a Section, must already be
    4.23 	 * valid in the MMU.
    4.24 	 */
    4.25-	va = PTR2UINT(v);
    4.26+	va = (uintptr)v;
    4.27 	assert(!(va & (1*MiB-1)) && size == 1*MiB);
    4.28 
    4.29 	x = L1X(va);
     5.1--- a/sys/src/9/bcm/trap.c
     5.2+++ b/sys/src/9/bcm/trap.c
     5.3@@ -405,7 +405,7 @@ callwithureg(void (*fn)(Ureg*))
     5.4 	Ureg ureg;
     5.5 
     5.6 	ureg.pc = getcallerpc(&fn);
     5.7-	ureg.sp = PTR2UINT(&fn);
     5.8+	ureg.sp = (uintptr)&fn;
     5.9 	fn(&ureg);
    5.10 }
    5.11 
     6.1--- a/sys/src/9/bcm/vcore.c
     6.2+++ b/sys/src/9/bcm/vcore.c
     6.3@@ -149,7 +149,7 @@ vcreq(int tag, void *buf, int vallen, in
     6.4 		memmove(prop->data, buf, vallen);
     6.5 	cachedwbinvse(prop, prop->len);
     6.6 	for(;;){
     6.7-		aprop = busaddr? dmaaddr(prop) : PTR2UINT(prop);
     6.8+		aprop = busaddr? dmaaddr(prop) : (uintptr)prop;
     6.9 		vcwrite(ChanProps, aprop);
    6.10 		r = vcread(ChanProps);
    6.11 		if(r == aprop)
     7.1--- a/sys/src/9/kw/arch.c
     7.2+++ b/sys/src/9/kw/arch.c
     7.3@@ -24,7 +24,7 @@ setkernur(Ureg* ureg, Proc* p)
     7.4 {
     7.5 	ureg->pc = p->sched.pc;
     7.6 	ureg->sp = p->sched.sp+4;
     7.7-	ureg->r14 = PTR2UINT(sched);
     7.8+	ureg->r14 = (uintptr)sched;
     7.9 }
    7.10 
    7.11 /*
    7.12@@ -95,8 +95,8 @@ linkproc(void)
    7.13 void
    7.14 kprocchild(Proc *p, void (*func)(void*), void *arg)
    7.15 {
    7.16-	p->sched.pc = PTR2UINT(linkproc);
    7.17-	p->sched.sp = PTR2UINT(p->kstack+KSTACK);
    7.18+	p->sched.pc = (uintptr)linkproc;
    7.19+	p->sched.sp = (uintptr)p->kstack+KSTACK;
    7.20 
    7.21 	p->kpfun = func;
    7.22 	p->kparg = arg;
     8.1--- a/sys/src/9/kw/fns.h
     8.2+++ b/sys/src/9/kw/fns.h
     8.3@@ -174,9 +174,6 @@ extern void kexit(Ureg*);
     8.4 #define	getpgcolor(a)	0
     8.5 #define	kmapinval()
     8.6 
     8.7-#define PTR2UINT(p)	((uintptr)(p))
     8.8-#define UINT2PTR(i)	((void*)(i))
     8.9-
    8.10 #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
    8.11 
    8.12 /*
    8.13@@ -195,7 +192,7 @@ extern void kexit(Ureg*);
    8.14 /*
    8.15  * These are not good enough.
    8.16  */
    8.17-#define KADDR(pa)	UINT2PTR(KZERO|((uintptr)(pa)))
    8.18-#define PADDR(va)	PTR2UINT(((uintptr)(va)) & ~KSEGM)
    8.19+#define KADDR(pa)	((void*)(KZERO|((uintptr)(pa))))
    8.20+#define PADDR(va)	(((uintptr)(va)) & ~KSEGM)
    8.21 
    8.22 #define MASK(v)	((1UL << (v)) - 1)	/* mask `v' bits wide */
     9.1--- a/sys/src/9/kw/main.c
     9.2+++ b/sys/src/9/kw/main.c
     9.3@@ -460,7 +460,7 @@ bootargs(uintptr base)
     9.4 	 * of the argument list checked in syscall.
     9.5 	 */
     9.6 	i = oargblen+1;
     9.7-	p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
     9.8+	p = (void*)(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
     9.9 	memmove(p, oargb, i);
    9.10 
    9.11 	/*
    9.12@@ -473,7 +473,7 @@ bootargs(uintptr base)
    9.13 	 * unused so it doesn't matter (at the moment...).
    9.14 	 */
    9.15 	av = (char**)(p - (oargc+2)*sizeof(char*));
    9.16-	ssize = base + BY2PG - PTR2UINT(av);
    9.17+	ssize = base + BY2PG - (uintptr)av;
    9.18 	*av++ = (char*)oargc;
    9.19 	for(i = 0; i < oargc; i++)
    9.20 		*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
    9.21@@ -515,8 +515,8 @@ userinit(void)
    9.22 	/*
    9.23 	 * Kernel Stack
    9.24 	 */
    9.25-	p->sched.pc = PTR2UINT(init0);
    9.26-	p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
    9.27+	p->sched.pc = (uintptr)init0;
    9.28+	p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr);
    9.29 	p->sched.sp = STACKALIGN(p->sched.sp);
    9.30 
    9.31 	/*
    9.32@@ -545,7 +545,7 @@ userinit(void)
    9.33 	pg->txtflush = ~0;
    9.34 	segpage(s, pg);
    9.35 	k = kmap(s->map[0]->pages[0]);
    9.36-	memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
    9.37+	memmove((void*)VA(k), initcode, sizeof initcode);
    9.38 	kunmap(k);
    9.39 
    9.40 	ready(p);
    9.41@@ -578,7 +578,7 @@ confinit(void)
    9.42 	memmove(conf.mem, sheevamem, sizeof(sheevamem));
    9.43 
    9.44 	conf.npage = 0;
    9.45-	pa = PADDR(PGROUND(PTR2UINT(end)));
    9.46+	pa = PADDR(PGROUND((uintptr)end));
    9.47 
    9.48 	/*
    9.49 	 *  we assume that the kernel is at the beginning of one of the
    10.1--- a/sys/src/9/kw/mmu.c
    10.2+++ b/sys/src/9/kw/mmu.c
    10.3@@ -154,7 +154,7 @@ mmul2empty(Proc* proc, int clear)
    10.4 	l2 = &proc->mmul2;
    10.5 	for(page = *l2; page != nil; page = page->next){
    10.6 		if(clear)
    10.7-			memset(UINT2PTR(page->va), 0, BY2PG);
    10.8+			memset((void*)page->va, 0, BY2PG);
    10.9 		l1[page->daddr] = Fault;
   10.10 		l2 = &page->next;
   10.11 	}
   10.12@@ -301,7 +301,7 @@ putmmu(uintptr va, uintptr pa, Page* pag
   10.13 		else{
   10.14 			pg = up->mmul2cache;
   10.15 			up->mmul2cache = pg->next;
   10.16-			memset(UINT2PTR(pg->va), 0, BY2PG);
   10.17+			memset((void*)pg->va, 0, BY2PG);
   10.18 		}
   10.19 		pg->daddr = x;
   10.20 		pg->next = up->mmul2;
   10.21@@ -323,7 +323,7 @@ putmmu(uintptr va, uintptr pa, Page* pag
   10.22 				m->mmul1hi = x;
   10.23 		}
   10.24 	}
   10.25-	pte = UINT2PTR(KADDR(PPN(*l1)));
   10.26+	pte = (void*)KADDR(PPN(*l1));
   10.27 	//print("pte %#p index %ld %#ux\n", pte, L2X(va), *(pte+L2X(va)));
   10.28 
   10.29 	/* protection bits are
   10.30@@ -372,7 +372,7 @@ mmuuncache(void* v, usize size)
   10.31 	 * Uncache a Section, must already be
   10.32 	 * valid in the MMU.
   10.33 	 */
   10.34-	va = PTR2UINT(v);
   10.35+	va = (uintptr)v;
   10.36 	assert(!(va & (1*MiB-1)) && size == 1*MiB);
   10.37 
   10.38 	x = L1X(va);
   10.39@@ -459,7 +459,7 @@ vmap(uintptr pa, usize size)
   10.40 	 * will fail.
   10.41 	 */
   10.42 	if(pa+size < 4*MiB)
   10.43-		return UINT2PTR(kseg0|pa);
   10.44+		return (void*)(kseg0|pa);
   10.45 
   10.46 	osize = size;
   10.47 	o = pa & (BY2PG-1);
   10.48@@ -473,7 +473,7 @@ vmap(uintptr pa, usize size)
   10.49 		panic("vmap(%#p, %ld) called from %#p: mmukmap fails %#p",
   10.50 			pa+o, osize, getcallerpc(&pa), pae);
   10.51 
   10.52-	return UINT2PTR(va+o);
   10.53+	return (void*)(va+o);
   10.54 }
   10.55 
   10.56 /* from 386 */
    11.1--- a/sys/src/9/kw/syscall.c
    11.2+++ b/sys/src/9/kw/syscall.c
    11.3@@ -41,7 +41,7 @@ noted(Ureg* cur, uintptr arg0)
    11.4 	nf = up->ureg;
    11.5 
    11.6 	/* sanity clause */
    11.7-	if(!okaddr(PTR2UINT(nf), sizeof(NFrame), 0)){
    11.8+	if(!okaddr((uintptr)nf, sizeof(NFrame), 0)){
    11.9 		qunlock(&up->debug);
   11.10 		pprint("bad ureg in noted %#p\n", nf);
   11.11 		pexit("Suicide", 0);
   11.12@@ -77,8 +77,8 @@ noted(Ureg* cur, uintptr arg0)
   11.13 		nf->arg1 = nf->msg;
   11.14 		nf->arg0 = &nf->ureg;
   11.15 		nf->ip = 0;
   11.16-		cur->sp = PTR2UINT(nf);
   11.17-		cur->r0 = PTR2UINT(nf->arg0);
   11.18+		cur->sp = (uintptr)nf;
   11.19+		cur->r0 = (uintptr)nf->arg0;
   11.20 		break;
   11.21 	default:
   11.22 		up->lastnote.flag = NDebug;
   11.23@@ -140,7 +140,7 @@ notify(Ureg* ureg)
   11.24 		qunlock(&up->debug);
   11.25 		pexit(n->msg, n->flag != NDebug);
   11.26 	}
   11.27-	if(!okaddr(PTR2UINT(up->notify), 1, 0)){
   11.28+	if(!okaddr((uintptr)up->notify, 1, 0)){
   11.29 		qunlock(&up->debug);
   11.30 		pprint("suicide: notify function address %#p\n", up->notify);
   11.31 		pexit("Suicide", 0);
   11.32@@ -153,7 +153,7 @@ notify(Ureg* ureg)
   11.33 		pexit("Suicide", 0);
   11.34 	}
   11.35 
   11.36-	nf = UINT2PTR(sp);
   11.37+	nf = (void*)sp;
   11.38 	memmove(&nf->ureg, ureg, sizeof(Ureg));
   11.39 	nf->old = up->ureg;
   11.40 	up->ureg = nf;
   11.41@@ -163,8 +163,8 @@ notify(Ureg* ureg)
   11.42 	nf->ip = 0;
   11.43 
   11.44 	ureg->sp = sp;
   11.45-	ureg->pc = PTR2UINT(up->notify);
   11.46-	ureg->r0 = PTR2UINT(nf->arg0);
   11.47+	ureg->pc = (uintptr)up->notify;
   11.48+	ureg->r0 = (uintptr)nf->arg0;
   11.49 
   11.50 	up->notified = 1;
   11.51 	up->nnote--;
    12.1--- a/sys/src/9/kw/trap.c
    12.2+++ b/sys/src/9/kw/trap.c
    12.3@@ -602,7 +602,7 @@ callwithureg(void (*fn)(Ureg*))
    12.4 	Ureg ureg;
    12.5 
    12.6 	ureg.pc = getcallerpc(&fn);
    12.7-	ureg.sp = PTR2UINT(&fn);
    12.8+	ureg.sp = (uintptr)&fn;
    12.9 	fn(&ureg);
   12.10 }
   12.11 
    13.1--- a/sys/src/9/omap/arch.c
    13.2+++ b/sys/src/9/omap/arch.c
    13.3@@ -24,7 +24,7 @@ setkernur(Ureg* ureg, Proc* p)
    13.4 {
    13.5 	ureg->pc = p->sched.pc;
    13.6 	ureg->sp = p->sched.sp+4;
    13.7-	ureg->r14 = PTR2UINT(sched);
    13.8+	ureg->r14 = (uintptr)sched;
    13.9 }
   13.10 
   13.11 /*
   13.12@@ -95,8 +95,8 @@ linkproc(void)
   13.13 void
   13.14 kprocchild(Proc *p, void (*func)(void*), void *arg)
   13.15 {
   13.16-	p->sched.pc = PTR2UINT(linkproc);
   13.17-	p->sched.sp = PTR2UINT(p->kstack+KSTACK);
   13.18+	p->sched.pc = (uintptr)linkproc;
   13.19+	p->sched.sp = (uintptr)p->kstack+KSTACK;
   13.20 
   13.21 	p->kpfun = func;
   13.22 	p->kparg = arg;
    14.1--- a/sys/src/9/omap/fns.h
    14.2+++ b/sys/src/9/omap/fns.h
    14.3@@ -165,13 +165,10 @@ extern void kexit(Ureg*);
    14.4 #define	getpgcolor(a)	0
    14.5 #define	kmapinval()
    14.6 
    14.7-#define PTR2UINT(p)	((uintptr)(p))
    14.8-#define UINT2PTR(i)	((void*)(i))
    14.9-
   14.10 #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
   14.11 
   14.12-#define KADDR(pa)	UINT2PTR(KZERO    | ((uintptr)(pa) & ~KSEGM))
   14.13-#define PADDR(va)	PTR2UINT(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
   14.14+#define KADDR(pa)	((void*)(KZERO | ((uintptr)(pa) & ~KSEGM)))
   14.15+#define PADDR(va)	(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
   14.16 
   14.17 #define wave(c) *(ulong *)PHYSCONS = (c)
   14.18 
    15.1--- a/sys/src/9/omap/main.c
    15.2+++ b/sys/src/9/omap/main.c
    15.3@@ -447,7 +447,7 @@ bootargs(uintptr base)
    15.4 	 * of the argument list checked in syscall.
    15.5 	 */
    15.6 	i = oargblen+1;
    15.7-	p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
    15.8+	p = (void*)(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
    15.9 	memmove(p, oargb, i);
   15.10 
   15.11 	/*
   15.12@@ -460,7 +460,7 @@ bootargs(uintptr base)
   15.13 	 * unused so it doesn't matter (at the moment...).
   15.14 	 */
   15.15 	av = (char**)(p - (oargc+2)*sizeof(char*));
   15.16-	ssize = base + BY2PG - PTR2UINT(av);
   15.17+	ssize = base + BY2PG - (uintptr)av;
   15.18 	*av++ = (char*)oargc;
   15.19 	for(i = 0; i < oargc; i++)
   15.20 		*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
   15.21@@ -502,8 +502,8 @@ userinit(void)
   15.22 	/*
   15.23 	 * Kernel Stack
   15.24 	 */
   15.25-	p->sched.pc = PTR2UINT(init0);
   15.26-	p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
   15.27+	p->sched.pc = (uintptr)init0;
   15.28+	p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr);
   15.29 	p->sched.sp = STACKALIGN(p->sched.sp);
   15.30 
   15.31 	/*
   15.32@@ -532,7 +532,7 @@ userinit(void)
   15.33 	pg->txtflush = ~0;
   15.34 	segpage(s, pg);
   15.35 	k = kmap(s->map[0]->pages[0]);
   15.36-	memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
   15.37+	memmove((void*)VA(k), initcode, sizeof initcode);
   15.38 	kunmap(k);
   15.39 
   15.40 	ready(p);
   15.41@@ -596,7 +596,7 @@ confinit(void)
   15.42 	memmove(conf.mem, omapmem, sizeof(omapmem));
   15.43 
   15.44 	conf.npage = 0;
   15.45-	pa = PADDR(PGROUND(PTR2UINT(end)));
   15.46+	pa = PADDR(PGROUND((uintptr)end));
   15.47 
   15.48 	/*
   15.49 	 *  we assume that the kernel is at the beginning of one of the
    16.1--- a/sys/src/9/omap/mmu.c
    16.2+++ b/sys/src/9/omap/mmu.c
    16.3@@ -138,7 +138,7 @@ mmul2empty(Proc* proc, int clear)
    16.4 	l2 = &proc->mmul2;
    16.5 	for(page = *l2; page != nil; page = page->next){
    16.6 		if(clear)
    16.7-			memset(UINT2PTR(page->va), 0, BY2PG);
    16.8+			memset((void*)page->va, 0, BY2PG);
    16.9 		l1[page->daddr] = Fault;
   16.10 		l2 = &page->next;
   16.11 	}
   16.12@@ -282,7 +282,7 @@ putmmu(uintptr va, uintptr pa, Page* pag
   16.13 		else{
   16.14 			pg = up->mmul2cache;
   16.15 			up->mmul2cache = pg->next;
   16.16-			memset(UINT2PTR(pg->va), 0, BY2PG);
   16.17+			memset((void*)pg->va, 0, BY2PG);
   16.18 		}
   16.19 		pg->daddr = x;
   16.20 		pg->next = up->mmul2;
   16.21@@ -302,7 +302,7 @@ putmmu(uintptr va, uintptr pa, Page* pag
   16.22 				m->mmul1hi = x;
   16.23 		}
   16.24 	}
   16.25-	pte = UINT2PTR(KADDR(PPN(*l1)));
   16.26+	pte = KADDR(PPN(*l1));
   16.27 	//print("pte %#p index %ld was %#ux\n", pte, L2X(va), *(pte+L2X(va)));
   16.28 
   16.29 	/* protection bits are
   16.30@@ -349,7 +349,7 @@ mmuuncache(void* v, usize size)
   16.31 	 * Uncache a Section, must already be
   16.32 	 * valid in the MMU.
   16.33 	 */
   16.34-	va = PTR2UINT(v);
   16.35+	va = (uintptr)v;
   16.36 	assert(!(va & (1*MiB-1)) && size == 1*MiB);
   16.37 
   16.38 	x = L1X(va);
   16.39@@ -433,7 +433,7 @@ vmap(uintptr pa, usize size)
   16.40 	 * will fail.
   16.41 	 */
   16.42 	if(pa+size < 4*MiB)
   16.43-		return UINT2PTR(kseg0|pa);
   16.44+		return (void*)(kseg0|pa);
   16.45 
   16.46 	osize = size;
   16.47 	o = pa & (BY2PG-1);
   16.48@@ -447,7 +447,7 @@ vmap(uintptr pa, usize size)
   16.49 		panic("vmap(%#p, %ld) called from %#p: mmukmap fails %#p",
   16.50 			pa+o, osize, getcallerpc(&pa), pae);
   16.51 
   16.52-	return UINT2PTR(va+o);
   16.53+	return (void*)(va+o);
   16.54 }
   16.55 
   16.56 /* from 386 */
    17.1--- a/sys/src/9/omap/syscall.c
    17.2+++ b/sys/src/9/omap/syscall.c
    17.3@@ -41,7 +41,7 @@ noted(Ureg* cur, uintptr arg0)
    17.4 	nf = up->ureg;
    17.5 
    17.6 	/* sanity clause */
    17.7-	if(!okaddr(PTR2UINT(nf), sizeof(NFrame), 0)){
    17.8+	if(!okaddr((uintptr)nf, sizeof(NFrame), 0)){
    17.9 		qunlock(&up->debug);
   17.10 		pprint("bad ureg in noted %#p\n", nf);
   17.11 		pexit("Suicide", 0);
   17.12@@ -77,8 +77,8 @@ noted(Ureg* cur, uintptr arg0)
   17.13 		nf->arg1 = nf->msg;
   17.14 		nf->arg0 = &nf->ureg;
   17.15 		nf->ip = 0;
   17.16-		cur->sp = PTR2UINT(nf);
   17.17-		cur->r0 = PTR2UINT(nf->arg0);
   17.18+		cur->sp = (uintptr)nf;
   17.19+		cur->r0 = (uintptr)nf->arg0;
   17.20 		break;
   17.21 	default:
   17.22 		up->lastnote.flag = NDebug;
   17.23@@ -140,7 +140,7 @@ notify(Ureg* ureg)
   17.24 		qunlock(&up->debug);
   17.25 		pexit(n->msg, n->flag != NDebug);
   17.26 	}
   17.27-	if(!okaddr(PTR2UINT(up->notify), 1, 0)){
   17.28+	if(!okaddr((uintptr)up->notify, 1, 0)){
   17.29 		qunlock(&up->debug);
   17.30 		pprint("suicide: notify function address %#p\n", up->notify);
   17.31 		pexit("Suicide", 0);
   17.32@@ -153,7 +153,7 @@ notify(Ureg* ureg)
   17.33 		pexit("Suicide", 0);
   17.34 	}
   17.35 
   17.36-	nf = UINT2PTR(sp);
   17.37+	nf = (void*)sp;
   17.38 	memmove(&nf->ureg, ureg, sizeof(Ureg));
   17.39 	nf->old = up->ureg;
   17.40 	up->ureg = nf;
   17.41@@ -163,8 +163,8 @@ notify(Ureg* ureg)
   17.42 	nf->ip = 0;
   17.43 
   17.44 	ureg->sp = sp;
   17.45-	ureg->pc = PTR2UINT(up->notify);
   17.46-	ureg->r0 = PTR2UINT(nf->arg0);
   17.47+	ureg->pc = (uintptr)up->notify;
   17.48+	ureg->r0 = (uintptr)nf->arg0;
   17.49 
   17.50 	up->notified = 1;
   17.51 	up->nnote--;
    18.1--- a/sys/src/9/omap/trap.c
    18.2+++ b/sys/src/9/omap/trap.c
    18.3@@ -644,7 +644,7 @@ callwithureg(void (*fn)(Ureg*))
    18.4 	Ureg ureg;
    18.5 
    18.6 	ureg.pc = getcallerpc(&fn);
    18.7-	ureg.sp = PTR2UINT(&fn);
    18.8+	ureg.sp = (uintptr)&fn;
    18.9 	fn(&ureg);
   18.10 }
   18.11 
    19.1--- a/sys/src/9/port/syscallfmt.c
    19.2+++ b/sys/src/9/port/syscallfmt.c
    19.3@@ -114,7 +114,7 @@ syscallfmt(ulong syscallno, uintptr pc, 
    19.4 		a = va_arg(list, char*);
    19.5 		fmtuserstring(&fmt, a, "");
    19.6 		argv = va_arg(list, char**);
    19.7-		evenaddr(PTR2UINT(argv));
    19.8+		evenaddr((uintptr)argv);
    19.9 		for(;;){
   19.10 			validaddr((uintptr)argv, sizeof(char**), 0);
   19.11 			a = *(char **)argv;
    20.1--- a/sys/src/9/teg2/arch.c
    20.2+++ b/sys/src/9/teg2/arch.c
    20.3@@ -24,7 +24,7 @@ setkernur(Ureg* ureg, Proc* p)
    20.4 {
    20.5 	ureg->pc = p->sched.pc;
    20.6 	ureg->sp = p->sched.sp+4;
    20.7-	ureg->r14 = PTR2UINT(sched);
    20.8+	ureg->r14 = (uintptr)sched;
    20.9 }
   20.10 
   20.11 /*
   20.12@@ -95,8 +95,8 @@ linkproc(void)
   20.13 void
   20.14 kprocchild(Proc *p, void (*func)(void*), void *arg)
   20.15 {
   20.16-	p->sched.pc = PTR2UINT(linkproc);
   20.17-	p->sched.sp = PTR2UINT(p->kstack+KSTACK);
   20.18+	p->sched.pc = (uintptr)linkproc;
   20.19+	p->sched.sp = (uintptr)p->kstack+KSTACK;
   20.20 
   20.21 	p->kpfun = func;
   20.22 	p->kparg = arg;
    21.1--- a/sys/src/9/teg2/fns.h
    21.2+++ b/sys/src/9/teg2/fns.h
    21.3@@ -217,12 +217,9 @@ extern void kexit(Ureg*);
    21.4 #define	getpgcolor(a)	0
    21.5 #define	kmapinval()
    21.6 
    21.7-#define PTR2UINT(p)	((uintptr)(p))
    21.8-#define UINT2PTR(i)	((void*)(i))
    21.9-
   21.10 #define	waserror()	(up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
   21.11 
   21.12-#define KADDR(pa)	UINT2PTR(KZERO    | ((uintptr)(pa) & ~KSEGM))
   21.13-#define PADDR(va)	PTR2UINT(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
   21.14+#define KADDR(pa)	((void*)(KZERO | ((uintptr)(pa) & ~KSEGM)))
   21.15+#define PADDR(va)	(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
   21.16 
   21.17 #define MASK(v)	((1UL << (v)) - 1)	/* mask `v' bits wide */
    22.1--- a/sys/src/9/teg2/main.c
    22.2+++ b/sys/src/9/teg2/main.c
    22.3@@ -643,7 +643,7 @@ bootargs(uintptr base)
    22.4 	 * of the argument list checked in syscall.
    22.5 	 */
    22.6 	i = oargblen+1;
    22.7-	p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
    22.8+	p = (void*)(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
    22.9 	memmove(p, oargb, i);
   22.10 
   22.11 	/*
   22.12@@ -656,7 +656,7 @@ bootargs(uintptr base)
   22.13 	 * unused so it doesn't matter (at the moment...).
   22.14 	 */
   22.15 	av = (char**)(p - (oargc+2)*sizeof(char*));
   22.16-	ssize = base + BY2PG - PTR2UINT(av);
   22.17+	ssize = base + BY2PG - (uintptr)av;
   22.18 	*av++ = (char*)oargc;
   22.19 	for(i = 0; i < oargc; i++)
   22.20 		*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
   22.21@@ -698,8 +698,8 @@ userinit(void)
   22.22 	/*
   22.23 	 * Kernel Stack
   22.24 	 */
   22.25-	p->sched.pc = PTR2UINT(init0);
   22.26-	p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
   22.27+	p->sched.pc = (uintptr)init0;
   22.28+	p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr);
   22.29 	p->sched.sp = STACKALIGN(p->sched.sp);
   22.30 
   22.31 	/*
   22.32@@ -728,7 +728,7 @@ userinit(void)
   22.33 	pg->txtflush = ~0;
   22.34 	segpage(s, pg);
   22.35 	k = kmap(s->map[0]->pages[0]);
   22.36-	memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
   22.37+	memmove((void*)VA(k), initcode, sizeof initcode);
   22.38 	kunmap(k);
   22.39 
   22.40 	ready(p);
   22.41@@ -797,7 +797,7 @@ confinit(void)
   22.42 	memmove(conf.mem, tsmem, sizeof(tsmem));
   22.43 
   22.44 	conf.npage = 0;
   22.45-	pa = PADDR(PGROUND(PTR2UINT(end)));
   22.46+	pa = PADDR(PGROUND((uintptr)end));
   22.47 
   22.48 	/*
   22.49 	 *  we assume that the kernel is at the beginning of one of the
    23.1--- a/sys/src/9/teg2/mmu.c
    23.2+++ b/sys/src/9/teg2/mmu.c
    23.3@@ -375,7 +375,7 @@ mmul2empty(Proc* proc, int clear)
    23.4 	l2 = &proc->mmul2;
    23.5 	for(page = *l2; page != nil; page = page->next){
    23.6 		if(clear)
    23.7-			memset(UINT2PTR(page->va), 0, BY2PG);
    23.8+			memset((void*)page->va, 0, BY2PG);
    23.9 		l1[page->daddr] = Fault;
   23.10 		allcache->wbse(l1, sizeof *l1);
   23.11 		l2 = &page->next;
   23.12@@ -527,7 +527,7 @@ putmmu(uintptr va, uintptr pa, Page* pag
   23.13 		else{
   23.14 			pg = up->mmul2cache;
   23.15 			up->mmul2cache = pg->next;
   23.16-			memset(UINT2PTR(pg->va), 0, BY2PG);
   23.17+			memset((void*)pg->va, 0, BY2PG);
   23.18 		}
   23.19 		pg->daddr = x;
   23.20 		pg->next = up->mmul2;
   23.21@@ -549,7 +549,7 @@ putmmu(uintptr va, uintptr pa, Page* pag
   23.22 				m->mmul1hi = x;
   23.23 		}
   23.24 	}
   23.25-	pte = UINT2PTR(KADDR(PPN(*l1)));
   23.26+	pte = KADDR(PPN(*l1));
   23.27 	if (Debug) {
   23.28 		iprint("pte %#p index %ld was %#ux\n", pte, L2X(va), *(pte+L2X(va)));
   23.29 		if (*(pte+L2X(va)))
   23.30@@ -602,7 +602,7 @@ mmuuncache(void* v, usize size)
   23.31 	 * Uncache a Section, must already be
   23.32 	 * valid in the MMU.
   23.33 	 */
   23.34-	va = PTR2UINT(v);
   23.35+	va = (uintptr)v;
   23.36 	assert(!(va & (1*MiB-1)) && size == 1*MiB);
   23.37 
   23.38 	x = L1X(va);
   23.39@@ -687,7 +687,7 @@ vmap(uintptr pa, usize size)
   23.40 	 * will fail.
   23.41 	 */
   23.42 	if(pa+size < 4*MiB)
   23.43-		return UINT2PTR(kseg0|pa);
   23.44+		return (void*)(kseg0|pa);
   23.45 
   23.46 	osize = size;
   23.47 	o = pa & (BY2PG-1);
   23.48@@ -701,7 +701,7 @@ vmap(uintptr pa, usize size)
   23.49 		panic("vmap(%#p, %ld) called from %#p: mmukmap fails %#p",
   23.50 			pa+o, osize, getcallerpc(&pa), pae);
   23.51 
   23.52-	return UINT2PTR(va+o);
   23.53+	return (void*)(va+o);
   23.54 }
   23.55 
   23.56 /* from 386 */
    24.1--- a/sys/src/9/teg2/syscall.c
    24.2+++ b/sys/src/9/teg2/syscall.c
    24.3@@ -47,7 +47,7 @@ noted(Ureg* cur, uintptr arg0)
    24.4 	nf = up->ureg;
    24.5 
    24.6 	/* sanity clause */
    24.7-	if(!okaddr(PTR2UINT(nf), sizeof(NFrame), 0)){
    24.8+	if(!okaddr((uintptr)nf, sizeof(NFrame), 0)){
    24.9 		qunlock(&up->debug);
   24.10 		pprint("bad ureg in noted %#p\n", nf);
   24.11 		pexit("Suicide", 0);
   24.12@@ -83,8 +83,8 @@ noted(Ureg* cur, uintptr arg0)
   24.13 		nf->arg1 = nf->msg;
   24.14 		nf->arg0 = &nf->ureg;
   24.15 		nf->ip = 0;
   24.16-		cur->sp = PTR2UINT(nf);
   24.17-		cur->r0 = PTR2UINT(nf->arg0);
   24.18+		cur->sp = (uintptr)nf;
   24.19+		cur->r0 = (uintptr)nf->arg0;
   24.20 		break;
   24.21 	default:
   24.22 		up->lastnote.flag = NDebug;
   24.23@@ -146,7 +146,7 @@ notify(Ureg* ureg)
   24.24 		qunlock(&up->debug);
   24.25 		pexit(n->msg, n->flag != NDebug);
   24.26 	}
   24.27-	if(!okaddr(PTR2UINT(up->notify), 1, 0)){
   24.28+	if(!okaddr((uintptr)up->notify, 1, 0)){
   24.29 		qunlock(&up->debug);
   24.30 		pprint("suicide: notify function address %#p\n", up->notify);
   24.31 		pexit("Suicide", 0);
   24.32@@ -159,7 +159,7 @@ notify(Ureg* ureg)
   24.33 		pexit("Suicide", 0);
   24.34 	}
   24.35 
   24.36-	nf = UINT2PTR(sp);
   24.37+	nf = (void*)sp;
   24.38 	memmove(&nf->ureg, ureg, sizeof(Ureg));
   24.39 	nf->old = up->ureg;
   24.40 	up->ureg = nf;
   24.41@@ -169,8 +169,8 @@ notify(Ureg* ureg)
   24.42 	nf->ip = 0;
   24.43 
   24.44 	ureg->sp = sp;
   24.45-	ureg->pc = PTR2UINT(up->notify);
   24.46-	ureg->r0 = PTR2UINT(nf->arg0);
   24.47+	ureg->pc = (uintptr)up->notify;
   24.48+	ureg->r0 = (uintptr)nf->arg0;
   24.49 
   24.50 	up->notified = 1;
   24.51 	up->nnote--;
    25.1--- a/sys/src/9/teg2/trap.c
    25.2+++ b/sys/src/9/teg2/trap.c
    25.3@@ -937,7 +937,7 @@ callwithureg(void (*fn)(Ureg*))
    25.4 
    25.5 	memset(&ureg, 0, sizeof ureg);
    25.6 	ureg.pc = getcallerpc(&fn);
    25.7-	ureg.sp = PTR2UINT(&fn);
    25.8+	ureg.sp = (uintptr)&fn;
    25.9 	fn(&ureg);
   25.10 }
   25.11