ref: 37d36fdd7f441aa184c4051d02e50e9e770f20f8
parent: 753fa51b77869eadcc27c00df34f09c3c9239fe2
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Apr 11 09:51:38 EDT 2019
kernel: get rid of PTR2UINT() and UINT2PTR() macros
--- a/sys/src/9/bcm/arch.c
+++ b/sys/src/9/bcm/arch.c
@@ -24,7 +24,7 @@
{
ureg->pc = p->sched.pc;
ureg->sp = p->sched.sp+4;
- ureg->r14 = PTR2UINT(sched);
+ ureg->r14 = (uintptr)sched;
}
/*
@@ -95,8 +95,8 @@
void
kprocchild(Proc *p, void (*func)(void*), void *arg)
{
- p->sched.pc = PTR2UINT(linkproc);
- p->sched.sp = PTR2UINT(p->kstack+KSTACK);
+ p->sched.pc = (uintptr)linkproc;
+ p->sched.sp = (uintptr)p->kstack+KSTACK;
p->kpfun = func;
p->kparg = arg;
--- a/sys/src/9/bcm/fns.h
+++ b/sys/src/9/bcm/fns.h
@@ -131,14 +131,9 @@
#define kmapinval()
#define countpagerefs(a, b)
-#define PTR2UINT(p) ((uintptr)(p))
-#define UINT2PTR(i) ((void*)(i))
-
#define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
-#define KADDR(pa) UINT2PTR(KZERO | ((uintptr)(pa) & ~KSEGM))
-#define PADDR(va) PTR2UINT(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
-#define DMAADDR(va) PTR2UINT(BUSDRAM | ((uintptr)(va) & ~KSEGM))
-#define DMAIO(va) PTR2UINT(BUSIO | ((uintptr)(va) & ~VIRTIO))
+#define KADDR(pa) ((void*)(KZERO | ((uintptr)(pa) & ~KSEGM)))
+#define PADDR(va) (PHYSDRAM | ((uintptr)(va) & ~KSEGM))
#define MASK(v) ((1UL << (v)) - 1) /* mask `v' bits wide */
--- a/sys/src/9/bcm/main.c
+++ b/sys/src/9/bcm/main.c
@@ -367,7 +367,7 @@
* of the argument list checked in syscall.
*/
i = oargblen+1;
- p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(Tos) - i));
+ p = (void*)STACKALIGN(base + BY2PG - sizeof(Tos) - i);
memmove(p, oargb, i);
/*
@@ -379,7 +379,7 @@
* not the usual (int argc, char* argv[])
*/
av = (char**)(p - (oargc+1)*sizeof(char*));
- ssize = base + BY2PG - PTR2UINT(av);
+ ssize = base + BY2PG - (uintptr)av;
for(i = 0; i < oargc; i++)
*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
*av = nil;
@@ -415,8 +415,8 @@
/*
* Kernel Stack
*/
- p->sched.pc = PTR2UINT(init0);
- p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
+ p->sched.pc = (uintptr)init0;
+ p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr);
p->sched.sp = STACKALIGN(p->sched.sp);
/*
@@ -445,7 +445,7 @@
pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
- memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
+ memmove((void*)VA(k), initcode, sizeof initcode);
kunmap(k);
ready(p);
@@ -485,7 +485,7 @@
conf.mem[0].limit = conf.mem[0].base + memsize;
conf.npage = 0;
- pa = PADDR(PGROUND(PTR2UINT(end)));
+ pa = PADDR(PGROUND((uintptr)end));
/*
* we assume that the kernel is at the beginning of one of the
--- a/sys/src/9/bcm/mmu.c
+++ b/sys/src/9/bcm/mmu.c
@@ -91,7 +91,7 @@
l2 = &proc->mmul2;
for(page = *l2; page != nil; page = page->next){
if(clear)
- memset(UINT2PTR(page->va), 0, L2size);
+ memset((void*)page->va, 0, L2size);
l1[page->daddr] = Fault;
l2 = &page->next;
}
@@ -241,7 +241,7 @@
m->mmul1hi = L1hi - x;
}
}
- pte = UINT2PTR(KADDR(PPN(*l1)));
+ pte = KADDR(PPN(*l1));
/* protection bits are
* PTERONLY|PTEVALID;
@@ -283,7 +283,7 @@
* Uncache a Section, must already be
* valid in the MMU.
*/
- va = PTR2UINT(v);
+ va = (uintptr)v;
assert(!(va & (1*MiB-1)) && size == 1*MiB);
x = L1X(va);
--- a/sys/src/9/bcm/trap.c
+++ b/sys/src/9/bcm/trap.c
@@ -405,7 +405,7 @@
Ureg ureg;
ureg.pc = getcallerpc(&fn);
- ureg.sp = PTR2UINT(&fn);
+ ureg.sp = (uintptr)&fn;
fn(&ureg);
}
--- a/sys/src/9/bcm/vcore.c
+++ b/sys/src/9/bcm/vcore.c
@@ -149,7 +149,7 @@
memmove(prop->data, buf, vallen);
cachedwbinvse(prop, prop->len);
for(;;){
- aprop = busaddr? dmaaddr(prop) : PTR2UINT(prop);
+ aprop = busaddr? dmaaddr(prop) : (uintptr)prop;
vcwrite(ChanProps, aprop);
r = vcread(ChanProps);
if(r == aprop)
--- a/sys/src/9/kw/arch.c
+++ b/sys/src/9/kw/arch.c
@@ -24,7 +24,7 @@
{
ureg->pc = p->sched.pc;
ureg->sp = p->sched.sp+4;
- ureg->r14 = PTR2UINT(sched);
+ ureg->r14 = (uintptr)sched;
}
/*
@@ -95,8 +95,8 @@
void
kprocchild(Proc *p, void (*func)(void*), void *arg)
{
- p->sched.pc = PTR2UINT(linkproc);
- p->sched.sp = PTR2UINT(p->kstack+KSTACK);
+ p->sched.pc = (uintptr)linkproc;
+ p->sched.sp = (uintptr)p->kstack+KSTACK;
p->kpfun = func;
p->kparg = arg;
--- a/sys/src/9/kw/fns.h
+++ b/sys/src/9/kw/fns.h
@@ -174,9 +174,6 @@
#define getpgcolor(a) 0
#define kmapinval()
-#define PTR2UINT(p) ((uintptr)(p))
-#define UINT2PTR(i) ((void*)(i))
-
#define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
/*
@@ -195,7 +192,7 @@
/*
* These are not good enough.
*/
-#define KADDR(pa) UINT2PTR(KZERO|((uintptr)(pa)))
-#define PADDR(va) PTR2UINT(((uintptr)(va)) & ~KSEGM)
+#define KADDR(pa) ((void*)(KZERO|((uintptr)(pa))))
+#define PADDR(va) (((uintptr)(va)) & ~KSEGM)
#define MASK(v) ((1UL << (v)) - 1) /* mask `v' bits wide */
--- a/sys/src/9/kw/main.c
+++ b/sys/src/9/kw/main.c
@@ -460,7 +460,7 @@
* of the argument list checked in syscall.
*/
i = oargblen+1;
- p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
+ p = (void*)(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
memmove(p, oargb, i);
/*
@@ -473,7 +473,7 @@
* unused so it doesn't matter (at the moment...).
*/
av = (char**)(p - (oargc+2)*sizeof(char*));
- ssize = base + BY2PG - PTR2UINT(av);
+ ssize = base + BY2PG - (uintptr)av;
*av++ = (char*)oargc;
for(i = 0; i < oargc; i++)
*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
@@ -515,8 +515,8 @@
/*
* Kernel Stack
*/
- p->sched.pc = PTR2UINT(init0);
- p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
+ p->sched.pc = (uintptr)init0;
+ p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr);
p->sched.sp = STACKALIGN(p->sched.sp);
/*
@@ -545,7 +545,7 @@
pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
- memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
+ memmove((void*)VA(k), initcode, sizeof initcode);
kunmap(k);
ready(p);
@@ -578,7 +578,7 @@
memmove(conf.mem, sheevamem, sizeof(sheevamem));
conf.npage = 0;
- pa = PADDR(PGROUND(PTR2UINT(end)));
+ pa = PADDR(PGROUND((uintptr)end));
/*
* we assume that the kernel is at the beginning of one of the
--- a/sys/src/9/kw/mmu.c
+++ b/sys/src/9/kw/mmu.c
@@ -154,7 +154,7 @@
l2 = &proc->mmul2;
for(page = *l2; page != nil; page = page->next){
if(clear)
- memset(UINT2PTR(page->va), 0, BY2PG);
+ memset((void*)page->va, 0, BY2PG);
l1[page->daddr] = Fault;
l2 = &page->next;
}
@@ -301,7 +301,7 @@
else{
pg = up->mmul2cache;
up->mmul2cache = pg->next;
- memset(UINT2PTR(pg->va), 0, BY2PG);
+ memset((void*)pg->va, 0, BY2PG);
}
pg->daddr = x;
pg->next = up->mmul2;
@@ -323,7 +323,7 @@
m->mmul1hi = x;
}
}
- pte = UINT2PTR(KADDR(PPN(*l1)));
+ pte = (void*)KADDR(PPN(*l1));
//print("pte %#p index %ld %#ux\n", pte, L2X(va), *(pte+L2X(va)));
/* protection bits are
@@ -372,7 +372,7 @@
* Uncache a Section, must already be
* valid in the MMU.
*/
- va = PTR2UINT(v);
+ va = (uintptr)v;
assert(!(va & (1*MiB-1)) && size == 1*MiB);
x = L1X(va);
@@ -459,7 +459,7 @@
* will fail.
*/
if(pa+size < 4*MiB)
- return UINT2PTR(kseg0|pa);
+ return (void*)(kseg0|pa);
osize = size;
o = pa & (BY2PG-1);
@@ -473,7 +473,7 @@
panic("vmap(%#p, %ld) called from %#p: mmukmap fails %#p",
pa+o, osize, getcallerpc(&pa), pae);
- return UINT2PTR(va+o);
+ return (void*)(va+o);
}
/* from 386 */
--- a/sys/src/9/kw/syscall.c
+++ b/sys/src/9/kw/syscall.c
@@ -41,7 +41,7 @@
nf = up->ureg;
/* sanity clause */
- if(!okaddr(PTR2UINT(nf), sizeof(NFrame), 0)){
+ if(!okaddr((uintptr)nf, sizeof(NFrame), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted %#p\n", nf);
pexit("Suicide", 0);
@@ -77,8 +77,8 @@
nf->arg1 = nf->msg;
nf->arg0 = &nf->ureg;
nf->ip = 0;
- cur->sp = PTR2UINT(nf);
- cur->r0 = PTR2UINT(nf->arg0);
+ cur->sp = (uintptr)nf;
+ cur->r0 = (uintptr)nf->arg0;
break;
default:
up->lastnote.flag = NDebug;
@@ -140,7 +140,7 @@
qunlock(&up->debug);
pexit(n->msg, n->flag != NDebug);
}
- if(!okaddr(PTR2UINT(up->notify), 1, 0)){
+ if(!okaddr((uintptr)up->notify, 1, 0)){
qunlock(&up->debug);
pprint("suicide: notify function address %#p\n", up->notify);
pexit("Suicide", 0);
@@ -153,7 +153,7 @@
pexit("Suicide", 0);
}
- nf = UINT2PTR(sp);
+ nf = (void*)sp;
memmove(&nf->ureg, ureg, sizeof(Ureg));
nf->old = up->ureg;
up->ureg = nf;
@@ -163,8 +163,8 @@
nf->ip = 0;
ureg->sp = sp;
- ureg->pc = PTR2UINT(up->notify);
- ureg->r0 = PTR2UINT(nf->arg0);
+ ureg->pc = (uintptr)up->notify;
+ ureg->r0 = (uintptr)nf->arg0;
up->notified = 1;
up->nnote--;
--- a/sys/src/9/kw/trap.c
+++ b/sys/src/9/kw/trap.c
@@ -602,7 +602,7 @@
Ureg ureg;
ureg.pc = getcallerpc(&fn);
- ureg.sp = PTR2UINT(&fn);
+ ureg.sp = (uintptr)&fn;
fn(&ureg);
}
--- a/sys/src/9/omap/arch.c
+++ b/sys/src/9/omap/arch.c
@@ -24,7 +24,7 @@
{
ureg->pc = p->sched.pc;
ureg->sp = p->sched.sp+4;
- ureg->r14 = PTR2UINT(sched);
+ ureg->r14 = (uintptr)sched;
}
/*
@@ -95,8 +95,8 @@
void
kprocchild(Proc *p, void (*func)(void*), void *arg)
{
- p->sched.pc = PTR2UINT(linkproc);
- p->sched.sp = PTR2UINT(p->kstack+KSTACK);
+ p->sched.pc = (uintptr)linkproc;
+ p->sched.sp = (uintptr)p->kstack+KSTACK;
p->kpfun = func;
p->kparg = arg;
--- a/sys/src/9/omap/fns.h
+++ b/sys/src/9/omap/fns.h
@@ -165,13 +165,10 @@
#define getpgcolor(a) 0
#define kmapinval()
-#define PTR2UINT(p) ((uintptr)(p))
-#define UINT2PTR(i) ((void*)(i))
-
#define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
-#define KADDR(pa) UINT2PTR(KZERO | ((uintptr)(pa) & ~KSEGM))
-#define PADDR(va) PTR2UINT(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
+#define KADDR(pa) ((void*)(KZERO | ((uintptr)(pa) & ~KSEGM)))
+#define PADDR(va) (PHYSDRAM | ((uintptr)(va) & ~KSEGM))
#define wave(c) *(ulong *)PHYSCONS = (c)
--- a/sys/src/9/omap/main.c
+++ b/sys/src/9/omap/main.c
@@ -447,7 +447,7 @@
* of the argument list checked in syscall.
*/
i = oargblen+1;
- p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
+ p = (void*)(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
memmove(p, oargb, i);
/*
@@ -460,7 +460,7 @@
* unused so it doesn't matter (at the moment...).
*/
av = (char**)(p - (oargc+2)*sizeof(char*));
- ssize = base + BY2PG - PTR2UINT(av);
+ ssize = base + BY2PG - (uintptr)av;
*av++ = (char*)oargc;
for(i = 0; i < oargc; i++)
*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
@@ -502,8 +502,8 @@
/*
* Kernel Stack
*/
- p->sched.pc = PTR2UINT(init0);
- p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
+ p->sched.pc = (uintptr)init0;
+ p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr);
p->sched.sp = STACKALIGN(p->sched.sp);
/*
@@ -532,7 +532,7 @@
pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
- memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
+ memmove((void*)VA(k), initcode, sizeof initcode);
kunmap(k);
ready(p);
@@ -596,7 +596,7 @@
memmove(conf.mem, omapmem, sizeof(omapmem));
conf.npage = 0;
- pa = PADDR(PGROUND(PTR2UINT(end)));
+ pa = PADDR(PGROUND((uintptr)end));
/*
* we assume that the kernel is at the beginning of one of the
--- a/sys/src/9/omap/mmu.c
+++ b/sys/src/9/omap/mmu.c
@@ -138,7 +138,7 @@
l2 = &proc->mmul2;
for(page = *l2; page != nil; page = page->next){
if(clear)
- memset(UINT2PTR(page->va), 0, BY2PG);
+ memset((void*)page->va, 0, BY2PG);
l1[page->daddr] = Fault;
l2 = &page->next;
}
@@ -282,7 +282,7 @@
else{
pg = up->mmul2cache;
up->mmul2cache = pg->next;
- memset(UINT2PTR(pg->va), 0, BY2PG);
+ memset((void*)pg->va, 0, BY2PG);
}
pg->daddr = x;
pg->next = up->mmul2;
@@ -302,7 +302,7 @@
m->mmul1hi = x;
}
}
- pte = UINT2PTR(KADDR(PPN(*l1)));
+ pte = KADDR(PPN(*l1));
//print("pte %#p index %ld was %#ux\n", pte, L2X(va), *(pte+L2X(va)));
/* protection bits are
@@ -349,7 +349,7 @@
* Uncache a Section, must already be
* valid in the MMU.
*/
- va = PTR2UINT(v);
+ va = (uintptr)v;
assert(!(va & (1*MiB-1)) && size == 1*MiB);
x = L1X(va);
@@ -433,7 +433,7 @@
* will fail.
*/
if(pa+size < 4*MiB)
- return UINT2PTR(kseg0|pa);
+ return (void*)(kseg0|pa);
osize = size;
o = pa & (BY2PG-1);
@@ -447,7 +447,7 @@
panic("vmap(%#p, %ld) called from %#p: mmukmap fails %#p",
pa+o, osize, getcallerpc(&pa), pae);
- return UINT2PTR(va+o);
+ return (void*)(va+o);
}
/* from 386 */
--- a/sys/src/9/omap/syscall.c
+++ b/sys/src/9/omap/syscall.c
@@ -41,7 +41,7 @@
nf = up->ureg;
/* sanity clause */
- if(!okaddr(PTR2UINT(nf), sizeof(NFrame), 0)){
+ if(!okaddr((uintptr)nf, sizeof(NFrame), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted %#p\n", nf);
pexit("Suicide", 0);
@@ -77,8 +77,8 @@
nf->arg1 = nf->msg;
nf->arg0 = &nf->ureg;
nf->ip = 0;
- cur->sp = PTR2UINT(nf);
- cur->r0 = PTR2UINT(nf->arg0);
+ cur->sp = (uintptr)nf;
+ cur->r0 = (uintptr)nf->arg0;
break;
default:
up->lastnote.flag = NDebug;
@@ -140,7 +140,7 @@
qunlock(&up->debug);
pexit(n->msg, n->flag != NDebug);
}
- if(!okaddr(PTR2UINT(up->notify), 1, 0)){
+ if(!okaddr((uintptr)up->notify, 1, 0)){
qunlock(&up->debug);
pprint("suicide: notify function address %#p\n", up->notify);
pexit("Suicide", 0);
@@ -153,7 +153,7 @@
pexit("Suicide", 0);
}
- nf = UINT2PTR(sp);
+ nf = (void*)sp;
memmove(&nf->ureg, ureg, sizeof(Ureg));
nf->old = up->ureg;
up->ureg = nf;
@@ -163,8 +163,8 @@
nf->ip = 0;
ureg->sp = sp;
- ureg->pc = PTR2UINT(up->notify);
- ureg->r0 = PTR2UINT(nf->arg0);
+ ureg->pc = (uintptr)up->notify;
+ ureg->r0 = (uintptr)nf->arg0;
up->notified = 1;
up->nnote--;
--- a/sys/src/9/omap/trap.c
+++ b/sys/src/9/omap/trap.c
@@ -644,7 +644,7 @@
Ureg ureg;
ureg.pc = getcallerpc(&fn);
- ureg.sp = PTR2UINT(&fn);
+ ureg.sp = (uintptr)&fn;
fn(&ureg);
}
--- a/sys/src/9/port/syscallfmt.c
+++ b/sys/src/9/port/syscallfmt.c
@@ -114,7 +114,7 @@
a = va_arg(list, char*);
fmtuserstring(&fmt, a, "");
argv = va_arg(list, char**);
- evenaddr(PTR2UINT(argv));
+ evenaddr((uintptr)argv);
for(;;){
validaddr((uintptr)argv, sizeof(char**), 0);
a = *(char **)argv;
--- a/sys/src/9/teg2/arch.c
+++ b/sys/src/9/teg2/arch.c
@@ -24,7 +24,7 @@
{
ureg->pc = p->sched.pc;
ureg->sp = p->sched.sp+4;
- ureg->r14 = PTR2UINT(sched);
+ ureg->r14 = (uintptr)sched;
}
/*
@@ -95,8 +95,8 @@
void
kprocchild(Proc *p, void (*func)(void*), void *arg)
{
- p->sched.pc = PTR2UINT(linkproc);
- p->sched.sp = PTR2UINT(p->kstack+KSTACK);
+ p->sched.pc = (uintptr)linkproc;
+ p->sched.sp = (uintptr)p->kstack+KSTACK;
p->kpfun = func;
p->kparg = arg;
--- a/sys/src/9/teg2/fns.h
+++ b/sys/src/9/teg2/fns.h
@@ -217,12 +217,9 @@
#define getpgcolor(a) 0
#define kmapinval()
-#define PTR2UINT(p) ((uintptr)(p))
-#define UINT2PTR(i) ((void*)(i))
-
#define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1]))
-#define KADDR(pa) UINT2PTR(KZERO | ((uintptr)(pa) & ~KSEGM))
-#define PADDR(va) PTR2UINT(PHYSDRAM | ((uintptr)(va) & ~KSEGM))
+#define KADDR(pa) ((void*)(KZERO | ((uintptr)(pa) & ~KSEGM)))
+#define PADDR(va) (PHYSDRAM | ((uintptr)(va) & ~KSEGM))
#define MASK(v) ((1UL << (v)) - 1) /* mask `v' bits wide */
--- a/sys/src/9/teg2/main.c
+++ b/sys/src/9/teg2/main.c
@@ -643,7 +643,7 @@
* of the argument list checked in syscall.
*/
i = oargblen+1;
- p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
+ p = (void*)(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i));
memmove(p, oargb, i);
/*
@@ -656,7 +656,7 @@
* unused so it doesn't matter (at the moment...).
*/
av = (char**)(p - (oargc+2)*sizeof(char*));
- ssize = base + BY2PG - PTR2UINT(av);
+ ssize = base + BY2PG - (uintptr)av;
*av++ = (char*)oargc;
for(i = 0; i < oargc; i++)
*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
@@ -698,8 +698,8 @@
/*
* Kernel Stack
*/
- p->sched.pc = PTR2UINT(init0);
- p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
+ p->sched.pc = (uintptr)init0;
+ p->sched.sp = (uintptr)p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr);
p->sched.sp = STACKALIGN(p->sched.sp);
/*
@@ -728,7 +728,7 @@
pg->txtflush = ~0;
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
- memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
+ memmove((void*)VA(k), initcode, sizeof initcode);
kunmap(k);
ready(p);
@@ -797,7 +797,7 @@
memmove(conf.mem, tsmem, sizeof(tsmem));
conf.npage = 0;
- pa = PADDR(PGROUND(PTR2UINT(end)));
+ pa = PADDR(PGROUND((uintptr)end));
/*
* we assume that the kernel is at the beginning of one of the
--- a/sys/src/9/teg2/mmu.c
+++ b/sys/src/9/teg2/mmu.c
@@ -375,7 +375,7 @@
l2 = &proc->mmul2;
for(page = *l2; page != nil; page = page->next){
if(clear)
- memset(UINT2PTR(page->va), 0, BY2PG);
+ memset((void*)page->va, 0, BY2PG);
l1[page->daddr] = Fault;
allcache->wbse(l1, sizeof *l1);
l2 = &page->next;
@@ -527,7 +527,7 @@
else{
pg = up->mmul2cache;
up->mmul2cache = pg->next;
- memset(UINT2PTR(pg->va), 0, BY2PG);
+ memset((void*)pg->va, 0, BY2PG);
}
pg->daddr = x;
pg->next = up->mmul2;
@@ -549,7 +549,7 @@
m->mmul1hi = x;
}
}
- pte = UINT2PTR(KADDR(PPN(*l1)));
+ pte = KADDR(PPN(*l1));
if (Debug) {
iprint("pte %#p index %ld was %#ux\n", pte, L2X(va), *(pte+L2X(va)));
if (*(pte+L2X(va)))
@@ -602,7 +602,7 @@
* Uncache a Section, must already be
* valid in the MMU.
*/
- va = PTR2UINT(v);
+ va = (uintptr)v;
assert(!(va & (1*MiB-1)) && size == 1*MiB);
x = L1X(va);
@@ -687,7 +687,7 @@
* will fail.
*/
if(pa+size < 4*MiB)
- return UINT2PTR(kseg0|pa);
+ return (void*)(kseg0|pa);
osize = size;
o = pa & (BY2PG-1);
@@ -701,7 +701,7 @@
panic("vmap(%#p, %ld) called from %#p: mmukmap fails %#p",
pa+o, osize, getcallerpc(&pa), pae);
- return UINT2PTR(va+o);
+ return (void*)(va+o);
}
/* from 386 */
--- a/sys/src/9/teg2/syscall.c
+++ b/sys/src/9/teg2/syscall.c
@@ -47,7 +47,7 @@
nf = up->ureg;
/* sanity clause */
- if(!okaddr(PTR2UINT(nf), sizeof(NFrame), 0)){
+ if(!okaddr((uintptr)nf, sizeof(NFrame), 0)){
qunlock(&up->debug);
pprint("bad ureg in noted %#p\n", nf);
pexit("Suicide", 0);
@@ -83,8 +83,8 @@
nf->arg1 = nf->msg;
nf->arg0 = &nf->ureg;
nf->ip = 0;
- cur->sp = PTR2UINT(nf);
- cur->r0 = PTR2UINT(nf->arg0);
+ cur->sp = (uintptr)nf;
+ cur->r0 = (uintptr)nf->arg0;
break;
default:
up->lastnote.flag = NDebug;
@@ -146,7 +146,7 @@
qunlock(&up->debug);
pexit(n->msg, n->flag != NDebug);
}
- if(!okaddr(PTR2UINT(up->notify), 1, 0)){
+ if(!okaddr((uintptr)up->notify, 1, 0)){
qunlock(&up->debug);
pprint("suicide: notify function address %#p\n", up->notify);
pexit("Suicide", 0);
@@ -159,7 +159,7 @@
pexit("Suicide", 0);
}
- nf = UINT2PTR(sp);
+ nf = (void*)sp;
memmove(&nf->ureg, ureg, sizeof(Ureg));
nf->old = up->ureg;
up->ureg = nf;
@@ -169,8 +169,8 @@
nf->ip = 0;
ureg->sp = sp;
- ureg->pc = PTR2UINT(up->notify);
- ureg->r0 = PTR2UINT(nf->arg0);
+ ureg->pc = (uintptr)up->notify;
+ ureg->r0 = (uintptr)nf->arg0;
up->notified = 1;
up->nnote--;
--- a/sys/src/9/teg2/trap.c
+++ b/sys/src/9/teg2/trap.c
@@ -937,7 +937,7 @@
memset(&ureg, 0, sizeof ureg);
ureg.pc = getcallerpc(&fn);
- ureg.sp = PTR2UINT(&fn);
+ ureg.sp = (uintptr)&fn;
fn(&ureg);
}