From: Kresten Krab Thorup Date: Mon, 26 Apr 1993 09:45:17 +0000 (+0000) Subject: Changed unsigned int to size_t when casting pointers to integers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=33d9bef5abfde175c943db1d2c1a3172c0ba21e4;p=gcc.git Changed unsigned int to size_t when casting pointers to integers From-SVN: r4233 --- diff --git a/gcc/objc/hash.h b/gcc/objc/hash.h index 3813051250f..6516b8a407c 100644 --- a/gcc/objc/hash.h +++ b/gcc/objc/hash.h @@ -27,7 +27,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __hash_INCLUDE_GNU #define __hash_INCLUDE_GNU - +#ifdef IN_OBJC +#include "gstddef.h" +#else +#include +#endif /* * This data structure is used to hold items @@ -152,10 +156,10 @@ void *hash_value_for_key (cache_ptr cache, const void *key); manipulation of the key pointer. (Use the lowest bits except for those likely to be 0 due to alignment.) */ -static inline unsigned int +static inline unsigned int hash_ptr (cache_ptr cache, const void *key) { - return ((unsigned int)key / sizeof (void *)) & cache->mask; + return ((size_t)key / sizeof (void *)) & cache->mask; } diff --git a/gcc/objc/init.c b/gcc/objc/init.c index eb31f246d68..453f166ef1c 100644 --- a/gcc/objc/init.c +++ b/gcc/objc/init.c @@ -241,7 +241,7 @@ __objc_init_protocols (struct objc_protocol_list* protos) for(i = 0; i < protos->count; i++) { - if (((int)((id)protos->list[i])->class_pointer) == PROTOCOL_VERSION) + if (((size_t)((id)protos->list[i])->class_pointer) == PROTOCOL_VERSION) ((id)protos->list[i])->class_pointer = proto_class; else { diff --git a/gcc/objc/objc.h b/gcc/objc/objc.h index ea6c1adb475..8d7b0594a83 100644 --- a/gcc/objc/objc.h +++ b/gcc/objc/objc.h @@ -485,7 +485,7 @@ extern __inline__ IMP objc_msg_lookup(id receiver, SEL op) { if(receiver) - return sarray_get(receiver->class_pointer->dtable, (unsigned int) op); + return sarray_get(receiver->class_pointer->dtable, (size_t) op); else return nil_method; } diff --git a/gcc/objc/sarray.c b/gcc/objc/sarray.c index 8ffab2254b3..50deeb0cf39 100644 --- a/gcc/objc/sarray.c +++ b/gcc/objc/sarray.c @@ -46,10 +46,10 @@ sarray_at_put(struct sarray* array, sidx index, void* element) struct sindex** the_index; struct sbucket** the_bucket; #ifdef OBJC_SPARSE3 - unsigned int ioffset; + size_t ioffset; #endif - unsigned int boffset; - unsigned int eoffset; + size_t boffset; + size_t eoffset; #ifdef PRECOMPUTE_SELECTORS union sofftype xx; xx.idx = index; @@ -139,9 +139,9 @@ struct sarray* sarray_new (int size, void* default_element) { #ifdef OBJC_SPARSE3 - unsigned num_indices = ((size-1)/(INDEX_CAPACITY))+1; + size_t num_indices = ((size-1)/(INDEX_CAPACITY))+1; #else /* OBJC_SPARSE2 */ - unsigned num_indices = ((size-1)/BUCKET_SIZE)+1; + size_t num_indices = ((size-1)/BUCKET_SIZE)+1; #endif int counter; struct sarray* arr; @@ -314,9 +314,9 @@ sarray_realloc(struct sarray* array, int newsize) void sarray_free(struct sarray* array) { #ifdef OBJC_SPARSE3 - unsigned int old_max_index = (array->capacity-1)/INDEX_CAPACITY; + size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY; #else - unsigned int old_max_index = (array->capacity-1)/BUCKET_SIZE; + size_t old_max_index = (array->capacity-1)/BUCKET_SIZE; #endif int counter = 0; @@ -393,9 +393,9 @@ struct sarray* sarray_lazy_copy(struct sarray* oarr) { #ifdef OBJC_SPARSE3 - unsigned num_indices = ((oarr->capacity-1)/INDEX_CAPACITY)+1; + size_t num_indices = ((oarr->capacity-1)/INDEX_CAPACITY)+1; #else /* OBJC_SPARSE2 */ - unsigned num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1; + size_t num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1; #endif struct sarray* arr; diff --git a/gcc/objc/sarray.h b/gcc/objc/sarray.h index 6d405001ae8..1d96078dc74 100644 --- a/gcc/objc/sarray.h +++ b/gcc/objc/sarray.h @@ -52,6 +52,9 @@ extern int idxsize; #include +/* An unsigned integer of same size as a pointer */ +#define SIZET_BITS (sizeof(size_t)*8) + #if defined(sparc) || defined(OBJC_SPARSE2) #define PRECOMPUTE_SELECTORS #endif @@ -79,24 +82,24 @@ extern int idxsize; #endif /* OBJC_SPARSE2 */ -typedef unsigned int sidx; +typedef size_t sidx; #ifdef PRECOMPUTE_SELECTORS struct soffset { #ifdef OBJC_SPARSE3 - unsigned char unused; - unsigned char eoffset; - unsigned char boffset; - unsigned char ioffset; + unsigned int unused : SIZET_BITS/4; + unsigned int eoffset : SIZET_BITS/4; + unsigned int boffset : SIZET_BITS/4; + unsigned int ioffset : SIZET_BITS/4; #else /* OBJC_SPARSE2 */ #ifdef sparc - unsigned int boffset : 30 - BUCKET_BITS; + unsigned int boffset : (SIZET_BITS - 2) - BUCKET_BITS; unsigned int eoffset : BUCKET_BITS; unsigned int unused : 2; #else - unsigned short boffset; - unsigned short eoffset; + unsigned int boffset : SIZET_BITS/2; + unsigned int eoffset : SIZET_BITS/2; #endif #endif /* OBJC_SPARSE2 */ }; @@ -165,7 +168,7 @@ soffset_decode(sidx index) } static inline sidx -soffset_encode(unsigned int offset) +soffset_encode(size_t offset) { union sofftype x; x.off.eoffset = offset%BUCKET_SIZE; @@ -180,14 +183,14 @@ soffset_encode(unsigned int offset) #else /* not PRECOMPUTE_SELECTORS */ -static inline unsigned int +static inline size_t soffset_decode(sidx index) { return index; } static inline sidx -soffset_encode(unsigned int offset) +soffset_encode(size_t offset) { return offset; } diff --git a/gcc/objc/selector.c b/gcc/objc/selector.c index fdbe6699c24..6eb2e43199c 100644 --- a/gcc/objc/selector.c +++ b/gcc/objc/selector.c @@ -95,8 +95,8 @@ sel_get_uid (const char *name) const char* sel_get_name (SEL selector) { - if ((soffset_decode((unsigned)selector) > 0) - && (soffset_decode((unsigned)selector) <= __objc_selector_max_index)) + if ((soffset_decode((sidx)selector) > 0) + && (soffset_decode((sidx)selector) <= __objc_selector_max_index)) return sarray_get (__objc_selector_array, (sidx) selector); else return NULL; diff --git a/gcc/objc/sendmsg.c b/gcc/objc/sendmsg.c index 06fd95a730d..1e14470cab6 100644 --- a/gcc/objc/sendmsg.c +++ b/gcc/objc/sendmsg.c @@ -68,10 +68,10 @@ __inline__ IMP get_imp (Class_t class, SEL sel) { #ifdef OBJC_SPARSE_LOOKUP - void* res = sarray_get (class->dtable, (unsigned int) sel); + void* res = sarray_get (class->dtable, (size_t) sel); if(res == __objc_init_install_dtable) __objc_install_dispatch_table_for_class (class); - return sarray_get (class->dtable, (unsigned int) sel); + return sarray_get (class->dtable, (size_t) sel); #else return cache_get (class, sel); #endif @@ -529,7 +529,7 @@ __objc_double_cache(Cache_t cache) static Cache_t __objc_cache_insert(Cache_t cache, SEL op, IMP imp) { - int index = ((unsigned int)op)&(cache)->mask; + int index = ((size_t)op)&(cache)->mask; if(op == 0) return cache;