]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
In libobjc/: 2010-12-21 Nicola Pero <nicola.pero@meta-innovation.com>
authorNicola Pero <nicola.pero@meta-innovation.com>
Tue, 21 Dec 2010 12:49:26 +0000 (12:49 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Tue, 21 Dec 2010 12:49:26 +0000 (12:49 +0000)
In libobjc/:
2010-12-21  Nicola Pero  <nicola.pero@meta-innovation.com>

* objc-private/module-abi-8.h (struct objc_symtab): Declare 'refs'
to be 'struct objc_selector *' and not 'SEL'.
* init.c (__objc_exec_class): Call
__objc_register_selectors_from_module instead of iterating over
each selector and calling __sel_register_typed_name for each.
* objc-private/selector.h: Declare
__objc_register_selectors_from_module instead of
__sel_register_typed_name.
* selector.c (__objc_register_selectors_from_module): New.
(__sel_register_typed_name): Made static.

From-SVN: r168113

libobjc/ChangeLog
libobjc/init.c
libobjc/objc-private/module-abi-8.h
libobjc/objc-private/selector.h
libobjc/selector.c

index 7d8033584b21f57f9e1de620d53bf22e538365fb..6935ac79213d99026a4142cefce39bca0834da07 100644 (file)
@@ -1,3 +1,16 @@
+2010-12-21  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc-private/module-abi-8.h (struct objc_symtab): Declare 'refs'
+       to be 'struct objc_selector *' and not 'SEL'.
+       * init.c (__objc_exec_class): Call
+       __objc_register_selectors_from_module instead of iterating over
+       each selector and calling __sel_register_typed_name for each.
+       * objc-private/selector.h: Declare
+       __objc_register_selectors_from_module instead of
+       __sel_register_typed_name.
+       * selector.c (__objc_register_selectors_from_module): New.
+       (__sel_register_typed_name): Made static.
+       
 2010-12-21  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * linking.m: Do not include objc/NXConstStr.h.
index f1eb83ab1d2ba0044325c628c4c29dc2006220db..0e0d372adad699c29fb42ec628aed2657e2dd148 100644 (file)
@@ -549,7 +549,7 @@ __objc_exec_class (struct objc_module *module)
   struct objc_list **cell;
 
   /* The table of selector references for this module.  */
-  SEL selectors = symtab->refs; 
+  struct objc_selector *selectors = symtab->refs;
 
   int i;
 
@@ -585,22 +585,9 @@ __objc_exec_class (struct objc_module *module)
   objc_mutex_lock (__objc_runtime_mutex);
   __objc_module_list = list_cons (module, __objc_module_list);
 
-  /* Replace referenced selectors from names to SEL's.  */
+  /* Replace referenced selectors from names to SELs.  */
   if (selectors)
-    {
-      for (i = 0; selectors[i].sel_id; ++i)
-       {
-         const char *name, *type;
-         name = (char *) selectors[i].sel_id;
-         type = (char *) selectors[i].sel_types;
-         /* Constructors are constant static data so we can safely
-            store pointers to them in the runtime
-            structures. is_const == YES.  */
-         __sel_register_typed_name (name, type, 
-                                    (struct objc_selector *) &(selectors[i]),
-                                    YES);
-       }
-    }
+    __objc_register_selectors_from_module (selectors);
 
   /* Parse the classes in the load module and gather selector
      information.  */
index 3ed836c518fd89d9175a13368e8e47fc38f22cdd..0c9574bb49911f59fd35f82ed780eed5305a8a0a 100644 (file)
@@ -48,10 +48,16 @@ struct objc_static_instances
 struct objc_symtab
 {
   unsigned long sel_ref_cnt;  /* Unused (always set to 0). */
-  SEL      refs;              /* The table of selectors referenced in
+  struct objc_selector *refs; /* The table of selectors referenced in
                                  this module.  This is terminated by a
                                  selector with NULL sel_id and NULL
-                                 sel_types.  */
+                                 sel_types.  Note that we use the type
+                                 'struct objc_selector *' and not
+                                 'SEL' (which is 'const struct
+                                 objc_selector *') because the sel_id
+                                 of these selectors is patched up by
+                                 the runtime when the module is
+                                 loaded.  */
   unsigned short cls_def_cnt; /* Number of classes compiled (defined)
                                  in the module. */
   unsigned short cat_def_cnt; /* Number of categories compiled
index 66413a946fed0114edc7a825082c1cef7feba87c..39fa6b6897a33428b604832366728982e356a49b 100644 (file)
@@ -43,6 +43,7 @@ void __objc_register_selectors_from_class(Class);
 void __objc_register_selectors_from_list (struct objc_method_list *);
 void __objc_register_selectors_from_description_list
 (struct objc_method_description_list *method_list);
+void __objc_register_selectors_from_module (struct objc_selector *selectors);
 
 /* Return whether a selector is mapped or not ("mapped" meaning that
    it has been inserted into the selector table).  This is private as
@@ -57,10 +58,6 @@ BOOL sel_is_mapped (SEL aSel);
 SEL
 sel_get_any_uid (const char *name);
 
-SEL
-__sel_register_typed_name (const char *name, const char *types, 
-                          struct objc_selector *orig, BOOL is_const);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index f63ceeb0f98d2330612d052304f653be7a939a94..699e52ee966ea48fbb0a0237de0c068a8295bf4a 100644 (file)
@@ -43,6 +43,11 @@ static cache_ptr      __objc_selector_hash  = 0; /* name -> uid !T:MUTEX */
 /* Number of selectors stored in each of the above tables.  */
 unsigned int __objc_selector_max_index = 0;     /* !T:MUTEX */
 
+/* Forward-declare an internal function.  */
+static SEL
+__sel_register_typed_name (const char *name, const char *types,
+                          struct objc_selector *orig, BOOL is_const);
+
 void __objc_init_selector_tables (void)
 {
   __objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0);
@@ -53,6 +58,29 @@ void __objc_init_selector_tables (void)
                     (compare_func_type) objc_compare_strings);
 }  
 
+/* Register a bunch of selectors from the table of selectors in a
+   module.  'selectors' should not be NULL.  The list is terminated by
+   a selectors with a NULL sel_id.  The selectors are assumed to
+   contain the 'name' in the sel_id field; this is replaced with the
+   final selector id after they are registered.  */
+void
+__objc_register_selectors_from_module (struct objc_selector *selectors)
+{
+  int i;
+
+  for (i = 0; selectors[i].sel_id; ++i)
+    {
+      const char *name, *type;
+      name = (char *) selectors[i].sel_id;
+      type = (char *) selectors[i].sel_types;
+      /* Constructors are constant static data and we can safely store
+        pointers to them in the runtime structures, so we set
+        is_const == YES.  */
+      __sel_register_typed_name (name, type, (struct objc_selector *) &(selectors[i]),
+                                /* is_const */ YES);
+    }
+}
+
 /* This routine is given a class and records all of the methods in its
    class structure in the record table.  */
 void
@@ -403,11 +431,16 @@ pool_alloc_selector(void)
 /* Store the passed selector name in the selector record and return
    its selector value (value returned by sel_get_uid).  Assume that
    the calling function has locked down __objc_runtime_mutex.  The
-   is_const parameter tells us if the name and types parameters are
+   'is_const' parameter tells us if the name and types parameters are
    really constant or not.  If YES then they are constant and we can
    just store the pointers.  If NO then we need to copy name and types
-   because the pointers may disappear later on.  */
-SEL
+   because the pointers may disappear later on.  If the 'orig'
+   parameter is not NULL, then we are registering a selector from a
+   module, and 'orig' is that selector.  In this case, we can put the
+   selector in the tables if needed, and orig->sel_id is updated with
+   the selector ID of the registered selector, and 'orig' is
+   returned.  */
+static SEL
 __sel_register_typed_name (const char *name, const char *types, 
                           struct objc_selector *orig, BOOL is_const)
 {