usermode/library/pmalloc/src/vistaheap.h

00001 /*
00002  * Copyright (c) 1997, 1998, 1999, 2000, David E. Lowell
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00015  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00018  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00019  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00020  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00021  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00022  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00023  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00024  * SUCH DAMAGE.
00025  *
00026  * Vista library, version 0.6.1, September 2000
00027  */
00028 
00029 #ifndef HEAP_H
00030 #define HEAP_H
00031 
00032 #include <sys/types.h>
00033 #include <sys/mman.h>
00034 
00035 
00036 #define NBUCKETS 32
00037 #define BUCKET_MIN 3 /* log base 2 of smallest bucket size */
00038 #define EXTENDSIZE 131072 /* minimum amount that morecore extends the file */
00039 #define DEFAULT_PROT (PROT_READ | PROT_WRITE)
00040 #define MMAP_FLAGS (MAP_FILE | MAP_FIXED | MAP_SHARED)
00041 #define UP_TO_PAGE(x) (x%PAGESIZE==0?x:(x-(x%PAGESIZE)+PAGESIZE))
00042 #define DOWN_TO_PAGE(x) (x%PAGESIZE==0?x:(x-(x%PAGESIZE)))
00043 #define MAP_ADDR ((void*)0x20000000000L)
00044 #define MAP_ADDR2 ((void*)0x21000000000L)
00045 
00046 typedef struct nugget_s {
00047         void*            addr;
00048         struct nugget_s* next;
00049 } nugget;
00050 
00051 typedef struct vistaheap_s {
00052         nugget*             bucketlists[NBUCKETS];
00053         nugget*             nlist; /* list of free nuggets for internals */
00054         char*               base;
00055         char*               limit;
00056         char*               hardlimit;
00057         volatile void*      key;          /* can point to a vista_segment (volatile) */
00058         struct vistaheap_s* allocator; /* vistaheap from which to alloc internal data */
00059 } vistaheap;
00060 
00061 __attribute__((tm_callable)) extern void* vistaheap_init(vistaheap*, void*, void*, vistaheap*);
00062 __attribute__((tm_callable)) extern void* vistaheap_malloc(vistaheap*, int);
00063 __attribute__((tm_callable)) extern void  vistaheap_free(vistaheap* h, void* p, int size);
00064 __attribute__((tm_callable)) extern void* morecore(vistaheap* h, int pages);
00065 __attribute__((tm_callable)) extern void  vistaheap_reinit_mutex(vistaheap* h);
00066 
00067 #endif
00068 

Generated on Sat Apr 23 11:43:36 2011 for Mnemosyne by  doxygen 1.4.7