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. */
#ifndef __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
......@@ -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;
}
......
......@@ -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
{
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -52,6 +52,9 @@ extern int idxsize;
#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)
#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;
}
......
......@@ -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;
......
......@@ -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;
......
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