Browse Source

Get the harvey build started (+ getcallerpc changes) (#731)

* Update .gitignore

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>

* Fixing up build files

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>

* Remove argument from getcallerpc since __builtin_return_address doesn't need one

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>

* Remove proc-SMP.c - wasn't used

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>

* Get libdraw and libmemdraw building

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Graham MacDonald 6 years ago
parent
commit
0a378b24be
85 changed files with 228 additions and 2208 deletions
  1. 1 10
      build.json
  2. 6 8
      sys/man/2/getcallerpc
  3. 1 1
      sys/src/9/amd64/arch.c
  4. 1 1
      sys/src/9/amd64/map.c
  5. 1 1
      sys/src/9/amd64/trap.c
  6. 1 1
      sys/src/9/amd64/usbohci.c
  7. 1 1
      sys/src/9/port/allocb.c
  8. 7 7
      sys/src/9/port/chan.c
  9. 1 1
      sys/src/9/port/devcons.c
  10. 1 1
      sys/src/9/port/devpipe.c
  11. 1 1
      sys/src/9/port/edf.c
  12. 0 1873
      sys/src/9/port/proc-SMP.c
  13. 1 1
      sys/src/9/port/proc.c
  14. 4 4
      sys/src/9/port/qio.c
  15. 16 16
      sys/src/9/port/qlock.c
  16. 10 10
      sys/src/9/port/taslock.c
  17. 10 10
      sys/src/9/port/tcklock.c
  18. 3 3
      sys/src/9/w/pxeload/load.c
  19. 4 4
      sys/src/cmd/abaco/util.c
  20. 4 4
      sys/src/cmd/acme/util.c
  21. 4 4
      sys/src/cmd/auth/factotum/util.c
  22. 3 3
      sys/src/cmd/aux/apm.c
  23. 3 3
      sys/src/cmd/aux/flashfs/aux.c
  24. 1 1
      sys/src/cmd/cwfs/iobuf.c
  25. 5 5
      sys/src/cmd/fossil/cache.c
  26. 1 1
      sys/src/cmd/fossil/disk.c
  27. 4 4
      sys/src/cmd/fossil/source.c
  28. 1 1
      sys/src/cmd/ip/snoopy/dns.c
  29. 2 2
      sys/src/cmd/ndb/convM2DNS.c
  30. 6 6
      sys/src/cmd/ndb/dn.c
  31. 3 3
      sys/src/cmd/nntpfs.c
  32. 1 1
      sys/src/cmd/plumb/plumber.c
  33. 1 1
      sys/src/cmd/unix/drawterm/gui-x11/x11.c
  34. 3 3
      sys/src/cmd/unix/drawterm/kern/allocb.c
  35. 3 3
      sys/src/cmd/unix/drawterm/kern/chan.c
  36. 1 1
      sys/src/cmd/unix/drawterm/kern/devpipe.c
  37. 3 3
      sys/src/cmd/unix/drawterm/kern/qio.c
  38. 5 5
      sys/src/cmd/unix/drawterm/libauth/attr.c
  39. 1 1
      sys/src/cmd/unix/drawterm/libc/lock.c
  40. 1 1
      sys/src/cmd/unix/drawterm/libmemdraw/alloc.c
  41. 1 1
      sys/src/cmd/venti/srv/disksched.c
  42. 1 1
      sys/src/cmd/venti/srv/icache.c
  43. 8 8
      sys/src/cmd/venti/srv/utils.c
  44. 1 1
      sys/src/cmd/vnc/compat.c
  45. 4 4
      sys/src/lib9p/mem.c
  46. 2 2
      sys/src/libString/s_alloc.c
  47. 1 1
      sys/src/libString/s_copy.c
  48. 5 5
      sys/src/libauth/attr.c
  49. 1 1
      sys/src/libdraw/alloc.c
  50. 0 6
      sys/src/libdraw/arith.c
  51. 1 1
      sys/src/libdraw/creadimage.c
  52. 0 27
      sys/src/libdraw/font.c
  53. 1 1
      sys/src/libdraw/getsubfont.c
  54. 1 1
      sys/src/libmemdraw/alloc.c
  55. 0 45
      sys/src/libmemdraw/draw.c
  56. 6 18
      sys/src/libmemdraw/fillpoly.c
  57. 0 9
      sys/src/libmemdraw/line.c
  58. 1 1
      sys/src/libmp/port/betomp.c
  59. 1 1
      sys/src/libmp/port/mpaux.c
  60. 1 1
      sys/src/libmp/port/mptobe.c
  61. 2 2
      sys/src/libndb/csgetval.c
  62. 1 1
      sys/src/libndb/csipinfo.c
  63. 2 2
      sys/src/libndb/dnsquery.c
  64. 3 3
      sys/src/libndb/ndbaux.c
  65. 2 2
      sys/src/libndb/ndbcache.c
  66. 1 1
      sys/src/libndb/ndbconcatenate.c
  67. 1 1
      sys/src/libndb/ndbdiscard.c
  68. 2 2
      sys/src/libndb/ndbgetipaddr.c
  69. 1 1
      sys/src/libndb/ndbgetval.c
  70. 6 6
      sys/src/libndb/ndbhash.c
  71. 4 4
      sys/src/libndb/ndbipinfo.c
  72. 2 2
      sys/src/libndb/ndbparse.c
  73. 4 4
      sys/src/libndb/ndbsubstitute.c
  74. 4 4
      sys/src/liboventi/plan9-io.c
  75. 2 2
      sys/src/liboventi/plan9-thread.c
  76. 1 1
      sys/src/liboventi/rpc.c
  77. 1 1
      sys/src/liboventi/server.c
  78. 1 1
      sys/src/liboventi/strdup.c
  79. 2 2
      sys/src/libsec/port/x509.c
  80. 1 1
      sys/src/libthread/lib.c
  81. 8 8
      sys/src/libventi/cache.c
  82. 5 5
      sys/src/libventi/file.c
  83. 3 3
      sys/src/libventi/mem.c
  84. 4 4
      sys/src/libventi/packet.c
  85. 3 0
      util/.gitignore

+ 1 - 10
build.json

@@ -1,11 +1,5 @@
 {
-	"k8cpu": {
-		"Projects": ["/sys/src/9/k10/k8cpu.json"]
-	},
-	"regress": {
-		"Projects": ["/sys/src/regress/regress.json"]
-	},
-	"kregress": {
+	"all": {
 		"Projects": [
 			"/sys/src/klibs.json",
 			"/sys/src/libs.json",
@@ -16,8 +10,5 @@
 			"/sys/src/regress/fs",
 			"/sys/src/9/$ARCH"
 		]
-	},
-	"kernels": {
-		"Projects": ["/sys/src/9/k10/k8cpu.json"]
 	}
 }

+ 6 - 8
sys/man/2/getcallerpc

@@ -7,27 +7,25 @@ getcallerpc \- fetch return PC of current function
 .br
 .B #include <libc.h>
 .PP
-.B uintptr getcallerpc(void *firstarg)
+.B uintptr getcallerpc(void)
 .SH DESCRIPTION
 .I Getcallerpc
 is a portable way to discover the PC to which the current function will return.
-.I Firstarg
-should be a pointer to the first argument to the function in question.
 .SH EXAMPLE
 .IP
 .EX
 void
-printpc(int arg)
+printpc(void)
 {
-	print("Called from %p\en", getcallerpc(&arg));
+	print("Called from %p\en", getcallerpc());
 }
 
 void
 main(int argc, char *argv[])
 {
-	printpc(0);
-	printpc(0);
-	printpc(0);
+	printpc();
+	printpc();
+	printpc();
 }
 .EE
 .SH SOURCE

+ 1 - 1
sys/src/9/amd64/arch.c

@@ -50,7 +50,7 @@ decref(Ref *r)
 	x = --r->ref;
 	unlock(&r->l);
 	if(x < 0)
-		panic("decref pc=%#p", getcallerpc(&r));
+		panic("decref pc=%#p", getcallerpc());
 
 	return x;
 }

+ 1 - 1
sys/src/9/amd64/map.c

@@ -46,7 +46,7 @@ PADDR(void* va)
 	if(pa > KSEG2)
 		return pa-KSEG2;
 
-	panic("PADDR: va %#p pa #%p @ %#p\n", va, _PADDR(va), getcallerpc(&va));
+	panic("PADDR: va %#p pa #%p @ %#p\n", va, _PADDR(va), getcallerpc());
 	return 0;
 }
 

+ 1 - 1
sys/src/9/amd64/trap.c

@@ -629,7 +629,7 @@ void
 callwithureg(void (*fn)(Ureg*))
 {
 	Ureg ureg;
-	ureg.ip = getcallerpc(&fn);
+	ureg.ip = getcallerpc();
 	ureg.sp = PTR2UINT(&fn);
 	fn(&ureg);
 }

+ 1 - 1
sys/src/9/amd64/usbohci.c

@@ -457,7 +457,7 @@ static void
 edlinked(Ed *ed, Ed *next)
 {
 	if(ed == nil)
-		print("edlinked: nil ed: pc %#p\n", getcallerpc(&ed));
+		print("edlinked: nil ed: pc %#p\n", getcallerpc());
 	ed->nexted = ptr2pa(next);
 	ed->next = next;
 }

+ 1 - 1
sys/src/9/port/allocb.c

@@ -67,7 +67,7 @@ allocb(int size)
 	 * Can still error out of here, though.
 	 */
 	if(up == nil)
