memory.c 1.25 KB
/*
 * Copyright (C) 1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * Copyright (C) 1998 Digital Equipment Corporation
 *
 * This file is part of the SimOS distribution.
 * See LICENSE file for terms of the license.
 *
 */

/* Memory allocation routines */

#include <stdio.h>
#include <malloc.h>
#include <sys/types.h>
#include <sys/mman.h>

void
print_mallinfo()
{
    struct mallinfo malloc_info;

    malloc_info = mallinfo();
    printf("arena= %d\n ", malloc_info.arena);
    printf("ordblks= %d\n ", malloc_info.ordblks);
    printf("smblks= %d\n ", malloc_info.smblks);
    printf("hblks= %d\n ", malloc_info.hblks);
    printf("hblkhd= %d\n ", malloc_info.hblkhd);
    printf("usmblks= %d\n ", malloc_info.usmblks);
    printf("fsmblks= %d\n ", malloc_info.fsmblks);
    printf("uordblks= %d\n ", malloc_info.uordblks);
    printf("fordblks= %d\n ", malloc_info.fordblks);
    printf("keepcost= %d\n ", malloc_info.keepcost);

}

void *
aint_malloc(size_t size)
{
    caddr_t pointer;
    
    if ( (pointer = mmap ((caddr_t) NULL, size,
			  PROT_READ | PROT_WRITE,
			  MAP_ANONYMOUS | MAP_VARIABLE | MAP_PRIVATE,
			  -1, 0)) == (caddr_t) -1) {
	perror("mmap");
	fatal("aint_malloc - out of memory");
    }

    return pointer;
}