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.53 2002/11/24 20:31:23 mast Exp $ + || $Id: block_alloc.h,v 1.54 2002/11/24 22:41:55 mast Exp $   */      #undef 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      #define PRE_INIT_BLOCK(X)   #define INIT_BLOCK(X)   #define EXIT_BLOCK(X)   #define COUNT_BLOCK(X)   #define COUNT_OTHER()   #define BLOCK_ALLOC_HSIZE_SHIFT 2   #define MAX_EMPTY_BLOCKS 4      #ifdef PIKE_RUN_UNLOCKED
pike.git/src/block_alloc.h:31:   /* Block Alloc UnLocked */   #define BA_UL(X) PIKE_CONCAT(X,_unlocked)   #define BA_STATIC static   #define BA_INLINE inline   #else   #define BA_UL(X) X   #define BA_STATIC   #define BA_INLINE   #endif    - /* Size of the members in the block struct below that doesn't contain -  * the payload data (i.e. that aren't x). This can be used in -  * BSIZE to make the block fit within a page. */ + #define BLOCK_ALLOC_FILL_PAGES(DATA, PAGES) \ +  BLOCK_ALLOC(DATA, \ +  ((PIKE_MALLOC_PAGE_SIZE * (PAGES)) \ +  - PIKE_MALLOC_OVERHEAD - BLOCK_HEADER_SIZE) / \ +  sizeof (struct DATA)) +  + #define PTR_HASH_ALLOC_FILL_PAGES(DATA, PAGES) \ +  PTR_HASH_ALLOC(DATA, \ +  ((PIKE_MALLOC_PAGE_SIZE * (PAGES)) \ +  - PIKE_MALLOC_OVERHEAD - BLOCK_HEADER_SIZE) / \ +  sizeof (struct DATA)) +  + #define PTR_HASH_ALLOC_FIXED_FILL_PAGES(DATA, PAGES) \ +  PTR_HASH_ALLOC_FIXED(DATA, \ +  ((PIKE_MALLOC_PAGE_SIZE * (PAGES)) \ +  - PIKE_MALLOC_OVERHEAD - BLOCK_HEADER_SIZE) / \ +  sizeof (struct DATA)) +  + /* Size of the members in the block struct below that don't contain +  * the payload data (i.e. that aren't x). This can be used in BSIZE to +  * make the block fit within a page. */ + #ifndef BLOCK_HEADER_SIZE   #define BLOCK_HEADER_SIZE (3 * sizeof (void *) + sizeof (INT32)) -  + #endif      #define BLOCK_ALLOC(DATA,BSIZE) \    \   struct PIKE_CONCAT(DATA,_block) \   { \    struct PIKE_CONCAT(DATA,_block) *next; \    struct PIKE_CONCAT(DATA,_block) *prev; \    struct DATA *PIKE_CONCAT3(free_,DATA,s); \    INT32 used; \    struct DATA x[BSIZE]; \
pike.git/src/block_alloc.h:318:   struct DATA **PIKE_CONCAT(DATA,_hash_table)=0; \   size_t PIKE_CONCAT(DATA,_hash_table_size)=0; \   size_t PIKE_CONCAT(DATA,_hash_table_magnitude)=0; \   static size_t PIKE_CONCAT(num_,DATA)=0; \    \   static inline struct DATA * \    PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(void *ptr, size_t hval) \   { \    struct DATA *p,**pp; \    p=PIKE_CONCAT(DATA,_hash_table)[hval]; \ -  if(!p || p->data == ptr) \ +  if(!p || p->PTR_HASH_ALLOC_DATA == ptr) \    { \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return p; \    } \    while((p=*(pp=&p->BLOCK_ALLOC_NEXT))) \    { \ -  if(p->data==ptr) \ +  if(p->PTR_HASH_ALLOC_DATA==ptr) \    { \    *pp=p->BLOCK_ALLOC_NEXT; \    p->BLOCK_ALLOC_NEXT=PIKE_CONCAT(DATA,_hash_table)[hval]; \    PIKE_CONCAT(DATA,_hash_table)[hval]=p; \    return p; \    } \    } \    return 0; \   } \    \
pike.git/src/block_alloc.h:466:    \   struct DATA *PIKE_CONCAT3(make_,DATA,_unlocked)(void *ptr, size_t hval) \   { \    struct DATA *p; \    \    DO_IF_DEBUG( if(!PIKE_CONCAT(DATA,_hash_table)) \    Pike_fatal("Hash table error!\n"); ) \    PIKE_CONCAT(num_,DATA)++; \    \    p=BA_UL(PIKE_CONCAT(alloc_,DATA))(); \ -  p->data=ptr; \ +  p->PTR_HASH_ALLOC_DATA=ptr; \    p->BLOCK_ALLOC_NEXT=PIKE_CONCAT(DATA,_hash_table)[hval]; \    PIKE_CONCAT(DATA,_hash_table)[hval]=p; \    return p; \   } \         #define PTR_HASH_ALLOC(DATA,BSIZE) \   struct DATA *PIKE_CONCAT3(make_,DATA,_unlocked)(void *ptr, size_t hval); \   LOW_PTR_HASH_ALLOC(DATA,BSIZE) \    \
pike.git/src/block_alloc.h:503:    malloc(PIKE_CONCAT(DATA,_hash_table_size)* \    sizeof(struct DATA *)))) \    { \    MEMSET(PIKE_CONCAT(DATA,_hash_table),0, \    sizeof(struct DATA *)*PIKE_CONCAT(DATA,_hash_table_size)); \    while(e-- > 0) \    { \    while((p=old_hash[e])) \    { \    old_hash[e]=p->BLOCK_ALLOC_NEXT; \ -  hval=(size_t)(p->data); \ +  hval=(size_t)(p->PTR_HASH_ALLOC_DATA); \    hval%=PIKE_CONCAT(DATA,_hash_table_size); \    p->BLOCK_ALLOC_NEXT=PIKE_CONCAT(DATA,_hash_table)[hval]; \    PIKE_CONCAT(DATA,_hash_table)[hval]=p; \    } \    } \    free((char *)old_hash); \    }else{ \    PIKE_CONCAT(DATA,_hash_table)=old_hash; \    PIKE_CONCAT(DATA,_hash_table_size)=e; \    } \
pike.git/src/block_alloc.h:533:    \    if(( PIKE_CONCAT(num_,DATA)>>BLOCK_ALLOC_HSIZE_SHIFT ) >= \    PIKE_CONCAT(DATA,_hash_table_size)) \    { \    PIKE_CONCAT(DATA,_rehash)(); \    hval=(size_t)ptr; \    hval%=PIKE_CONCAT(DATA,_hash_table_size); \    } \    \    p=BA_UL(PIKE_CONCAT(alloc_,DATA))(); \ -  p->data=ptr; \ +  p->PTR_HASH_ALLOC_DATA=ptr; \    p->BLOCK_ALLOC_NEXT=PIKE_CONCAT(DATA,_hash_table)[hval]; \    PIKE_CONCAT(DATA,_hash_table)[hval]=p; \    return p; \   }