-		panic("allocb without up: %#p\n", getcallerpc(&size));
+		panic("allocb without up: %#p\n", getcallerpc());
 	if((b = _allocb(size)) == nil){
 		mallocsummary();
 		panic("allocb: no memory for %d bytes\n", size);

+ 7 - 7
sys/src/9/port/chan.c

@@ -116,7 +116,7 @@ kstrdup(char **p, char *s)
 	/* if it's a user, we can wait for memory; if not, something's very wrong */
 	if(up){
 		t = smalloc(n);
-		setmalloctag(t, getcallerpc(&p));
+		setmalloctag(t, getcallerpc());
 	}else{
 		t = malloc(n);
 		if(t == nil)
@@ -192,7 +192,7 @@ newpath(char *s)
 	 * allowed, but other names with / in them draw warnings.
 	 */
 	if(strchr(s, '/') && strcmp(s, "#/") != 0 && strcmp(s, "/") != 0)
-		print("newpath: %s from %#p\n", s, getcallerpc(&s));
+		print("newpath: %s from %#p\n", s, getcallerpc());
 
 	p->mlen = 1;
 	p->malen = PATHMSLOP;
@@ -389,7 +389,7 @@ cclose(Chan *c)
 {
 	Proc *up = externup();
 	if(c->flag&CFREE)
-		panic("cclose %#p", getcallerpc(&c));
+		panic("cclose %#p", getcallerpc());
 
 	DBG("cclose %#p name=%s ref=%d\n", c, c->path->s, c->r.ref);
 	if(decref(&c->r))
@@ -422,7 +422,7 @@ void
 ccloseq(Chan *c)
 {
 	if(c->flag&CFREE)
-		panic("ccloseq %#p", getcallerpc(&c));
+		panic("ccloseq %#p", getcallerpc());
 
 	DBG("ccloseq %#p name=%s ref=%d\n", c, c->path->s, c->r.ref);
 
@@ -559,7 +559,7 @@ cmount(Chan **newp, Chan *old, int flag, char *spec)
 		error(Emount);
 
 	if(old->umh)
-		print("cmount: unexpected umh, caller %#p\n", getcallerpc(&newp));
+		print("cmount: unexpected umh, caller %#p\n", getcallerpc());
 
 	order = flag&MORDER;
 
@@ -1677,13 +1677,13 @@ validname0(char *aname, int slashok, int dup, uintptr_t pc)
 void
 validname(char *aname, int slashok)
 {
-	validname0(aname, slashok, 0, getcallerpc(&aname));
+	validname0(aname, slashok, 0, getcallerpc());
 }
 
 char*
 validnamedup(char *aname, int slashok)
 {
-	return validname0(aname, slashok, 1, getcallerpc(&aname));
+	return validname0(aname, slashok, 1, getcallerpc());
 }
 
 void

+ 1 - 1
sys/src/9/port/devcons.c

@@ -410,7 +410,7 @@ sysfatal(char *fmt, ...)
 void
 _assert(char *fmt)
 {
-	panic("assert failed at %#p: %s", getcallerpc(&fmt), fmt);
+	panic("assert failed at %#p: %s", getcallerpc(), fmt);
 }
 
 int

+ 1 - 1
sys/src/9/port/devpipe.c

@@ -323,7 +323,7 @@ pipewrite(Chan *c, void *va, int32_t n, int64_t mm)
 	Pipe *p;
 
 	if(0)if(!islo())
-		print("pipewrite hi %#p\n", getcallerpc(&c)); // devmnt?
+		print("pipewrite hi %#p\n", getcallerpc()); // devmnt?
 
 	if(waserror()) {
 		/* avoid notes when pipe is a mounted queue */

+ 1 - 1
sys/src/9/port/edf.c

@@ -99,7 +99,7 @@ edflock(Proc *p)
 		return nil;
 	ilock(&thelock);
 	if((e = p->edf) && (e->flags & Admitted)){
-		thelock._pc = getcallerpc(&p);
+		thelock._pc = getcallerpc();
 #ifdef EDFCYCLES
 		edfcycles -= lcycles();
 #endif

+ 0 - 1873
sys/src/9/port/proc-SMP.c

@@ -1,1873 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-#include	<u.h>
-#include	"../port/lib.h"
-#include	"mem.h"
-#include	"dat.h"
-#include	"fns.h"
-#include	"../port/error.h"
-
-#include	"../port/edf.h"
-#include	"errstr.h"
-#include	<trace.h>
-
-enum
-{
-	Scaling=2,
-
-	AMPmincores = 5,
-};
-
-Ref	noteidalloc;
-
-static Ref pidalloc;
-
-static Sched run;
-
-
-struct Procalloc procalloc;
-
-extern Proc* psalloc(void);
-extern void pshash(Proc*);
-extern void psrelease(Proc*);
-extern void psunhash(Proc*);
-
-static int reprioritize(Proc*);
-static void updatecpu(Proc*);
-
-static void rebalance(void);
-
-char *statename[] =
-{	/* BUG: generate automatically */
-	"Dead",
-	"Moribund",
-	"Ready",
-	"Scheding",
-	"Running",
-	"Queueing",
-	"QueueingR",
-	"QueueingW",
-	"Wakeme",
-	"Broken",
-	"Stopped",
-	"Rendez",
-	"Waitrelease",
-	"Exotic",
-	"Down",
-};
-
-Sched*
-procsched(Proc *p)
-{
-	return &run;
-}
-
-/*
- * bad planning, once more.
- */
-void
-procinit0(void)
-{
-	run.schedgain = 30;
-
-}
-
-/*
- * Always splhi()'ed.
- */
-void
-schedinit(void)		/* never returns */
-{
-	Edf *e;
-
-	m->inidle = 1;
-	m->proc = nil;
-	ainc(&run.nmach);
-
-	setlabel(&m->sched);
-	if(up) {
-		if((e = up->edf) && (e->flags & Admitted))
-			edfrecord(up);
-		m->qstart = 0;
-		m->qexpired = 0;
-		coherence();
-		m->proc = 0;
-		switch(up->state) {
-		case Running:
-			ready(up);
-			break;
-		case Moribund:
-			up->state = Dead;
-			stopac();
-			edfstop(up);
-			if (up->edf)
-				free(up->edf);
-			up->edf = nil;
-
-			/*
-			 * Holding locks from pexit:
-			 * 	procalloc
-			 *	pga
-			 */
-			mmurelease(up);
-			unlock(&pga);
-
-			psrelease(up);
-			unlock(&procalloc);
-			break;
-		}
-		up->mach = nil;
-		updatecpu(up);
-		up = nil;
-	}
-	sched();
-}
-
-/*
- * Check if the stack has more than 4*KiB free.
- * Do not call panic, the stack is gigantic.
- */
-static void
-stackok(void)
-{
-	char dummy;
-
-	if(&dummy < (char*)up->kstack + 4*KiB){
-		print("tc kernel stack overflow, cpu%d stopped\n", machp()->machno);
-		DONE();
-	}
-}
-
-/*
- *  If changing this routine, look also at sleep().  It
- *  contains a copy of the guts of sched().
- */
-void
-sched(void)
-{
-	Proc *p;
-
-	if(m->ilockdepth)
-		panic("cpu%d: ilockdepth %d, last lock %#p at %#p, sched called from %#p",
-			machp()->machno,
-			m->ilockdepth,
-			up? up->lastilock: nil,
-			(up && up->lastilock)? up->lastilock->_pc: 0,
-			getcallerpc(&p+2));
-
-	if(up){
-		/*
-		 * Delay the sched until the process gives up the locks
-		 * it is holding.  This avoids dumb lock loops.
-		 * Don't delay if the process is Moribund.
-		 * It called sched to die.
-		 * But do sched eventually.  This avoids a missing unlock
-		 * from hanging the entire kernel.
-		 * But don't reschedule procs holding palloc or procalloc.
-		 * Those are far too important to be holding while asleep.
-		 *
-		 * This test is not exact.  There can still be a few
-		 * instructions in the middle of taslock when a process
-		 * holds a lock but Lock.p has not yet been initialized.
-		 */
-		if(up->nlocks)
-		if(up->state != Moribund)
-		if(up->delaysched < 20
-		|| pga.Lock.p == up
-		|| procalloc.Lock.p == up){
-			up->delaysched++;
- 			run.delayedscheds++;
-			return;
-		}
-		up->delaysched = 0;
-
-		splhi();
-		/* statistics */
-		if(up->nqtrap == 0 && up->nqsyscall == 0)
-			up->nfullq++;
-		m->cs++;
-
-		stackok();
-
-		procsave(up);
-		mmuflushtlb(machp()->pml4->pa);
-		if(setlabel(&up->sched)){
-			procrestore(up);
-			spllo();
-			return;
-		}
-		gotolabel(&m->sched);
-	}
-
-	m->inidle = 1;
-	p = runproc();	/* core 0 never returns */
-	m->inidle = 0;
-
-	if(!p->edf){
-		updatecpu(p);
-		p->priority = reprioritize(p);
-	}
-	up = p;
-	m->qstart = machp()->ticks;
-	up->nqtrap = 0;
-	up->nqsyscall = 0;
-	up->state = Running;
-	up->mach = m;
-	m->proc = up;
-	mmuswitch(up);
-
-	assert(!up->wired || up->wired == m);
-	gotolabel(&up->sched);
-}
-
-int
-anyready(void)
-{
-	return run.runvec;
-}
-
-int
-anyhigher(void)
-{
-	return run.runvec & ~((1<<(up->priority+1))-1);
-}
-
-/*
- *  here once per clock tick to see if we should resched
- */
-
-void
-hzsched(void)
-{
-	/* once a second, rebalance will reprioritize ready procs */
-	if(machp()->machno == 0){
-		rebalance();
-		return;
-	}
-
-	/* with <= 4 cores, we use SMP and core 0 does not set qexpired for us */
-	if(sys->nmach <= AMPmincores)
-		if(machp()->ticks - m->qstart >= HZ/10)
-			m->qexpired = 1;
-
-	/* unless preempted, get to run */
-	if(m->qexpired && anyready())
-		up->delaysched++;
-}
-
-/*
- *  here at the end of non-clock interrupts to see if we should preempt the
- *  current process.  Returns 1 if preempted, 0 otherwise.
- */
-int
-preempted(void)
-{
-	if(up && up->state == Running)
-	if(up->preempted == 0)
-	if(anyhigher())
-	if(!active.exiting){
-		/*  Core 0 is dispatching all interrupts, so no core
-		 *  actually running a user process is ever going call preempted, unless
-		 *  we consider IPIs for preemption or we distribute interrupts.
-		 *  But we are going to use SMP for machines with few cores.
-		panic("preemted used");
-		 */
-
-		up->preempted = 1;
-		sched();
-		splhi();
-		up->preempted = 0;
-		return 1;
-	}
-	return 0;
-}
-
-/*
- * Update the cpu time average for this particular process,
- * which is about to change from up -> not up or vice versa.
- * p->lastupdate is the last time an updatecpu happened.
- *
- * The cpu time average is a decaying average that lasts
- * about D clock ticks.  D is chosen to be approximately
- * the cpu time of a cpu-intensive "quick job".  A job has to run
- * for approximately D clock ticks before we home in on its
- * actual cpu usage.  Thus if you manage to get in and get out
- * quickly, you won't be penalized during your burst.  Once you
- * start using your share of the cpu for more than about D
- * clock ticks though, your p->cpu hits 1000 (1.0) and you end up
- * below all the other quick jobs.  Interactive tasks, because
- * they basically always use less than their fair share of cpu,
- * will be rewarded.
- *
- * If the process has not been running, then we want to
- * apply the filter
- *
- *	cpu = cpu * (D-1)/D
- *
- * n times, yielding
- *
- *	cpu = cpu * ((D-1)/D)^n
- *
- * but D is big enough that this is approximately
- *
- * 	cpu = cpu * (D-n)/D
- *
- * so we use that instead.
- *
- * If the process has been running, we apply the filter to
- * 1 - cpu, yielding a similar equation.  Note that cpu is
- * stored in fixed point (* 1000).
- *
- * Updatecpu must be called before changing up, in order
- * to maintain accurate cpu usage statistics.  It can be called
- * at any time to bring the stats for a given proc up-to-date.
- */
-static void
-updatecpu(Proc *p)
-{
-	int D, n, t, ocpu;
-
-	if(p->edf)
-		return;
-
-	t = sys->ticks*Scaling + Scaling/2;
-	n = t - p->lastupdate;
-	p->lastupdate = t;
-
-	if(n == 0)
-		return;
-	D = run.schedgain*HZ*Scaling;
-	if(n > D)
-		n = D;
-
-	ocpu = p->cpu;
-	if(p != up)
-		p->cpu = (ocpu*(D-n))/D;
-	else{
-		t = 1000 - ocpu;
-		t = (t*(D-n))/D;
-		p->cpu = 1000 - t;
-	}
-
-//iprint("pid %d %s for %d cpu %d -> %d\n", p->pid,p==up?"active":"inactive",n, ocpu,p->cpu);
-}
-
-/*
- * On average, p has used p->cpu of a cpu recently.
- * Its fair share is nmach/m->load of a cpu.  If it has been getting
- * too much, penalize it.  If it has been getting not enough, reward it.
- * I don't think you can get much more than your fair share that
- * often, so most of the queues are for using less.  Having a priority
- * of 3 means you're just right.  Having a higher priority (up to p->basepri)
- * means you're not using as much as you could.
- */
-static int
-reprioritize(Proc *p)
-{
-	int fairshare, n, load, ratio;
-
-	load = sys->load;
-	if(load == 0)
-		return p->basepri;
-
-	/*
-	 *  fairshare = 1.000 * conf.nproc * 1.000/load,
-	 * except the decimal point is moved three places
-	 * on both load and fairshare.
-	 */
-	fairshare = (sys->nmach*1000*1000)/load;
-	n = p->cpu;
-	if(n == 0)
-		n = 1;
-	ratio = (fairshare+n/2) / n;
-	if(ratio > p->basepri)
-		ratio = p->basepri;
-	if(ratio < 0)
-		panic("reprioritize");
-//iprint("pid %d cpu %d load %d fair %d pri %d\n", p->pid, p->cpu, load, fairshare, ratio);
-	return ratio;
-}
-
-/*
- * add a process to a scheduling queue
- */
-static void
-queueproc(Sched *sch, Schedq *rq, Proc *p, int locked)
-{
-	int pri;
-
-	pri = rq - sch->runq;
-	if(!locked)
-		lock(sch);
-	else if(canlock(sch))
-		panic("queueproc: locked and can lock");
-	p->priority = pri;
-	p->rnext = 0;
-	if(rq->tail)
-		rq->tail->rnext = p;
-	else
-		rq->head = p;
-	rq->tail = p;
-	rq->n++;
-	sch->nrdy++;
-	sch->runvec |= 1<<pri;
-	if(!locked)
-		unlock(sch);
-}
-
-/*
- *  try to remove a process from a scheduling queue (called splhi)
- */
-Proc*
-dequeueproc(Sched *sch, Schedq *rq, Proc *tp)
-{
-	Proc *l, *p;
-
-	if(!canlock(sch))
-		return nil;
-
-	/*
-	 *  the queue may have changed before we locked runq,
-	 *  refind the target process.
-	 */
-	l = 0;
-	for(p = rq->head; p; p = p->rnext){
-		if(p == tp)
-			break;
-		l = p;
-	}
-
-	/*
-	 *  p->mach==0 only when process state is saved
-	 */
-
-	if(p == 0 || p->mach){
-		unlock(sch);
-		return nil;
-	}
-	if(p->rnext == 0)
-		rq->tail = l;
-	if(l)
-		l->rnext = p->rnext;
-	else
-		rq->head = p->rnext;
-	if(rq->head == nil)
-		sch->runvec &= ~(1<<(rq-sch->runq));
-	rq->n--;
-	sch->nrdy--;
-	if(p->state != Ready)
-		print("dequeueproc %s %d %s\n", p->text, p->pid, statename[p->state]);
-
-	unlock(sch);
-	return p;
-}
-
-static void
-schedready(Sched *sch, Proc *p, int locked)
-{
-	Mpl pl;
-	int pri;
-	Schedq *rq;
-
-	pl = splhi();
-	if(edfready(p)){
-		splx(pl);
-		return;
-	}
-
-	updatecpu(p);
-	pri = reprioritize(p);
-	p->priority = pri;
-	rq = &sch->runq[pri];
-	p->state = Ready;
-	queueproc(sch, rq, p, locked);
-	if(p->trace)
-		proctrace(p, SReady, 0);
-	splx(pl);
-}
-
-/*
- *  ready(p) picks a new priority for a process and sticks it in the
- *  runq for that priority.
- */
-void
-ready(Proc *p)
-{
-	schedready(procsched(p), p, 0);
-}
-
-/*
- *  yield the processor and drop our priority
- */
-void
-yield(void)
-{
-	if(anyready()){
-		/* pretend we just used 1/2 tick */
-		up->lastupdate -= Scaling/2;
-		sched();
-	}
-}
-
-/*
- *  recalculate priorities once a second.  We need to do this
- *  since priorities will otherwise only be recalculated when
- *  the running process blocks.
- */
-static void
-rebalance(void)
-{
-	Mpl pl;
-	int pri, npri, t;
-	Schedq *rq;
-	Proc *p;
-
-	t = machp()->ticks;
-	if(t - run.balancetime < HZ)
-		return;
-	run.balancetime = t;
-
-	for(pri=0, rq=run.runq; pri<Npriq; pri++, rq++){
-another:
-		p = rq->head;
-		if(p == nil)
-			continue;
-		if(p->mp != m)
-			continue;
-		if(pri == p->basepri)
-			continue;
-		updatecpu(p);
-		npri = reprioritize(p);
-		if(npri != pri){
-			pl = splhi();
-			p = dequeueproc(&run, rq, p);
-			if(p)
-				queueproc(&run, &run.runq[npri], p, 0);
-			splx(pl);
-			goto another;
-		}
-	}
-}
-
-/*
- * Process p is ready to run, but there's no available core.
- * Try to make a core available by
- * 1. preempting a process with lower priority, or
- * 2. preempting one with the same priority that had more than HZ/10, or
- * 3. rescheduling one that run more than HZ, in the hope he gets his priority lowered.
- */
-static void
-preemptfor(Proc *p)
-{
-	Proc *up = externup();
-	uint32_t delta;
-	uint i, j, rr;
-	Proc *mup;
-	Mach *mp;
-
-	assert(machp()->machno == 0);
-	/*
-	 * try to preempt a lower priority process first, default back to
-	 * round robin otherwise.
-	 */
-	for(rr = 0; rr < 2; rr++)
-		for(i = 0; i < MACHMAX; i++){
-			j = pickcore(p->color, i);
-			if((mp = sys->machptr[j]) != nil && mp->online && mp->nixtype == NIXTC){
-				if(mp == m)
-					continue;
-				/*
-				 * Caution here: mp->proc can change, even die.
-				 */
-				mup = mp->proc;
-				if(mup == nil)		/* one got idle */
-					return;
-				delta = mp->ticks - mp->qstart;
-				if(mup->priority < p->priority){
-					mp->qexpired = 1;
-					return;
-				}
-				if(rr && mup->priority == p->priority && delta > HZ/10){
-					mp->qexpired = 1;
-					return;
-				}
-				if(rr & delta > HZ){
-					mp->qexpired = 1;
-					return;
-				}
-			}
-	}
-}
-
-/*
- * Scheduling thread run as the main loop of cpu 0
- * Used in AMP sched.
- */
-static void
-mach0sched(void)
-{
-	Schedq *rq;
-	Proc *p;
-	Mach *mp;
-	uint32_t start, now;
-	int n, i, j;
-
-	assert(machp()->machno == 0);
-	acmodeset(NIXKC);		/* we don't time share any more */
-	n = 0;
-	start = perfticks();
-loop:
-
-	/*
-	 * find a ready process that we might run.
-	 */
-	spllo();
-	for(rq = &run.runq[Nrq-1]; rq >= run.runq; rq--)
-		for(p = rq->head; p; p = p->rnext){
-			/*
-			 * wired processes may only run when their core is available.
-			 */
-			if(p->wired != nil){
-				if(p->wired->proc == nil)
-					goto found;
-				continue;
-			}
-			/*
-			 * find a ready process that did run at an available core
-			 * or one that has not moved for some time.
-			 */
-			if(p->mp == nil || p->mp->proc == nil || n>0)
-				goto found;
-		}
-	/* waste time or halt the CPU */
-	idlehands();
-	/* remember how much time we're here */
-	now = perfticks();
-	m->perf.inidle += now-start;
-	start = now;
-	n++;
-	goto loop;
-
-found:
-	assert(machp()->machno == 0);
-	splhi();
-	/*
-	 * find a core for this process, but honor wiring.
-	 */
-	mp = p->wired;
-	if(mp != nil){
-		if(mp->proc != nil)
-			goto loop;
-	}else{
-		for(i = 0; i < MACHMAX; i++){
-			j = pickcore(p->color, i);
-			if((mp = sys->machptr[j]) != nil && mp->online && mp->nixtype == NIXTC)
-				if(mp != m && mp->proc == nil)
-					break;
-		}
-		if(i == MACHMAX){
-			preemptfor(p);
-			goto loop;
-		}
-	}
-
-	p = dequeueproc(&run, rq, p);
-	mp->proc = p;
-	if(p != nil){
-		p->state = Scheding;
-		p->mp = mp;
-	}
-
-	n = 0;
-	goto loop;
-}
-
-/*
- * SMP performs better than AMP with few cores.
- * So, leave this here by now. We should probably
- * write a unified version of runproc good enough for
- * both SMP and AMP.
- */
-static Proc*
-smprunproc(void)
-{
-	Schedq *rq;
-	Proc *p;
-	uint32_t start, now;
-	int i;
-
-	start = perfticks();
-	run.preempts++;
-
-loop:
-	/*
-	 *  find a process that last ran on this processor (affinity),
-	 *  or one that hasn't moved in a while (load balancing).  Every
-	 *  time around the loop affinity goes down.
-	 */
-	spllo();
-	for(i = 0;; i++){
-		/*
-		 *  find the highest priority target process that this
-		 *  processor can run given affinity constraints.
-		 *
-		 */
-		for(rq = &run.runq[Nrq-1]; rq >= run.runq; rq--){
-			for(p = rq->head; p; p = p->rnext){
-				if(p->mp == nil || p->mp == sys->machptr[machp()->machno]
-				|| (!p->wired && i > 0))
-					goto found;
-			}
-		}
-
-		/* waste time or halt the CPU */
-		idlehands();
-		/* remember how much time we're here */
-		now = perfticks();
-		m->perf.inidle += now-start;
-		start = now;
-	}
-
-found:
-	splhi();
-	p = dequeueproc(&run, rq, p);
-	if(p == nil)
-		goto loop;
-
-	p->state = Scheding;
-	p->mp = sys->machptr[machp()->machno];
-
-	if(edflock(p)){
-		edfrun(p, rq == &run.runq[PriEdf]);	/* start deadline timer and do admin */
-		edfunlock();
-	}
-	if(p->trace)
-		proctrace(p, SRun, 0);
-	return p;
-}
-
-/*
- *  pick a process to run.
- *  most of this is used in AMP sched.
- *  (on a quad core or less, we use SMP).
- *  In the case of core 0 we always return nil, but
- *  schedule the picked process at any other available TC.
- *  In the case of other cores we wait until a process is given
- *  by core 0.
- */
-Proc*
-runproc(void)
-{
-	Schedq *rq;
-	Proc *p;
-	uint32_t start, now;
-
-	if(sys->nmach <= AMPmincores)
-		return smprunproc();
-
-	start = perfticks();
-	run.preempts++;
-	rq = nil;
-	if(machp()->machno != 0){
-		do{
-			spllo();
-			while(m->proc == nil)
-				idlehands();
-			now = perfticks();
-			m->perf.inidle += now-start;
-			start = now;
-			splhi();
-			p = m->proc;
-		}while(p == nil);
-		p->state = Scheding;
-		p->mp = sys->machptr[machp()->machno];
-
-		if(edflock(p)){
-			edfrun(p, rq == &run.runq[PriEdf]);	/* start deadline timer and do admin */
-			edfunlock();
-		}
-		if(p->trace)
-			proctrace(p, SRun, 0);
-		return p;
-	}
-
-	mach0sched();
-	return nil;	/* not reached */
-}
-
-int
-canpage(Proc *p)
-{
-	int ok;
-	Sched *sch;
-
-	splhi();
-	sch = procsched(p);
-	lock(sch);
-	/* Only reliable way to see if we are Running */
-	if(p->mach == 0) {
-		p->newtlb = 1;
-		ok = 1;
-	}
-	else
-		ok = 0;
-	unlock(sch);
-	spllo();
-
-	return ok;
-}
-
-Proc*
-newproc(void)
-{
-	Proc *p;
-
-	p = psalloc();
-
-	p->state = Scheding;
-	p->psstate = "New";
-	p->mach = 0;
-	p->qnext = 0;
-	p->nchild = 0;
-	p->nwait = 0;
-	p->waitq = 0;
-	p->parent = 0;
-	p->pgrp = 0;
-	p->egrp = 0;
-	p->fgrp = 0;
-	p->rgrp = 0;
-	p->pdbg = 0;
-	p->kp = 0;
-	if(up != nil && up->procctl == Proc_tracesyscall)
-		p->procctl = Proc_tracesyscall;
-	else
-		p->procctl = 0;
-	p->syscalltrace = nil;
-	p->notepending = 0;
-	p->ureg = 0;
-	p->privatemem = 0;
-	p->noswap = 0;
-	p->errstr = p->errbuf0;
-	p->syserrstr = p->errbuf1;
-	p->errbuf0[0] = '\0';
-	p->errbuf1[0] = '\0';
-	p->nlocks = 0;
-	p->delaysched = 0;
-	p->trace = 0;
-	kstrdup(&p->user, "*nouser");
-	kstrdup(&p->text, "*notext");
-	kstrdup(&p->args, "");
-	p->nargs = 0;
-	p->setargs = 0;
-	memset(p->seg, 0, sizeof p->seg);
-	p->pid = incref(&pidalloc);
-	pshash(p);
-	p->noteid = incref(&noteidalloc);
-	if(p->pid <= 0 || p->noteid <= 0)
-		panic("pidalloc");
-	if(p->kstack == 0)
-		p->kstack = smalloc(KSTACK);
-
-	/* sched params */
-	p->mp = 0;
-	p->wired = 0;
-	procpriority(p, PriNormal, 0);
-	p->cpu = 0;
-	p->lastupdate = sys->ticks*Scaling;
-	p->edf = nil;
-
-	p->ntrap = 0;
-	p->nintr = 0;
-	p->nsyscall = 0;
-	p->nactrap = 0;
-	p->nacsyscall = 0;
-	p->nicc = 0;
-	p->actime = 0ULL;
-	p->tctime = 0ULL;
-	p->ac = nil;
-	p->nfullq = 0;
-	memset(&p->PMMU, 0, sizeof p->PMMU);
-	return p;
-}
-
-/*
- * wire this proc to a machine
- */
-void
-procwired(Proc *p, int bm)
-{
-	Proc *up = externup();
-	Proc *pp;
-	int i;
-	char nwired[MACHMAX];
-	Mach *wm;
-
-	if(bm < 0){
-		/* pick a machine to wire to */
-		memset(nwired, 0, sizeof(nwired));
-		p->wired = 0;
-		for(i=0; (pp = psincref(i)) != nil; i++){
-			wm = pp->wired;
-			if(wm && pp->pid)
-				nwired[wmachp()->machno]++;
-			psdecref(pp);
-		}
-		bm = 0;
-		for(i=0; i<sys->nmach; i++)
-			if(nwired[i] < nwired[bm])
-				bm = i;
-	} else {
-		/* use the virtual machine requested */
-		bm = bm % sys->nmach;
-	}
-
-	p->wired = sys->machptr[bm];
-	p->mp = p->wired;
-
-	/*
-	 * adjust our color to the new domain.
-	 */
-	if(up == nil || p != up)
-		return;
-	up->color = corecolor(up->mp->machno);
-	qlock(&up->seglock);
-	for(i = 0; i < NSEG; i++)
-		if(up->seg[i])
-			up->seg[i]->color = up->color;
-	qunlock(&up->seglock);
-}
-
-void
-procpriority(Proc *p, int pri, int fixed)
-{
-	if(pri >= Npriq)
-		pri = Npriq - 1;
-	else if(pri < 0)
-		pri = 0;
-	p->basepri = pri;
-	p->priority = pri;
-	if(fixed){
-		p->fixedpri = 1;
-	} else {
-		p->fixedpri = 0;
-	}
-}
-
-/*
- *  sleep if a condition is not true.  Another process will
- *  awaken us after it sets the condition.  When we awaken
- *  the condition may no longer be true.
- *
- *  we lock both the process and the rendezvous to keep r->p
- *  and p->r synchronized.
- */
-void
-sleep(Rendez *r, int (*f)(void*), void *arg)
-{
-	Mpl pl;
-
-	pl = splhi();
-
-	if(up->nlocks)
-		print("process %d sleeps with %d locks held, last lock %#p locked at pc %#p, sleep called from %#p\n",
-			up->pid, up->nlocks, up->lastlock, up->lastlock->_pc, getcallerpc(&r));
-	lock(r);
-	lock(&up->rlock);
-	if(r->p){
-		print("double sleep called from %#p, %d %d\n",
-			getcallerpc(&r), r->p->pid, up->pid);
-		dumpstack();
-	}
-
-	/*
-	 *  Wakeup only knows there may be something to do by testing
-	 *  r->p in order to get something to lock on.
-	 *  Flush that information out to memory in case the sleep is
-	 *  committed.
-	 */
-	r->p = up;
-
-	if((*f)(arg) || up->notepending){
-		/*
-		 *  if condition happened or a note is pending
-		 *  never mind
-		 */
-		r->p = nil;
-		unlock(&up->rlock);
-		unlock(r);
-	} else {
-		/*
-		 *  now we are committed to
-		 *  change state and call scheduler
-		 */
-		if(up->trace)
-			proctrace(up, SSleep, 0);
-		up->state = Wakeme;
-		up->r = r;
-
-		/* statistics */
-		m->cs++;
-
-		procsave(up);
-		mmuflushtlb(machp()->pml4->pa);
-		if(setlabel(&up->sched)) {
-			/*
-			 *  here when the process is awakened
-			 */
-			procrestore(up);
-			spllo();
-		} else {
-			/*
-			 *  here to go to sleep (i.e. stop Running)
-			 */
-			unlock(&up->rlock);
-			unlock(r);
-			gotolabel(&m->sched);
-		}
-	}
-
-	if(up->notepending) {
-		up->notepending = 0;
-		splx(pl);
-		if(up->procctl == Proc_exitme && up->closingfgrp)
-			forceclosefgrp();
-		error(Eintr);
-	}
-
-	splx(pl);
-}
-
-static int
-tfn(void *arg)
-{
-	return up->trend == nil || up->tfn(arg);
-}
-
-void
-twakeup(Ureg* ureg, Timer *t)
-{
-	Proc *p;
-	Rendez *trend;
-
-	p = t->ta;
-	trend = p->trend;
-	p->trend = 0;
-	if(trend)
-		wakeup(trend);
-}
-
-void
-tsleep(Rendez *r, int (*fn)(void*), void *arg, int32_t ms)
-{
-	if (up->tt){
-		print("tsleep: timer active: mode %d, tf %#p\n",
-			up->tmode, up->tf);
-		timerdel(up);
-	}
-	up->tns = MS2NS(ms);
-	up->tf = twakeup;
-	up->tmode = Trelative;
-	up->ta = up;
-	up->trend = r;
-	up->tfn = fn;
-	timeradd(up);
-
-	if(waserror()){
-		timerdel(up);
-		nexterror();
-	}
-	sleep(r, tfn, arg);
-	if (up->tt)
-		timerdel(up);
-	up->twhen = 0;
-	poperror();
-}
-
-/*
- *  Expects that only one process can call wakeup for any given Rendez.
- *  We hold both locks to ensure that r->p and p->r remain consistent.
- *  Richard Miller has a better solution that doesn't require both to
- *  be held simultaneously, but I'm a paranoid - presotto.
- */
-Proc*
-wakeup(Rendez *r)
-{
-	Mpl pl;
-	Proc *p;
-
-	pl = splhi();
-
-	lock(r);
-	p = r->p;
-
-	if(p != nil){
-		lock(&p->rlock);
-		if(p->state != Wakeme || p->r != r)
-			panic("wakeup: state");
-		r->p = nil;
-		p->r = nil;
-		ready(p);
-		unlock(&p->rlock);
-	}
-	unlock(r);
-
-	splx(pl);
-
-	return p;
-}
-
-/*
- *  if waking a sleeping process, this routine must hold both
- *  p->rlock and r->lock.  However, it can't know them in
- *  the same order as wakeup causing a possible lock ordering
- *  deadlock.  We break the deadlock by giving up the p->rlock
- *  lock if we can't get the r->lock and retrying.
- */
-int
-postnote(Proc *p, int dolock, char *n, int flag)
-{
-	Mpl pl;
-	int ret;
-	Rendez *r;
-	Proc *d, **l;
-
-	if(dolock)
-		qlock(&p->debug);
-
-	if(flag != NUser && (p->notify == 0 || p->notified))
-		p->nnote = 0;
-
-	ret = 0;
-	if(p->nnote < NNOTE) {
-		strcpy(p->note[p->nnote].msg, n);
-		p->note[p->nnote++].flag = flag;
-		ret = 1;
-	}
-	p->notepending = 1;
-
-	/* NIX  */
-	if(p->state == Exotic){
-		/* it could be that the process is not running
-		 * in the AC when we interrupt the AC, but then
-		 * we'd only get an extra interrupt in the AC, and
-		 * nothing should happen.
-		 */
-		intrac(p);
-	}
-
-	if(dolock)
-		qunlock(&p->debug);
-
-	/* this loop is to avoid lock ordering problems. */
-	for(;;){
-		pl = splhi();
-		lock(&p->rlock);
-		r = p->r;
-
-		/* waiting for a wakeup? */
-		if(r == nil)
-			break;	/* no */
-
-		/* try for the second lock */
-		if(canlock(r)){
-			if(p->state != Wakeme || r->p != p)
-				panic("postnote: state %d %d %d", r->p != p, p->r != r, p->state);
-			p->r = nil;
-			r->p = nil;
-			ready(p);
-			unlock(r);
-			break;
-		}
-
-		/* give other process time to get out of critical section and try again */
-		unlock(&p->rlock);
-		splx(pl);
-		sched();
-	}
-	unlock(&p->rlock);
-	splx(pl);
-
-	if(p->state != Rendezvous){
-		if(p->state == Semdown)
-			ready(p);
-		return ret;
-	}
-	/* Try and pull out of a rendezvous */
-	lock(p->rgrp);
-	if(p->state == Rendezvous) {
-		p->rendval = ~0;
-		l = &REND(p->rgrp, p->rendtag);
-		for(d = *l; d; d = d->rendhash) {
-			if(d == p) {
-				*l = p->rendhash;
-				break;
-			}
-			l = &d->rendhash;
-		}
-		ready(p);
-	}
-	unlock(p->rgrp);
-	return ret;
-}
-
-/*
- * weird thing: keep at most NBROKEN around
- */
-#define	NBROKEN 4
-struct
-{
-	QLock;
-	int	n;
-	Proc	*p[NBROKEN];
-}broken;
-
-void
-addbroken(Proc *p)
-{
-	qlock(&broken);
-	if(broken.n == NBROKEN) {
-		ready(broken.p[0]);
-		memmove(&broken.p[0], &broken.p[1], sizeof(Proc*)*(NBROKEN-1));
-		--broken.n;
-	}
-	broken.p[broken.n++] = p;
-	qunlock(&broken);
-
-	stopac();
-	edfstop(up);
-	p->state = Broken;
-	p->psstate = 0;
-	sched();
-}
-
-void
-unbreak(Proc *p)
-{
-	int b;
-
-	qlock(&broken);
-	for(b=0; b < broken.n; b++)
-		if(broken.p[b] == p) {
-			broken.n--;
-			memmove(&broken.p[b], &broken.p[b+1],
-					sizeof(Proc*)*(NBROKEN-(b+1)));
-			ready(p);
-			break;
-		}
-	qunlock(&broken);
-}
-
-int
-freebroken(void)
-{
-	int i, n;
-
-	qlock(&broken);
-	n = broken.n;
-	for(i=0; i<n; i++) {
-		ready(broken.p[i]);
-		broken.p[i] = 0;
-	}
-	broken.n = 0;
-	qunlock(&broken);
-	return n;
-}
-
-void
-pexit(char *exitstr, int freemem)
-{
-	Proc *p;
-	Segment **s, **es;
-	int32_t utime, stime;
-	Waitq *wq, *f, *next;
-	Fgrp *fgrp;
-	Egrp *egrp;
-	Rgrp *rgrp;
-	Pgrp *pgrp;
-	Chan *dot;
-
-	if(0 && up->nfullq > 0)
-		iprint(" %s=%d", up->text, up->nfullq);
-	if(0 && up->nicc > 0)
-		iprint(" [%s nicc %ud tctime %ulld actime %ulld]\n",
-			up->text, up->nicc, up->tctime, up->actime);
-	if(up->syscalltrace != nil)
-		free(up->syscalltrace);
-	up->syscalltrace = nil;
-	up->alarm = 0;
-
-	if (up->tt)
-		timerdel(up);
-	if(up->trace)
-		proctrace(up, SDead, 0);
-
-	/* nil out all the resources under lock (free later) */
-	qlock(&up->debug);
-	fgrp = up->fgrp;
-	up->fgrp = nil;
-	egrp = up->egrp;
-	up->egrp = nil;
-	rgrp = up->rgrp;
-	up->rgrp = nil;
-	pgrp = up->pgrp;
-	up->pgrp = nil;
-	dot = up->dot;
-	up->dot = nil;
-	qunlock(&up->debug);
-
-
-	if(fgrp)
-		closefgrp(fgrp);
-	if(egrp)
-		closeegrp(egrp);
-	if(rgrp)
-		closergrp(rgrp);
-	if(dot)
-		cclose(dot);
-	if(pgrp)
-		closepgrp(pgrp);
-
-	/*
-	 * if not a kernel process and have a parent,
-	 * do some housekeeping.
-	 */
-	if(up->kp == 0) {
-		p = up->parent;
-		if(p == 0) {
-			if(exitstr == 0)
-				exitstr = "unknown";
-			panic("boot process died: %s", exitstr);
-		}
-
-		while(waserror())
-			;
-
-		wq = smalloc(sizeof(Waitq));
-		poperror();
-
-		wq->w.pid = up->pid;
-		utime = up->time[TUser] + up->time[TCUser];
-		stime = up->time[TSys] + up->time[TCSys];
-		wq->w.time[TUser] = tk2ms(utime);
-		wq->w.time[TSys] = tk2ms(stime);
-		wq->w.time[TReal] = tk2ms(sys->ticks - up->time[TReal]);
-		if(exitstr && exitstr[0])
-			snprint(wq->w.msg, sizeof(wq->w.msg), "%s %d: %s",
-				up->text, up->pid, exitstr);
-		else
-			wq->w.msg[0] = '\0';
-
-		lock(&p->exl);
-		/*
-		 * Check that parent is still alive.
-		 */
-		if(p->pid == up->parentpid && p->state != Broken) {
-			p->nchild--;
-			p->time[TCUser] += utime;
-			p->time[TCSys] += stime;
-			/*
-			 * If there would be more than 128 wait records
-			 * processes for my parent, then don't leave a wait
-			 * record behind.  This helps prevent badly written
-			 * daemon processes from accumulating lots of wait
-			 * records.
-		 	 */
-			if(p->nwait < 128) {
-				wq->next = p->waitq;
-				p->waitq = wq;
-				p->nwait++;
-				wq = nil;
-				wakeup(&p->waitr);
-			}
-		}
-		unlock(&p->exl);
-		if(wq)
-			free(wq);
-	}
-
-	if(!freemem)
-		addbroken(up);
-
-	qlock(&up->seglock);
-	es = &up->seg[NSEG];
-	for(s = up->seg; s < es; s++) {
-		if(*s) {
-			putseg(*s);
-			*s = 0;
-		}
-	}
-	qunlock(&up->seglock);
-
-	lock(&up->exl);		/* Prevent my children from leaving waits */
-	psunhash(up);
-	up->pid = 0;
-	wakeup(&up->waitr);
-	unlock(&up->exl);
-
-	for(f = up->waitq; f; f = next) {
-		next = f->next;
-		free(f);
-	}
-
-	/* release debuggers */
-	qlock(&up->debug);
-	if(up->pdbg) {
-		wakeup(&up->pdbg->sleep);
-		up->pdbg = 0;
-	}
-	qunlock(&up->debug);
-
-	/* Sched must not loop for these locks */
-	lock(&procalloc);
-	lock(&pga);
-
-	stopac();
-	edfstop(up);
-	up->state = Moribund;
-	sched();
-	panic("pexit");
-}
-
-int
-haswaitq(void *x)
-{
-	Proc *p;
-
-	p = (Proc *)x;
-	return p->waitq != 0;
-}
-
-int
-pwait(Waitmsg *w)
-{
-	int cpid;
-	Waitq *wq;
-
-	if(!canqlock(&up->qwaitr))
-		error(Einuse);
-
-	if(waserror()) {
-		qunlock(&up->qwaitr);
-		nexterror();
-	}
-
-	lock(&up->exl);
-	if(up->nchild == 0 && up->waitq == 0) {
-		unlock(&up->exl);
-		error(Enochild);
-	}
-	unlock(&up->exl);
-
-	sleep(&up->waitr, haswaitq, up);
-
-	lock(&up->exl);
-	wq = up->waitq;
-	up->waitq = wq->next;
-	up->nwait--;
-	unlock(&up->exl);
-
-	qunlock(&up->qwaitr);
-	poperror();
-
-	if(w)
-		memmove(w, &wq->w, sizeof(Waitmsg));
-	cpid = wq->w.pid;
-	free(wq);
-
-	return cpid;
-}
-
-void
-dumpaproc(Proc *p)
-{
-	uintptr_t bss;
-	char *s;
-
-	if(p == 0)
-		return;
-
-	bss = 0;
-	if(p->seg[HSEG])
-		bss = p->seg[HSEG]->top;
-	else if(p->seg[BSEG])
-		bss = p->seg[BSEG]->top;
-
-	s = p->psstate;
-	if(s == 0)
-		s = statename[p->state];
-	print("%3d:%10s pc %#p dbgpc %#p  %8s (%s) ut %ld st %ld bss %#p qpc %#p nl %d nd %lud lpc %#p pri %lud\n",
-		p->pid, p->text, p->pc, dbgpc(p), s, statename[p->state],
-		p->time[0], p->time[1], bss, p->qpc, p->nlocks,
-		p->delaysched, p->lastlock ? p->lastlock->_pc : 0, p->priority);
-}
-
-void
-procdump(void)
-{
-	int i;
-	Proc *p;
-
-	if(up)
-		print("up %d\n", up->pid);
-	else
-		print("no current process\n");
-	for(i=0; (p = psincref(i)) != nil; i++) {
-		if(p->state != Dead)
-			dumpaproc(p);
-		psdecref(p);
-	}
-}
-
-/*
- *  wait till all processes have flushed their mmu
- *  state about segement s
- */
-void
-procflushseg(Segment *s)
-{
-	Proc *up = externup();
-	int i, ns, nm, nwait;
-	Proc *p;
-	Mach *mp;
-
-	/*
-	 *  tell all processes with this
-	 *  segment to flush their mmu's
-	 */
-	nwait = 0;
-	for(i=0; (p = psincref(i)) != nil; i++) {
-		if(p->state == Dead){
-			psdecref(p);
-			continue;
-		}
-		for(ns = 0; ns < NSEG; ns++){
-			if(p->seg[ns] == s){
-				p->newtlb = 1;
-				for(nm = 0; nm < MACHMAX; nm++)
-					if((mp = sys->machptr[nm]) != nil && mp->online)
-						if(mp->proc == p){
-							mp->mmuflush = 1;
-							nwait++;
-						}
-				break;
-			}
-		}
-		psdecref(p);
-	}
-
-	if(nwait == 0)
-		return;
-
-	/*
-	 *  wait for all processors to take a clock interrupt
-	 *  and flush their mmu's.
-	 *  NIX BUG: this won't work if another core is in AC mode.
-	 *  In that case we must IPI it, but only if that core is
-	 *  using this segment.
-	 */
-	for(i = 0; i < MACHMAX; i++)
-		if((mp = sys->machptr[i]) != nil && mp->online)
-			if(mp != m)
-				while(mp->mmuflush)
-					sched();
-}
-
-void
-scheddump(void)
-{
-	Proc *p;
-	Schedq *rq;
-
-	for(rq = &run.runq[Nrq-1]; rq >= run.runq; rq--){
-		if(rq->head == 0)
-			continue;
-		print("run[%ld]:", rq-run.runq);
-		for(p = rq->head; p; p = p->rnext)
-			print(" %d(%lud)", p->pid, machp()->ticks - p->readytime);
-		print("\n");
-		delay(150);
-	}
-	print("nrdy %d\n", run.nrdy);
-}
-
-void
-kproc(char *name, void (*func)(void *), void *arg)
-{
-	Proc *p;
-	static Pgrp *kpgrp;
-
-	p = newproc();
-	p->psstate = 0;
-	p->procmode = 0640;
-	p->kp = 1;
-	p->noswap = 1;
-
-	p->scallnr = up->scallnr;
-	memmove(p->arg, up->arg, sizeof(up->arg));
-	p->nerrlab = 0;
-	p->slash = up->slash;
-	p->dot = up->dot;
-	if(p->dot)
-		incref(p->dot);
-
-	memmove(p->note, up->note, sizeof(p->note));
-	p->nnote = up->nnote;
-	p->notified = 0;
-	p->lastnote = up->lastnote;
-	p->notify = up->notify;
-	p->ureg = 0;
-	p->dbgreg = 0;
-
-	procpriority(p, PriKproc, 0);
-
-	kprocchild(p, func, arg);
-
-	kstrdup(&p->user, eve);
-	kstrdup(&p->text, name);
-	if(kpgrp == 0)
-		kpgrp = newpgrp();
-	p->pgrp = kpgrp;
-	incref(kpgrp);
-
-	memset(p->time, 0, sizeof(p->time));
-	p->time[TReal] = sys->ticks;
-	ready(p);
-	/*
-	 *  since the bss/data segments are now shareable,
-	 *  any mmu info about this process is now stale
-	 *  and has to be discarded.
-	 */
-	p->newtlb = 1;
-	mmuflush();
-}
-
-/*
- *  called splhi() by notify().  See comment in notify for the
- *  reasoning.
- */
-void
-procctl(Proc *p)
-{
-	Mpl pl;
-	char *state;
-
-	switch(p->procctl) {
-	case Proc_exitbig:
-		spllo();
-		pexit("Killed: Insufficient physical memory", 1);
-
-	case Proc_exitme:
-		spllo();		/* pexit has locks in it */
-		pexit("Killed", 1);
-
-	case Proc_traceme:
-		if(p->nnote == 0)
-			return;
-		/* No break */
-
-	case Proc_stopme:
-		p->procctl = 0;
-		state = p->psstate;
-		p->psstate = "Stopped";
-		/* free a waiting debugger */
-		pl = spllo();
-		qlock(&p->debug);
-		if(p->pdbg) {
-			wakeup(&p->pdbg->sleep);
-			p->pdbg = 0;
-		}
-		qunlock(&p->debug);
-		splhi();
-		p->state = Stopped;
-		sched();
-		p->psstate = state;
-		splx(pl);
-		return;
-
-	case Proc_toac:
-		p->procctl = 0;
-		/*
-		 * This pretends to return from the system call,
-		 * by moving to a core, but never returns (unless
-		 * the process gets moved back to a TC.)
-		 */
-		spllo();
-		runacore();
-		return;
-
-	case Proc_totc:
-		p->procctl = 0;
-		if(p != up)
-			panic("procctl: stopac: p != up");
-		spllo();
-		stopac();
-		return;
-	}
-}
-
-void
-error(char *err)
-{
-	spllo();
-
-	assert(up->nerrlab < NERR);
-	kstrcpy(up->errstr, err, ERRMAX);
-	setlabel(&up->errlab[NERR-1]);
-	nexterror();
-}
-
-void
-nexterror(void)
-{
-	gotolabel(&up->errlab[--up->nerrlab]);
-}
-
-void
-exhausted(char *resource)
-{
-	char buf[ERRMAX];
-
-	sprint(buf, "no free %s", resource);
-	iprint("%s\n", buf);
-	error(buf);
-}
-
-void
-killbig(char *why)
-{
-	int i, x;
-	Segment *s;
-	uint32_t l, max;
-	Proc *p, *kp;
-
-	max = 0;
-	kp = nil;
-	for(x = 0; (p = psincref(x)) != nil; x++) {
-		if(p->state == Dead || p->kp){
-			psdecref(p);
-			continue;
-		}
-		l = 0;
-		for(i=1; i<NSEG; i++) {
-			s = p->seg[i];
-			if(s != 0)
-				l += s->top - s->base;
-		}
-		if(l > max && ((p->procmode&0222) || strcmp(eve, p->user)!=0)) {
-			if(kp != nil)
-				psdecref(kp);
-			kp = p;
-			max = l;
-		}
-		else
-			psdecref(p);
-	}
-	if(kp == nil)
-		return;
-
-	print("%d: %s killed: %s\n", kp->pid, kp->text, why);
-	for(x = 0; (p = psincref(x)) != nil; x++) {
-		if(p->state == Dead || p->kp){
-			psdecref(p);
-			continue;
-		}
-		if(p != kp && p->seg[BSEG] && p->seg[BSEG] == kp->seg[BSEG])
-			p->procctl = Proc_exitbig;
-		psdecref(p);
-	}
-
-	kp->procctl = Proc_exitbig;
-	for(i = 0; i < NSEG; i++) {
-		s = kp->seg[i];
-		if(s != 0 && canqlock(&s->lk)) {
-			mfreeseg(s, s->base, (s->top - s->base)/BIGPGSZ);
-			qunlock(&s->lk);
-		}
-	}
-	psdecref(kp);
-}
-
-/*
- *  change ownership to 'new' of all processes owned by 'old'.  Used when
- *  eve changes.
- */
-void
-renameuser(char *old, char *new)
-{
-	int i;
-	Proc *p;
-
-	for(i = 0; (p = psincref(i)) != nil; i++){
-		if(p->user!=nil && strcmp(old, p->user)==0)
-			kstrdup(&p->user, new);
-		psdecref(p);
-	}
-}
-
-/*
- *  time accounting called by clock() splhi'd
- *  only cpu1 computes system load average
- *  but the system load average is accounted for cpu0.
- */
-void
-accounttime(void)
-{
-	Proc *p;
-	uint32_t n, per;
-
-	p = m->proc;
-	if(p) {
-		if(machp()->machno == 1)
-			run.nrun++;
-		p->time[p->insyscall]++;
-	}
-
-	/* calculate decaying duty cycles */
-	n = perfticks();
-	per = n - m->perf.last;
-	m->perf.last = n;
-	per = (m->perf.period*(HZ-1) + per)/HZ;
-	if(per != 0)
-		m->perf.period = per;
-
-	m->perf.avg_inidle = (m->perf.avg_inidle*(HZ-1)+m->perf.inidle)/HZ;
-	m->perf.inidle = 0;
-
-	m->perf.avg_inintr = (m->perf.avg_inintr*(HZ-1)+m->perf.inintr)/HZ;
-	m->perf.inintr = 0;
-
-	/* only one processor gets to compute system load averages.
-	 * it has to be mach 1 when we use AMP.
-	 */
-	if(sys->nmach > 1 && machp()->machno != 1)
-		return;
-
-	/*
-	 * calculate decaying load average.
-	 * if we decay by (n-1)/n then it takes
-	 * n clock ticks to go from load L to .36 L once
-	 * things quiet down.  it takes about 5 n clock
-	 * ticks to go to zero.  so using HZ means this is
-	 * approximately the load over the last second,
-	 * with a tail lasting about 5 seconds.
-	 */
-	n = run.nrun;
-	run.nrun = 0;
-	n = (run.nrdy+n)*1000;
-	sys->load = (sys->load*(HZ-1)+n)/HZ;
-}
-
-void
-halt(void)
-{
-	if(run.nrdy != 0)
-		return;
-	hardhalt();
-}

+ 1 - 1
sys/src/9/port/proc.c

@@ -930,7 +930,7 @@ sleep(Rendez *r, int (*f)(void*), void *arg)
 	lock(&up->rlock);
 	if(r->_p){
 		print("double sleep called from %#p, %d %d\n",
-			getcallerpc(&r), r->_p->pid, up->pid);
+			getcallerpc(), r->_p->pid, up->pid);
 		dumpstack();
 	}
 

+ 4 - 4
sys/src/9/port/qio.c

@@ -108,7 +108,7 @@ padblock(Block *bp, int size)
 		}
 
 		if(bp->next)
-			panic("padblock %#p", getcallerpc(&bp));
+			panic("padblock %#p", getcallerpc());
 		n = BLEN(bp);
 		padblockcnt++;
 		nbp = allocb(size+n);
@@ -122,7 +122,7 @@ padblock(Block *bp, int size)
 		size = -size;
 
 		if(bp->next)
-			panic("padblock %#p", getcallerpc(&bp));
+			panic("padblock %#p", getcallerpc());
 
 		if(bp->lim - bp->wp >= size)
 			return bp;
@@ -238,7 +238,7 @@ pullupblock(Block *bp, int n)
 			/* shouldn't happen but why crash if it does */
 			if(i < 0){
 				print("pullupblock -ve length, from %#p\n",
-					getcallerpc(&bp));
+					getcallerpc());
 				i = 0;
 			}
 			memmove(bp->wp, nbp->rp, i);
@@ -1325,7 +1325,7 @@ qwrite(Queue *q, void *vp, int len)
 	uint8_t *p = vp;
 
 	QDEBUG if(!islo())
-		print("qwrite hi %#p\n", getcallerpc(&q));
+		print("qwrite hi %#p\n", getcallerpc());
 
 	sofar = 0;
 	do {

+ 16 - 16
sys/src/9/port/qlock.c

@@ -43,16 +43,16 @@ qlock(QLock *q)
 	}
 
 	if(up != nil && up->nlocks)
-		print("qlock: %#p: nlocks %d", getcallerpc(&q), up->nlocks);
+		print("qlock: %#p: nlocks %d", getcallerpc(), up->nlocks);
 
 	if(!canlock(&q->use)){
 		lock(&q->use);
-		slockstat(getcallerpc(&q), t0);
+		slockstat(getcallerpc(), t0);
 	}
 	qlockstats.qlock++;
 	if(!q->locked) {
 		q->locked = 1;
-		q->pc = getcallerpc(&q);
+		q->pc = getcallerpc();
 		unlock(&q->use);
 		return;
 	}
@@ -67,12 +67,12 @@ qlock(QLock *q)
 	q->tail = up;
 	up->qnext = 0;
 	up->state = Queueing;
-	up->qpc = getcallerpc(&q);
+	up->qpc = getcallerpc();
 	if(up->trace)
 		proctrace(up, SLock, 0);
 	unlock(&q->use);
 	sched();
-	lockstat(getcallerpc(&q), t0);
+	lockstat(getcallerpc(), t0);
 }
 
 int
@@ -85,7 +85,7 @@ canqlock(QLock *q)
 		return 0;
 	}
 	q->locked = 1;
-	q->pc = getcallerpc(&q);
+	q->pc = getcallerpc();
 	unlock(&q->use);
 
 	return 1;
@@ -100,11 +100,11 @@ qunlock(QLock *q)
 	if(!canlock(&q->use)){
 		cycles(&t0);
 		lock(&q->use);
-		slockstat(getcallerpc(&q), t0);
+		slockstat(getcallerpc(), t0);
 	}
 	if (q->locked == 0)
 		print("qunlock called with qlock not held, from %#p\n",
-			getcallerpc(&q));
+			getcallerpc());
 	p = q->head;
 	if(p){
 		q->head = p->qnext;
@@ -130,7 +130,7 @@ rlock(RWlock *q)
 	cycles(&t0);
 	if(!canlock(&q->use)){
 		lock(&q->use);
-		slockstat(getcallerpc(&q), t0);
+		slockstat(getcallerpc(), t0);
 	}
 	qlockstats.rlock++;
 	if(q->writer == 0 && q->head == nil){
@@ -155,7 +155,7 @@ rlock(RWlock *q)
 		proctrace(up, SLock, 0);
 	unlock(&q->use);
 	sched();
-	lockstat(getcallerpc(&q), t0);
+	lockstat(getcallerpc(), t0);
 }
 
 void
@@ -167,7 +167,7 @@ runlock(RWlock *q)
 	if(!canlock(&q->use)){
 		cycles(&t0);
 		lock(&q->use);
-		slockstat(getcallerpc(&q), t0);
+		slockstat(getcallerpc(), t0);
 	}
 	p = q->head;
 	if(--(q->readers) > 0 || p == nil){
@@ -196,12 +196,12 @@ wlock(RWlock *q)
 	cycles(&t0);
 	if(!canlock(&q->use)){
 		lock(&q->use);
-		slockstat(getcallerpc(&q), t0);
+		slockstat(getcallerpc(), t0);
 	}
 	qlockstats.wlock++;
 	if(q->readers == 0 && q->writer == 0){
 		/* noone waiting, go for it */
-		q->wpc = getcallerpc(&q);
+		q->wpc = getcallerpc();
 		q->wproc = up;
 		q->writer = 1;
 		unlock(&q->use);
@@ -224,7 +224,7 @@ wlock(RWlock *q)
 		proctrace(up, SLock, 0);
 	unlock(&q->use);
 	sched();
-	lockstat(getcallerpc(&q), t0);
+	lockstat(getcallerpc(), t0);
 }
 
 void
@@ -236,7 +236,7 @@ wunlock(RWlock *q)
 	if(!canlock(&q->use)){
 		cycles(&t0);
 		lock(&q->use);
-		slockstat(getcallerpc(&q), t0);
+		slockstat(getcallerpc(), t0);
 	}
 	p = q->head;
 	if(p == nil){
@@ -279,7 +279,7 @@ canrlock(RWlock *q)
 	if(!canlock(&q->use)){
 		cycles(&t0);
 		lock(&q->use);
-		slockstat(getcallerpc(&q), t0);
+		slockstat(getcallerpc(), t0);
 	}
 	qlockstats.rlock++;
 	if(q->writer == 0 && q->head == nil){

+ 10 - 10
sys/src/9/port/taslock.c

@@ -129,7 +129,7 @@ lock(Lock *l)
 	uintptr_t pc;
 	uint64_t t0;
 
-	pc = getcallerpc(&l);
+	pc = getcallerpc();
 
 	lockstats.locks++;
 	if(up)
@@ -195,7 +195,7 @@ ilock(Lock *l)
 	uintptr_t pc;
 	uint64_t t0;
 
-	pc = getcallerpc(&l);
+	pc = getcallerpc();
 	lockstats.locks++;
 
 	pl = splhi();
@@ -247,7 +247,7 @@ canlock(Lock *l)
 
 	if(up)
 		up->lastlock = l;
-	l->_pc = getcallerpc(&l);
+	l->_pc = getcallerpc();
 	l->p = up;
 	l->isilock = 0;
 	if(LOCKCYCLES)
@@ -272,11 +272,11 @@ unlock(Lock *l)
 	}
 
 	if(l->key == 0)
-		print("unlock: not locked: pc %#p\n", getcallerpc(&l));
+		print("unlock: not locked: pc %#p\n", getcallerpc());
 	if(l->isilock)
-		print("unlock of ilock: pc %#p, held by %#p\n", getcallerpc(&l), l->_pc);
+		print("unlock of ilock: pc %#p, held by %#p\n", getcallerpc(), l->_pc);
 	if(l->p != up)
-		print("unlock: up changed: pc %#p, acquired at pc %#p, lock p %#p, unlock up %#p\n", getcallerpc(&l), l->_pc, l->p, up);
+		print("unlock: up changed: pc %#p, acquired at pc %#p, lock p %#p, unlock up %#p\n", getcallerpc(), l->_pc, l->p, up);
 	l->m = nil;
 	l->key = 0;
 	coherence();
@@ -307,14 +307,14 @@ iunlock(Lock *l)
 	}
 
 	if(l->key == 0)
-		print("iunlock: not locked: pc %#p\n", getcallerpc(&l));
+		print("iunlock: not locked: pc %#p\n", getcallerpc());
 	if(!l->isilock)
-		print("iunlock of lock: pc %#p, held by %#p\n", getcallerpc(&l), l->_pc);
+		print("iunlock of lock: pc %#p, held by %#p\n", getcallerpc(), l->_pc);
 	if(islo())
-		print("iunlock while lo: pc %#p, held by %#p\n", getcallerpc(&l), l->_pc);
+		print("iunlock while lo: pc %#p, held by %#p\n", getcallerpc(), l->_pc);
 	if(l->m != machp()){
 		print("iunlock by cpu%d, locked by cpu%d: pc %#p, held by %#p\n",
-			machp()->machno, l->m->machno, getcallerpc(&l), l->_pc);
+			machp()->machno, l->m->machno, getcallerpc(), l->_pc);
 	}
 
 	pl = l->pl;

+ 10 - 10
sys/src/9/port/tcklock.c

@@ -175,7 +175,7 @@ lock(Lock *l)
 	uint32_t user;
 	uint64_t t0;
 
-	pc = getcallerpc(&l);
+	pc = getcallerpc();
 	lockstats.locks++;
 	if(up)
 		ainc(&up->nlocks);	/* prevent being scheded */
@@ -223,7 +223,7 @@ ilock(Lock *l)
 	uint64_t t0;
 	uint32_t user;
 
-	pc = getcallerpc(&l);
+	pc = getcallerpc();
 	lockstats.locks++;
 
 	pl = splhi();
@@ -255,7 +255,7 @@ canlock(Lock *l)
 	uintptr_t pc;
 	uint64_t t0;
 
-	pc = getcallerpc(&l);
+	pc = getcallerpc();
 
 	lockstats.locks++;
 	if(up)
@@ -286,12 +286,12 @@ void
 unlock(Lock *l)
 {
 	if(getticket(l->key) == getuser(l->key))
-		print("unlock: not locked: pc %#p\n", getcallerpc(&l));
+		print("unlock: not locked: pc %#p\n", getcallerpc());
 	if(l->isilock)
-		print("unlock of ilock: pc %#p, held by %#p\n", getcallerpc(&l), l->pc);
+		print("unlock of ilock: pc %#p, held by %#p\n", getcallerpc(), l->pc);
 	if(l->p != up)
 		print("unlock: up changed: pc %#p, acquired at pc %#p,"
-			" lock p %#p, unlock up %#p\n", getcallerpc(&l), l->pc, l->p, up);
+			" lock p %#p, unlock up %#p\n", getcallerpc(), l->pc, l->p, up);
 	l->m = nil;
 	incticket(&l->key);
 
@@ -310,14 +310,14 @@ iunlock(Lock *l)
 	Mpl pl;
 
 	if(getticket(l->key) == getuser(l->key))
-		print("iunlock: not locked: pc %#p\n", getcallerpc(&l));
+		print("iunlock: not locked: pc %#p\n", getcallerpc());
 	if(!l->isilock)
-		print("iunlock of lock: pc %#p, held by %#p\n", getcallerpc(&l), l->pc);
+		print("iunlock of lock: pc %#p, held by %#p\n", getcallerpc(), l->pc);
 	if(islo())
-		print("iunlock while lo: pc %#p, held by %#p\n", getcallerpc(&l), l->pc);
+		print("iunlock while lo: pc %#p, held by %#p\n", getcallerpc(), l->pc);
 	if(l->m != m){
 		print("iunlock by cpu%d, locked by cpu%d: pc %#p, held by %#p\n",
-			machp()->machno, l->machp()->machno, getcallerpc(&l), l->pc);
+			machp()->machno, l->machp()->machno, getcallerpc(), l->pc);
 	}
 
 	pl = l->pl;

