pike.git / src / block_alloc.h

version» Context lines:

pike.git/src/block_alloc.h:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: block_alloc.h,v 1.63 2003/03/14 15:50:43 grubba Exp $ + || $Id: block_alloc.h,v 1.64 2003/03/15 16:18:32 grubba Exp $   */      #undef PRE_INIT_BLOCK -  + #undef DO_PRE_INIT_BLOCK   #undef INIT_BLOCK   #undef EXIT_BLOCK   #undef BLOCK_ALLOC   #undef LOW_PTR_HASH_ALLOC   #undef PTR_HASH_ALLOC_FIXED   #undef PTR_HASH_ALLOC   #undef COUNT_BLOCK   #undef COUNT_OTHER   #undef BLOCK_ALLOC_HSIZE_SHIFT   #undef MAX_EMPTY_BLOCKS   #undef BLOCK_ALLOC_FILL_PAGES   #undef PTR_HASH_ALLOC_FILL_PAGES   #undef PTR_HASH_ALLOC_FIXED_FILL_PAGES      /* Note: The block_alloc mutex is held while PRE_INIT_BLOCK runs. */   #define PRE_INIT_BLOCK(X)   #define INIT_BLOCK(X) - #ifdef DEBUG_MALLOC - #define EXIT_BLOCK(X) MEMSET((X), 0x55, sizeof(*(X))) - #else +    #define EXIT_BLOCK(X) - #endif /* DEBUG_MALLOC */ +    #define COUNT_BLOCK(X)   #define COUNT_OTHER()   #define BLOCK_ALLOC_HSIZE_SHIFT 2   #define MAX_EMPTY_BLOCKS 4      #ifndef BLOCK_ALLOC_USED   #define BLOCK_ALLOC_USED DO_IF_DMALLOC(real_used) DO_IF_NOT_DMALLOC(used)   #endif    -  + /* Invalidate the block as far as possible if running with dmalloc. +  */ + #define DO_PRE_INIT_BLOCK(X) do { \ +  DO_IF_DMALLOC(MEMSET((X), 0x55, sizeof(*(X)))); \ +  PRE_INIT_BLOCK(X); \ +  } while (0) +    #ifndef PIKE_HASH_T   /* Used to be size_t, but that led to performance problems    * on 64-bit architectures without % on 64bit unsigned.    */   #define PIKE_HASH_T unsigned INT32   #endif /* !PIKE_HASH_T */      #ifdef PIKE_RUN_UNLOCKED   #include "threads.h"   
pike.git/src/block_alloc.h:115:    exit(17); \    } \    if((n->next=PIKE_CONCAT(DATA,_blocks))) \    n->next->prev=n; \    n->prev=NULL; \    n->used=0; \    DO_IF_DMALLOC(n->real_used = 0); \    PIKE_CONCAT(DATA,_blocks)=n; \    PIKE_CONCAT(DATA,_free_blocks)=n; \    \ +  DO_PRE_INIT_BLOCK( n->x ); \    n->x[0].BLOCK_ALLOC_NEXT=NULL; \ -  PRE_INIT_BLOCK( n->x ); \ +     for(e=1;e<(BSIZE);e++) \    { \ -  +  DO_PRE_INIT_BLOCK( (n->x+e) ); \    n->x[e].BLOCK_ALLOC_NEXT=(void *)&n->x[e-1]; \ -  PRE_INIT_BLOCK( (n->x+e) ); \ +     } \    n->PIKE_CONCAT3(free_,DATA,s)=&n->x[(BSIZE)-1]; \    /* Mark the new blocks as unavailable for now... */ \    PIKE_MEM_NA(n->x); \   } \    \   BA_STATIC BA_INLINE struct DATA *BA_UL(PIKE_CONCAT(alloc_,DATA))(void) \   { \    struct DATA *tmp; \    struct PIKE_CONCAT(DATA,_block) *blk; \
pike.git/src/block_alloc.h:244:    blk->next->prev = blk->prev; \    blk->prev = NULL; \    blk->next = PIKE_CONCAT(DATA,_blocks); \    blk->next->prev = blk; \    PIKE_CONCAT(DATA,_blocks) = blk; \    } \    if(PIKE_CONCAT(DATA,_free_blocks) == NULL) \    PIKE_CONCAT(DATA,_free_blocks) = blk; \    } \    \ +  DO_PRE_INIT_BLOCK(d); \    d->BLOCK_ALLOC_NEXT = (void *)blk->PIKE_CONCAT3(free_,DATA,s); \    blk->PIKE_CONCAT3(free_,DATA,s)=d; \ -  PRE_INIT_BLOCK(d); \ +     /* Mark block as unavailable. */ \    PIKE_MEM_NA(*d); \    \    if(!--blk->BLOCK_ALLOC_USED && \    ++PIKE_CONCAT3(num_empty_,DATA,_blocks) > MAX_EMPTY_BLOCKS) { \    if(blk == PIKE_CONCAT(DATA,_free_blocks)) { \    if((blk->prev->next = blk->next)) \    blk->next->prev = blk->prev; \    PIKE_CONCAT(DATA,_free_blocks) = blk->prev; \    } else { \