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.67 2003/03/17 13:57:39 grubba Exp $ + || $Id: block_alloc.h,v 1.68 2003/06/30 17:06:08 mast 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
pike.git/src/block_alloc.h:377:    PIKE_CONCAT(DATA,_hash_table)[hval]=p; \    return p; \    } \    } \    return 0; \   } \    \   struct DATA *PIKE_CONCAT(find_,DATA)(void *ptr) \   { \    struct DATA *p; \ -  PIKE_HASH_T hval = (PIKE_HASH_T)(((char *)ptr)-(char *)0); \ +  PIKE_HASH_T hval = (PIKE_HASH_T)PTR_TO_INT(ptr); \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    if(!PIKE_CONCAT(DATA,_hash_table_size)) { \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return 0; \    } \    hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    p=PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(ptr, hval); \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return p; \   } \
pike.git/src/block_alloc.h:409:    while((p=p->BLOCK_ALLOC_NEXT)) \    { \    if(p->PTR_HASH_ALLOC_DATA==ptr) return p; \    } \    return 0; \   } \    \   static struct DATA *PIKE_CONCAT(just_find_,DATA)(void *ptr) \   { \    struct DATA *p; \ -  PIKE_HASH_T hval = (PIKE_HASH_T)(((char *)ptr)-(char *)0); \ +  PIKE_HASH_T hval = (PIKE_HASH_T)PTR_TO_INT(ptr); \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    if(!PIKE_CONCAT(DATA,_hash_table_size)) { \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return 0; \    } \    hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    p=PIKE_CONCAT3(just_find_,DATA,_unlocked)(ptr, hval); \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return p; \   } \    \    \    \   struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr) \   { \    struct DATA *p; \ -  PIKE_HASH_T hval = (PIKE_HASH_T)(((char *)ptr)-(char *)0); \ +  PIKE_HASH_T hval = (PIKE_HASH_T)PTR_TO_INT(ptr); \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    p=PIKE_CONCAT3(make_,DATA,_unlocked)(ptr,hval); \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return p; \   } \    \   struct DATA *PIKE_CONCAT(get_,DATA)(void *ptr) \   { \    struct DATA *p; \ -  PIKE_HASH_T hval = (size_t)(((char *)ptr)-(char *)0); \ +  PIKE_HASH_T hval = (PIKE_HASH_T)PTR_TO_INT(ptr); \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    if(!(p=PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(ptr, hval))) \    p=PIKE_CONCAT3(make_,DATA,_unlocked)(ptr, hval); \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return p; \   } \    \   int PIKE_CONCAT3(check_,DATA,_semafore)(void *ptr) \   { \    struct DATA *p; \ -  PIKE_HASH_T hval = (PIKE_HASH_T)(((char *)ptr)-(char *)0); \ +  PIKE_HASH_T hval = (PIKE_HASH_T)PTR_TO_INT(ptr); \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    if((p=PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(ptr, hval))) \    { \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return 0; \    } \    \    PIKE_CONCAT3(make_,DATA,_unlocked)(ptr, hval); \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return 1; \   } \    \   void PIKE_CONCAT(move_,DATA)(struct DATA *block, void *new_ptr) \   { \    PIKE_HASH_T hval = \ -  (PIKE_HASH_T)(((char *)block->PTR_HASH_ALLOC_DATA)-(char *)0); \ +  (PIKE_HASH_T)PTR_TO_INT(block->PTR_HASH_ALLOC_DATA); \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    if (!PIKE_CONCAT3(really_low_find_,DATA,_unlocked)( \    block->PTR_HASH_ALLOC_DATA, hval)) \    Pike_fatal("The block to move wasn't found.\n"); \    DO_IF_DEBUG( \    if (PIKE_CONCAT(DATA,_hash_table)[hval] != block) \    Pike_fatal("Expected the block to be at the top of the hash chain.\n"); \    ); \    PIKE_CONCAT(DATA,_hash_table)[hval] = block->BLOCK_ALLOC_NEXT; \    block->PTR_HASH_ALLOC_DATA = new_ptr; \ -  hval = (PIKE_HASH_T)(((char *)new_ptr)-(char *)0) % \ +  hval = (PIKE_HASH_T)PTR_TO_INT(new_ptr) % \    (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    block->BLOCK_ALLOC_NEXT = PIKE_CONCAT(DATA,_hash_table)[hval]; \    PIKE_CONCAT(DATA,_hash_table)[hval] = block; \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \   } \    \   int PIKE_CONCAT(remove_,DATA)(void *ptr) \   { \    struct DATA *p; \ -  PIKE_HASH_T hval = (PIKE_HASH_T)(((char *)ptr)-(char *)0); \ +  PIKE_HASH_T hval = (PIKE_HASH_T)PTR_TO_INT(ptr); \    DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \    if(!PIKE_CONCAT(DATA,_hash_table)) \    { \    DO_IF_RUN_UNLOCKED(mt_unlock(&PIKE_CONCAT(DATA,_mutex))); \    return 0; \    } \    hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    if((p=PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(ptr, hval))) \    { \    PIKE_CONCAT(num_,DATA)--; \
pike.git/src/block_alloc.h:598:    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 = (PIKE_HASH_T)(((char *)p->PTR_HASH_ALLOC_DATA)-(char *)0); \ +  hval = (PIKE_HASH_T)PTR_TO_INT(p->PTR_HASH_ALLOC_DATA); \    hval %= (PIKE_HASH_T)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:624:    struct DATA *p; \    \    DO_IF_DEBUG( if(!PIKE_CONCAT(DATA,_hash_table)) \    Pike_fatal("Hash table error!\n"); ) \    PIKE_CONCAT(num_,DATA)++; \    \    if(( PIKE_CONCAT(num_,DATA)>>BLOCK_ALLOC_HSIZE_SHIFT ) >= \    PIKE_CONCAT(DATA,_hash_table_size)) \    { \    PIKE_CONCAT(DATA,_rehash)(); \ -  hval = (PIKE_HASH_T)(((char *)ptr)-(char *)0); \ +  hval = (PIKE_HASH_T)PTR_TO_INT(ptr); \    hval %= (PIKE_HASH_T)PIKE_CONCAT(DATA,_hash_table_size); \    } \    \    p=BA_UL(PIKE_CONCAT(alloc_,DATA))(); \    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; \   }