+ 3 - 3
sys/src/9/w/pxeload/load.c

@@ -520,7 +520,7 @@ ialloc(uint32_t n, int align)
 	palloc = p+n;
 	if(palloc > memend)
 		panic("ialloc(%lud, %d) called from 0x%lux\n",
-			n, align, getcallerpc(&n));
+			n, align, getcallerpc());
 	return memset((void*)p, 0, n);
 }
 
@@ -531,7 +531,7 @@ xspanalloc(uint32_t size, int align, uint32_t span)
 
 	if((palloc + (size+align+span)) > memend)
 		panic("xspanalloc(%lud, %d, 0x%lux) called from 0x%lux\n",
-			size, align, span, getcallerpc(&size));
+			size, align, span, getcallerpc());
 
 	a = (uint32_t)ialloc(size+align+span, 0);
 
@@ -565,7 +565,7 @@ allocb(int size)
 	if(bp == 0){
 		if((palloc + (sizeof(Block)+size+64)) > memend)
 			panic("allocb(%d) called from 0x%lux\n",
-				size, getcallerpc(&size));
+				size, getcallerpc());
 		bp = ialloc(sizeof(Block)+size+64, 0);
 		addr = (uint32_t)bp;
 		addr = ROUNDUP(addr + sizeof(Block), 8);

