X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=sys%2Fsrc%2F9%2Fport%2Fsegment.c;h=e9e8959df8fa994735f684fea746a4fe37befaa3;hb=b450cb7e32ac9233d6d9225600feaf8b4a84301d;hp=c2ad137f192fc42822ffb4c3071eb775204182ad;hpb=d6eb7cc71c89762694fad552aa21489c55bf0a29;p=plan9front.git diff --git a/sys/src/9/port/segment.c b/sys/src/9/port/segment.c index c2ad137f1..e9e8959df 100644 --- a/sys/src/9/port/segment.c +++ b/sys/src/9/port/segment.c @@ -5,8 +5,6 @@ #include "fns.h" #include "../port/error.h" -int imagereclaim(int); - /* * Attachable segment types */ @@ -234,6 +232,9 @@ attachimage(int type, Chan *c, uintptr base, ulong len) { Image *i, **l; + c->flag &= ~CCACHE; + cclunk(c); + lock(&imagealloc); /* @@ -274,7 +275,6 @@ found: unlock(&imagealloc); if(i->c == nil){ i->c = c; - c->flag &= ~CCACHE; incref(c); } @@ -295,20 +295,22 @@ found: return i; } -extern int pagereclaim(Image*, int); /* page.c */ - -int -imagereclaim(int min) +ulong +imagereclaim(ulong pages) { static Image *i, *ie; - int j, n; + ulong np; + int j; + + if(pages == 0) + return 0; eqlock(&imagealloc.ireclaim); if(i == nil){ i = imagealloc.list; ie = &imagealloc.list[conf.nimage]; } - n = 0; + np = 0; for(j = 0; j < conf.nimage; j++, i++){ if(i >= ie) i = imagealloc.list; @@ -319,14 +321,14 @@ imagereclaim(int min) * reclaim pages from inactive images. */ if(imagealloc.free != nil || i->ref == i->pgref){ - n += pagereclaim(i, min - n); - if(n >= min) + np += pagereclaim(i, pages - np); + if(np >= pages) break; } } qunlock(&imagealloc.ireclaim); - return n; + return np; } void @@ -334,7 +336,7 @@ putimage(Image *i) { Image *f, **l; Chan *c; - int r; + long r; if(i->notext){ decref(i); @@ -374,7 +376,7 @@ putimage(Image *i) ccloseq(c); /* does not block */ } -long +uintptr ibrk(uintptr addr, int seg) { Segment *s, *ns; @@ -602,9 +604,6 @@ segattach(Proc *p, ulong attr, char *name, uintptr va, uintptr len) if(va != 0 && va >= USTKTOP) error(Ebadarg); - validaddr((uintptr)name, 1, 0); - vmemchr(name, 0, ~0); - for(sno = 0; sno < NSEG; sno++) if(p->seg[sno] == nil && sno != ESEG) break; @@ -837,10 +836,6 @@ segmentioproc(void *arg) incref(sio->s); up->seg[sno] = sio->s; - cclose(up->dot); - up->dot = up->slash; - incref(up->dot); - while(waserror()) ; for(done = 0; !done;){