Branch: Tag:

2003-06-30

2003-06-30 17:11:20 by Martin Stjernholm <mast@lysator.liu.se>

Cleaned up some pointer handling.

Rev: src/apply_low.h:1.19
Rev: src/backend.cmod:1.43
Rev: src/block_alloc.h:1.68
Rev: src/builtin_functions.c:1.497
Rev: src/cyclic.c:1.11
Rev: src/encode.c:1.190
Rev: src/fdlib.c:1.63
Rev: src/fsort_template.h:1.16
Rev: src/gc.c:1.220
Rev: src/interpret.c:1.307
Rev: src/interpret.h:1.142
Rev: src/interpret_functions.h:1.151
Rev: src/las.c:1.336
Rev: src/main.c:1.177
Rev: src/mapping.c:1.168
Rev: src/mapping.h:1.50
Rev: src/modules/Oracle/oracle.c:1.78
Rev: src/modules/_Charset/misc.c:1.14
Rev: src/multiset.c:1.74
Rev: src/object.c:1.238
Rev: src/object.h:1.79
Rev: src/pike_macros.h:1.37
Rev: src/pike_memory.c:1.146
Rev: src/pike_search.c:1.16
Rev: src/pike_search_engine2.c:1.9
Rev: src/pike_threadlib.h:1.47
Rev: src/pike_types.c:1.218
Rev: src/port.c:1.72
Rev: src/port.h:1.51
Rev: src/signal_handler.c:1.274
Rev: src/svalue.c:1.168
Rev: src/threads.c:1.219

2:   || 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
384:   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))); \
416:   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))); \
433:   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); \
444:   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))) \
456:   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))) \
473:   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)( \
485:    ); \    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; \
495:   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)) \    { \
605:    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; \
631:    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); \    } \    \