+ 4 - 4
sys/src/cmd/abaco/util.c

@@ -105,7 +105,7 @@ emalloc(uint32_t n)
 	p = malloc(n);
 	if(p == nil)
 		error("malloc failed");
-	setmalloctag(p, getcallerpc(&n));
+	setmalloctag(p, getcallerpc());
 	memset(p, 0, n);
 	return p;
 }
@@ -116,7 +116,7 @@ erealloc(void *p, uint32_t n)
 	p = realloc(p, n);
 	if(p == nil)
 		error("realloc failed");
-	setmalloctag(p, getcallerpc(&n));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 
@@ -130,7 +130,7 @@ erunestrdup(Rune *r)
 	p = runestrdup(r);
 	if(p == nil)
 		error("runestrdup failed");
-	setmalloctag(p, getcallerpc(&r));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 
@@ -142,7 +142,7 @@ estrdup(char *s)
 	t = strdup(s);
 	if(t == nil)
 		error("strdup failed");
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }
 

+ 4 - 4
sys/src/cmd/acme/util.c

@@ -290,7 +290,7 @@ runetobyte(Rune *r, int n)
 	if(r == nil)
 		return nil;
 	s = emalloc(n*UTFmax+1);
-	setmalloctag(s, getcallerpc(&r));
+	setmalloctag(s, getcallerpc());
 	snprint(s, n*UTFmax+1, "%.*S", n, r);
 	return s;
 }
