#include "fns.h"
#include "../port/error.h"
-int imagereclaim(int);
-
/*
* Attachable segment types
*/
{
Image *i, **l;
+ c->flag &= ~CCACHE;
+ cclunk(c);
+
lock(&imagealloc);
/*
unlock(&imagealloc);
if(i->c == nil){
i->c = c;
- c->flag &= ~CCACHE;
incref(c);
}
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;
* 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
{
Image *f, **l;
Chan *c;
- int r;
+ long r;
if(i->notext){
decref(i);
ccloseq(c); /* does not block */
}
-long
+uintptr
ibrk(uintptr addr, int seg)
{
Segment *s, *ns;
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;
incref(sio->s);
up->seg[sno] = sio->s;
- cclose(up->dot);
- up->dot = up->slash;
- incref(up->dot);
-
while(waserror())
;
for(done = 0; !done;){