pike.git/
src/
block_alloc.h
Branch:
Tag:
Non-build tags
All tags
No tags
2001-07-04
2001-07-04 06:44:50 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
59e011bd8d076edd39908d4d8645a4f60be84746 (
29
lines) (+
15
/-
14
)
[
Show
|
Annotate
]
Branch:
7.9
saner hashing
Rev: src/block_alloc.h:1.31
Rev: src/block_alloc_h.h:1.9
1:
-
/* $Id: block_alloc.h,v 1.
30
2001/07/
01
19
:
59
:
48
mast
Exp $ */
+
/* $Id: block_alloc.h,v 1.
31
2001/07/
04
06
:
44
:
50
hubbe
Exp $ */
#undef PRE_INIT_BLOCK #undef INIT_BLOCK #undef EXIT_BLOCK
157:
BLOCK_ALLOC(DATA,BSIZE) \ \ struct DATA **PIKE_CONCAT(DATA,_hash_table)=0; \
-
ptrdiff
_t PIKE_CONCAT(DATA,_hash_table_size)=0; \
-
static
ptrdiff
_t PIKE_CONCAT(num_,DATA)=0;
\
+
size
_t PIKE_CONCAT(DATA,_hash_table_size)=0;
\
+
static
size
_t PIKE_CONCAT(num_,DATA)=0; \
\ inline struct DATA * \
-
PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(void *ptr,
ptrdiff
_t hval) \
+
PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(void *ptr,
size
_t hval) \
{ \ struct DATA *p,**pp; \ p=PIKE_CONCAT(DATA,_hash_table)[hval]; \
203:
/* Time to re-hash */ \ struct DATA **old_hash; \ struct DATA *p; \
-
ptrdiff
_t hval;
\
-
ptrdiff
_t e; \
+
size
_t hval; \
+
size
_t e;
\
\ old_hash= PIKE_CONCAT(DATA,_hash_table); \ e=PIKE_CONCAT(DATA,_hash_table_size); \
217:
{ \ MEMSET(PIKE_CONCAT(DATA,_hash_table),0, \ sizeof(struct DATA *)*PIKE_CONCAT(DATA,_hash_table_size)); \
-
while(--
e
>
=
0) \
+
while(
e
-- >
0) \
{ \ while((p=old_hash[e])) \ { \ old_hash[e]=p->BLOCK_ALLOC_NEXT; \
-
hval=(
ptrdiff
_t)(p->data);
\
+
hval=(
size
_t)(p->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; \
236:
} \ \ \
-
struct DATA *PIKE_CONCAT3(make_,DATA,_unlocked)(void *ptr,
ptrdiff
_t hval) \
+
struct DATA *PIKE_CONCAT3(make_,DATA,_unlocked)(void *ptr,
size
_t hval) \
{ \ struct DATA *p; \ \
249:
PIKE_CONCAT(DATA,_hash_table_size)) \ { \ PIKE_CONCAT(DATA,_rehash)(); \
-
hval=(
ptrdiff
_t)ptr;
\
+
hval=(
size
_t)ptr; \
hval%=PIKE_CONCAT(DATA,_hash_table_size); \ } \ \
260:
return p; \ } \ \
-
struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr,
ptrdiff
_t hval) \
+
struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr,
size
_t hval)
\
{ \ struct DATA *p; \ DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \
272:
struct DATA *PIKE_CONCAT(get_,DATA)(void *ptr) \ { \ struct DATA *p; \
-
ptrdiff
_t hval=(
ptrdiff
_t)ptr;
\
+
size
_t hval=(
size
_t)ptr; \
DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \ hval%=PIKE_CONCAT(DATA,_hash_table_size); \ if(!(p=PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(ptr, hval))) \
284:
int PIKE_CONCAT3(check_,DATA,_semafore)(void *ptr) \ { \ struct DATA *p; \
-
ptrdiff
_t hval=(
ptrdiff
_t)ptr;
\
+
size
_t hval=(
size
_t)ptr; \
DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \ hval%=PIKE_CONCAT(DATA,_hash_table_size); \ if((p=PIKE_CONCAT3(really_low_find_,DATA,_unlocked)(ptr, hval))) \
301:
int PIKE_CONCAT(remove_,DATA)(void *ptr) \ { \ struct DATA *p; \
-
ptrdiff
_t hval=(
ptrdiff
_t)ptr;
\
+
size
_t hval=(
size
_t)ptr; \
DO_IF_RUN_UNLOCKED(mt_lock(&PIKE_CONCAT(DATA,_mutex))); \ if(!PIKE_CONCAT(DATA,_hash_table)) \ { \