@@ -403,7 +403,7 @@ estrdup(char *s)
 	t = strdup(s);
 	if(t == nil)
 		error("strdup failed");
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }
 
@@ -415,7 +415,7 @@ emalloc(uint n)
 	p = malloc(n);
 	if(p == nil)
 		error("malloc failed");
-	setmalloctag(p, getcallerpc(&n));
+	setmalloctag(p, getcallerpc());
 	memset(p, 0, n);
 	return p;
 }
@@ -426,7 +426,7 @@ erealloc(void *p, uint n)
 	p = realloc(p, n);
 	if(p == nil)
 		error("realloc failed");
-	setmalloctag(p, getcallerpc(&n));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 

+ 4 - 4
sys/src/cmd/auth/factotum/util.c

@@ -827,7 +827,7 @@ safecpy(char *to, char *from, int n)
 		return to;
 	if(from==nil)
 		sysfatal("safecpy called with from==nil, pc=%#p",
-			getcallerpc(&to));
+			getcallerpc());
 	strncpy(to, from, n-1);
 	return to;
 }
@@ -844,7 +844,7 @@ setattr(Attr *a, char *fmt, ...)
 	va_end(arg);
 	b = _parseattr(buf);
 	a = setattrs(a, b);
-	setmalloctag(a, getcallerpc(&a));
+	setmalloctag(a, getcallerpc());
 	_freeattr(b);
 	return a;
 }
@@ -886,7 +886,7 @@ setattrs(Attr *a, Attr *b)
 		}
 		if(found == 0){
 			*l = _mkattr(b->type, b->name, b->val, nil);
-			setmalloctag(*l, getcallerpc(&a));
+			setmalloctag(*l, getcallerpc());
 		}
 continue2:;
 	}
@@ -896,7 +896,7 @@ continue2:;
 void
 setmalloctaghere(void *v)
 {
-	setmalloctag(v, getcallerpc(&v));
+	setmalloctag(v, getcallerpc());
 }
 
 Attr*

+ 3 - 3
sys/src/cmd/aux/apm.c

@@ -565,7 +565,7 @@ emalloc(uint32_t n)
 	if(v == nil)
 		sysfatal("out of memory allocating %lu", n);
 	memset(v, 0, n);
-	setmalloctag(v, getcallerpc(&n));
+	setmalloctag(v, getcallerpc());
 	return v;
 }
 
@@ -580,7 +580,7 @@ estrdup(char *s)
 	l = strlen(s)+1;
 	t = emalloc(l);
 	memcpy(t, s, l);
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }
 
@@ -596,7 +596,7 @@ estrdupn(char *s, int n)
 	t = emalloc(l+1);
 	memmove(t, s, l);
 	t[l] = '\0';
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }
 

+ 3 - 3
sys/src/cmd/aux/flashfs/aux.c

@@ -24,7 +24,7 @@ emalloc9p(uint32_t sz)
 		exits("mem");
 	}
 	memset(v, 0, sz);
-	setmalloctag(v, getcallerpc(&sz));
+	setmalloctag(v, getcallerpc());
 	return v;
 }
 
@@ -35,7 +35,7 @@ erealloc9p(void *v, uint32_t sz)
 		fprint(2, "out of memory allocating %lu\n", sz);
 		exits("mem");
 	}
-	setrealloctag(v, getcallerpc(&v));
+	setrealloctag(v, getcallerpc());
 	return v;
 }
 
@@ -48,6 +48,6 @@ estrdup9p(char *s)
 		fprint(2, "out of memory in strdup(%.10s)\n", s);
 		exits("mem");
 	}
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }

+ 1 - 1
sys/src/cmd/cwfs/iobuf.c

@@ -111,7 +111,7 @@ xloop:
 	p->addr = addr;
 	p->dev = d;
 	p->flags = flag;
-//	p->pc = getcallerpc(&d);
+//	p->pc = getcallerpc();
 	unlock(hp);
 	if(iobufmap(p))
 		if(flag & Brd) {

+ 5 - 5
sys/src/cmd/fossil/cache.c

@@ -562,7 +562,7 @@ fprint(2, "%s: _cacheLocal want epoch %u got %u\n", argv0, epoch, b->l.epoch);
 		return nil;
 	}
 
