mirror of git://gcc.gnu.org/git/gcc.git
In libobjc/: 2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com>
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. From-SVN: r168139
This commit is contained in:
parent
2fdd3e0468
commit
1575c9deae
|
@ -1,5 +1,15 @@
|
||||||
2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com>
|
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.
|
||||||
|
|
||||||
|
2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||||
|
|
||||||
* init.c (_objc_load_callback): Initialize with 0.
|
* init.c (_objc_load_callback): Initialize with 0.
|
||||||
(__objc_call_callback): Renamed to __objc_call_load_callback.
|
(__objc_call_callback): Renamed to __objc_call_load_callback.
|
||||||
Check _objc_load_callback only once, and if it is not set, return
|
Check _objc_load_callback only once, and if it is not set, return
|
||||||
|
|
|
@ -446,11 +446,12 @@ __objc_init_class_tables (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function adds a class to the class hash table, and assigns the
|
/* This function adds a class to the class hash table, and assigns the
|
||||||
class a number, unless it's already known. */
|
class a number, unless it's already known. Return 'YES' if the
|
||||||
void
|
class was added. Return 'NO' if the class was already known. */
|
||||||
|
BOOL
|
||||||
__objc_add_class_to_hash (Class class)
|
__objc_add_class_to_hash (Class class)
|
||||||
{
|
{
|
||||||
Class h_class;
|
Class existing_class;
|
||||||
|
|
||||||
objc_mutex_lock (__objc_runtime_mutex);
|
objc_mutex_lock (__objc_runtime_mutex);
|
||||||
|
|
||||||
|
@ -461,21 +462,28 @@ __objc_add_class_to_hash (Class class)
|
||||||
assert (CLS_ISCLASS (class));
|
assert (CLS_ISCLASS (class));
|
||||||
|
|
||||||
/* Check to see if the class is already in the hash table. */
|
/* Check to see if the class is already in the hash table. */
|
||||||
h_class = class_table_get_safe (class->name);
|
existing_class = class_table_get_safe (class->name);
|
||||||
if (! h_class)
|
|
||||||
{
|
|
||||||
/* The class isn't in the hash table. Add the class and assign a class
|
|
||||||
number. */
|
|
||||||
static unsigned int class_number = 1;
|
|
||||||
|
|
||||||
|
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. */
|
||||||
|
static unsigned int class_number = 1;
|
||||||
|
|
||||||
CLS_SETNUMBER (class, class_number);
|
CLS_SETNUMBER (class, class_number);
|
||||||
CLS_SETNUMBER (class->class_pointer, class_number);
|
CLS_SETNUMBER (class->class_pointer, class_number);
|
||||||
|
|
||||||
++class_number;
|
++class_number;
|
||||||
class_table_insert (class->name, class);
|
class_table_insert (class->name, class);
|
||||||
}
|
|
||||||
|
|
||||||
objc_mutex_unlock (__objc_runtime_mutex);
|
objc_mutex_unlock (__objc_runtime_mutex);
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Class
|
Class
|
||||||
|
|
|
@ -879,22 +879,26 @@ void
|
||||||
__objc_init_class (Class class)
|
__objc_init_class (Class class)
|
||||||
{
|
{
|
||||||
/* Store the class in the class table and assign class numbers. */
|
/* Store the class in the class table and assign class numbers. */
|
||||||
__objc_add_class_to_hash (class);
|
if (__objc_add_class_to_hash (class))
|
||||||
|
{
|
||||||
/* Register all of the selectors in the class and meta class. */
|
/* Register all of the selectors in the class and meta class. */
|
||||||
__objc_register_selectors_from_class (class);
|
__objc_register_selectors_from_class (class);
|
||||||
__objc_register_selectors_from_class ((Class) class->class_pointer);
|
__objc_register_selectors_from_class ((Class) class->class_pointer);
|
||||||
|
|
||||||
/* Install the fake dispatch tables. */
|
/* Install the fake dispatch tables. */
|
||||||
__objc_install_premature_dtable (class);
|
__objc_install_premature_dtable (class);
|
||||||
__objc_install_premature_dtable (class->class_pointer);
|
__objc_install_premature_dtable (class->class_pointer);
|
||||||
|
|
||||||
/* Register the instance methods as class methods, this is only done
|
/* Register the instance methods as class methods, this is only
|
||||||
for root classes. */
|
done for root classes. */
|
||||||
__objc_register_instance_methods_to_class (class);
|
__objc_register_instance_methods_to_class (class);
|
||||||
|
|
||||||
if (class->protocols)
|
if (class->protocols)
|
||||||
__objc_init_protocols (class->protocols);
|
__objc_init_protocols (class->protocols);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_objc_abort ("Module contains duplicate class '%s'\n",
|
||||||
|
class->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* __objc_init_protocol must be called with __objc_runtime_mutex
|
/* __objc_init_protocol must be called with __objc_runtime_mutex
|
||||||
|
|
|
@ -52,17 +52,17 @@ objc/runtime.h. */
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
extern void __objc_add_class_to_hash(Class); /* (objc-class.c) */
|
extern BOOL __objc_add_class_to_hash (Class); /* (objc-class.c) */
|
||||||
extern void __objc_init_class_tables(void); /* (objc-class.c) */
|
extern void __objc_init_class_tables (void); /* (objc-class.c) */
|
||||||
extern void __objc_init_dispatch_tables(void); /* (objc-dispatch.c) */
|
extern void __objc_init_dispatch_tables (void); /* (objc-dispatch.c) */
|
||||||
extern void __objc_install_premature_dtable(Class); /* (objc-dispatch.c) */
|
extern void __objc_install_premature_dtable (Class); /* (objc-dispatch.c) */
|
||||||
extern void __objc_resolve_class_links(void); /* (objc-class.c) */
|
extern void __objc_resolve_class_links (void); /* (objc-class.c) */
|
||||||
extern void __objc_update_dispatch_table_for_class (Class);/* (objc-msg.c) */
|
extern void __objc_update_dispatch_table_for_class (Class);/* (objc-msg.c) */
|
||||||
|
|
||||||
extern int __objc_init_thread_system(void); /* thread.c */
|
extern int __objc_init_thread_system (void); /* thread.c */
|
||||||
extern int __objc_fini_thread_system(void); /* thread.c */
|
extern int __objc_fini_thread_system (void); /* thread.c */
|
||||||
extern void __objc_init_class (Class class); /* init.c */
|
extern void __objc_init_class (Class class); /* init.c */
|
||||||
extern void class_add_method_list(Class, struct objc_method_list *);
|
extern void class_add_method_list (Class, struct objc_method_list *);
|
||||||
|
|
||||||
/* Registering instance methods as class methods for root classes */
|
/* Registering instance methods as class methods for root classes */
|
||||||
extern void __objc_register_instance_methods_to_class(Class);
|
extern void __objc_register_instance_methods_to_class(Class);
|
||||||
|
|
Loading…
Reference in New Issue