From 4ea82e14da24e70891145b84c1fd1158f5f7f118 Mon Sep 17 00:00:00 2001 From: theraven Date: Wed, 2 Jun 2010 11:12:27 +0000 Subject: [PATCH] Fixed hash functions. Tweaked class resolve function to make sure that it keeps scanning the list as long as one or more classes is resolved while scanning it. --- class_table.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/class_table.c b/class_table.c index 48bf1c9..47d9ba6 100644 --- a/class_table.c +++ b/class_table.c @@ -16,13 +16,13 @@ void __objc_compute_ivar_offsets(Class class); //////////////////////////////////////////////////////////////////////////////// // +load method hash table //////////////////////////////////////////////////////////////////////////////// -static int imp_compare(IMP i1, IMP i2) +static int imp_compare(const void *i1, void *i2) { return i1 == i2; } -static int imp_hash(const IMP imp) +static int32_t imp_hash(const void *imp) { - return ((int)(intptr_t)imp) >> 4; + return (int32_t)(((uintptr_t)imp) >> 4); } #define MAP_TABLE_NAME load_messages #define MAP_TABLE_COMPARE_FUNCTION imp_compare @@ -230,12 +230,22 @@ void __objc_resolve_class_links(void) { LOCK_UNTIL_RETURN(__objc_runtime_mutex); Class class = unresolved_class_list; - while ((Nil != class)) + BOOL resolvedClass; + do { - Class next = class->unresolved_class_next; - objc_resolve_class(class); - class = next; - } + resolvedClass = NO; + while ((Nil != class)) + { + Class next = class->unresolved_class_next; + objc_resolve_class(class); + if (resolvedClass || + objc_test_class_flag(class, objc_class_flag_resolved)) + { + resolvedClass = YES; + } + class = next; + } + } while (resolvedClass); } // FIXME: Remove this once all uses of it in the runtime have been removed