-	b->pc = getcallerpc(&c);
+	b->pc = getcallerpc();
 	for(;;){
 		switch(b->iostate){
 		default:
@@ -623,7 +623,7 @@ cacheLocalData(Cache *c, uint32_t addr, int type, uint32_t tag, int mode,
 		blockPut(b);
 		return nil;
 	}
-	b->pc = getcallerpc(&c);
+	b->pc = getcallerpc();
 	return b;
 }
 
@@ -645,7 +645,7 @@ cacheGlobal(Cache *c, uint8_t score[VtScoreSize], int type, uint32_t tag,
 	if(addr != NilBlock){
 		b = cacheLocalData(c, addr, type, tag, mode, 0);
 		if(b)
-			b->pc = getcallerpc(&c);
+			b->pc = getcallerpc();
 		return b;
 	}
 
@@ -685,7 +685,7 @@ if(0)fprint(2, "%s: cacheGlobal %V %d\n", argv0, score, type);
 	bwatchLock(b);
 	vtLock(b->lk);
 	b->nlock = 1;
-	b->pc = getcallerpc(&c);
+	b->pc = getcallerpc();
 
 	switch(b->iostate){
 	default:
@@ -808,7 +808,7 @@ if(0)fprint(2, "%s: fsAlloc %u type=%d tag = %x\n", argv0, addr, type, tag);
 	lastAlloc = addr;
 	fl->nused++;
 	vtUnlock(fl->lk);
-	b->pc = getcallerpc(&c);
+	b->pc = getcallerpc();
 	return b;
 }
 

+ 1 - 1
sys/src/cmd/fossil/disk.c

@@ -298,7 +298,7 @@ diskSize(Disk *disk, int part)
 static uintptr
 mypc(int x)
 {
-	return getcallerpc(&x);
+	return getcallerpc();
 }
 
 static char *

+ 4 - 4
sys/src/cmd/fossil/source.c

@@ -556,7 +556,7 @@ blockWalk(Block *p, int index, int mode, Fs *fs, Entry *e)
 	}
 
 	if(b)
-		b->pc = getcallerpc(&p);
+		b->pc = getcallerpc();
 
 	if(b == nil || mode == OReadOnly)
 		return b;
@@ -584,7 +584,7 @@ blockWalk(Block *p, int index, int mode, Fs *fs, Entry *e)
 	if(b == nil)
 		return nil;
 
-	b->pc = getcallerpc(&p);
+	b->pc = getcallerpc();
 	assert(b->l.epoch == fs->ehi);
 
 	blockDirty(b);
@@ -813,7 +813,7 @@ _sourceBlock(Source *r, uint32_t bn, int mode, int early, uint32_t tag)
 		blockPut(b);
 		b = bb;
 	}
-	b->pc = getcallerpc(&r);
+	b->pc = getcallerpc();
 	return b;
 Err:
 	blockPut(b);
@@ -827,7 +827,7 @@ sourceBlock(Source *r, uint32_t bn, int mode)
 
 	b = _sourceBlock(r, bn, mode, 0, 0);
 	if(b)
-		b->pc = getcallerpc(&r);
+		b->pc = getcallerpc();
 	return b;
 }
 

+ 1 - 1
sys/src/cmd/ip/snoopy/dns.c

@@ -426,7 +426,7 @@ rralloc(int type)
 
 	rp = emalloc(sizeof(*rp));
 	rp->magic = RRmagic;
-	rp->pc = getcallerpc(&type);
+	rp->pc = getcallerpc();
 	rp->type = type;
 	setmalloctag(rp, rp->pc);
 	switch(type){

+ 2 - 2
sys/src/cmd/ndb/convM2DNS.c

@@ -553,7 +553,7 @@ rrloop(Scan *sp, char *what, int count, int quest)
 		rp = quest? convM2Q(sp): convM2RR(sp, what);
 		if(rp == nil)
 			break;
-		setmalloctag(rp, getcallerpc(&sp));
+		setmalloctag(rp, getcallerpc());
 		/*
 		 * it might be better to ignore the bad rr, possibly break out,
 		 * but return the previous rrs, if any.  that way our callers
@@ -567,7 +567,7 @@ rrloop(Scan *sp, char *what, int count, int quest)
 		l = &rp->next;
 	}
 //	if(first)
-//		setmalloctag(first, getcallerpc(&sp));
+//		setmalloctag(first, getcallerpc());
 	return first;
 }
 

+ 6 - 6
sys/src/cmd/ndb/dn.c

@@ -917,7 +917,7 @@ rrcopy(RR *rp, RR **last)
 	if (canlock(&dnlock))
 		abort();	/* rrcopy called with dnlock not held */
 	nrp = rralloc(rp->type);
-	setmalloctag(nrp, getcallerpc(&rp));
+	setmalloctag(nrp, getcallerpc());
 	switch(rp->type){
 	case Ttxt:
 		*nrp = *rp;
@@ -1017,7 +1017,7 @@ rrlookup(DN *dp, int type, int flag)
 		if(rp->auth)
 		if(tsame(type, rp->type)) {
 			last = rrcopy(rp, last);
-			// setmalloctag(*last, getcallerpc(&dp));
+			// setmalloctag(*last, getcallerpc());
 		}
 	}
 	if(first)
@@ -1072,7 +1072,7 @@ out:
 	unlock(&dnlock);
 //	dnslog("rrlookup(%s) -> %#p\t# in-core only", dp->name, first);
 //	if (first)
-//		setmalloctag(first, getcallerpc(&dp));
+//		setmalloctag(first, getcallerpc());
 	return first;
 }
 
@@ -1802,7 +1802,7 @@ emalloc(int size)
 	x = mallocz(size, 1);
 	if(x == nil)
 		abort();
-	setmalloctag(x, getcallerpc(&size));
+	setmalloctag(x, getcallerpc());
 	return x;
 }
 
@@ -1817,7 +1817,7 @@ estrdup(char *s)
 	if(p == nil)
 		abort();
 	memmove(p, s, size);
-	setmalloctag(p, getcallerpc(&s));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 
@@ -1981,7 +1981,7 @@ rralloc(int type)
 
 	rp = emalloc(sizeof(*rp));
 	rp->magic = RRmagic;
-	rp->pc = getcallerpc(&type);
+	rp->pc = getcallerpc();
 	rp->type = type;
 	if (rp->type != type)
 		dnslog("rralloc: bogus type %d", type);

+ 3 - 3
sys/src/cmd/nntpfs.c

@@ -97,7 +97,7 @@ emalloc(uint32_t n)
 	if(v == nil)
 		sysfatal("out of memory allocating %lu", n);
 	memset(v, 0, n);
-	setmalloctag(v, getcallerpc(&n));
+	setmalloctag(v, getcallerpc());
 	return v;
 }
 
@@ -112,7 +112,7 @@ estrdup(char *s)
 	l = strlen(s)+1;
 	t = emalloc(l);
 	memcpy(t, s, l);
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }
 
@@ -128,7 +128,7 @@ estrdupn(char *s, int n)
 	t = emalloc(l+1);
 	memmove(t, s, l);
 	t[l] = '\0';
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }
 

+ 1 - 1
sys/src/cmd/plumb/plumber.c

@@ -153,6 +153,6 @@ estrdup(char *s)
 	t = strdup(s);
 	if(t == nil)
 		error("estrdup failed: %r");
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }

+ 1 - 1
sys/src/cmd/unix/drawterm/gui-x11/x11.c

@@ -244,7 +244,7 @@ xallocmemimage(Rectangle r, uint32_t chan, int pmid)
 	}
 
 	xm->xi = xi;
-	xm->pc = getcallerpc(&r);
+	xm->pc = getcallerpc();
 	xm->r = r;
 	
 	/*

+ 3 - 3
sys/src/cmd/unix/drawterm/kern/allocb.c

@@ -69,11 +69,11 @@ allocb(int size)
 	 * Can still error out of here, though.
 	 */
 	if(up == nil)
-		panic("allocb without up: %p\n", getcallerpc(&size));
+		panic("allocb without up: %p\n", getcallerpc());
 	if((b = _allocb(size)) == nil){
 		panic("allocb: no memory for %d bytes\n", size);
 	}
-	setmalloctag(b, getcallerpc(&size));
+	setmalloctag(b, getcallerpc());
 
 	return b;
 }
@@ -97,7 +97,7 @@ iallocb(int size)
 				ialloc.bytes, conf.ialloc);
 		return nil;
 	}
-	setmalloctag(b, getcallerpc(&size));
+	setmalloctag(b, getcallerpc());
 	b->flag = BINTR;
 
 	ilock(&ialloc.lk);

+ 3 - 3
sys/src/cmd/unix/drawterm/kern/chan.c

@@ -121,7 +121,7 @@ decref(Ref *r)
 	x = --r->ref;
 	unlock(&r->lk);
 	if(x < 0)
-		panic("decref, pc=0x%p", getcallerpc(&r));
+		panic("decref, pc=0x%p", getcallerpc());
 
 	return x;
 }
@@ -181,7 +181,7 @@ kstrdup(char **p, char *s)
 	/* if it's a user, we can wait for memory; if not, something's very wrong */
 	if(up){
 		t = smalloc(n);
-		setmalloctag(t, getcallerpc(&p));
+		setmalloctag(t, getcallerpc());
 	}else{
 		t = malloc(n);
 		if(t == nil)
@@ -363,7 +363,7 @@ void
 cclose(Chan *c)
 {
 	if(c->flag&CFREE)
-		panic("cclose %p", getcallerpc(&c));
+		panic("cclose %p", getcallerpc());
 
 	if(decref(&c->ref))
 		return;

+ 1 - 1
sys/src/cmd/unix/drawterm/kern/devpipe.c

@@ -323,7 +323,7 @@ pipewrite(Chan *c, void *va, int32_t n, int64_t offset)
 
 	USED(offset);
 	if(!islo())
-		print("pipewrite hi %lux\n", getcallerpc(&c));
+		print("pipewrite hi %lux\n", getcallerpc());
 
 	if(waserror()) {
 		/* avoid notes when pipe is a mounted queue */

+ 3 - 3
sys/src/cmd/unix/drawterm/kern/qio.c

@@ -105,7 +105,7 @@ padblock(Block *bp, int size)
 		}
 
 		if(bp->next)
-			panic("padblock 0x%p", getcallerpc(&bp));
+			panic("padblock 0x%p", getcallerpc());
 		n = BLEN(bp);
 		padblockcnt++;
 		nbp = allocb(size+n);
@@ -119,7 +119,7 @@ padblock(Block *bp, int size)
 		size = -size;
 
 		if(bp->next)
-			panic("padblock 0x%p", getcallerpc(&bp));
+			panic("padblock 0x%p", getcallerpc());
 
 		if(bp->lim - bp->wp >= size)
 			return bp;
@@ -1279,7 +1279,7 @@ qwrite(Queue *q, void *vp, int len)
 	uint8_t *p = vp;
 
 	QDEBUG if(!islo())
-		print("qwrite hi %p\n", getcallerpc(&q));
+		print("qwrite hi %p\n", getcallerpc());
 
 	sofar = 0;
 	do {

+ 5 - 5
sys/src/cmd/unix/drawterm/libauth/attr.c

@@ -47,7 +47,7 @@ _copyattr(Attr *a)
 	la = &na;
 	for(; a; a=a->next){
 		*la = _mkattr(a->type, a->name, a->val, nil);
-		setmalloctag(*la, getcallerpc(&a));
+		setmalloctag(*la, getcallerpc());
 		la = &(*la)->next;
 	}
 	*la = nil;
@@ -111,7 +111,7 @@ _mkattr(int type, char *name, char *val, Attr *next)
 	if(a->name==nil || a->val==nil)
 		sysfatal("_mkattr malloc: %r");
 	a->next = next;
-	setmalloctag(a, getcallerpc(&type));
+	setmalloctag(a, getcallerpc());
 	return a;
 }
 
@@ -156,16 +156,16 @@ _parseattr(char *s)
 		//	}else
 				type = AttrNameval;
 			a = _mkattr(type, t, p, a);
-			setmalloctag(a, getcallerpc(&s));
+			setmalloctag(a, getcallerpc());
 		}
 		else if(t[strlen(t)-1] == '?'){
 			t[strlen(t)-1] = '\0';
 			a = _mkattr(AttrQuery, t, "", a);
-			setmalloctag(a, getcallerpc(&s));
+			setmalloctag(a, getcallerpc());
 		}else{
 			/* really a syntax error, but better to provide some indication */
 			a = _mkattr(AttrNameval, t, "", a);
-			setmalloctag(a, getcallerpc(&s));
+			setmalloctag(a, getcallerpc());
 		}
 	}
 	free(s);

+ 1 - 1
sys/src/cmd/unix/drawterm/libc/lock.c

@@ -102,7 +102,7 @@ lock(Lock *lk)
 	for(;;) {
 		if(canlock(lk))
 			return;
-		iprint("lock loop %ld: val=%d &lock=%ux pc=%p\n", getpid(), lk->key, lk, getcallerpc(&lk));
+		iprint("lock loop %ld: val=%d &lock=%ux pc=%p\n", getpid(), lk->key, lk, getcallerpc());
 		osmsleep(1000);
 	}
 }

+ 1 - 1
sys/src/cmd/unix/drawterm/libmemdraw/alloc.c

@@ -107,7 +107,7 @@ _allocmemimage(Rectangle r, uint32_t chan)
 	*(Memdata**)p = md;
 	p += sizeof(Memdata*);
 
-	*(uint32_t*)p = getcallerpc(&r);
+	*(uint32_t*)p = getcallerpc();
 	p += sizeof(uint32_t);
 
 	/* if this changes, memimagemove must change too */

+ 1 - 1
sys/src/cmd/venti/srv/disksched.c

@@ -90,7 +90,7 @@ diskaccess(int level)
 {
 	if(level < 0 || level >= nelem(lasttime)){
 		fprint(2, "bad level in diskaccess; caller=%#p\n",
-			getcallerpc(&level));
+			getcallerpc());
 		return;
 	}
 	lasttime[level] = time(0);

+ 1 - 1
sys/src/cmd/venti/srv/icache.c

@@ -423,7 +423,7 @@ insertscore(uint8_t score[VtScoreSize], IAddr *ia, int state, AState *as)
 		toload = nil;
 		if(as == nil)
 			fprint(2, "%T insertscore IEDirty without as; called from %#p\n",
-				getcallerpc(&score));
+				getcallerpc());
 		else{
 			if(icache.as.aa > as->aa)
 				fprint(2, "%T insertscore: aa moving backward: %#llx -> %#llx\n", icache.as.aa, as->aa);

+ 8 - 8
sys/src/cmd/venti/srv/utils.c

@@ -159,8 +159,8 @@ emalloc(uint32_t n)
 		sysfatal("out of memory allocating %lu", n);
 	}
 	memset(p, 0xa5, n);
-	setmalloctag(p, getcallerpc(&n));
-if(0)print("emalloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&n));
+	setmalloctag(p, getcallerpc());
+if(0)print("emalloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc());
 	return p;
 }
 
@@ -176,8 +176,8 @@ ezmalloc(uint32_t n)
 		sysfatal("out of memory allocating %lu", n);
 	}
 	memset(p, 0, n);
-	setmalloctag(p, getcallerpc(&n));
-if(0)print("ezmalloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&n));
+	setmalloctag(p, getcallerpc());
+if(0)print("ezmalloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc());
 	return p;
 }
 
@@ -190,8 +190,8 @@ erealloc(void *p, uint32_t n)
 			abort();
 		sysfatal("out of memory allocating %lu", n);
 	}
-	setrealloctag(p, getcallerpc(&p));
-if(0)print("erealloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc(&p));
+	setrealloctag(p, getcallerpc());
+if(0)print("erealloc %p-%p by %#p\n", p, (char*)p+n, getcallerpc());
 	return p;
 }
 
@@ -204,8 +204,8 @@ estrdup(char *s)
 	n = strlen(s) + 1;
 	t = emalloc(n);
 	memmove(t, s, n);
-	setmalloctag(t, getcallerpc(&s));
-if(0)print("estrdup %p-%p by %#p\n", t, (char*)t+n, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
+if(0)print("estrdup %p-%p by %#p\n", t, (char*)t+n, getcallerpc());
 	return t;
 }
 

+ 1 - 1
sys/src/cmd/vnc/compat.c

@@ -118,7 +118,7 @@ smalloc(uint32_t n)
 	p = mallocz(n, 1);
 	if(p == nil)
 		panic("out of memory");
-	setmalloctag(p, getcallerpc(&n));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 

+ 4 - 4
sys/src/lib9p/mem.c

@@ -24,7 +24,7 @@ emalloc9p(uint32_t sz)
 		exits("mem");
 	}
 	memset(v, 0, sz);
-	setmalloctag(v, getcallerpc(&sz));
+	setmalloctag(v, getcallerpc());
 	return v;
 }
 
@@ -38,8 +38,8 @@ erealloc9p(void *v, uint32_t sz)
 		exits("mem");
 	}
 	if(v == nil)
-		setmalloctag(nv, getcallerpc(&v));
-	setrealloctag(nv, getcallerpc(&v));
+		setmalloctag(nv, getcallerpc());
+	setrealloctag(nv, getcallerpc());
 	return nv;
 }
 
