/*
* Called to allocate permanent data structures
* Alignment is in number of bytes. It pertains both to the start and
* end of the allocated memory.
*/
void*
ialloc(uintptr n, int align)
{
char *p;
int m;
if(align <= 0)
align = sizeof(uintptr);
mainmem->lock(mainmem);
p = sbrk(0);
if(m = n % align)
n += align - m;
if(m = (uintptr)p % align)
p += align - m;
if(brk(p+n) < 0)
panic("ialloc: out of memory");
mainmem->unlock(mainmem);
return p;
}
enum { HWIDTH = 8 }; /* buffers per hash */
/*
* allocate rest of mem
* for io buffers.
*/
void
iobufinit(void)
{
int i;
char *xiop;
Iobuf *p, *q;
Hiob *hp;