aboutsummaryrefslogtreecommitdiff
path: root/libobjc
diff options
context:
space:
mode:
Diffstat (limited to 'libobjc')
-rw-r--r--libobjc/ChangeLog30
-rw-r--r--libobjc/Makefile.in8
-rw-r--r--libobjc/archive.c135
-rw-r--r--libobjc/encoding.c21
-rw-r--r--libobjc/hash.c34
-rw-r--r--libobjc/hash_compat.c97
-rw-r--r--libobjc/init.c11
-rw-r--r--libobjc/libobjc.def7
-rw-r--r--libobjc/objc/hash.h129
-rw-r--r--libobjc/selector.c16
10 files changed, 380 insertions, 108 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog
index 39b942461e6..a3298e9cea2 100644
--- a/libobjc/ChangeLog
+++ b/libobjc/ChangeLog
@@ -1,3 +1,33 @@
+2005-04-20 Release Manager
+
+ * GCC 4.0.0 released.
+
+2005-03-03 David Ayers <d.ayers@inode.at>
+
+ * objc/hash.h (OBJC_IGNORE_DEPRECATED_API): Update deprecated
+ version reference. Correct typo.
+
+2005-03-02 David Ayers <d.ayers@inode.at>
+
+ PR libobjc/19024
+ * Makefile.in (OBJS): Add hash_compat.lo.
+ (OBJS_GC): Add hash_compat_gc.lo.
+ (hash_compat_gc.lo): New target and rule.
+ * objc/hash.h (hash_new, hash_delete, hash_add, hash_remove)
+ (hash_next, hash_value_for_key, hash_is_key_in_hash)
+ (hash_ptr, hash_string, compare_ptrs, compare_strings): Prefix
+ with objc_. Add deprecated non prefixed inlined versions.
+ (OBJC_IGNORE_DEPRECATED_API): New macro to hide deprecated
+ declarations.
+ * hash.c (hash_new, hash_delete, hash_add, hash_remove, hash_next)
+ (hash_value_for_key, hash_is_key_in_hash): Prefix with objc_ and
+ update callers.
+ * hash_compat.c: New file.
+ * archive.c: Update callers.
+ * init.c: Likewise.
+ * selector.c: Likewise.
+ * libobjc.def: Add objc_ versions of hash functions.
+
2004-12-20 Andrew Pinski <pinskia@physics.uc.edu>
PR libobjc/12035
diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in
index 16c890ddd89..46e5ce56bee 100644
--- a/libobjc/Makefile.in
+++ b/libobjc/Makefile.in
@@ -145,13 +145,13 @@ OBJC_H = hash.h objc-list.h sarray.h objc.h objc-api.h \
OBJS = archive.lo class.lo encoding.lo gc.lo hash.lo init.lo linking.lo \
misc.lo nil_method.lo NXConstStr.lo Object.lo objects.lo \
Protocol.lo sarray.lo selector.lo sendmsg.lo thr.lo \
- $(OBJC_THREAD_FILE).lo exception.lo
+ $(OBJC_THREAD_FILE).lo exception.lo hash_compat.lo
OBJS_GC = archive_gc.lo class_gc.lo encoding_gc.lo gc_gc.lo hash_gc.lo \
init_gc.lo linking_gc.lo misc_gc.lo nil_method_gc.lo \
NXConstStr_gc.lo Object_gc.lo objects_gc.lo Protocol_gc.lo \
sarray_gc.lo selector_gc.lo sendmsg_gc.lo thr_gc.lo \
- $(OBJC_THREAD_FILE)_gc.lo exception_gc.lo
+ $(OBJC_THREAD_FILE)_gc.lo exception_gc.lo hash_compat_gc.lo
runtime-info.h:
echo "" > tmp-runtime.m
@@ -182,6 +182,10 @@ hash_gc.lo: hash.c
$(LIBTOOL_COMPILE) $(CC) -c -o $@ $(ALL_CFLAGS) $(OBJC_GCFLAGS) \
$(INCLUDES) $<
+hash_compat_gc.lo: hash_compat.c
+ $(LIBTOOL_COMPILE) $(CC) -c -o $@ $(ALL_CFLAGS) $(OBJC_GCFLAGS) \
+ $(INCLUDES) $<
+
init_gc.lo: init.c
$(LIBTOOL_COMPILE) $(CC) -c -o $@ $(ALL_CFLAGS) $(OBJC_GCFLAGS) \
$(INCLUDES) $<
diff --git a/libobjc/archive.c b/libobjc/archive.c
index 096ca6931dc..5c3616ca329 100644
--- a/libobjc/archive.c
+++ b/libobjc/archive.c
@@ -301,12 +301,13 @@ objc_write_string_atomic (struct objc_typed_stream *stream,
unsigned char *string, unsigned int nbytes)
{
unsigned long key;
- if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, string))))
+ if ((key = PTR2LONG(objc_hash_value_for_key (stream->stream_table, string))))
return objc_write_use_common (stream, key);
else
{
int length;
- hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(string)), string);
+ objc_hash_add (&stream->stream_table,
+ LONG2PTR(key=PTR2LONG(string)), string);
if ((length = objc_write_register_common (stream, key)))
return objc_write_string (stream, string, nbytes);
return length;
@@ -386,7 +387,7 @@ int
objc_write_object_reference (struct objc_typed_stream *stream, id object)
{
unsigned long key;
- if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object))))
+ if ((key = PTR2LONG(objc_hash_value_for_key (stream->object_table, object))))
return objc_write_use_common (stream, key);
__objc_write_extension (stream, _BX_OBJREF);
@@ -415,7 +416,7 @@ int
objc_write_object (struct objc_typed_stream *stream, id object)
{
unsigned long key;
- if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object))))
+ if ((key = PTR2LONG(objc_hash_value_for_key (stream->object_table, object))))
return objc_write_use_common (stream, key);
else if (object == nil)
@@ -424,7 +425,8 @@ objc_write_object (struct objc_typed_stream *stream, id object)
else
{
int length;
- hash_add (&stream->object_table, LONG2PTR(key=PTR2LONG(object)), object);
+ objc_hash_add (&stream->object_table,
+ LONG2PTR(key=PTR2LONG(object)), object);
if ((length = objc_write_register_common (stream, key)))
return __objc_write_object (stream, object);
return length;
@@ -446,12 +448,13 @@ objc_write_class (struct objc_typed_stream *stream,
struct objc_class *class)
{
unsigned long key;
- if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, class))))
+ if ((key = PTR2LONG(objc_hash_value_for_key (stream->stream_table, class))))
return objc_write_use_common (stream, key);
else
{
int length;
- hash_add (&stream->stream_table, LONG2PTR(key = PTR2LONG(class)), class);
+ objc_hash_add (&stream->stream_table,
+ LONG2PTR(key = PTR2LONG(class)), class);
if ((length = objc_write_register_common (stream, key)))
return __objc_write_class (stream, class);
return length;
@@ -482,12 +485,13 @@ objc_write_selector (struct objc_typed_stream *stream, SEL selector)
return __objc_write_selector (stream, selector);
sel_name = sel_get_name (selector);
- if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, sel_name))))
+ if ((key = PTR2LONG(objc_hash_value_for_key (stream->stream_table,
+ sel_name))))
return objc_write_use_common (stream, key);
else
{
int length;
- hash_add (&stream->stream_table,
+ objc_hash_add (&stream->stream_table,
LONG2PTR(key = PTR2LONG(sel_name)), (char *) sel_name);
if ((length = objc_write_register_common (stream, key)))
return __objc_write_selector (stream, selector);
@@ -755,7 +759,7 @@ objc_read_string (struct objc_typed_stream *stream,
int length = buf[0]&_B_VALUE;
(*string) = (char*)objc_malloc (length + 1);
if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), *string);
+ objc_hash_add (&stream->stream_table, LONG2PTR(key), *string);
len = (*stream->read) (stream->physical, *string, length);
(*string)[length] = '\0';
}
@@ -765,7 +769,7 @@ objc_read_string (struct objc_typed_stream *stream,
{
char *tmp;
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
- tmp = hash_value_for_key (stream->stream_table, LONG2PTR (key));
+ tmp = objc_hash_value_for_key (stream->stream_table, LONG2PTR (key));
*string = objc_malloc (strlen (tmp) + 1);
strcpy (*string, tmp);
}
@@ -778,7 +782,7 @@ objc_read_string (struct objc_typed_stream *stream,
if (len) {
(*string) = (char*)objc_malloc (nbytes + 1);
if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), *string);
+ objc_hash_add (&stream->stream_table, LONG2PTR(key), *string);
len = (*stream->read) (stream->physical, *string, nbytes);
(*string)[nbytes] = '\0';
}
@@ -823,7 +827,7 @@ objc_read_object (struct objc_typed_stream *stream, id *object)
/* register? */
if (key)
- hash_add (&stream->object_table, LONG2PTR(key), *object);
+ objc_hash_add (&stream->object_table, LONG2PTR(key), *object);
/* send -read: */
if (__objc_responds_to (*object, read_sel))
@@ -841,17 +845,19 @@ objc_read_object (struct objc_typed_stream *stream, id *object)
if (key)
objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
- (*object) = hash_value_for_key (stream->object_table, LONG2PTR(key));
+ (*object) = objc_hash_value_for_key (stream->object_table,
+ LONG2PTR(key));
}
else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */
{
struct objc_list *other;
len = objc_read_unsigned_long (stream, &key);
- other = (struct objc_list *) hash_value_for_key (stream->object_refs,
+ other
+ = (struct objc_list *) objc_hash_value_for_key (stream->object_refs,
LONG2PTR(key));
- hash_add (&stream->object_refs, LONG2PTR(key),
- (void *)list_cons (object, other));
+ objc_hash_add (&stream->object_refs, LONG2PTR(key),
+ (void *)list_cons (object, other));
}
else if (buf[0] == (_B_EXT | _BX_OBJROOT)) /* a root object */
@@ -898,10 +904,11 @@ objc_read_class (struct objc_typed_stream *stream, Class *class)
/* register */
if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), *class);
+ objc_hash_add (&stream->stream_table, LONG2PTR(key), *class);
objc_read_unsigned_long (stream, &version);
- hash_add (&stream->class_table, (*class)->name, (void *)version);
+ objc_hash_add (&stream->class_table,
+ (*class)->name, (void *)version);
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
@@ -909,7 +916,8 @@ objc_read_class (struct objc_typed_stream *stream, Class *class)
if (key)
objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
- *class = hash_value_for_key (stream->stream_table, LONG2PTR(key));
+ *class = objc_hash_value_for_key (stream->stream_table,
+ LONG2PTR(key));
if (! *class)
objc_error (nil, OBJC_ERR_BAD_CLASS,
"cannot find class for key %lu", key);
@@ -956,7 +964,8 @@ objc_read_selector (struct objc_typed_stream *stream, SEL* selector)
/* register */
if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), (void *) *selector);
+ objc_hash_add (&stream->stream_table,
+ LONG2PTR(key), (void *) *selector);
}
else if ((buf[0]&_B_CODE) == _B_UCOMM)
@@ -964,8 +973,8 @@ objc_read_selector (struct objc_typed_stream *stream, SEL* selector)
if (key)
objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
- (*selector) = hash_value_for_key (stream->stream_table,
- LONG2PTR(key));
+ (*selector) = objc_hash_value_for_key (stream->stream_table,
+ LONG2PTR(key));
}
else
@@ -1475,54 +1484,54 @@ __objc_write_typed_stream_signature (TypedStream *stream)
static void __objc_finish_write_root_object(struct objc_typed_stream *stream)
{
- hash_delete (stream->object_table);
- stream->object_table = hash_new(64,
- (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
+ objc_hash_delete (stream->object_table);
+ stream->object_table = objc_hash_new (64,
+ (hash_func_type) objc_hash_ptr,
+ (compare_func_type) objc_compare_ptrs);
}
static void __objc_finish_read_root_object(struct objc_typed_stream *stream)
{
node_ptr node;
SEL awake_sel = sel_get_any_uid ("awake");
- cache_ptr free_list = hash_new (64,
- (hash_func_type) hash_ptr,
- (compare_func_type) compare_ptrs);
+ cache_ptr free_list = objc_hash_new (64,
+ (hash_func_type) objc_hash_ptr,
+ (compare_func_type) objc_compare_ptrs);
/* resolve object forward references */
- for (node = hash_next (stream->object_refs, NULL); node;
- node = hash_next (stream->object_refs, node))
+ for (node = objc_hash_next (stream->object_refs, NULL); node;
+ node = objc_hash_next (stream->object_refs, node))
{
struct objc_list *reflist = node->value;
const void *key = node->key;
- id object = hash_value_for_key (stream->object_table, key);
+ id object = objc_hash_value_for_key (stream->object_table, key);
while (reflist)
{
*((id*) reflist->head) = object;
- if (hash_value_for_key (free_list,reflist) == NULL)
- hash_add (&free_list,reflist,reflist);
+ if (objc_hash_value_for_key (free_list,reflist) == NULL)
+ objc_hash_add (&free_list,reflist,reflist);
reflist = reflist->tail;
}
}
/* apply __objc_free to all objects stored in free_list */
- for (node = hash_next (free_list, NULL); node;
- node = hash_next (free_list, node))
+ for (node = objc_hash_next (free_list, NULL); node;
+ node = objc_hash_next (free_list, node))
objc_free ((void *) node->key);
- hash_delete (free_list);
+ objc_hash_delete (free_list);
/* empty object reference table */
- hash_delete (stream->object_refs);
- stream->object_refs = hash_new(8, (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
+ objc_hash_delete (stream->object_refs);
+ stream->object_refs = objc_hash_new (8, (hash_func_type) objc_hash_ptr,
+ (compare_func_type) objc_compare_ptrs);
/* call -awake for all objects read */
if (awake_sel)
{
- for (node = hash_next (stream->object_table, NULL); node;
- node = hash_next (stream->object_table, node))
+ for (node = objc_hash_next (stream->object_table, NULL); node;
+ node = objc_hash_next (stream->object_table, node))
{
id object = node->value;
if (__objc_responds_to (object, awake_sel))
@@ -1531,10 +1540,10 @@ static void __objc_finish_read_root_object(struct objc_typed_stream *stream)
}
/* empty object table */
- hash_delete (stream->object_table);
- stream->object_table = hash_new(64,
- (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
+ objc_hash_delete (stream->object_table);
+ stream->object_table = objc_hash_new(64,
+ (hash_func_type)objc_hash_ptr,
+ (compare_func_type)objc_compare_ptrs);
}
/*
@@ -1548,21 +1557,22 @@ objc_open_typed_stream (FILE *physical, int mode)
s->mode = mode;
s->physical = physical;
- s->stream_table = hash_new (64,
- (hash_func_type) hash_ptr,
- (compare_func_type) compare_ptrs);
- s->object_table = hash_new (64,
- (hash_func_type) hash_ptr,
- (compare_func_type) compare_ptrs);
+ s->stream_table = objc_hash_new (64,
+ (hash_func_type) objc_hash_ptr,
+ (compare_func_type) objc_compare_ptrs);
+ s->object_table = objc_hash_new (64,
+ (hash_func_type) objc_hash_ptr,
+ (compare_func_type) objc_compare_ptrs);
s->eof = (objc_typed_eof_func) __objc_feof;
s->flush = (objc_typed_flush_func) fflush;
s->writing_root_p = 0;
if (mode == OBJC_READONLY)
{
- s->class_table = hash_new (8, (hash_func_type) hash_string,
- (compare_func_type) compare_strings);
- s->object_refs = hash_new (8, (hash_func_type) hash_ptr,
- (compare_func_type) compare_ptrs);
+ s->class_table
+ = objc_hash_new (8, (hash_func_type) objc_hash_string,
+ (compare_func_type) objc_compare_strings);
+ s->object_refs = objc_hash_new (8, (hash_func_type) objc_hash_ptr,
+ (compare_func_type) objc_compare_ptrs);
s->read = (objc_typed_read_func) __objc_fread;
s->write = (objc_typed_write_func) __objc_no_write;
__objc_read_typed_stream_signature (s);
@@ -1621,12 +1631,12 @@ objc_close_typed_stream (TypedStream *stream)
if (stream->mode == OBJC_READONLY)
{
__objc_finish_read_root_object (stream); /* Just in case... */
- hash_delete (stream->class_table);
- hash_delete (stream->object_refs);
+ objc_hash_delete (stream->class_table);
+ objc_hash_delete (stream->object_refs);
}
- hash_delete (stream->stream_table);
- hash_delete (stream->object_table);
+ objc_hash_delete (stream->stream_table);
+ objc_hash_delete (stream->object_table);
if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM))
fclose ((FILE *)stream->physical);
@@ -1650,7 +1660,8 @@ long
objc_get_stream_class_version (TypedStream *stream, Class class)
{
if (stream->class_table)
- return PTR2LONG(hash_value_for_key (stream->class_table, class->name));
+ return PTR2LONG(objc_hash_value_for_key (stream->class_table,
+ class->name));
else
return class_get_version (class);
}
diff --git a/libobjc/encoding.c b/libobjc/encoding.c
index 7f71276b556..046b664b8fb 100644
--- a/libobjc/encoding.c
+++ b/libobjc/encoding.c
@@ -780,6 +780,23 @@ objc_layout_structure (const char *type,
layout->record_align = MAX (layout->record_align, STRUCTURE_SIZE_BOUNDARY);
}
+/* APPLE LOCAL begin Macintosh alignment 2002-2-26 --ff */
+#ifdef RS6000_PIC_OFFSET_TABLE_REGNUM
+/* Ick, darwin.h doesn't work anymore... Fix this please. */
+#undef ROUND_TYPE_ALIGN
+#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
+ ((TREE_CODE (STRUCT) == RECORD_TYPE \
+ || TREE_CODE (STRUCT) == UNION_TYPE \
+ || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
+ && TARGET_ALIGN_NATURAL == 0 \
+ ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
+ : (TREE_CODE (STRUCT) == VECTOR_TYPE \
+ && ALTIVEC_VECTOR_MODE (TYPE_MODE (STRUCT))) \
+ ? MAX (MAX ((COMPUTED), (SPECIFIED)), 128) \
+ : MAX ((COMPUTED), (SPECIFIED)))
+#define TARGET_ALIGN_MAC68K 0
+#endif
+/* APPLE LOCAL end Macintosh alignment 2002-2-26 --ff */
BOOL
objc_layout_structure_next_member (struct objc_struct_layout *layout)
@@ -845,9 +862,11 @@ objc_layout_structure_next_member (struct objc_struct_layout *layout)
#ifdef BIGGEST_FIELD_ALIGNMENT
desired_align = MIN (desired_align, BIGGEST_FIELD_ALIGNMENT);
#endif
+/* APPLE LOCAL begin Macintosh alignment 2002-2-26 --ff */
#ifdef ADJUST_FIELD_ALIGN
- desired_align = ADJUST_FIELD_ALIGN (type, desired_align);
+ desired_align = ADJUST_FIELD_ALIGN (type, desired_align, layout->prev_type == 0);
#endif
+/* APPLE LOCAL end Macintosh alignment 2002-2-26 --ff */
/* Record must have at least as much alignment as any field.
Otherwise, the alignment of the field within the record
diff --git a/libobjc/hash.c b/libobjc/hash.c
index cbea81ad424..e2072b605f7 100644
--- a/libobjc/hash.c
+++ b/libobjc/hash.c
@@ -40,8 +40,8 @@ Boston, MA 02111-1307, USA. */
((cache)->size * 2)
cache_ptr
-hash_new (unsigned int size, hash_func_type hash_func,
- compare_func_type compare_func)
+objc_hash_new (unsigned int size, hash_func_type hash_func,
+ compare_func_type compare_func)
{
cache_ptr cache;
@@ -77,7 +77,7 @@ hash_new (unsigned int size, hash_func_type hash_func,
void
-hash_delete (cache_ptr cache)
+objc_hash_delete (cache_ptr cache)
{
node_ptr node;
node_ptr next_node;
@@ -85,17 +85,17 @@ hash_delete (cache_ptr cache)
/* Purge all key/value pairs from the table. */
/* Step through the nodes one by one and remove every node WITHOUT
- using hash_next. this makes hash_delete much more efficient. */
+ using objc_hash_next. this makes objc_hash_delete much more efficient. */
for (i = 0;i < cache->size;i++) {
if ((node = cache->node_table[i])) {
/* an entry in the hash table has been found, now step through the
nodes next in the list and free them. */
while ((next_node = node->next)) {
- hash_remove (cache,node->key);
+ objc_hash_remove (cache,node->key);
node = next_node;
}
- hash_remove (cache,node->key);
+ objc_hash_remove (cache,node->key);
}
}
@@ -106,7 +106,7 @@ hash_delete (cache_ptr cache)
void
-hash_add (cache_ptr *cachep, const void *key, void *value)
+objc_hash_add (cache_ptr *cachep, const void *key, void *value)
{
size_t indx = (*(*cachep)->hash_func)(*cachep, key);
node_ptr node = (node_ptr) objc_calloc (1, sizeof (struct cache_node));
@@ -149,19 +149,19 @@ hash_add (cache_ptr *cachep, const void *key, void *value)
primitive functions thereby increasing its
correctness. */
node_ptr node1 = NULL;
- cache_ptr new = hash_new (EXPANSION (*cachep),
- (*cachep)->hash_func,
- (*cachep)->compare_func);
+ cache_ptr new = objc_hash_new (EXPANSION (*cachep),
+ (*cachep)->hash_func,
+ (*cachep)->compare_func);
DEBUG_PRINTF ("Expanding cache %#x from %d to %d\n",
(int) *cachep, (*cachep)->size, new->size);
/* Copy the nodes from the first hash table to the new one. */
- while ((node1 = hash_next (*cachep, node1)))
- hash_add (&new, node1->key, node1->value);
+ while ((node1 = objc_hash_next (*cachep, node1)))
+ objc_hash_add (&new, node1->key, node1->value);
/* Trash the old cache. */
- hash_delete (*cachep);
+ objc_hash_delete (*cachep);
/* Return a pointer to the new hash table. */
*cachep = new;
@@ -170,7 +170,7 @@ hash_add (cache_ptr *cachep, const void *key, void *value)
void
-hash_remove (cache_ptr cache, const void *key)
+objc_hash_remove (cache_ptr cache, const void *key)
{
size_t indx = (*cache->hash_func)(cache, key);
node_ptr node = cache->node_table[indx];
@@ -206,7 +206,7 @@ hash_remove (cache_ptr cache, const void *key)
node_ptr
-hash_next (cache_ptr cache, node_ptr node)
+objc_hash_next (cache_ptr cache, node_ptr node)
{
/* If the scan is being started then reset the last node
visitied pointer and bucket index. */
@@ -246,7 +246,7 @@ hash_next (cache_ptr cache, node_ptr node)
Return NULL if the KEY is not recorded. */
void *
-hash_value_for_key (cache_ptr cache, const void *key)
+objc_hash_value_for_key (cache_ptr cache, const void *key)
{
node_ptr node = cache->node_table[(*cache->hash_func)(cache, key)];
void *retval = NULL;
@@ -267,7 +267,7 @@ hash_value_for_key (cache_ptr cache, const void *key)
Return NO if it does not */
BOOL
-hash_is_key_in_hash (cache_ptr cache, const void *key)
+objc_hash_is_key_in_hash (cache_ptr cache, const void *key)
{
node_ptr node = cache->node_table[(*cache->hash_func)(cache, key)];
diff --git a/libobjc/hash_compat.c b/libobjc/hash_compat.c
new file mode 100644
index 00000000000..46c273858a6
--- /dev/null
+++ b/libobjc/hash_compat.c
@@ -0,0 +1,97 @@
+/* Binary compatibility hash implementations for Objective C.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* As a special exception, if you link this library with files
+ compiled with GCC to produce an executable, this does not cause
+ the resulting executable to be covered by the GNU General Public License.
+ This exception does not however invalidate any other reasons why
+ the executable file might be covered by the GNU General Public License. */
+
+#define OBJC_IGNORE_DEPRECATED_API 1
+#include "hash.h"
+
+cache_ptr
+hash_new (unsigned int size,
+ hash_func_type hash_func,
+ compare_func_type compare_func)
+{
+ return objc_hash_new(size, hash_func, compare_func);
+}
+
+void
+hash_delete(cache_ptr cache)
+{
+ objc_hash_delete(cache);
+}
+
+void
+hash_add (cache_ptr *cachep, const void *key, void *value)
+{
+ objc_hash_add(cachep, key, value);
+}
+
+void
+hash_remove (cache_ptr cache, const void *key)
+{
+ objc_hash_remove (cache, key);
+}
+
+node_ptr
+hash_next (cache_ptr cache, node_ptr node)
+{
+ return objc_hash_next (cache, node);
+}
+
+void *
+hash_value_for_key (cache_ptr cache, const void *key)
+{
+ return objc_hash_value_for_key (cache, key);
+}
+
+BOOL
+hash_is_key_in_hash (cache_ptr cache, const void *key)
+{
+ return objc_hash_is_key_in_hash (cache, key);
+}
+
+unsigned int
+hash_ptr (cache_ptr cache, const void *key)
+{
+ return objc_hash_ptr (cache, key);
+}
+
+unsigned int
+hash_string (cache_ptr cache, const void *key)
+{
+ return objc_hash_string (cache, key);
+}
+
+int
+compare_ptrs (const void *k1, const void *k2)
+{
+ return objc_compare_ptrs (k1, k2);
+}
+
+int
+compare_strings (const void *k1, const void *k2)
+{
+ return objc_compare_strings (k1, k2);
+}
+
diff --git a/libobjc/init.c b/libobjc/init.c
index 33a933875b0..3eb53866f38 100644
--- a/libobjc/init.c
+++ b/libobjc/init.c
@@ -363,10 +363,12 @@ __objc_send_message_in_list (MethodList_t method_list, Class class, SEL op)
Method_t mth = &method_list->method_list[i];
if (mth->method_name && sel_eq (mth->method_name, op)
- && ! hash_is_key_in_hash (__objc_load_methods, mth->method_imp))
+ && ! objc_hash_is_key_in_hash (__objc_load_methods, mth->method_imp))
{
/* Add this method into the +load hash table */
- hash_add (&__objc_load_methods, mth->method_imp, mth->method_imp);
+ objc_hash_add (&__objc_load_methods,
+ mth->method_imp,
+ mth->method_imp);
DEBUG_PRINTF ("sending +load in class: %s\n", class->name);
@@ -538,8 +540,9 @@ __objc_exec_class (Module_t module)
__objc_init_class_tables ();
__objc_init_dispatch_tables ();
__objc_class_tree_list = list_cons (NULL, __objc_class_tree_list);
- __objc_load_methods
- = hash_new (128, (hash_func_type)hash_ptr, compare_ptrs);
+ __objc_load_methods = objc_hash_new (128,
+ (hash_func_type)objc_hash_ptr,
+ objc_compare_ptrs);
previous_constructors = 1;
}
diff --git a/libobjc/libobjc.def b/libobjc/libobjc.def
index 2443d4c7b4c..bd50959cf07 100644
--- a/libobjc/libobjc.def
+++ b/libobjc/libobjc.def
@@ -22,6 +22,7 @@ LIBRARY libobjc
EXPORTS
search_for_method_in_list
objc_get_uninstalled_dtable
+objc_hash_is_key_in_hash
hash_is_key_in_hash
objc_verror
_objc_load_callback
@@ -155,9 +156,15 @@ sarray_lazy_copy
sarray_new
sarray_realloc
sarray_remove_garbage
+objc_hash_add
hash_add
+objc_hash_delete
hash_delete
+objc_hash_new
hash_new
+objc_hash_next
hash_next
+objc_hash_remove
hash_remove
+objc_hash_value_for_key
hash_value_for_key
diff --git a/libobjc/objc/hash.h b/libobjc/objc/hash.h
index f56e0c01841..e3002c4539a 100644
--- a/libobjc/objc/hash.h
+++ b/libobjc/objc/hash.h
@@ -62,7 +62,7 @@ typedef struct cache_node
*
* Unfortunately there is a mutual data structure reference problem with this
* typedef. Therefore, to remove compiler warnings the functions passed to
- * hash_new will have to be casted to this type.
+ * objc_hash_new will have to be casted to this type.
*/
typedef unsigned int (*hash_func_type) (void *, const void *);
@@ -111,25 +111,25 @@ extern cache_ptr module_hash_table, class_hash_table;
/* Allocate and initialize a hash table. */
-cache_ptr hash_new (unsigned int size,
- hash_func_type hash_func,
- compare_func_type compare_func);
+cache_ptr objc_hash_new (unsigned int size,
+ hash_func_type hash_func,
+ compare_func_type compare_func);
/* Deallocate all of the hash nodes and the cache itself. */
-void hash_delete (cache_ptr cache);
+void objc_hash_delete (cache_ptr cache);
/* Add the key/value pair to the hash table. If the
hash table reaches a level of fullness then it will be resized.
assert if the key is already in the hash. */
-void hash_add (cache_ptr *cachep, const void *key, void *value);
+void objc_hash_add (cache_ptr *cachep, const void *key, void *value);
/* Remove the key/value pair from the hash table.
assert if the key isn't in the table. */
-void hash_remove (cache_ptr cache, const void *key);
+void objc_hash_remove (cache_ptr cache, const void *key);
/* Used to index through the hash table. Start with NULL
to get the first entry.
@@ -140,15 +140,15 @@ void hash_remove (cache_ptr cache, const void *key);
Cache nodes are returned such that key or value can
be extracted. */
-node_ptr hash_next (cache_ptr cache, node_ptr node);
+node_ptr objc_hash_next (cache_ptr cache, node_ptr node);
/* Used to return a value from a hash table using a given key. */
-void *hash_value_for_key (cache_ptr cache, const void *key);
+void *objc_hash_value_for_key (cache_ptr cache, const void *key);
/* Used to determine if the given key exists in the hash table */
-BOOL hash_is_key_in_hash (cache_ptr cache, const void *key);
+BOOL objc_hash_is_key_in_hash (cache_ptr cache, const void *key);
/************************************************
@@ -163,7 +163,7 @@ BOOL hash_is_key_in_hash (cache_ptr cache, const void *key);
except for those likely to be 0 due to alignment.) */
static inline unsigned int
-hash_ptr (cache_ptr cache, const void *key)
+objc_hash_ptr (cache_ptr cache, const void *key)
{
return ((size_t)key / sizeof (void *)) & cache->mask;
}
@@ -172,7 +172,7 @@ hash_ptr (cache_ptr cache, const void *key)
/* Calculate a hash code by iterating over a NULL
terminate string. */
static inline unsigned int
-hash_string (cache_ptr cache, const void *key)
+objc_hash_string (cache_ptr cache, const void *key)
{
unsigned int ret = 0;
unsigned int ctr = 0;
@@ -189,7 +189,7 @@ hash_string (cache_ptr cache, const void *key)
/* Compare two pointers for equality. */
static inline int
-compare_ptrs (const void *k1, const void *k2)
+objc_compare_ptrs (const void *k1, const void *k2)
{
return (k1 == k2);
}
@@ -197,7 +197,7 @@ compare_ptrs (const void *k1, const void *k2)
/* Compare two strings. */
static inline int
-compare_strings (const void *k1, const void *k2)
+objc_compare_strings (const void *k1, const void *k2)
{
if (k1 == k2)
return 1;
@@ -207,6 +207,107 @@ compare_strings (const void *k1, const void *k2)
return ! strcmp ((const char *) k1, (const char *) k2);
}
+#ifndef OBJC_IGNORE_DEPRECATED_API
+/* Deprecated as of 4.0 */
+
+static inline cache_ptr
+hash_new (unsigned int size,
+ hash_func_type hash_func,
+ compare_func_type compare_func) __attribute__ ((deprecated));
+static inline cache_ptr
+hash_new (unsigned int size,
+ hash_func_type hash_func,
+ compare_func_type compare_func)
+{
+ return objc_hash_new(size, hash_func, compare_func);
+}
+
+static inline void
+hash_delete(cache_ptr cache) __attribute__ ((deprecated));
+static inline void
+hash_delete(cache_ptr cache)
+{
+ objc_hash_delete(cache);
+}
+
+static inline void
+hash_add (cache_ptr *cachep,
+ const void *key,
+ void *value) __attribute__ ((deprecated));
+static inline void
+hash_add (cache_ptr *cachep, const void *key, void *value)
+{
+ objc_hash_add(cachep, key, value);
+}
+
+static inline void
+hash_remove (cache_ptr cache, const void *key) __attribute__ ((deprecated));
+static inline void
+hash_remove (cache_ptr cache, const void *key)
+{
+ objc_hash_remove (cache, key);
+}
+
+static inline node_ptr
+hash_next (cache_ptr cache, node_ptr node) __attribute__ ((deprecated));
+static inline node_ptr
+hash_next (cache_ptr cache, node_ptr node)
+{
+ return objc_hash_next (cache, node);
+}
+
+static inline void *
+hash_value_for_key (cache_ptr cache,
+ const void *key) __attribute__ ((deprecated));
+static inline void *
+hash_value_for_key (cache_ptr cache, const void *key)
+{
+ return objc_hash_value_for_key (cache, key);
+}
+
+static inline BOOL
+hash_is_key_in_hash (cache_ptr cache,
+ const void *key) __attribute__ ((deprecated));
+static inline BOOL
+hash_is_key_in_hash (cache_ptr cache, const void *key)
+{
+ return objc_hash_is_key_in_hash (cache, key);
+}
+
+static inline unsigned int
+hash_ptr (cache_ptr cache, const void *key) __attribute__ ((deprecated));
+static inline unsigned int
+hash_ptr (cache_ptr cache, const void *key)
+{
+ return objc_hash_ptr (cache, key);
+}
+
+static inline unsigned int
+hash_string (cache_ptr cache, const void *key) __attribute__ ((deprecated));
+static inline unsigned int
+hash_string (cache_ptr cache, const void *key)
+{
+ return objc_hash_string (cache, key);
+}
+
+static inline int
+compare_ptrs (const void *k1, const void *k2) __attribute__ ((deprecated));
+static inline int
+compare_ptrs (const void *k1, const void *k2)
+{
+ return objc_compare_ptrs (k1, k2);
+}
+
+static inline int
+compare_strings (const void *k1, const void *k2) __attribute__ ((deprecated));
+static inline int
+compare_strings (const void *k1, const void *k2)
+{
+ return objc_compare_strings (k1, k2);
+}
+#endif /* OBJC_IGNORE_DEPRECATED_API */
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/libobjc/selector.c b/libobjc/selector.c
index edaef2d959d..ce8acf7ac3a 100644
--- a/libobjc/selector.c
+++ b/libobjc/selector.c
@@ -43,9 +43,9 @@ void __objc_init_selector_tables (void)
__objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0);
__objc_selector_names = sarray_new (SELECTOR_HASH_SIZE, 0);
__objc_selector_hash
- = hash_new (SELECTOR_HASH_SIZE,
- (hash_func_type) hash_string,
- (compare_func_type) compare_strings);
+ = objc_hash_new (SELECTOR_HASH_SIZE,
+ (hash_func_type) objc_hash_string,
+ (compare_func_type) objc_compare_strings);
}
/* This routine is given a class and records all of the methods in its class
@@ -195,7 +195,7 @@ sel_get_typed_uid (const char *name, const char *types)
objc_mutex_lock (__objc_runtime_mutex);
- i = (sidx) hash_value_for_key (__objc_selector_hash, name);
+ i = (sidx) objc_hash_value_for_key (__objc_selector_hash, name);
if (i == 0)
{
objc_mutex_unlock (__objc_runtime_mutex);
@@ -235,7 +235,7 @@ sel_get_any_typed_uid (const char *name)
objc_mutex_lock (__objc_runtime_mutex);
- i = (sidx) hash_value_for_key (__objc_selector_hash, name);
+ i = (sidx) objc_hash_value_for_key (__objc_selector_hash, name);
if (i == 0)
{
objc_mutex_unlock (__objc_runtime_mutex);
@@ -266,7 +266,7 @@ sel_get_any_uid (const char *name)
objc_mutex_lock (__objc_runtime_mutex);
- i = (sidx) hash_value_for_key (__objc_selector_hash, name);
+ i = (sidx) objc_hash_value_for_key (__objc_selector_hash, name);
if (soffset_decode (i) == 0)
{
objc_mutex_unlock (__objc_runtime_mutex);
@@ -368,7 +368,7 @@ __sel_register_typed_name (const char *name, const char *types,
sidx i;
struct objc_list *l;
- i = (sidx) hash_value_for_key (__objc_selector_hash, name);
+ i = (sidx) objc_hash_value_for_key (__objc_selector_hash, name);
if (soffset_decode (i) != 0)
{
for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
@@ -453,7 +453,7 @@ __sel_register_typed_name (const char *name, const char *types,
sarray_at_put_safe (__objc_selector_names, i, (void *) new_name);
sarray_at_put_safe (__objc_selector_array, i, (void *) l);
if (is_new)
- hash_add (&__objc_selector_hash, (void *) new_name, (void *) i);
+ objc_hash_add (&__objc_selector_hash, (void *) new_name, (void *) i);
}
sarray_realloc (__objc_uninstalled_dtable, __objc_selector_max_index + 1);