@@ -52,6 +52,6 @@ estrdup9p(char *s)
 		fprint(2, "out of memory in strdup(%.10s)\n", s);
 		exits("mem");
 	}
-	setmalloctag(t, getcallerpc(&s));
+	setmalloctag(t, getcallerpc());
 	return t;
 }

+ 2 - 2
sys/src/libString/s_alloc.c

@@ -64,13 +64,13 @@ s_newalloc(int len)
 	sp = _s_alloc();
 	if(sp == nil)
 		sysfatal("s_newalloc: %r");
-	setmalloctag(sp, getcallerpc(&len));
+	setmalloctag(sp, getcallerpc());
 	if(len < STRLEN)
 		len = STRLEN;
 	sp->base = sp->ptr = malloc(len);
 	if (sp->base == nil)
 		sysfatal("s_newalloc: %r");
-	setmalloctag(sp->base, getcallerpc(&len));
+	setmalloctag(sp->base, getcallerpc());
 
 	sp->end = sp->base + len;
 	s_terminate(sp);

+ 1 - 1
sys/src/libString/s_copy.c

@@ -21,7 +21,7 @@ s_copy(char *cp)
 
 	len = strlen(cp)+1;
 	sp = s_newalloc(len);
-	setmalloctag(sp, getcallerpc(&cp));
+	setmalloctag(sp, getcallerpc());
 	strcpy(sp->base, cp);
 	sp->ptr = sp->base + len - 1;		/* point to 0 terminator */
 	return sp;

+ 5 - 5
sys/src/libauth/attr.c

@@ -47,7 +47,7 @@ _copyattr(Attr *a)
 	la = &na;
 	for(; a; a=a->next){
 		*la = _mkattr(a->type, a->name, a->val, nil);
-		setmalloctag(*la, getcallerpc(&a));
+		setmalloctag(*la, getcallerpc());
 		la = &(*la)->next;
 	}
 	*la = nil;
@@ -111,7 +111,7 @@ _mkattr(int type, char *name, char *val, Attr *next)
 	if(a->name==nil || a->val==nil)
 		sysfatal("_mkattr malloc: %r");
 	a->next = next;
-	setmalloctag(a, getcallerpc(&type));
+	setmalloctag(a, getcallerpc());
 	return a;
 }
 
@@ -156,16 +156,16 @@ _parseattr(char *s)
 		//	}else
 				type = AttrNameval;
 			a = _mkattr(type, t, p, a);
-			setmalloctag(a, getcallerpc(&s));
+			setmalloctag(a, getcallerpc());
 		}
 		else if(t[strlen(t)-1] == '?'){
 			t[strlen(t)-1] = '\0';
 			a = _mkattr(AttrQuery, t, "", a);
-			setmalloctag(a, getcallerpc(&s));
+			setmalloctag(a, getcallerpc());
 		}else{
 			/* really a syntax error, but better to provide some indication */
 			a = _mkattr(AttrNameval, t, "", a);
-			setmalloctag(a, getcallerpc(&s));
+			setmalloctag(a, getcallerpc());
 		}
 	}
 	free(s);

+ 1 - 1
sys/src/libdraw/alloc.c

@@ -18,7 +18,7 @@ allocimage(Display *d, Rectangle r, uint32_t chan, int repl, uint32_t val)
 
 	i =  _allocimage(nil, d, r, chan, repl, val, 0, 0);
 	if (i)
-		setmalloctag(i, getcallerpc(&d));
+		setmalloctag(i, getcallerpc());
 	return i;
 }
 

+ 0 - 6
sys/src/libdraw/arith.c

@@ -175,12 +175,6 @@ uint32_t drawld2chan[] = {
 	CMAP8,
 };
 
-/*
- * was used by libmemlayer/line.c; made static, instead of deleting it,
- * to avoid updating many binaries on sources.
- */
-static int log2[] = { -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5 };
-
 uint32_t
 setalpha(uint32_t color, uint8_t alpha)
 {

+ 1 - 1
sys/src/libdraw/creadimage.c

@@ -67,7 +67,7 @@ creadimage(Display *d, int fd, int dolock)
 		if(dolock)
 			lockdisplay(d);
 		i = allocimage(d, r, chan, 0, 0);
-		setmalloctag(i, getcallerpc(&d));
+		setmalloctag(i, getcallerpc());
 		if(dolock)
 			unlockdisplay(d);
 		if(i == nil)

+ 0 - 27
sys/src/libdraw/font.c

@@ -12,7 +12,6 @@
 #include <draw.h>
 
 static int	fontresize(Font*, int, int, int);
-static int	freeup(Font*);
 
 #define	PJW	0	/* use NUL==pjw for invisible characters */
 
@@ -331,32 +330,6 @@ loadchar(Font *f, Rune r, Cacheinfo *c, int h, int noflush,
 	return 1;
 }
 
-/* release all subfonts, return number freed */
-static
-int
-freeup(Font *f)
-{
-	Cachesubf *s, *es;
-	int nf;
-
-	if(f->sub[0]->name == nil)	/* font from mkfont; don't free */
-		return 0;
-	s = f->subf;
-	es = s+f->nsubf;
-	nf = 0;
-	while(s < es){
-		if(s->age){
-			freesubfont(s->f);
-			s->cf = nil;
-			s->f = nil;
-			s->age = 0;
-			nf++;
-		}
-		s++;
-	}
-	return nf;
-}
-
 /* return whether resize succeeded && f->cache is unchanged */
 static int
 fontresize(Font *f, int wid, int ncache, int depth)

+ 1 - 1
sys/src/libdraw/getsubfont.c

@@ -41,6 +41,6 @@ _getsubfont(Display *d, char *name)
 	if(f == 0)
 		fprint(2, "getsubfont: can't read %s: %r\n", name);
 	close(fd);
-	setmalloctag(f, getcallerpc(&d));
+	setmalloctag(f, getcallerpc());
 	return f;
 }

+ 1 - 1
sys/src/libmemdraw/alloc.c

@@ -102,7 +102,7 @@ allocmemimage(Rectangle r, uint32_t chan)
 	*(Memdata**)p = md;
 	p += sizeof(Memdata*);
 
-	*(uint32_t*)p = getcallerpc(&r);
+	*(uint32_t*)p = getcallerpc();
 	p += sizeof(uint32_t);
 
 	/* if this changes, memimagemove must change too */

+ 0 - 45
sys/src/libmemdraw/draw.c

@@ -94,7 +94,6 @@ static uint32_t pixelbits(Memimage*, Point);
 void
 memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op)
 {
-	static int n = 0;
 	Memdrawparam par;
 
 	if(mask == nil)
@@ -441,9 +440,6 @@ struct Param {
 	int	convdx;
 };
 
-static uint8_t *drawbuf;
-static int	ndrawbuf;
-static int	mdrawbuf;
 static Readfn	greymaskread, replread, readptr;
 static Writefn	nullwrite;
 static Calcfn	alphacalc0, alphacalc14, alphacalc2810, alphacalc3679, alphacalc5, alphacalc11, alphacalcS;
@@ -455,7 +451,6 @@ static Writefn*	writefn(Memimage*);
 
 static Calcfn*	boolcopyfn(Memimage*, Memimage*);
 static Readfn*	convfn(Memimage*, Param*, Memimage*, Param*, int*);
-static Readfn*	ptrfn(Memimage*);
 
 static Calcfn *alphacalc[Ncomp] =
 {
@@ -1936,20 +1931,6 @@ boolcopyfn(Memimage *img, Memimage *mask)
 	return nil;
 }
 
-/*
- * Optimized draw for filling and scrolling; uses memset and memmove.
- */
-static void
-memsetb(void *vp, uint8_t val, int n)
-{
-	uint8_t *p, *ep;
-
-	p = vp;
-	ep = p+n;
-	while(p<ep)
-		*p++ = val;
-}
-
 static void
 memsets(void *vp, uint16_t val, int n)
 {
@@ -2468,32 +2449,6 @@ DBG print("bsh %d\n", bsh);
 }
 #undef DBG
 
-
-/*
- * Fill entire byte with replicated (if necessary) copy of source pixel,
- * assuming destination ldepth is >= source ldepth.
- *
- * This code is just plain wrong for >8bpp.
- *
-ulong
-membyteval(Memimage *src)
-{
-	int i, val, bpp;
-	uchar uc;
-
-	unloadmemimage(src, src->r, &uc, 1);
-	bpp = src->depth;
-	uc <<= (src->r.min.x&(7/src->depth))*src->depth;
-	uc &= ~(0xFF>>bpp);
-	/* pixel value is now in high part of byte. repeat throughout byte 
-	val = uc;
-	for(i=bpp; i<8; i<<=1)
-		val |= val>>i;
-	return val;
-}
- * 
- */
-
 void
 memfillcolor(Memimage *i, uint32_t val)
 {

+ 6 - 18
sys/src/libmemdraw/fillpoly.c

@@ -35,18 +35,6 @@ static	int	zcompare(const void*, const void*);
 static	void	xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int, int, int, int);
 static	void	yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int, int);
 
-static void
-fillcolor(Memimage *dst, int left, int right, int y, Memimage *src, Point p)
-{
-	int srcval;
-
-	USED(src);
-	srcval = p.x;
-	p.x = left;
-	p.y = y;
-	memset(byteaddr(dst, p), srcval, right-left);
-}
-
 static void
 fillline(Memimage *dst, int left, int right, int y, Memimage *src, Point p, int op)
 {
@@ -483,8 +471,8 @@ ycompare(const void *a, const void *b)
 	Seg **s0, **s1;
 	int32_t y0, y1;
 
-	s0 = a;
-	s1 = b;
+	s0 = (Seg **)a;
+	s1 = (Seg **)b;
 	y0 = (*s0)->p0.y;
 	y1 = (*s1)->p0.y;
 
@@ -501,8 +489,8 @@ xcompare(const void *a, const void *b)
 	Seg **s0, **s1;
 	int32_t x0, x1;
 
-	s0 = a;
-	s1 = b;
+	s0 = (Seg **)a;
+	s1 = (Seg **)b;
 	x0 = (*s0)->p0.x;
 	x1 = (*s1)->p0.x;
 
@@ -519,8 +507,8 @@ zcompare(const void *a, const void *b)
 	Seg **s0, **s1;
 	int32_t z0, z1;
 
-	s0 = a;
-	s1 = b;
+	s0 = (Seg **)a;
+	s1 = (Seg **)b;
 	z0 = (*s0)->z;
 	z1 = (*s1)->z;
 

+ 0 - 9
sys/src/libmemdraw/line.c

@@ -20,15 +20,6 @@ enum
 	Arrow3 = 3,
 };
 
-static
-int
-lmin(int a, int b)
-{
-	if(a < b)
-		return a;
-	return b;
-}
-
 static
 int
 lmax(int a, int b)

+ 1 - 1
sys/src/libmp/port/betomp.c

@@ -20,7 +20,7 @@ betomp(uint8_t *p, uint n, mpint *b)
 
 	if(b == nil){
 		b = mpnew(0);
-		setmalloctag(b, getcallerpc(&p));
+		setmalloctag(b, getcallerpc());
 	}
 
 	// dump leading zeros

+ 1 - 1
sys/src/libmp/port/mpaux.c

@@ -67,7 +67,7 @@ mpnew(int n)
 		sysfatal("mpsetminbits: n < 0");
 
 	b = mallocz(sizeof(mpint), 1);
-	setmalloctag(b, getcallerpc(&n));
+	setmalloctag(b, getcallerpc());
 	if(b == nil)
 		sysfatal("mpnew: %r");
 	n = DIGITS(n);

+ 1 - 1
sys/src/libmp/port/mptobe.c

@@ -24,7 +24,7 @@ mptobe(mpint *b, uint8_t *p, uint n, uint8_t **pp)
 	if(p == nil){
 		n = (b->top+1)*Dbytes;
 		p = malloc(n);
-		setmalloctag(p, getcallerpc(&b));
+		setmalloctag(p, getcallerpc());
 	}
 	if(p == nil)
 		return -1;

+ 2 - 2
sys/src/libndb/csgetval.c

@@ -88,7 +88,7 @@ csgetvalue(char *netroot, char *attr, char *val, char *rattr,
 	}
 
 	if(pp){
-		setmalloctag(first, getcallerpc(&netroot));
+		setmalloctag(first, getcallerpc());
 		*pp = first;
 	} else
 		ndbfree(first);
@@ -114,6 +114,6 @@ csgetval(char *netroot, char *attr, char *val, char *rattr,
 		}
 		free(p);
 	}
-	ndbsetmalloctag(t, getcallerpc(&netroot));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }

+ 1 - 1
sys/src/libndb/csipinfo.c

@@ -72,6 +72,6 @@ csipinfo(char *netroot, char *attr, char *val, char **list, int n)
 	}
 	close(fd);
 
-	ndbsetmalloctag(first, getcallerpc(&netroot));
+	ndbsetmalloctag(first, getcallerpc());
 	return first;
 }

+ 2 - 2
sys/src/libndb/dnsquery.c

@@ -76,7 +76,7 @@ dnsquery(char *net, char *val, char *type)
 	 * walking to /net*^/dns.  Must be prepared to re-open it on error.
 	 */
 	close(fd);
-	ndbsetmalloctag(t, getcallerpc(&net));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }
 
@@ -165,6 +165,6 @@ doquery(int fd, char *dn, char *type)
 		}
 	}
 
-	ndbsetmalloctag(first, getcallerpc(&fd));
+	ndbsetmalloctag(first, getcallerpc());
 	return first;
 }

+ 3 - 3
sys/src/libndb/ndbaux.c

@@ -31,7 +31,7 @@ _ndbparsetuple(char *cp, Ndbtuple **tp)
 		return 0;
 
 	t = ndbnew(nil, nil);
-	setmalloctag(t, getcallerpc(&cp));
+	setmalloctag(t, getcallerpc());
 	*tp = t;
 
 	/* parse attribute */
@@ -95,10 +95,10 @@ _ndbparseline(char *cp)
 		last = t;
 		t->line = 0;
 		t->entry = 0;
-		setmalloctag(t, getcallerpc(&cp));
+		setmalloctag(t, getcallerpc());
 	}
 	if(first)
 		last->line = first;
-	ndbsetmalloctag(first, getcallerpc(&cp));
+	ndbsetmalloctag(first, getcallerpc());
 	return first;
 }

+ 2 - 2
sys/src/libndb/ndbcache.c

@@ -73,7 +73,7 @@ ndbcopy(Ndb *db, Ndbtuple *from_t, Ndbs *from_s, Ndbs *to_s)
 		last = to_t;
 		newline = from_t->line != from_t->entry;
 	}
-	ndbsetmalloctag(first, getcallerpc(&db));
+	ndbsetmalloctag(first, getcallerpc());
 	return first;
 }
 
@@ -137,7 +137,7 @@ _ndbcacheadd(Ndb *db, Ndbs *s, char *attr, char *val, Ndbtuple *t)
 	*l = nil;
 err:
 	ndbcachefree(c);
-	ndbsetmalloctag(t, getcallerpc(&db));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }
 

+ 1 - 1
sys/src/libndb/ndbconcatenate.c

@@ -23,6 +23,6 @@ ndbconcatenate(Ndbtuple *a, Ndbtuple *b)
 	for(t = a; t->entry; t = t->entry)
 		;
 	t->entry = b;
-	ndbsetmalloctag(a, getcallerpc(&a));
+	ndbsetmalloctag(a, getcallerpc());
 	return a;
 }

+ 1 - 1
sys/src/libndb/ndbdiscard.c

@@ -34,6 +34,6 @@ ndbdiscard(Ndbtuple *t, Ndbtuple *a)
 	a->entry = nil;
 	ndbfree(a);
 
-	ndbsetmalloctag(t, getcallerpc(&t));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }

+ 2 - 2
sys/src/libndb/ndbgetipaddr.c

@@ -25,7 +25,7 @@ ndbgetipaddr(Ndb *db, char *val)
 	attr = ipattr(val);
 	if(strcmp(attr, "ip") == 0){
 		it = ndbnew("ip", val);
-		ndbsetmalloctag(it, getcallerpc(&db));
+		ndbsetmalloctag(it, getcallerpc());
 		return it;
 	}
 
@@ -53,6 +53,6 @@ ndbgetipaddr(Ndb *db, char *val)
 		}
 	}
 
-	ndbsetmalloctag(first, getcallerpc(&db));
+	ndbsetmalloctag(first, getcallerpc());
 	return first;
 }

