diff options
author | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-12-21 22:49:37 +0000 |
---|---|---|
committer | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-12-21 22:49:37 +0000 |
commit | 7d026d14fe10ddd8779c2b171097c4e8b4cdf9ea (patch) | |
tree | 7b230e110e8855f7e0345ca7c88cdfb6276368f2 /libobjc/class.c | |
parent | ce31fa3fe8776af79a61af8858b7d5bb14f22bd6 (diff) | |
download | gcc-7d026d14fe10ddd8779c2b171097c4e8b4cdf9ea.tar.gz |
In libobjc/:
2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com>
PR libobjc/18764
* class.c (__objc_add_class_to_hash): Return YES if the class was
added, and NO if it already existed.
* init.c (__objc_init_class): If __objc_add_class_to_hash returns
NO, then abort the program with an error message.
* objc-private/runtime.h (__objc_add_class_to_hash): Updated
declaration.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc/class.c')
-rw-r--r-- | libobjc/class.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/libobjc/class.c b/libobjc/class.c index cf8e4c42728..b9e8730beb2 100644 --- a/libobjc/class.c +++ b/libobjc/class.c @@ -446,11 +446,12 @@ __objc_init_class_tables (void) } /* This function adds a class to the class hash table, and assigns the - class a number, unless it's already known. */ -void + class a number, unless it's already known. Return 'YES' if the + class was added. Return 'NO' if the class was already known. */ +BOOL __objc_add_class_to_hash (Class class) { - Class h_class; + Class existing_class; objc_mutex_lock (__objc_runtime_mutex); @@ -461,21 +462,28 @@ __objc_add_class_to_hash (Class class) assert (CLS_ISCLASS (class)); /* Check to see if the class is already in the hash table. */ - h_class = class_table_get_safe (class->name); - if (! h_class) + existing_class = class_table_get_safe (class->name); + + if (existing_class) + { + objc_mutex_unlock (__objc_runtime_mutex); + return NO; + } + else { - /* The class isn't in the hash table. Add the class and assign a class - number. */ + /* The class isn't in the hash table. Add the class and assign + a class number. */ static unsigned int class_number = 1; - + CLS_SETNUMBER (class, class_number); CLS_SETNUMBER (class->class_pointer, class_number); ++class_number; class_table_insert (class->name, class); - } - objc_mutex_unlock (__objc_runtime_mutex); + objc_mutex_unlock (__objc_runtime_mutex); + return YES; + } } Class |