*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: malloc.c,v 1.8 1996/08/21 03:47:22 tholo Exp $";
+static char rcsid[] = "$OpenBSD: malloc.c,v 1.9 1996/09/06 16:14:36 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
/*
unsigned input;
{
int result;
- asm("bsfl %1,%0" : "=r" (result) : "r" (input));
+ __asm("bsfl %1,%0" : "=r" (result) : "r" (input));
return result+1;
}
unsigned input;
{
int result;
- asm("bsrl %1,%0" : "=r" (result) : "r" (input));
+ __asm("bsrl %1,%0" : "=r" (result) : "r" (input));
return result+1;
}
struct pginfo *pi;
int bit;
{
- asm("btsl %0,(%1)" :
+ __asm("btsl %0,(%1)" :
: "r" (bit & (MALLOC_BITS-1)), "r" (pi->bits+(bit/MALLOC_BITS)));
}
struct pginfo *pi;
int bit;
{
- asm("btcl %0,(%1)" :
+ __asm("btcl %0,(%1)" :
: "r" (bit & (MALLOC_BITS-1)), "r" (pi->bits+(bit/MALLOC_BITS)));
}
/* Get new pages */
new = (struct pginfo**) mmap(0, i * malloc_pagesize, PROT_READ|PROT_WRITE,
- MAP_ANON|MAP_PRIVATE, -1, 0);
+ MAP_ANON|MAP_PRIVATE, -1, (off_t)0);
if (new == (struct pginfo **)-1)
return 0;
/* Allocate one page for the page directory */
page_dir = (struct pginfo **) mmap(0, malloc_pagesize, PROT_READ|PROT_WRITE,
- MAP_ANON|MAP_PRIVATE, -1, 0);
+ MAP_ANON|MAP_PRIVATE, -1, (off_t)0);
if (page_dir == (struct pginfo **) -1)
wrterror("(Init) my first mmap failed. (check limits ?)\n");
}
p = pf->page;
- pf->page += size;
+ pf->page = (char *)pf->page + size;
pf->size -= size;
break;
}
/* Do a bunch at a time */
for(;k-i >= MALLOC_BITS; i += MALLOC_BITS)
- bp->bits[i / MALLOC_BITS] = ~0;
+ bp->bits[i / MALLOC_BITS] = (u_long)~0;
for(; i < k; i++)
set_bit(bp,i);
k <<= bp->shift;
if (malloc_junk)
- memset(bp->page + k, SOME_JUNK, bp->size);
+ memset((char *)bp->page + k, SOME_JUNK, bp->size);
- return bp->page + k;
+ return (void *)((char *)bp->page + k);
}
/*
l = i << malloc_pageshift;
- tail = ptr+l;
+ tail = (char *)ptr + l;
/* add to free-list */
if (!px)
} else {
/* Find the right spot, leave pf pointing to the modified entry. */
- tail = ptr+l;
+ tail = (char *)ptr + l;
for(pf = free_list.next; pf->end < ptr && pf->next; pf = pf->next)
; /* Race ahead here */
px = 0;
} else if (pf->end == ptr ) {
/* Append to the previous entry */
- pf->end += l;
+ pf->end = (char *)pf->end + l;
pf->size += l;
if (pf->next && pf->end == pf->next->page ) {
/* And collapse the next too. */
* Keep the cache intact. Notice that the '>' above guarantees that
* the pf will always have at least one page afterwards.
*/
- pf->end = pf->page + malloc_cache;
+ pf->end = (char *)pf->page + malloc_cache;
pf->size = malloc_cache;
brk(pf->end);
* Free a chunk, and possibly the page it's on, if the page becomes empty.
*/
+/* ARGSUSED */
static __inline void
free_bytes(ptr, index, info)
void *ptr;