remove the assumption that sizeof(void*)==type big enough to address physical memory==ulong; more preparation for 64-bit fs kernels. Reference: /n/atom/patch/applied2013/fstypesync Date: Sun Aug 25 23:57:44 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/fs/pc/trap.c Sun Aug 25 23:55:36 2013 +++ /sys/src/fs/pc/trap.c Sun Aug 25 23:55:36 2013 @@ -366,9 +366,9 @@ dumpregs(Ureg *ur) { dumpregs2(ur); - print(" ur %lux\n", (ulong)ur); + print(" ur %#p\n", ur); dumpregs2(&lasttrap); - print(" lastur %lux\n", (ulong)lastur); + print(" lastur %#p\n", lastur); } void --- /sys/src/fs/pc/mmu.c Sun Aug 25 23:55:37 2013 +++ /sys/src/fs/pc/mmu.c Sun Aug 25 23:55:38 2013 @@ -214,7 +214,7 @@ ulong* mmuwalk(ulong* pdb, ulong va, int level, int create) { - ulong pa, *table; + uintmem pa, *table; /* * Walk the page-table pointed to by pdb and return a pointer @@ -241,7 +241,7 @@ case 2: if(*table & PTESIZE) - panic("mmuwalk2: va 0x%ux entry 0x%ux\n", va, *table); + panic("mmuwalk2: va %#p entry %#p\n", va, *table); if(!(*table & PTEVALID)){ pa = PADDR(ialloc(BY2PG, BY2PG)); *table = pa|PTEWRITE|PTEVALID; --- /sys/src/fs/pc/mem.h Sun Aug 25 23:55:39 2013 +++ /sys/src/fs/pc/mem.h Sun Aug 25 23:55:39 2013 @@ -24,7 +24,7 @@ #define KZERO 0x30000000 /* base of kernel address space */ #define KTZERO 0x30100000 /* first address in kernel text */ -#define KADDR(a) ((void*)((ulong)(a)+KZERO)) +#define KADDR(a) ((void*)((uintptr)(a)+KZERO)) #define MACHSIZE 4096 @@ -83,6 +83,6 @@ #define PTEUSER (1<<2) #define PTESIZE (1<<7) -#define MACHADDR ((ulong)&mach0) /* hack number 1 */ +#define MACHADDR ((uintptr)&mach0) /* hack number 1 */ #define IFLAG 0x200 /* psw: interrupt enable, to be accurate */ --- /sys/src/fs/pc/malloc.c Sun Aug 25 23:55:40 2013 +++ /sys/src/fs/pc/malloc.c Sun Aug 25 23:55:41 2013 @@ -2,8 +2,8 @@ #include "mem.h" #include "io.h" -ulong niob; -ulong nhiob; +uint niob; +uint nhiob; Hiob *hiob; void @@ -92,7 +92,7 @@ nhiob = niob / HWIDTH; while(!prime(nhiob)) nhiob++; - print(" %ld buffers; %ld hashes\n", niob, nhiob); + print(" %d buffers; %d hashes\n", niob, nhiob); hiob = ialloc(nhiob * sizeof(Hiob), 0); hp = hiob; for(i=0; iargs, uintmem); + + if(sizeof(uintmem) <= 4 /* || (pa & ~(uintmem)0xffffffff) == 0 */){ + if(f->flags & FmtSharp) + return fmtprint(f, "%#.8ux", (u32int)pa); + return fmtprint(f, "%ud", (u32int)pa); + } + + if(f->flags & FmtSharp) + return fmtprint(f, "%#.16llux", (u64int)pa); + return fmtprint(f, "%llud", (u64int)pa); +} + void formatinit(void) { @@ -785,6 +803,7 @@ fmtinstall('E', Efmt); /* print ether addresses */ fmtinstall('I', Ifmt); /* print ip addresses */ fmtinstall(L'φ', φfmt); /* print ip flags */ + fmtinstall(L'P', Pfmt); /* print uintmem */ } void @@ -1070,7 +1089,7 @@ int i, c; long s; - if(q == 0) + if(q == nil) panic("recv null q"); for(;;) { ilock(q); --- /sys/src/fs/port/portfns.h Sun Aug 25 23:55:50 2013 +++ /sys/src/fs/port/portfns.h Sun Aug 25 23:55:51 2013 @@ -3,6 +3,7 @@ void arpstart(void); void apcinit(void); void arginit(void); +void _assert(char*); void atexit(void (*)(void*), void*); char* authaname(Auth*); void authinit(void); @@ -38,7 +39,7 @@ void cmd_writeconf(int, char*[]); int checkname(char*); int checktag(Iobuf*, int, Off); -void clock(Timet, ulong); +void clock(Timet, uintptr); void clockinit(void); void clockreload(Timet); void devcopyproc(void); @@ -152,7 +153,7 @@ void mballocpool(int, int, int, int, void (*)(Msgbuf*)); void mbinit(void); void mbfree(Msgbuf*); -ulong meminit(void); +uintmem meminit(void); Iobuf* movebuf(Iobuf*); void mcatinit(Device*); int mcatread(Device*, Off, void*); --- /sys/src/fs/port/con.c Sun Aug 25 23:55:52 2013 +++ /sys/src/fs/port/con.c Sun Aug 25 23:55:53 2013 @@ -750,7 +750,7 @@ strcat(conline, argv[i]); } cmd_exec(conline); - t2 = MACHP(0)->ticks; + t2 = Ticks; print("time = %ld ms\n", TK2MS(t2-t1)); } @@ -766,7 +766,7 @@ void cmd_files(int, char *[]) { - long i, n; + int i, n; Chan *cp; for(cp = chans; cp; cp = cp->next) @@ -779,7 +779,7 @@ n++; files[i].cp->nfile++; } - print("%ld out of %ld files used\n", n, conf.nfile); + print("%d out of %d files used\n", n, conf.nfile); unlock(&flock); n = 0; @@ -792,7 +792,7 @@ n += cp->nfile; } } - print("%ld out of %ld files used\n", n, conf.nfile); + print("%d out of %d files used\n", n, conf.nfile); } static void --- /sys/src/fs/port/uidgid.c Sun Aug 25 23:55:54 2013 +++ /sys/src/fs/port/uidgid.c Sun Aug 25 23:55:55 2013 @@ -86,7 +86,7 @@ uid[u].ngrp = 0; u++; if(u >= conf.nuid) { - print("conf.nuid too small (%ld)\n", conf.nuid); + print("conf.nuid too small (%d)\n", conf.nuid); break; } } @@ -227,7 +227,7 @@ while(uidtop(nuid) != 0) nuid++; if(cons.nuid >= conf.nuid) { - print("conf.nuid too small (%ld)\n", conf.nuid); + print("conf.nuid too small (%d)\n", conf.nuid); return; } @@ -271,7 +271,7 @@ if(u2->uid == ui->uid) return; if(cons.ngid+ui->ngrp+1 >= conf.gidspace) { - print("conf.gidspace too small (%ld)\n", conf.gidspace); + print("conf.gidspace too small (%d)\n", conf.gidspace); return; } for(i = 0; i < ui->ngrp; i++) { --- /sys/src/fs/port/portdat.h Sun Aug 25 23:55:57 2013 +++ /sys/src/fs/port/portdat.h Sun Aug 25 23:55:58 2013 @@ -531,29 +531,29 @@ struct Conf { - ulong nmach; /* processors */ - ulong nproc; /* processes */ - uintptr mem; /* total physical bytes of memory */ - uintptr sparemem; /* memory left for check/dump and chans */ - ulong nuid; /* distinct uids */ - ulong nserve; /* server processes */ - ulong nrahead; /* read ahead processes */ - ulong nfile; /* number of fid -- system wide */ - ulong nwpath; /* number of active paths, derived from nfile */ - ulong gidspace; /* space for gid names -- derived from nuid */ - ulong nlgmsg; /* number of large message buffers */ - ulong nsmmsg; /* number of small message buffers */ + uint nmach; /* processors */ + uint nproc; /* processes */ + uintmem mem; /* total physical bytes of memory */ + uintmem sparemem; /* memory left for check/dump and chans */ + uint nuid; /* distinct uids */ + uint nserve; /* server processes */ + uint nrahead; /* read ahead processes */ + uint nfile; /* number of fid -- system wide */ + uint nwpath; /* number of active paths, derived from nfile */ + uint gidspace; /* space for gid names -- derived from nuid */ + uint nlgmsg; /* number of large message buffers */ + uint nsmmsg; /* number of small message buffers */ Off recovcw; /* recover addresses */ Off recovro; Off firstsb; Off recovsb; - ulong nauth; /* number of Auth structs */ + uint nauth; /* number of Auth structs */ uchar nodump; /* no periodic dumps */ uchar ripoff; uchar dumpreread; /* read and compare in dump copy */ uchar idedma; /* flag: use DMA on IDE disks? */ uchar fastworm; /* flag: don't cache cw reads in c device */ - ulong uartonly; /* botch? work around soekris with no vga. */ + uint uartonly; /* botch? work around soekris with no vga. */ }; /* @@ -576,7 +576,7 @@ short flags; Chan* chan; Msgbuf* next; - ulong param; + uint param; int category; uchar* data; /* rp or wp: current processing point */ uchar* xdata; /* base of allocation */ @@ -996,5 +996,5 @@ #pragma varargck type "φ" uint extern Rendez dawnrend; -extern ulong nhiob; +extern uint nhiob; extern Hiob *hiob; --- /sys/src/fs/port/proc.c Sun Aug 25 23:55:59 2013 +++ /sys/src/fs/port/proc.c Sun Aug 25 23:55:59 2013 @@ -62,13 +62,15 @@ /* HACK */ if(argc == 1) - for(i=0; iidle); + for(i=0; iidle); + prflush(); + } p = procalloc.arena; for(i=0; itext; - if(!text) + if(text == nil) continue; for(j=1; jsched); - if(u) { - m->proc = 0; + if(u != nil) { + m->proc = nil; p = u; - u = 0; + u = nil; if(p->state == Running) ready(p); - p->mach = 0; + p->mach = nil; } sched(); } @@ -109,11 +111,11 @@ { User *p; - if(u) { + if(u != nil) { splhi(); if(setlabel(&u->sched)) { /* woke up */ - if(u->mach) - panic("mach non zero"); + if(u->mach != nil) + panic("mach non nil"); u->state = Running; u->mach = m; m->proc = u; @@ -160,18 +162,18 @@ User *p; for (;;) { - while(runq.head == 0) /* if nobody to run, */ + while(runq.head == nil) /* if nobody to run, */ idle(); /* idle with intrs enabled */ splhi(); lock(&runq); p = runq.head; - if (p != nil && !p->mach) + if (p != nil && p->mach == nil) break; unlock(&runq); spllo(); } - if(p->rnext == 0) - runq.tail = 0; + if(p->rnext == nil) + runq.tail = nil; runq.head = p->rnext; if(p->state != Ready) print("runproc %d %s\n", p->pid, statename[p->state]); @@ -290,7 +292,7 @@ lock(&talarm); /* take out of list if checkalarm didn't */ if (u == nil) - panic("tsleep: nil u"); + panic("cpu%d: tsleep: nil u from %#p", m->machno, getcallerpc(&r)); if(u->trend) { l = &talarm.list; for(f = *l; f; f = f->tlink) {