diff --git a/src/block_alloc.h b/src/block_alloc.h index 55dcd5d4b0a7438d535ec81c96a2f03b6c190963..a0bc5573c2953d94a689277f39535ed5dca476de 100644 --- a/src/block_alloc.h +++ b/src/block_alloc.h @@ -1,4 +1,4 @@ -/* $Id: block_alloc.h,v 1.21 2000/05/16 18:32:34 hubbe Exp $ */ +/* $Id: block_alloc.h,v 1.22 2000/08/10 09:12:39 grubba Exp $ */ #undef PRE_INIT_BLOCK #undef INIT_BLOCK #undef EXIT_BLOCK @@ -113,11 +113,11 @@ void PIKE_CONCAT3(count_memory_in_,DATA,s)(INT32 *num_, INT32 *size_) \ BLOCK_ALLOC(DATA,BSIZE) \ \ struct DATA **PIKE_CONCAT(DATA,_hash_table)=0; \ -int PIKE_CONCAT(DATA,_hash_table_size)=0; \ -static int PIKE_CONCAT(num_,DATA)=0; \ +ptrdiff_t PIKE_CONCAT(DATA,_hash_table_size)=0; \ +static ptrdiff_t PIKE_CONCAT(num_,DATA)=0; \ \ inline struct DATA * \ - PIKE_CONCAT(really_low_find_,DATA)(void *ptr, int hval) \ + PIKE_CONCAT(really_low_find_,DATA)(void *ptr, ptrdiff_t hval) \ { \ struct DATA *p,**pp; \ p=PIKE_CONCAT(DATA,_hash_table)[hval]; \ @@ -139,7 +139,7 @@ inline struct DATA * \ \ struct DATA *PIKE_CONCAT(find_,DATA)(void *ptr) \ { \ - unsigned int hval=(long)ptr; \ + size_t hval = (size_t)ptr; \ hval%=PIKE_CONCAT(DATA,_hash_table_size); \ return PIKE_CONCAT(really_low_find_,DATA)(ptr, hval); \ } \ @@ -150,8 +150,8 @@ static void PIKE_CONCAT(DATA,_rehash)() \ /* Time to re-hash */ \ struct DATA **old_hash= PIKE_CONCAT(DATA,_hash_table); \ struct DATA *p; \ - int hval; \ - int e=PIKE_CONCAT(DATA,_hash_table_size); \ + ptrdiff_t hval; \ + ptrdiff_t e=PIKE_CONCAT(DATA,_hash_table_size); \ \ PIKE_CONCAT(DATA,_hash_table_size)*=2; \ PIKE_CONCAT(DATA,_hash_table_size)++; \ @@ -166,7 +166,7 @@ static void PIKE_CONCAT(DATA,_rehash)() \ while((p=old_hash[e])) \ { \ old_hash[e]=p->BLOCK_ALLOC_NEXT; \ - hval=(long)(p-> data); \ + hval=(ptrdiff_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; \ @@ -180,7 +180,7 @@ static void PIKE_CONCAT(DATA,_rehash)() \ } \ \ \ -struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr, int hval) \ +struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr, ptrdiff_t hval) \ { \ struct DATA *p; \ \ @@ -192,7 +192,7 @@ struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr, int hval) \ PIKE_CONCAT(DATA,_hash_table_size)) \ { \ PIKE_CONCAT(DATA,_rehash)(); \ - hval=(long)ptr; \ + hval=(ptrdiff_t)ptr; \ hval%=PIKE_CONCAT(DATA,_hash_table_size); \ } \ \ @@ -206,7 +206,7 @@ struct DATA *PIKE_CONCAT(make_,DATA)(void *ptr, int hval) \ struct DATA *PIKE_CONCAT(get_,DATA)(void *ptr) \ { \ struct DATA *p; \ - int hval=(long)ptr; \ + ptrdiff_t hval=(ptrdiff_t)ptr; \ hval%=PIKE_CONCAT(DATA,_hash_table_size); \ if((p=PIKE_CONCAT(really_low_find_,DATA)(ptr, hval))) \ return p; \ @@ -217,7 +217,7 @@ struct DATA *PIKE_CONCAT(get_,DATA)(void *ptr) \ int PIKE_CONCAT3(check_,DATA,_semafore)(void *ptr) \ { \ struct DATA *p; \ - int hval=(long)ptr; \ + ptrdiff_t hval=(ptrdiff_t)ptr; \ hval%=PIKE_CONCAT(DATA,_hash_table_size); \ if((p=PIKE_CONCAT(really_low_find_,DATA)(ptr, hval))) \ return 0; \ @@ -229,7 +229,7 @@ int PIKE_CONCAT3(check_,DATA,_semafore)(void *ptr) \ int PIKE_CONCAT(remove_,DATA)(void *ptr) \ { \ struct DATA *p; \ - int hval=(long)ptr; \ + ptrdiff_t hval=(ptrdiff_t)ptr; \ if(!PIKE_CONCAT(DATA,_hash_table)) return 0; \ hval%=PIKE_CONCAT(DATA,_hash_table_size); \ if((p=PIKE_CONCAT(really_low_find_,DATA)(ptr, hval))) \ @@ -246,7 +246,7 @@ int PIKE_CONCAT(remove_,DATA)(void *ptr) \ void PIKE_CONCAT3(init_,DATA,_hash)(void) \ { \ extern INT32 hashprimes[32]; \ - extern int my_log2(unsigned INT32 x); \ + extern ptrdiff_t my_log2(size_t x); \ PIKE_CONCAT(DATA,_hash_table_size)=hashprimes[my_log2(BSIZE)]; \ \ PIKE_CONCAT(DATA,_hash_table)=(struct DATA **) \ diff --git a/src/cpp.c b/src/cpp.c index 96cd61040be5cc7cc0d09934ed1687958091ce0d..6b804d952e5dd0f159edaaa604a7494555635585 100644 --- a/src/cpp.c +++ b/src/cpp.c @@ -5,7 +5,7 @@ \*/ /* - * $Id: cpp.c,v 1.72 2000/08/10 08:50:01 grubba Exp $ + * $Id: cpp.c,v 1.73 2000/08/10 08:52:09 grubba Exp $ */ #include "global.h" #include "stralloc.h" @@ -790,8 +790,9 @@ static struct pike_string *filter_bom(struct pike_string *data) return(data); } -static INT32 low_cpp(struct cpp *this, void *data, ptrdiff_t len, int shift, - int flags, int auto_convert, struct pike_string *charset); +static ptrdiff_t low_cpp(struct cpp *this, void *data, ptrdiff_t len, + int shift, int flags, int auto_convert, + struct pike_string *charset); #define SHIFT 0 #include "preprocessor.h" @@ -805,8 +806,9 @@ static INT32 low_cpp(struct cpp *this, void *data, ptrdiff_t len, int shift, #include "preprocessor.h" #undef SHIFT -static INT32 low_cpp(struct cpp *this, void *data, ptrdiff_t len, int shift, - int flags, int auto_convert, struct pike_string *charset) +static ptrdiff_t low_cpp(struct cpp *this, void *data, ptrdiff_t len, + int shift, int flags, int auto_convert, + struct pike_string *charset) { switch(shift) { case 0: diff --git a/src/cyclic.c b/src/cyclic.c index 14bf52d56100511bb9a3966a5c698349178c91a8..f686f18574069fa228c3c4fdc7454321bfb2ec37 100644 --- a/src/cyclic.c +++ b/src/cyclic.c @@ -1,7 +1,7 @@ #include "global.h" #include "cyclic.h" -RCSID("$Id: cyclic.c,v 1.4 2000/05/07 00:39:17 hubbe Exp $"); +RCSID("$Id: cyclic.c,v 1.5 2000/08/10 08:54:34 grubba Exp $"); #define CYCLIC_HASH_SIZE 4711 @@ -9,15 +9,15 @@ CYCLIC *cyclic_hash[CYCLIC_HASH_SIZE]; static void low_unlink_cyclic(CYCLIC *c) { - unsigned int h; + size_t h; CYCLIC **p; - h=(int)c->id; + h=(ptrdiff_t)c->id; h*=33; - h|=(int)c->a; + h|=(ptrdiff_t)c->a; h*=33; - h|=(int)c->b; + h|=(ptrdiff_t)c->b; h*=33; - h|=(int)c->th; + h|=(ptrdiff_t)c->th; h*=33; h%=CYCLIC_HASH_SIZE; @@ -44,17 +44,17 @@ void *begin_cyclic(CYCLIC *c, void *a, void *b) { - unsigned int h; + size_t h; void *ret=0; CYCLIC *p; - h=(int)id; + h=(ptrdiff_t)id; h*=33; - h|=(int)a; + h|=(ptrdiff_t)a; h*=33; - h|=(int)b; + h|=(ptrdiff_t)b; h*=33; - h|=(int)th; + h|=(ptrdiff_t)th; h*=33; h%=CYCLIC_HASH_SIZE; @@ -67,7 +67,7 @@ void *begin_cyclic(CYCLIC *c, } } - c->ret=(void *)1; + c->ret=(void *)(ptrdiff_t)1; c->a=a; c->b=b; c->id=id; diff --git a/src/docode.c b/src/docode.c index 9b9358c4ba0e38856e32a32aca0af440114b34ed..9222962b54b187cc6b1e9c5419214ba311945a01 100644 --- a/src/docode.c +++ b/src/docode.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: docode.c,v 1.76 2000/07/12 12:38:40 grubba Exp $"); +RCSID("$Id: docode.c,v 1.77 2000/08/10 09:01:54 grubba Exp $"); #include "las.h" #include "program.h" #include "pike_types.h" @@ -273,7 +273,8 @@ static int do_docode2(node *n,int flags) /* Stack check */ { - long x_= ((char *)&x_) + STACK_DIRECTION * (32768) - Pike_interpreter.stack_top ; + ptrdiff_t x_= ((char *)&x_) + STACK_DIRECTION * (32768) - + Pike_interpreter.stack_top ; x_*=STACK_DIRECTION; if(x_>0) { diff --git a/src/dynamic_buffer.c b/src/dynamic_buffer.c index 20d4d45af9618b572d0b572401da39dabdb11c16..6958cb64561f36184305465f42887d89a84fa82e 100644 --- a/src/dynamic_buffer.c +++ b/src/dynamic_buffer.c @@ -10,7 +10,7 @@ #include "error.h" #include "pike_memory.h" -RCSID("$Id: dynamic_buffer.c,v 1.11 2000/08/04 10:59:22 grubba Exp $"); +RCSID("$Id: dynamic_buffer.c,v 1.12 2000/08/10 09:03:10 grubba Exp $"); static dynamic_buffer buff; @@ -128,7 +128,7 @@ PMOD_EXPORT struct pike_string *debug_low_free_buf(dynamic_buffer *buf) PMOD_EXPORT struct pike_string *debug_free_buf(void) { return low_free_buf(&buff); } PMOD_EXPORT char *make_buf_space(INT32 space) { return low_make_buf_space(space,&buff); } PMOD_EXPORT void my_putchar(char b) { low_my_putchar(b,&buff); } -PMOD_EXPORT void my_binary_strcat(const char *b,INT32 l) { low_my_binary_strcat(b,l,&buff); } +PMOD_EXPORT void my_binary_strcat(const char *b, ptrdiff_t l) { low_my_binary_strcat(b,l,&buff); } PMOD_EXPORT void my_strcat(const char *b) { my_binary_strcat(b,strlen(b)); } PMOD_EXPORT void init_buf(void) { low_reinit_buf(&buff); } PMOD_EXPORT void init_buf_with_string(string s) { low_init_buf_with_string(s,&buff); } diff --git a/src/dynamic_load.c b/src/dynamic_load.c index dba154a419ed0a321e5522ce2717fabe1dc6430e..6ca7dee7544490b5903c8a42f0065db37b3b852b 100644 --- a/src/dynamic_load.c +++ b/src/dynamic_load.c @@ -8,7 +8,7 @@ # include "pike_macros.h" # include "main.h" -RCSID("$Id: dynamic_load.c,v 1.41 2000/07/28 17:16:54 hubbe Exp $"); +RCSID("$Id: dynamic_load.c,v 1.42 2000/08/10 09:04:42 grubba Exp $"); #endif /* !TESTING */ @@ -51,9 +51,9 @@ typedef void (*modfun)(void); #ifdef USE_LOADLIBRARY #include <windows.h> -static TCHAR *convert_string(const char *str, int len) +static TCHAR *convert_string(const char *str, ptrdiff_t len) { - int e; + ptrdiff_t e; TCHAR *ret=(TCHAR *)xalloc((len+1) * sizeof(TCHAR)); for(e=0;e<len;e++) ret[e]=EXTRACT_UCHAR(str+e); ret[e]=0; diff --git a/src/encode.c b/src/encode.c index b2f95fb23690af0e8757641db24a195b6ca6b3af..57db65daaf575dbf3a974015731240b3ce273161 100644 --- a/src/encode.c +++ b/src/encode.c @@ -25,7 +25,7 @@ #include "version.h" #include "bignum.h" -RCSID("$Id: encode.c,v 1.62 2000/07/07 19:27:12 grubba Exp $"); +RCSID("$Id: encode.c,v 1.63 2000/08/10 09:01:00 grubba Exp $"); /* #define ENCODE_DEBUG */ @@ -186,14 +186,14 @@ static int type_to_tag(int type) static int (*tag_to_type)(int) = type_to_tag; /* Let's cram those bits... */ -static void code_entry(int tag, INT32 num, struct encode_data *data) +static void code_entry(int tag, ptrdiff_t num, struct encode_data *data) { int t; EDB( - fprintf(stderr,"encode: code_entry(tag=%d (%s), num=%d)\n", + fprintf(stderr,"encode: code_entry(tag=%d (%s), num=%ld)\n", tag, get_name_of_type(tag_to_type(tag)), - num) ); + (long)num) ); if(num<0) { tag |= TAG_NEG; @@ -229,7 +229,7 @@ static void code_entry(int tag, INT32 num, struct encode_data *data) } } -static void code_number(INT32 num, struct encode_data *data) +static void code_number(ptrdiff_t num, struct encode_data *data) { code_entry(num & 15, num >> 4, data); } @@ -1602,9 +1602,10 @@ static unsigned char extract_char(char **v, INT32 *l) return ((unsigned char *)(*v))[-1]; } -static INT32 extract_int(char **v, INT32 *l) +static ptrdiff_t extract_int(char **v, INT32 *l) { - INT32 j,i; + INT32 j; + ptrdiff_t i; j=extract_char(v,l); if(j & 0x80) return (j & 0x7f); diff --git a/src/fsort_template.h b/src/fsort_template.h index 00b4de16288152e8c0ccd513b9d9dcd302f9bef2..dd8bbaf1dc948445ebb972254b7aa5ccdab10e78 100644 --- a/src/fsort_template.h +++ b/src/fsort_template.h @@ -1,5 +1,5 @@ /* - * $Id: fsort_template.h,v 1.7 2000/07/28 17:16:55 hubbe Exp $ + * $Id: fsort_template.h,v 1.8 2000/08/10 09:07:57 grubba Exp $ */ #ifndef SWAP @@ -14,7 +14,7 @@ #define INC(X) X=STEP(X,1) #define DEC(X) X=STEP(X,-1) -#define SIZE ((long)(char *)STEP((TYPE *)0,1)) +#define SIZE ((ptrdiff_t)(char *)STEP((TYPE *)0,1)) #define PARENT(X) (((X)-1)>>1) #define CHILD1(X) (((X)<<1)+1) @@ -45,7 +45,7 @@ static void MKNAME(_do_sort)(register TYPE *bas, }else{ if(--max_recursion <= 0) { - long howmany,x,y,z; + ptrdiff_t howmany,x,y,z; howmany=((((char *)last)-((char *)bas))/SIZE)+1; if(howmany<2) return; diff --git a/src/pike_macros.h b/src/pike_macros.h index 05bbf66a614e79614ab374d981a1fbe3dbaccc4e..d0b9d38046c612363ec77382d730a834670cceba 100644 --- a/src/pike_macros.h +++ b/src/pike_macros.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: pike_macros.h,v 1.18 2000/08/03 13:02:13 grubba Exp $ + * $Id: pike_macros.h,v 1.19 2000/08/10 09:13:20 grubba Exp $ */ #ifndef MACROS_H #define MACROS_H @@ -96,6 +96,6 @@ /* Needed for fsort_template.h */ -int my_log2(unsigned INT32 x); +ptrdiff_t my_log2(size_t x); #endif diff --git a/src/stuff.c b/src/stuff.c index f1127707ee5867e913ac55f4af153937da579d42..031c17c6ec911963da7488acae55879f1bd01a66 100644 --- a/src/stuff.c +++ b/src/stuff.c @@ -5,7 +5,7 @@ \*/ /* - * $Id: stuff.c,v 1.11 2000/07/28 17:16:55 hubbe Exp $ + * $Id: stuff.c,v 1.12 2000/08/10 09:20:00 grubba Exp $ */ #include "global.h" #include "stuff.h" @@ -51,7 +51,7 @@ PMOD_EXPORT INT32 hashprimes[32] = /* same thing as (int)floor(log((double)x) / log(2.0)) */ /* Except a bit quicker :) (hopefully) */ -PMOD_EXPORT int my_log2(unsigned INT32 x) +PMOD_EXPORT int my_log2(size_t x) { static signed char bit[256] = { @@ -72,7 +72,18 @@ PMOD_EXPORT int my_log2(unsigned INT32 x) 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, }; - register unsigned int tmp; + register size_t tmp; +#if SIZEOF_CHAR_P > 4 + if((tmp=(x>>32))) + { + if((x=(tmp>>16))) { + if((tmp=(x>>8))) return bit[tmp]+56; + return bit[x]+48; + } + if((x=(tmp>>8))) return bit[x]+40; + return bit[tmp]+32; + } +#endif /* SIZEOF_CHAP_P > 4 */ if((tmp=(x>>16))) { if((x=(tmp>>8))) return bit[x]+24; diff --git a/src/stuff.h b/src/stuff.h index e9ffedf957f379254ee070b61ac12989ae959609..d2aa4fc7336c83d3c43eda4499c78ffb7acaae2f 100644 --- a/src/stuff.h +++ b/src/stuff.h @@ -5,7 +5,7 @@ \*/ /* - * $Id: stuff.h,v 1.7 1999/03/01 05:32:40 hubbe Exp $ + * $Id: stuff.h,v 1.8 2000/08/10 09:13:47 grubba Exp $ */ #ifndef STUFF_H #define STUFF_H @@ -13,7 +13,7 @@ #include "global.h" /* Prototypes begin here */ -int my_log2(unsigned INT32 x); +ptrdiff_t my_log2(size_t x); int count_bits(unsigned INT32 x); int is_more_than_one_bit(unsigned INT32 x); double my_strtod(char *nptr, char **endptr);