Main Page | Modules | Data Structures | File List | Data Fields | Globals

bmalloc.h

Go to the documentation of this file.
00001 /* Needs beeos.h, also to set HOSTED_BUILD */
00002 /*@-exportfcn@*/ /*@-protoparamname@*/
00003 /*@external@*/
00004 void bmallocinit(void) 
00005     /*@globals internalState@*/
00006     /*@modifies internalState@*/;
00007 /*@external@*/ 
00008 void bfree(char /*@null@*/ *addr);
00009 /*@external@*/ /*@null@*/ /*@exposed@*/
00010 char *bmalloc(ushort size, char /*@exposed@*/ /*@null@*/ *pExist);
00011 /*@external@*/ /*@null@*/ /*@exposed@*/
00012 char *bremalloc(ushort size, char /*@exposed@*/ /*@returned@*/ *pExist)
00013     /*@globals internalState@*/
00014     /*@modifies internalState@*/;
00015 /*@=exportfcn@*/ /*@=protoparamname@*/
00016 #ifndef IN_BMEM
00017     extern bool lk_bfree;       /* Thread locking */
00018     extern bool lk_bmalloc; /* Thread locking */
00019 #endif
00020 
00021 #define ALLOC_NUMBLOCKS(addr) (*((uchar*)addr - 1))
00022 
00023 /* BMEM.C CONFIG START */
00024 #define SRAM_BLOCKSIZE 40 /* No. bytes per block */
00025 #define SRAM_NUMBLOCKS (SRAM_SIZE/SRAM_BLOCKSIZE) /* No. of blocks in bheap space */
00026 
00027 #define BMALLOC     /* Enables the bmalloc() function */
00028 #define BREALLOC    /* Enables the bmalloc() realloc code */
00029 #define BREMALLOC   /* Enables the bremalloc() function */
00030 /* #define BMEM_DEBUG */    /* Enabels debug printf() statements */
00031 /* BMEM.C CONFIG END */
00032 
00033 /* BEGIN CONFIG SANITY CHECK */
00034 #ifndef BMALLOC
00035 #  ifdef BMEM_DEBUG
00036 #    error BMEM_DEBUG defined without BMALLOC; no debug statements to enable
00037 #  endif
00038 #  ifdef BREALLOC
00039 #    error BREALLOC defined without BMALLOC
00040 #  endif
00041 #  ifdef BREMALLOC
00042 #    error BREMALLOC defined without BMALLOC
00043 #  endif
00044 #endif      /* #ifndef BMALLOC */
00045 
00046 #ifdef BMEM_DEBUG
00047 #  ifndef HOSTED_BUILD
00048 /*#    error BMEM_DEBUG defined without HOSTED_BUILD*/
00049 /*#    error Uncomment me in bmalloc.h if you are sure you want this.*/
00050 #  endif
00051 #endif
00052 
00053 #ifdef BREMALLOC
00054 #  ifndef BREALLOC
00055 #    error BREMALLOC defined without BREALLOC
00056 #  endif
00057 #endif      /* #ifdef BREMALLOC */
00058 /* END CONFIG SANITY CHECK */
00059 
00060 /* These SRAM_ macros are for malloc() stuff. */
00061 #define SRAM_ADDR2BLOCK(addr) ( (addr - bheap) / SRAM_BLOCKSIZE )
00062 #define SRAM_BLOCK2ADDR(block) (bheap + (block * SRAM_BLOCKSIZE))
00063 #define SRAM_BITCLR(block) bitnclr(&(bheap_bitmap[block/8]), block % 8)
00064 #define SRAM_BITSET(block) bitnset(&(bheap_bitmap[block/8]), block % 8)
00065 #define SRAM_BITCHECK(block) bitncheck(&(bheap_bitmap[block/8]), block % 8)

Generated on Sat Apr 10 17:08:02 2004 for BeeOS by doxygen 1.3.6-20040222