diff options
author | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-12 02:43:25 +0000 |
---|---|---|
committer | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-12 02:43:25 +0000 |
commit | e983fc72f816b0a770c81bf768b0c75d45feadf9 (patch) | |
tree | 1565198dee2ff7c323dd7ae7d47bcb976d011d43 /libobjc/init.c | |
parent | f9c4db38bb3400de0b809ed37f01b2949ea16558 (diff) | |
download | gcc-e983fc72f816b0a770c81bf768b0c75d45feadf9.tar.gz |
In libobjc/:
2010-10-12 Nicola Pero <nicola.pero@meta-innovation.com>
* Makefile.in (C_SOURCE_FILES): Added protocols.c.
* objc-private/protocols.h: New.
* protocols.c: New.
* init.c: Include objc-private/protocols.h.
(__objc_exec_class): Call __objc_protocols_init on startup.
(__objc_init_protocols): Call __objc_protocols_add_protocol.
* objc-private/runtime.h: Use (struct objc_method_list *) instead
of MethodList_t, and (struct objc_method *) instead of Method_t.
* objc/deprecated/struct_objc_class.h: Define
__objc_STRUCT_OBJC_CLASS_defined.
* objc-private/module-abi-8.h (struct
objc_method_description_list): New.
(struct objc_class): Only define if
__objc_STRUCT_OBJC_CLASS_defined is undefined.
* objc/runtime.h (class_getName): New.
(objc_getProtocol): New.
(objc_copyProtocolList): New.
(class_addProtocol): New.
(class_conformsToProtocol): New.
(class_copyProtocolList): New.
(protocol_conformsToProtocol): New.
(protocol_isEqual): New.
(protocol_getName): New.
(protocol_getMethodDescription): New.
(protocol_copyMethodDescriptionList): New.
(protocol_getProperty): New.
(protocol_copyPropertyList): New.
(protocol_copyProtocolList): New.
* class.c (class_getName): New.
* selector.c (sel_isEqual): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165349 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc/init.c')
-rw-r--r-- | libobjc/init.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/libobjc/init.c b/libobjc/init.c index deb089d7e16..9384f5865c3 100644 --- a/libobjc/init.c +++ b/libobjc/init.c @@ -33,6 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "objc-private/objc-list.h" #include "objc-private/runtime.h" #include "objc-private/objc-sync.h" /* For __objc_sync_init() */ +#include "objc-private/protocols.h" /* For __objc_protocols_init() and __objc_protocols_add_protocol() */ /* The version number of this runtime. This must match the number defined in gcc (objc-act.c). */ @@ -48,7 +49,17 @@ static struct objc_list *unclaimed_proto_list = 0; /* !T:MUTEX */ /* List of unresolved static instances. */ static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */ -/* Global runtime "write" mutex. */ +/* Global runtime "write" mutex. Having a single mutex prevents + deadlocks, but reduces concurrency. To improve concurrency, some + groups of functions in the runtime have their own separate mutex + (eg, __class_table_lock in class.c); to avoid deadlocks, these + routines must make sure that they never acquire any other lock + while holding their own local lock. Ie, they should lock, execute + some C code that does not perform any calls to other runtime + functions which may potentially lock different locks, then unlock. + If they need to perform any calls to other runtime functions that + may potentially lock other locks, then they should use the global + __objc_runtime_mutex. */ objc_mutex_t __objc_runtime_mutex = 0; /* Number of threads that are alive. */ @@ -551,6 +562,7 @@ __objc_exec_class (Module_t module) __objc_load_methods = objc_hash_new (128, (hash_func_type)objc_hash_ptr, objc_compare_ptrs); + __objc_protocols_init (); __objc_sync_init (); previous_constructors = 1; } @@ -862,10 +874,14 @@ __objc_init_protocols (struct objc_protocol_list *protos) struct objc_protocol *aProto = protos->list[i]; if (((size_t)aProto->class_pointer) == PROTOCOL_VERSION) { - /* assign class pointer */ + /* Assign class pointer */ aProto->class_pointer = proto_class; - /* init super protocols */ + /* Register the protocol in the hashtable or protocols by + name. */ + __objc_protocols_add_protocol (aProto->protocol_name, aProto); + + /* Init super protocols */ __objc_init_protocols (aProto->protocol_list); } else if (protos->list[i]->class_pointer != proto_class) |