+ 1 - 1
sys/src/libndb/ndbgetval.c

@@ -82,6 +82,6 @@ ndbgetval(Ndb *db, Ndbs *s, char *attr, char *val, char *rattr,
 		}
 		free(p);
 	}
-	ndbsetmalloctag(t, getcallerpc(&db));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }

+ 6 - 6
sys/src/libndb/ndbhash.c

@@ -133,13 +133,13 @@ ndbsearch(Ndb *db, Ndbs *s, char *attr, char *val)
 	if(_ndbcachesearch(db, s, attr, val, &t) == 0){
 		/* found in cache */
 		if(t != nil){
-			ndbsetmalloctag(t, getcallerpc(&db));
+			ndbsetmalloctag(t, getcallerpc());
 			return t;	/* answer from this file */
 		}
 		if(db->next == nil)
 			return nil;
 		t = ndbsearch(db->next, s, attr, val);
-		ndbsetmalloctag(t, getcallerpc(&db));
+		ndbsetmalloctag(t, getcallerpc());
 		return t;
 	}
 
@@ -150,7 +150,7 @@ ndbsearch(Ndb *db, Ndbs *s, char *attr, char *val)
 		p = hfread(s->hf, s->ptr+NDBHLEN, NDBPLEN);
 		if(p == 0){
 			t = _ndbcacheadd(db, s, attr, val, nil);
-			ndbsetmalloctag(t, getcallerpc(&db));
+			ndbsetmalloctag(t, getcallerpc());
 			return t;
 		}
 		s->ptr = NDBGETP(p);
@@ -165,7 +165,7 @@ ndbsearch(Ndb *db, Ndbs *s, char *attr, char *val)
 		if(db->next == 0)
 			return nil;
 		t = ndbsearch(db->next, s, attr, val);
-		ndbsetmalloctag(t, getcallerpc(&db));
+		ndbsetmalloctag(t, getcallerpc());
 		return t;
 	} else {
 		s->ptr = 0;
@@ -173,7 +173,7 @@ ndbsearch(Ndb *db, Ndbs *s, char *attr, char *val)
 	}
 	t = ndbsnext(s, attr, val);
 	_ndbcacheadd(db, s, attr, val, (t != nil && s->db == db)?t:nil);
-	ndbsetmalloctag(t, getcallerpc(&db));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }
 
@@ -264,6 +264,6 @@ nextfile:
 
 	/* advance search to next db file */
 	t = ndbsearch(db->next, s, attr, val);
-	ndbsetmalloctag(t, getcallerpc(&s));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }

+ 4 - 4
sys/src/libndb/ndbipinfo.c

@@ -49,7 +49,7 @@ mkfilter(int argc, char **argv)
 		}
 		strncpy(t->attr, p, sizeof(t->attr)-1);
 	}
-	ndbsetmalloctag(first, getcallerpc(&argc));
+	ndbsetmalloctag(first, getcallerpc());
 	return first;
 }
 
@@ -107,7 +107,7 @@ filter(Ndb *db, Ndbtuple *t, Ndbtuple *f)
 		if(nf->ptr & Ffound)
 			nf->ptr = (nf->ptr & ~Ffound) | Fignore;
 
-	ndbsetmalloctag(t, getcallerpc(&db));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }
 
@@ -155,7 +155,7 @@ subnet(Ndb *db, uint8_t *net, Ndbtuple *f, int prefix)
 		ndbfree(nt);
 		nt = ndbsnext(&s, "ip", netstr);
 	}
-	ndbsetmalloctag(t, getcallerpc(&db));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }
 
@@ -259,6 +259,6 @@ ndbipinfo(Ndb *db, char *attr, char *val, char **alist, int n)
 	}
 
 	ndbfree(f);
-	ndbsetmalloctag(t, getcallerpc(&db));
+	ndbsetmalloctag(t, getcallerpc());
 	return t;
 }

+ 2 - 2
sys/src/libndb/ndbparse.c

@@ -53,7 +53,7 @@ ndbparse(Ndb *db)
 		t = _ndbparseline(line);
 		if(t == 0)
 			continue;
-		setmalloctag(t, getcallerpc(&db));
+		setmalloctag(t, getcallerpc());
 		if(first)
 			last->entry = t;
 		else
@@ -62,6 +62,6 @@ ndbparse(Ndb *db)
 		while(last->entry)
 			last = last->entry;
 	}
-	ndbsetmalloctag(first, getcallerpc(&db));
+	ndbsetmalloctag(first, getcallerpc());
 	return first;
 }

+ 4 - 4
sys/src/libndb/ndbsubstitute.c

@@ -19,12 +19,12 @@ ndbsubstitute(Ndbtuple *t, Ndbtuple *a, Ndbtuple *b)
 	Ndbtuple *nt;
 
 	if(a == b){
-		ndbsetmalloctag(t, getcallerpc(&t));
+		ndbsetmalloctag(t, getcallerpc());
 		return t;
 	}
 	if(b == nil){
 		t = ndbdiscard(t, a);
-		ndbsetmalloctag(t, getcallerpc(&t));
+		ndbsetmalloctag(t, getcallerpc());
 		return t;
 	}
 
@@ -46,10 +46,10 @@ ndbsubstitute(Ndbtuple *t, Ndbtuple *a, Ndbtuple *b)
 	ndbfree(a);
 
 	if(a == t){
-		ndbsetmalloctag(b, getcallerpc(&t));
+		ndbsetmalloctag(b, getcallerpc());
 		return b;
 	}else{
-		ndbsetmalloctag(t, getcallerpc(&t));
+		ndbsetmalloctag(t, getcallerpc());
 		return t;
 	}
 }

+ 4 - 4
sys/src/liboventi/plan9-io.c

@@ -34,7 +34,7 @@ vtMemAlloc(int size)
 	p = malloc(size);
 	if(p == 0)
 		vtFatal("vtMemAlloc: out of memory");
-	setmalloctag(p, getcallerpc(&size));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 
@@ -43,7 +43,7 @@ vtMemAllocZ(int size)
 {
 	void *p = vtMemAlloc(size);
 	memset(p, 0, size);
-	setmalloctag(p, getcallerpc(&size));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 
@@ -55,7 +55,7 @@ vtMemRealloc(void *p, int size)
 	p = realloc(p, size);
 	if(p == 0)
 		vtFatal("vtRealloc: out of memory");
-	setrealloctag(p, getcallerpc(&size));
+	setrealloctag(p, getcallerpc());
 	return p;
 }
 
@@ -81,7 +81,7 @@ vtMemBrk(int n)
 	pad = (align - (uintptr)buf) & (align-1);
 	if(n + pad > nbuf) {
 		buf = vtMemAllocZ(ChunkSize);
-		setmalloctag(buf, getcallerpc(&n));
+		setmalloctag(buf, getcallerpc());
 		nbuf = ChunkSize;
 		pad = (align - (uintptr)buf) & (align-1);
 		nchunk++;

+ 2 - 2
sys/src/liboventi/plan9-thread.c

@@ -212,7 +212,7 @@ vtRendezAlloc(VtLock *p)
 
 	q = vtMemAllocZ(sizeof(VtRendez));
 	q->lk = p;
-	setmalloctag(q, getcallerpc(&p));
+	setmalloctag(q, getcallerpc());
 	return q;
 }
 
@@ -248,7 +248,7 @@ vtLock(VtLock *p)
 	Thread *t;
 
 	lock(&p->lk);
-	p->pc = getcallerpc(&p);
+	p->pc = getcallerpc();
 	t = *vtRock;
 	if(p->writer == nil && p->readers == 0) {
 		p->writer = t;

+ 1 - 1
sys/src/liboventi/rpc.c

@@ -374,7 +374,7 @@ vtGetString(Packet *p, char **ret)
 		return 0;
 	}
 	s = vtMemAlloc(n+1);
-	setmalloctag(s, getcallerpc(&p));
+	setmalloctag(s, getcallerpc());
 	if(!packetConsume(p, (uint8_t*)s, n)) {
 		vtMemFree(s);
 		return 0;

+ 1 - 1
sys/src/liboventi/server.c

@@ -22,7 +22,7 @@ vtServerAlloc(VtServerVtbl *vtbl)
 {
 	VtSession *z = vtAlloc();
 	z->vtbl = vtMemAlloc(sizeof(VtServerVtbl));
-	setmalloctag(z->vtbl, getcallerpc(&vtbl));
+	setmalloctag(z->vtbl, getcallerpc());
 	*z->vtbl = *vtbl;
 	return z;
 }

+ 1 - 1
sys/src/liboventi/strdup.c

@@ -22,6 +22,6 @@ vtStrDup(char *s)
 	n = strlen(s) + 1;
 	ss = vtMemAlloc(n);
 	memmove(ss, s, n);
-	setmalloctag(ss, getcallerpc(&s));
+	setmalloctag(ss, getcallerpc());
 	return ss;
 }

+ 2 - 2
sys/src/libsec/port/x509.c

@@ -177,7 +177,7 @@ emalloc(int n)
 	if(p == nil)
 		sysfatal("out of memory");
 	memset(p, 0, n);
-	setmalloctag(p, getcallerpc(&n));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 
@@ -1429,7 +1429,7 @@ mkel(Elem e, Elist* tail)
 	Elist* el;
 
 	el = (Elist*)emalloc(sizeof(Elist));
-	setmalloctag(el, getcallerpc(&e));
+	setmalloctag(el, getcallerpc());
 	el->hd = e;
 	el->tl = tail;
 	return el;

+ 1 - 1
sys/src/libthread/lib.c

@@ -22,7 +22,7 @@ _threadmalloc(int32_t size, int z)
 	m = malloc(size);
 	if (m == nil)
 		sysfatal("Malloc of size %ld failed: %r", size);
-	setmalloctag(m, getcallerpc(&size));
+	setmalloctag(m, getcallerpc());
 	totalmalloc += size;
 	if (size > 100000000) {
 		fprint(2, "Malloc of size %ld, total %ld\n", size, totalmalloc);

+ 8 - 8
sys/src/libventi/cache.c

@@ -338,7 +338,7 @@ vtcachelocal(VtCache *c, uint32_t addr, int type)
 
 	qlock(&b->lk);
 	b->nlock = 1;
-	b->pc = getcallerpc(&c);
+	b->pc = getcallerpc();
 	return b;
 }
 
@@ -358,7 +358,7 @@ vtcacheallocblock(VtCache *c, int type)
 
 	qlock(&b->lk);
 	b->nlock = 1;
-	b->pc = getcallerpc(&c);
+	b->pc = getcallerpc();
 	return b;
 }
 
@@ -375,14 +375,14 @@ vtcacheglobal(VtCache *c, uint8_t score[VtScoreSize], int type)
 	uint32_t addr;
 
 	if(vttracelevel)
-		fprint(2, "vtcacheglobal %V %d from %p\n", score, type, getcallerpc(&c));
+		fprint(2, "vtcacheglobal %V %d from %p\n", score, type, getcallerpc());
 	addr = vtglobaltolocal(score);
 	if(addr != NilBlock){
 		if(vttracelevel)
 			fprint(2, "vtcacheglobal %V %d => local\n", score, type);
 		b = vtcachelocal(c, addr, type);
 		if(b)
-			b->pc = getcallerpc(&c);
+			b->pc = getcallerpc();
 		return b;
 	}
 
@@ -413,7 +413,7 @@ vtcacheglobal(VtCache *c, uint8_t score[VtScoreSize], int type)
 		}
 		if(vttracelevel)
 			fprint(2, "vtcacheglobal %V %d => found in cache; returning\n", score, type);
-		b->pc = getcallerpc(&c);
+		b->pc = getcallerpc();
 		return b;
 	}
 
@@ -461,7 +461,7 @@ vtcacheglobal(VtCache *c, uint8_t score[VtScoreSize], int type)
 	b->nlock = 1;
 	if(vttracelevel)
 		fprint(2, "vtcacheglobal %V %d => loaded into cache; returning\n", score, type);
-	b->pc = getcallerpc(&b);
+	b->pc = getcallerpc();
 	return b;
 }
 
@@ -492,7 +492,7 @@ vtblockput(VtBlock* b)
 
 if(0)fprint(2, "vtblockput: %d: %x %d %d\n", getpid(), b->addr, c->nheap, b->iostate);
 	if(vttracelevel)
-		fprint(2, "vtblockput %p from %p\n", b, getcallerpc(&b));
+		fprint(2, "vtblockput %p from %p\n", b, getcallerpc());
 
 	if(--b->nlock > 0)
 		return;
@@ -584,7 +584,7 @@ vtblockcopy(VtBlock *b)
 	}
 	memmove(bb->data, b->data, b->c->blocksize);
 	vtblockput(b);
-	bb->pc = getcallerpc(&b);
+	bb->pc = getcallerpc();
 	return bb;
 }
 

+ 5 - 5
sys/src/libventi/file.c

@@ -727,7 +727,7 @@ assert(b->type == VtDirType);
 		vtblockput(b);
 		b = bb;
 	}
-	b->pc = getcallerpc(&r);
+	b->pc = getcallerpc();
 	return b;
 Err:
 	vtblockput(b);
@@ -841,7 +841,7 @@ fileloadblock(VtFile *r, int mode)
 			b = vtcacheglobal(r->c, r->score, VtDirType);
 			if(b == nil)
 				return nil;
-			b->pc = getcallerpc(&r);
+			b->pc = getcallerpc();
 			return b;
 		}
 		assert(r->parent != nil);
@@ -911,7 +911,7 @@ vtfilelock(VtFile *r, int mode)
 	 */
 	assert(r->b == nil);
 	r->b = b;
-	b->pc = getcallerpc(&r);
+	b->pc = getcallerpc();
 	return 0;
 }
 
@@ -958,8 +958,8 @@ vtfilelock2(VtFile *r, VtFile *rr, int mode)
 	 */
 	r->b = b;
 	rr->b = bb;
-	b->pc = getcallerpc(&r);
-	bb->pc = getcallerpc(&r);
+	b->pc = getcallerpc();
+	bb->pc = getcallerpc();
 	return 0;
 }
 

+ 3 - 3
sys/src/libventi/mem.c

@@ -33,7 +33,7 @@ vtmalloc(int size)
 	p = malloc(size);
 	if(p == 0)
 		sysfatal("vtmalloc: out of memory");
-	setmalloctag(p, getcallerpc(&size));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 
@@ -42,7 +42,7 @@ vtmallocz(int size)
 {
 	void *p = vtmalloc(size);
 	memset(p, 0, size);
-	setmalloctag(p, getcallerpc(&size));
+	setmalloctag(p, getcallerpc());
 	return p;
 }
 
@@ -54,7 +54,7 @@ vtrealloc(void *p, int size)
 	p = realloc(p, size);
 	if(p == 0)
 		sysfatal("vtMemRealloc: out of memory");
-	setrealloctag(p, getcallerpc(&size));
+	setrealloctag(p, getcallerpc());
 	return p;
 }
 

+ 4 - 4
sys/src/libventi/packet.c

@@ -149,7 +149,7 @@ packetfree(Packet *p)
 		return;
 
 	NOTFREE(p);
-	p->pc = getcallerpc(&p);
+	p->pc = getcallerpc();
 
 	for(f=p->first; f!=nil; f=ff) {
 		ff = f->next;
@@ -178,7 +178,7 @@ packetdup(Packet *p, int offset, int n)
 	}
 
 	pp = packetalloc();
-	pp->pc = getcallerpc(&p);
+	pp->pc = getcallerpc();
 	if(n == 0){
 		NOTFREE(pp);
 		return pp;
@@ -229,7 +229,7 @@ packetsplit(Packet *p, int n)
 	}
 
 	pp = packetalloc();
-	pp->pc = getcallerpc(&p);
+	pp->pc = getcallerpc();
 	if(n == 0){
 		NOTFREE(pp);
 		return pp;
@@ -814,7 +814,7 @@ packetforeign(uint8_t *buf, int n, void (*free)(void *a), void *a)
 	Frag *f;
 
 	p = packetalloc();
-	p->pc = getcallerpc(&buf);
+	p->pc = getcallerpc();
 	f = fragalloc(p, 0, 0, nil);
 	f->free = free;
 	f->a = a;

+ 3 - 0
util/.gitignore

@@ -9,3 +9,6 @@
 /telnet
 /ufs
 /vendor
+/convert
+/preen
+/profile