+SEL
+sel_getTypedSelector (const char *name)
+{
+ sidx i;
+
+ if (name == NULL)
+ return NULL;
+
+ objc_mutex_lock (__objc_runtime_mutex);
+
+ /* Look for a typed selector. */
+ i = (sidx) objc_hash_value_for_key (__objc_selector_hash, name);
+ if (i != 0)
+ {
+ struct objc_list *l;
+ SEL returnValue = NULL;
+
+ for (l = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
+ l; l = l->tail)
+ {
+ SEL s = (SEL) l->head;
+ if (s->sel_types)
+ {
+ if (returnValue == NULL)
+ {
+ /* First typed selector that we find. Keep it in
+ returnValue, but keep checking as we want to
+ detect conflicts. */
+ returnValue = s;
+ }
+ else
+ {
+ /* We had already found a typed selectors, so we
+ have multiple ones. Double-check that they have
+ different types, just in case for some reason we
+ got duplicates with the same types. If so, it's
+ OK, we'll ignore the duplicate. */
+ if (returnValue->sel_types == s->sel_types)
+ continue;
+ else if (sel_types_match (returnValue->sel_types, s->sel_types))
+ continue;
+ else
+ {
+ /* The types of the two selectors are different;
+ it's a conflict. Too bad. Return NULL. */
+ objc_mutex_unlock (__objc_runtime_mutex);
+ return NULL;
+ }
+ }
+ }
+ }
+
+ if (returnValue != NULL)
+ {
+ objc_mutex_unlock (__objc_runtime_mutex);
+ return returnValue;
+ }
+ }
+
+ /* No typed selector found. Return NULL. */
+ objc_mutex_unlock (__objc_runtime_mutex);
+ return 0;
+}
+
+SEL *
+sel_copyTypedSelectorList (const char *name, unsigned int *numberOfReturnedSelectors)
+{
+ unsigned int count = 0;
+ SEL *returnValue = NULL;
+ sidx i;
+
+ if (name == NULL)
+ {
+ if (numberOfReturnedSelectors)
+ *numberOfReturnedSelectors = 0;
+ return NULL;
+ }
+
+ objc_mutex_lock (__objc_runtime_mutex);
+
+ /* Count how many selectors we have. */
+ i = (sidx) objc_hash_value_for_key (__objc_selector_hash, name);
+ if (i != 0)
+ {
+ struct objc_list *selector_list = NULL;
+ selector_list = (struct objc_list *) sarray_get_safe (__objc_selector_array, i);
+
+ /* Count how many selectors we have. */
+ {
+ struct objc_list *l;
+ for (l = selector_list; l; l = l->tail)
+ count++;
+ }
+
+ if (count != 0)
+ {
+ /* Allocate enough memory to hold them. */
+ returnValue = (SEL *)(malloc (sizeof (SEL) * (count + 1)));
+
+ /* Copy the selectors. */
+ {
+ unsigned int j;
+ for (j = 0; j < count; j++)
+ {
+ returnValue[j] = (SEL)(selector_list->head);
+ selector_list = selector_list->tail;
+ }
+ returnValue[j] = NULL;
+ }
+ }
+ }
+
+ objc_mutex_unlock (__objc_runtime_mutex);
+
+ if (numberOfReturnedSelectors)
+ *numberOfReturnedSelectors = count;
+
+ return returnValue;
+}
+
+/* Get the name of a selector. If the selector is unknown, the empty
+ string "" is returned. */