1 /* GNU Objective C Runtime initialization
2 Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
3 Contributed by Kresten Krab Thorup
4 +load support contributed by Ovidiu Predescu <ovidiu@net-community.com>
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation; either version 2, or (at your option) any later version.
12 GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 You should have received a copy of the GNU General Public License along with
18 GNU CC; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 /* As a special exception, if you link this library with files compiled with
22 GCC to produce an executable, this does not cause the resulting executable
23 to be covered by the GNU General Public License. This exception does not
24 however invalidate any other reasons why the executable file might be
25 covered by the GNU General Public License. */
29 /* The version number of this runtime. This must match the number
30 defined in gcc (objc-act.c). */
31 #define OBJC_VERSION 8
32 #define PROTOCOL_VERSION 2
34 /* This list contains all modules currently loaded into the runtime. */
35 static struct objc_list
*__objc_module_list
= 0; /* !T:MUTEX */
37 /* This list contains all proto_list's not yet assigned class links. */
38 static struct objc_list
*unclaimed_proto_list
= 0; /* !T:MUTEX */
40 /* List of unresolved static instances. */
41 static struct objc_list
*uninitialized_statics
= 0; /* !T:MUTEX */
43 /* Global runtime "write" mutex. */
44 objc_mutex_t __objc_runtime_mutex
= 0;
46 /* Number of threads that are alive. */
47 int __objc_runtime_threads_alive
= 1; /* !T:MUTEX */
49 /* Check compiler vs runtime version. */
50 static void init_check_module_version (Module_t
);
52 /* Assign isa links to protos. */
53 static void __objc_init_protocols (struct objc_protocol_list
*protos
);
55 /* Add protocol to class. */
56 static void __objc_class_add_protocols (Class
, struct objc_protocol_list
*);
58 /* This is a hook which is called by __objc_exec_class every time a
59 class or a category is loaded into the runtime. This may e.g. help
60 a dynamic loader determine the classes that have been loaded when
61 an object file is dynamically linked in. */
62 void (*_objc_load_callback
) (Class
class, Category
*category
); /* !T:SAFE */
64 /* Is all categories/classes resolved? */
65 BOOL __objc_dangling_categories
= NO
; /* !T:UNUSED */
68 __sel_register_typed_name (const char *name
, const char *types
,
69 struct objc_selector
*orig
, BOOL is_const
);
71 /* Sends +load to all classes and categories in certain situations. */
72 static void objc_send_load (void);
74 /* Inserts all the classes defined in module in a tree of classes that
75 resembles the class hierarchy. This tree is traversed in preorder
76 and the classes in its nodes receive the +load message if these
77 methods were not executed before. The algorithm ensures that when
78 the +load method of a class is executed all the superclasses have
79 been already received the +load message. */
80 static void __objc_create_classes_tree (Module_t module
);
82 static void __objc_call_callback (Module_t module
);
84 /* A special version that works only before the classes are completely
85 installed in the runtime. */
86 static BOOL
class_is_subclass_of_class (Class
class, Class superclass
);
88 typedef struct objc_class_tree
{
90 struct objc_list
*subclasses
; /* `head' is pointer to an objc_class_tree */
93 /* This is a linked list of objc_class_tree trees. The head of these
94 trees are root classes (their super class is Nil). These different
95 trees represent different class hierarchies. */
96 static struct objc_list
*__objc_class_tree_list
= NULL
;
98 /* Keeps the +load methods who have been already executed. This hash
99 should not be destroyed during the execution of the program. */
100 static cache_ptr __objc_load_methods
= NULL
;
102 /* Creates a tree of classes whose topmost class is directly inherited
103 from `upper' and the bottom class in this tree is
104 `bottom_class'. The classes in this tree are super classes of
105 `bottom_class'. `subclasses' member of each tree node point to the
106 next subclass tree node. */
108 static objc_class_tree
*
109 create_tree_of_subclasses_inherited_from (Class bottom_class
, Class upper
)
111 Class superclass
= bottom_class
->super_class
?
112 objc_lookup_class ((char *) bottom_class
->super_class
)
115 objc_class_tree
*tree
, *prev
;
117 DEBUG_PRINTF ("create_tree_of_subclasses_inherited_from:");
118 DEBUG_PRINTF ("bottom_class = %s, upper = %s\n",
119 (bottom_class
? bottom_class
->name
: NULL
),
120 (upper
? upper
->name
: NULL
));
122 tree
= prev
= objc_calloc (1, sizeof (objc_class_tree
));
123 prev
->class = bottom_class
;
125 while (superclass
!= upper
)
127 tree
= objc_calloc (1, sizeof (objc_class_tree
));
128 tree
->class = superclass
;
129 tree
->subclasses
= list_cons (prev
, tree
->subclasses
);
130 superclass
= (superclass
->super_class
?
131 objc_lookup_class ((char *) superclass
->super_class
)
139 /* Insert the `class' into the proper place in the `tree' class
140 hierarchy. This function returns a new tree if the class has been
141 successfully inserted into the tree or NULL if the class is not
142 part of the classes hierarchy described by `tree'. This function is
143 private to objc_tree_insert_class (), you should not call it
146 static objc_class_tree
*
147 __objc_tree_insert_class (objc_class_tree
*tree
, Class
class)
149 DEBUG_PRINTF ("__objc_tree_insert_class: tree = %x, class = %s\n",
153 return create_tree_of_subclasses_inherited_from (class, NULL
);
154 else if (class == tree
->class)
156 /* `class' has been already inserted */
157 DEBUG_PRINTF ("1. class %s was previously inserted\n", class->name
);
160 else if ((class->super_class
?
161 objc_lookup_class ((char *) class->super_class
)
165 /* If class is a direct subclass of tree->class then add class to the
166 list of subclasses. First check to see if it wasn't already
168 struct objc_list
*list
= tree
->subclasses
;
169 objc_class_tree
*node
;
173 /* Class has been already inserted; do nothing just return
175 if (((objc_class_tree
*) list
->head
)->class == class)
177 DEBUG_PRINTF ("2. class %s was previously inserted\n",
184 /* Create a new node class and insert it into the list of subclasses */
185 node
= objc_calloc (1, sizeof (objc_class_tree
));
187 tree
->subclasses
= list_cons (node
, tree
->subclasses
);
188 DEBUG_PRINTF ("3. class %s inserted\n", class->name
);
193 /* The class is not a direct subclass of tree->class. Search for
194 class's superclasses in the list of subclasses. */
195 struct objc_list
*subclasses
= tree
->subclasses
;
197 /* Precondition: the class must be a subclass of tree->class;
198 otherwise return NULL to indicate our caller that it must
199 take the next tree. */
200 if (! class_is_subclass_of_class (class, tree
->class))
203 for (; subclasses
!= NULL
; subclasses
= subclasses
->tail
)
205 Class aClass
= ((objc_class_tree
*) (subclasses
->head
))->class;
207 if (class_is_subclass_of_class (class, aClass
))
209 /* If we found one of class's superclasses we insert the
210 class into its subtree and return the original tree
211 since nothing has been changed. */
213 = __objc_tree_insert_class (subclasses
->head
, class);
214 DEBUG_PRINTF ("4. class %s inserted\n", class->name
);
219 /* We haven't found a subclass of `class' in the `subclasses'
220 list. Create a new tree of classes whose topmost class is a
221 direct subclass of tree->class. */
223 objc_class_tree
*new_tree
224 = create_tree_of_subclasses_inherited_from (class, tree
->class);
225 tree
->subclasses
= list_cons (new_tree
, tree
->subclasses
);
226 DEBUG_PRINTF ("5. class %s inserted\n", class->name
);
232 /* This function inserts `class' in the right tree hierarchy classes. */
235 objc_tree_insert_class (Class
class)
237 struct objc_list
*list_node
;
238 objc_class_tree
*tree
;
240 list_node
= __objc_class_tree_list
;
243 tree
= __objc_tree_insert_class (list_node
->head
, class);
246 list_node
->head
= tree
;
250 list_node
= list_node
->tail
;
253 /* If the list was finished but the class hasn't been inserted,
257 __objc_class_tree_list
= list_cons (NULL
, __objc_class_tree_list
);
258 __objc_class_tree_list
->head
= __objc_tree_insert_class (NULL
, class);
262 /* Traverse tree in preorder. Used to send +load. */
265 objc_preorder_traverse (objc_class_tree
*tree
,
267 void (*function
) (objc_class_tree
*, int))
269 struct objc_list
*node
;
271 (*function
) (tree
, level
);
272 for (node
= tree
->subclasses
; node
; node
= node
->tail
)
273 objc_preorder_traverse (node
->head
, level
+ 1, function
);
276 /* Traverse tree in postorder. Used to destroy a tree. */
279 objc_postorder_traverse (objc_class_tree
*tree
,
281 void (*function
) (objc_class_tree
*, int))
283 struct objc_list
*node
;
285 for (node
= tree
->subclasses
; node
; node
= node
->tail
)
286 objc_postorder_traverse (node
->head
, level
+ 1, function
);
287 (*function
) (tree
, level
);
290 /* Used to print a tree class hierarchy. */
294 __objc_tree_print (objc_class_tree
*tree
, int level
)
298 for (i
= 0; i
< level
; i
++)
300 printf ("%s\n", tree
->class->name
);
304 /* Walks on a linked list of methods in the reverse order and executes
305 all the methods corresponding to `op' selector. Walking in the
306 reverse order assures the +load of class is executed first and then
307 +load of categories because of the way in which categories are
308 added to the class methods. */
311 __objc_send_message_in_list (MethodList_t method_list
, Class
class, SEL op
)
318 /* First execute the `op' message in the following method lists */
319 __objc_send_message_in_list (method_list
->method_next
, class, op
);
321 /* Search the method list. */
322 for (i
= 0; i
< method_list
->method_count
; i
++)
324 Method_t mth
= &method_list
->method_list
[i
];
326 if (mth
->method_name
&& sel_eq (mth
->method_name
, op
)
327 && ! hash_is_key_in_hash (__objc_load_methods
, mth
->method_imp
))
329 /* Add this method into the +load hash table */
330 hash_add (&__objc_load_methods
, mth
->method_imp
, mth
->method_imp
);
332 DEBUG_PRINTF ("sending +load in class: %s\n", class->name
);
334 /* The method was found and wasn't previously executed. */
335 (*mth
->method_imp
) ((id
)class, mth
->method_name
);
343 __objc_send_load (objc_class_tree
*tree
,
344 int level
__attribute__ ((__unused__
)))
346 static SEL load_sel
= 0;
347 Class
class = tree
->class;
348 MethodList_t method_list
= class->class_pointer
->methods
;
351 load_sel
= sel_register_name ("load");
353 __objc_send_message_in_list (method_list
, class, load_sel
);
357 __objc_destroy_class_tree_node (objc_class_tree
*tree
,
358 int level
__attribute__ ((__unused__
)))
363 /* This is used to check if the relationship between two classes
364 before the runtime completely installs the classes. */
367 class_is_subclass_of_class (Class
class, Class superclass
)
369 for (; class != Nil
;)
371 if (class == superclass
)
373 class = (class->super_class
?
374 objc_lookup_class ((char *) class->super_class
)
381 /* This list contains all the classes in the runtime system for whom
382 their superclasses are not yet known to the runtime. */
383 static struct objc_list
*unresolved_classes
= 0;
385 /* Extern function used to reference the Object and NXConstantString
388 extern void __objc_force_linking (void);
391 __objc_force_linking (void)
393 extern void __objc_linking (void);
397 /* Run through the statics list, removing modules as soon as all its
398 statics have been initialized. */
401 objc_init_statics (void)
403 struct objc_list
**cell
= &uninitialized_statics
;
404 struct objc_static_instances
**statics_in_module
;
406 objc_mutex_lock (__objc_runtime_mutex
);
410 int module_initialized
= 1;
412 for (statics_in_module
= (*cell
)->head
;
413 *statics_in_module
; statics_in_module
++)
415 struct objc_static_instances
*statics
= *statics_in_module
;
416 Class
class = objc_lookup_class (statics
->class_name
);
419 module_initialized
= 0;
420 /* Actually, the static's class_pointer will be NULL when we
421 haven't been here before. However, the comparison is to be
422 reminded of taking into account class posing and to think about
423 possible semantics... */
424 else if (class != statics
->instances
[0]->class_pointer
)
428 for (inst
= &statics
->instances
[0]; *inst
; inst
++)
430 (*inst
)->class_pointer
= class;
432 /* ??? Make sure the object will not be freed. With
433 refcounting, invoke `-retain'. Without refcounting, do
434 nothing and hope that `-free' will never be invoked. */
436 /* ??? Send the object an `-initStatic' or something to
437 that effect now or later on? What are the semantics of
438 statically allocated instances, besides the trivial
439 NXConstantString, anyway? */
443 if (module_initialized
)
445 /* Remove this module from the uninitialized list. */
446 struct objc_list
*this = *cell
;
451 cell
= &(*cell
)->tail
;
454 objc_mutex_unlock (__objc_runtime_mutex
);
455 } /* objc_init_statics */
457 /* This function is called by constructor functions generated for each
458 module compiled. (_GLOBAL_$I$...) The purpose of this function is
459 to gather the module pointers so that they may be processed by the
460 initialization routines as soon as possible. */
463 __objc_exec_class (Module_t module
)
465 /* Have we processed any constructors previously? This flag is used to
466 indicate that some global data structures need to be built. */
467 static BOOL previous_constructors
= 0;
469 static struct objc_list
*unclaimed_categories
= 0;
471 /* The symbol table (defined in objc-api.h) generated by gcc */
472 Symtab_t symtab
= module
->symtab
;
474 /* The statics in this module */
475 struct objc_static_instances
**statics
476 = symtab
->defs
[symtab
->cls_def_cnt
+ symtab
->cat_def_cnt
];
478 /* Entry used to traverse hash lists */
479 struct objc_list
**cell
;
481 /* The table of selector references for this module */
482 SEL selectors
= symtab
->refs
;
487 DEBUG_PRINTF ("received module: %s\n", module
->name
);
489 /* check gcc version */
490 init_check_module_version (module
);
492 /* On the first call of this routine, initialize some data structures. */
493 if (! previous_constructors
)
495 /* Initialize thread-safe system */
496 __objc_init_thread_system ();
497 __objc_runtime_threads_alive
= 1;
498 __objc_runtime_mutex
= objc_mutex_allocate ();
500 __objc_init_selector_tables ();
501 __objc_init_class_tables ();
502 __objc_init_dispatch_tables ();
503 __objc_class_tree_list
= list_cons (NULL
, __objc_class_tree_list
);
505 = hash_new (128, (hash_func_type
)hash_ptr
, compare_ptrs
);
506 previous_constructors
= 1;
509 /* Save the module pointer for later processing. (not currently used) */
510 objc_mutex_lock (__objc_runtime_mutex
);
511 __objc_module_list
= list_cons (module
, __objc_module_list
);
513 /* Replace referenced selectors from names to SEL's. */
516 for (i
= 0; selectors
[i
].sel_id
; ++i
)
518 const char *name
, *type
;
519 name
= (char *) selectors
[i
].sel_id
;
520 type
= (char *) selectors
[i
].sel_types
;
521 /* Constructors are constant static data so we can safely store
522 pointers to them in the runtime structures. is_const == YES */
523 __sel_register_typed_name (name
, type
,
524 (struct objc_selector
*) &(selectors
[i
]),
529 /* Parse the classes in the load module and gather selector information. */
530 DEBUG_PRINTF ("gathering selectors from module: %s\n", module
->name
);
531 for (i
= 0; i
< symtab
->cls_def_cnt
; ++i
)
533 Class
class = (Class
) symtab
->defs
[i
];
534 const char *superclass
= (char *) class->super_class
;
536 /* Make sure we have what we think. */
537 assert (CLS_ISCLASS (class));
538 assert (CLS_ISMETA (class->class_pointer
));
539 DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name
);
541 /* Initialize the subclass list to be NULL.
542 In some cases it isn't and this crashes the program. */
543 class->subclass_list
= NULL
;
545 /* Store the class in the class table and assign class numbers. */
546 __objc_add_class_to_hash (class);
548 /* Register all of the selectors in the class and meta class. */
549 __objc_register_selectors_from_class (class);
550 __objc_register_selectors_from_class ((Class
) class->class_pointer
);
552 /* Install the fake dispatch tables */
553 __objc_install_premature_dtable (class);
554 __objc_install_premature_dtable (class->class_pointer
);
556 /* Register the instance methods as class methods, this is
557 only done for root classes. */
558 __objc_register_instance_methods_to_class (class);
560 if (class->protocols
)
561 __objc_init_protocols (class->protocols
);
563 /* Check to see if the superclass is known in this point. If it's not
564 add the class to the unresolved_classes list. */
565 if (superclass
&& ! objc_lookup_class (superclass
))
566 unresolved_classes
= list_cons (class, unresolved_classes
);
569 /* Process category information from the module. */
570 for (i
= 0; i
< symtab
->cat_def_cnt
; ++i
)
572 Category_t category
= symtab
->defs
[i
+ symtab
->cls_def_cnt
];
573 Class
class = objc_lookup_class (category
->class_name
);
575 /* If the class for the category exists then append its methods. */
579 DEBUG_PRINTF ("processing categories from (module,object): %s, %s\n",
583 /* Do instance methods. */
584 if (category
->instance_methods
)
585 class_add_method_list (class, category
->instance_methods
);
587 /* Do class methods. */
588 if (category
->class_methods
)
589 class_add_method_list ((Class
) class->class_pointer
,
590 category
->class_methods
);
592 if (category
->protocols
)
594 __objc_init_protocols (category
->protocols
);
595 __objc_class_add_protocols (class, category
->protocols
);
598 /* Register the instance methods as class methods, this is
599 only done for root classes. */
600 __objc_register_instance_methods_to_class (class);
604 /* The object to which the category methods belong can't be found.
605 Save the information. */
606 unclaimed_categories
= list_cons (category
, unclaimed_categories
);
611 uninitialized_statics
= list_cons (statics
, uninitialized_statics
);
612 if (uninitialized_statics
)
613 objc_init_statics ();
615 /* Scan the unclaimed category hash. Attempt to attach any unclaimed
616 categories to objects. */
617 for (cell
= &unclaimed_categories
; *cell
; )
619 Category_t category
= (*cell
)->head
;
620 Class
class = objc_lookup_class (category
->class_name
);
624 DEBUG_PRINTF ("attaching stored categories to object: %s\n",
627 list_remove_head (cell
);
629 if (category
->instance_methods
)
630 class_add_method_list (class, category
->instance_methods
);
632 if (category
->class_methods
)
633 class_add_method_list ((Class
) class->class_pointer
,
634 category
->class_methods
);
636 if (category
->protocols
)
638 __objc_init_protocols (category
->protocols
);
639 __objc_class_add_protocols (class, category
->protocols
);
642 /* Register the instance methods as class methods, this is
643 only done for root classes. */
644 __objc_register_instance_methods_to_class (class);
647 cell
= &(*cell
)->tail
;
650 if (unclaimed_proto_list
&& objc_lookup_class ("Protocol"))
652 list_mapcar (unclaimed_proto_list
,
653 (void (*) (void *))__objc_init_protocols
);
654 list_free (unclaimed_proto_list
);
655 unclaimed_proto_list
= 0;
660 objc_mutex_unlock (__objc_runtime_mutex
);
664 objc_send_load (void)
666 if (! __objc_module_list
)
669 /* Try to find out if all the classes loaded so far also have their
670 superclasses known to the runtime. We suppose that the objects
671 that are allocated in the +load method are in general of a class
672 declared in the same module. */
673 if (unresolved_classes
)
675 Class
class = unresolved_classes
->head
;
677 while (objc_lookup_class ((char *) class->super_class
))
679 list_remove_head (&unresolved_classes
);
680 if (unresolved_classes
)
681 class = unresolved_classes
->head
;
686 /* If we still have classes for whom we don't have yet their
687 super classes known to the runtime we don't send the +load
689 if (unresolved_classes
)
693 /* Special check to allow creating and sending messages to constant
694 strings in +load methods. If these classes are not yet known,
695 even if all the other classes are known, delay sending of +load. */
696 if (! objc_lookup_class ("NXConstantString") ||
697 ! objc_lookup_class ("Object"))
700 /* Iterate over all modules in the __objc_module_list and call on
701 them the __objc_create_classes_tree function. This function
702 creates a tree of classes that resembles the class hierarchy. */
703 list_mapcar (__objc_module_list
,
704 (void (*) (void *)) __objc_create_classes_tree
);
706 while (__objc_class_tree_list
)
709 objc_preorder_traverse (__objc_class_tree_list
->head
,
710 0, __objc_tree_print
);
712 objc_preorder_traverse (__objc_class_tree_list
->head
,
713 0, __objc_send_load
);
714 objc_postorder_traverse (__objc_class_tree_list
->head
,
715 0, __objc_destroy_class_tree_node
);
716 list_remove_head (&__objc_class_tree_list
);
719 list_mapcar (__objc_module_list
, (void (*) (void *)) __objc_call_callback
);
720 list_free (__objc_module_list
);
721 __objc_module_list
= NULL
;
725 __objc_create_classes_tree (Module_t module
)
727 /* The runtime mutex is locked in this point */
729 Symtab_t symtab
= module
->symtab
;
732 /* Iterate thru classes defined in this module and insert them in
733 the classes tree hierarchy. */
734 for (i
= 0; i
< symtab
->cls_def_cnt
; i
++)
736 Class
class = (Class
) symtab
->defs
[i
];
738 objc_tree_insert_class (class);
743 __objc_call_callback (Module_t module
)
745 /* The runtime mutex is locked in this point. */
747 Symtab_t symtab
= module
->symtab
;
750 /* Iterate thru classes defined in this module and call the callback
752 for (i
= 0; i
< symtab
->cls_def_cnt
; i
++)
754 Class
class = (Class
) symtab
->defs
[i
];
756 /* Call the _objc_load_callback for this class. */
757 if (_objc_load_callback
)
758 _objc_load_callback (class, 0);
761 /* Call the _objc_load_callback for categories. Don't register the
762 instance methods as class methods for categories to root classes
763 since they were already added in the class. */
764 for (i
= 0; i
< symtab
->cat_def_cnt
; i
++)
766 Category_t category
= symtab
->defs
[i
+ symtab
->cls_def_cnt
];
767 Class
class = objc_lookup_class (category
->class_name
);
769 if (_objc_load_callback
)
770 _objc_load_callback (class, category
);
774 /* Sanity check the version of gcc used to compile `module'. */
777 init_check_module_version (Module_t module
)
779 if ((module
->version
!= OBJC_VERSION
) || (module
->size
!= sizeof (Module
)))
783 if (module
->version
> OBJC_VERSION
)
784 code
= OBJC_ERR_OBJC_VERSION
;
785 else if (module
->version
< OBJC_VERSION
)
786 code
= OBJC_ERR_GCC_VERSION
;
788 code
= OBJC_ERR_MODULE_SIZE
;
790 objc_error (nil
, code
, "Module %s version %d doesn't match runtime %d\n",
791 module
->name
, (int)module
->version
, OBJC_VERSION
);
796 __objc_init_protocols (struct objc_protocol_list
*protos
)
799 static Class proto_class
= 0;
804 objc_mutex_lock (__objc_runtime_mutex
);
807 proto_class
= objc_lookup_class ("Protocol");
811 unclaimed_proto_list
= list_cons (protos
, unclaimed_proto_list
);
812 objc_mutex_unlock (__objc_runtime_mutex
);
817 assert (protos
->next
== 0); /* only single ones allowed */
820 for (i
= 0; i
< protos
->count
; i
++)
822 struct objc_protocol
*aProto
= protos
->list
[i
];
823 if (((size_t)aProto
->class_pointer
) == PROTOCOL_VERSION
)
825 /* assign class pointer */
826 aProto
->class_pointer
= proto_class
;
828 /* init super protocols */
829 __objc_init_protocols (aProto
->protocol_list
);
831 else if (protos
->list
[i
]->class_pointer
!= proto_class
)
833 objc_error (nil
, OBJC_ERR_PROTOCOL_VERSION
,
834 "Version %d doesn't match runtime protocol version %d\n",
835 (int) ((char *) protos
->list
[i
]->class_pointer
841 objc_mutex_unlock (__objc_runtime_mutex
);
845 __objc_class_add_protocols (Class
class, struct objc_protocol_list
*protos
)
852 protos
->next
= class->protocols
;
853 class->protocols
= protos
;