Commit 33d9bef5 by Kresten Krab Thorup

Changed unsigned int to size_t when casting pointers to integers

From-SVN: r4233
parent e312f965
...@@ -27,7 +27,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ ...@@ -27,7 +27,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef __hash_INCLUDE_GNU #ifndef __hash_INCLUDE_GNU
#define __hash_INCLUDE_GNU #define __hash_INCLUDE_GNU
#ifdef IN_OBJC
#include "gstddef.h"
#else
#include <stddef.h>
#endif
/* /*
* This data structure is used to hold items * This data structure is used to hold items
...@@ -152,10 +156,10 @@ void *hash_value_for_key (cache_ptr cache, const void *key); ...@@ -152,10 +156,10 @@ void *hash_value_for_key (cache_ptr cache, const void *key);
manipulation of the key pointer. (Use the lowest bits manipulation of the key pointer. (Use the lowest bits
except for those likely to be 0 due to alignment.) */ 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) hash_ptr (cache_ptr cache, const void *key)
{ {
return ((unsigned int)key / sizeof (void *)) & cache->mask; return ((size_t)key / sizeof (void *)) & cache->mask;
} }
......
...@@ -241,7 +241,7 @@ __objc_init_protocols (struct objc_protocol_list* protos) ...@@ -241,7 +241,7 @@ __objc_init_protocols (struct objc_protocol_list* protos)
for(i = 0; i < protos->count; i++) 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; ((id)protos->list[i])->class_pointer = proto_class;
else else
{ {
......
...@@ -485,7 +485,7 @@ extern __inline__ IMP ...@@ -485,7 +485,7 @@ extern __inline__ IMP
objc_msg_lookup(id receiver, SEL op) objc_msg_lookup(id receiver, SEL op)
{ {
if(receiver) if(receiver)
return sarray_get(receiver->class_pointer->dtable, (unsigned int) op); return sarray_get(receiver->class_pointer->dtable, (size_t) op);
else else
return nil_method; return nil_method;
} }
......
...@@ -46,10 +46,10 @@ sarray_at_put(struct sarray* array, sidx index, void* element) ...@@ -46,10 +46,10 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
struct sindex** the_index; struct sindex** the_index;
struct sbucket** the_bucket; struct sbucket** the_bucket;
#ifdef OBJC_SPARSE3 #ifdef OBJC_SPARSE3
unsigned int ioffset; size_t ioffset;
#endif #endif
unsigned int boffset; size_t boffset;
unsigned int eoffset; size_t eoffset;
#ifdef PRECOMPUTE_SELECTORS #ifdef PRECOMPUTE_SELECTORS
union sofftype xx; union sofftype xx;
xx.idx = index; xx.idx = index;
...@@ -139,9 +139,9 @@ struct sarray* ...@@ -139,9 +139,9 @@ struct sarray*
sarray_new (int size, void* default_element) sarray_new (int size, void* default_element)
{ {
#ifdef OBJC_SPARSE3 #ifdef OBJC_SPARSE3
unsigned num_indices = ((size-1)/(INDEX_CAPACITY))+1; size_t num_indices = ((size-1)/(INDEX_CAPACITY))+1;
#else /* OBJC_SPARSE2 */ #else /* OBJC_SPARSE2 */
unsigned num_indices = ((size-1)/BUCKET_SIZE)+1; size_t num_indices = ((size-1)/BUCKET_SIZE)+1;
#endif #endif
int counter; int counter;
struct sarray* arr; struct sarray* arr;
...@@ -314,9 +314,9 @@ sarray_realloc(struct sarray* array, int newsize) ...@@ -314,9 +314,9 @@ sarray_realloc(struct sarray* array, int newsize)
void void
sarray_free(struct sarray* array) { sarray_free(struct sarray* array) {
#ifdef OBJC_SPARSE3 #ifdef OBJC_SPARSE3
unsigned int old_max_index = (array->capacity-1)/INDEX_CAPACITY; size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY;
#else #else
unsigned int old_max_index = (array->capacity-1)/BUCKET_SIZE; size_t old_max_index = (array->capacity-1)/BUCKET_SIZE;
#endif #endif
int counter = 0; int counter = 0;
...@@ -393,9 +393,9 @@ struct sarray* ...@@ -393,9 +393,9 @@ struct sarray*
sarray_lazy_copy(struct sarray* oarr) sarray_lazy_copy(struct sarray* oarr)
{ {
#ifdef OBJC_SPARSE3 #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 */ #else /* OBJC_SPARSE2 */
unsigned num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1; size_t num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1;
#endif #endif
struct sarray* arr; struct sarray* arr;
......
...@@ -52,6 +52,9 @@ extern int idxsize; ...@@ -52,6 +52,9 @@ extern int idxsize;
#include <assert.h> #include <assert.h>
/* An unsigned integer of same size as a pointer */
#define SIZET_BITS (sizeof(size_t)*8)
#if defined(sparc) || defined(OBJC_SPARSE2) #if defined(sparc) || defined(OBJC_SPARSE2)
#define PRECOMPUTE_SELECTORS #define PRECOMPUTE_SELECTORS
#endif #endif
...@@ -79,24 +82,24 @@ extern int idxsize; ...@@ -79,24 +82,24 @@ extern int idxsize;
#endif /* OBJC_SPARSE2 */ #endif /* OBJC_SPARSE2 */
typedef unsigned int sidx; typedef size_t sidx;
#ifdef PRECOMPUTE_SELECTORS #ifdef PRECOMPUTE_SELECTORS
struct soffset { struct soffset {
#ifdef OBJC_SPARSE3 #ifdef OBJC_SPARSE3
unsigned char unused; unsigned int unused : SIZET_BITS/4;
unsigned char eoffset; unsigned int eoffset : SIZET_BITS/4;
unsigned char boffset; unsigned int boffset : SIZET_BITS/4;
unsigned char ioffset; unsigned int ioffset : SIZET_BITS/4;
#else /* OBJC_SPARSE2 */ #else /* OBJC_SPARSE2 */
#ifdef sparc #ifdef sparc
unsigned int boffset : 30 - BUCKET_BITS; unsigned int boffset : (SIZET_BITS - 2) - BUCKET_BITS;
unsigned int eoffset : BUCKET_BITS; unsigned int eoffset : BUCKET_BITS;
unsigned int unused : 2; unsigned int unused : 2;
#else #else
unsigned short boffset; unsigned int boffset : SIZET_BITS/2;
unsigned short eoffset; unsigned int eoffset : SIZET_BITS/2;
#endif #endif
#endif /* OBJC_SPARSE2 */ #endif /* OBJC_SPARSE2 */
}; };
...@@ -165,7 +168,7 @@ soffset_decode(sidx index) ...@@ -165,7 +168,7 @@ soffset_decode(sidx index)
} }
static inline sidx static inline sidx
soffset_encode(unsigned int offset) soffset_encode(size_t offset)
{ {
union sofftype x; union sofftype x;
x.off.eoffset = offset%BUCKET_SIZE; x.off.eoffset = offset%BUCKET_SIZE;
...@@ -180,14 +183,14 @@ soffset_encode(unsigned int offset) ...@@ -180,14 +183,14 @@ soffset_encode(unsigned int offset)
#else /* not PRECOMPUTE_SELECTORS */ #else /* not PRECOMPUTE_SELECTORS */
static inline unsigned int static inline size_t
soffset_decode(sidx index) soffset_decode(sidx index)
{ {
return index; return index;
} }
static inline sidx static inline sidx
soffset_encode(unsigned int offset) soffset_encode(size_t offset)
{ {
return offset; return offset;
} }
......
...@@ -95,8 +95,8 @@ sel_get_uid (const char *name) ...@@ -95,8 +95,8 @@ sel_get_uid (const char *name)
const char* const char*
sel_get_name (SEL selector) sel_get_name (SEL selector)
{ {
if ((soffset_decode((unsigned)selector) > 0) if ((soffset_decode((sidx)selector) > 0)
&& (soffset_decode((unsigned)selector) <= __objc_selector_max_index)) && (soffset_decode((sidx)selector) <= __objc_selector_max_index))
return sarray_get (__objc_selector_array, (sidx) selector); return sarray_get (__objc_selector_array, (sidx) selector);
else else
return NULL; return NULL;
......
...@@ -68,10 +68,10 @@ __inline__ IMP ...@@ -68,10 +68,10 @@ __inline__ IMP
get_imp (Class_t class, SEL sel) get_imp (Class_t class, SEL sel)
{ {
#ifdef OBJC_SPARSE_LOOKUP #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) if(res == __objc_init_install_dtable)
__objc_install_dispatch_table_for_class (class); __objc_install_dispatch_table_for_class (class);
return sarray_get (class->dtable, (unsigned int) sel); return sarray_get (class->dtable, (size_t) sel);
#else #else
return cache_get (class, sel); return cache_get (class, sel);
#endif #endif
...@@ -529,7 +529,7 @@ __objc_double_cache(Cache_t cache) ...@@ -529,7 +529,7 @@ __objc_double_cache(Cache_t cache)
static Cache_t static Cache_t
__objc_cache_insert(Cache_t cache, SEL op, IMP imp) __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) if(op == 0)
return cache; return cache;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment