/* GNU Objective C Runtime class related functions
- Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
Contributed by Kresten Krab Thorup and Dennis Glatting.
This file is part of GNU CC.
#include "sarray.h"
/* The table of classname->class. Used for objc_lookup_class and friends */
-static cache_ptr __objc_class_hash = 0;
+static cache_ptr __objc_class_hash = 0; /* !T:MUTEX */
/* This is a hook which is called by objc_get_class and
objc_lookup_class if the runtime is not able to find the class.
This may e.g. try to load in the class using dynamic loading */
-Class (*_objc_lookup_class)(const char* name) = 0;
+Class (*_objc_lookup_class)(const char* name) = 0; /* !T:SAFE */
/* True when class links has been resolved */
-BOOL __objc_class_links_resolved = NO;
+BOOL __objc_class_links_resolved = NO; /* !T:UNUSED */
/* Initial number of buckets size of class hash table. */
if(__objc_class_hash)
return;
+ objc_mutex_lock(__objc_runtime_mutex);
+
__objc_class_hash
= hash_new (CLASS_HASH_SIZE,
(hash_func_type) hash_string,
(compare_func_type) compare_strings);
+
+ objc_mutex_unlock(__objc_runtime_mutex);
}
/* This function adds a class to the class hash table, and assigns the
{
Class h_class;
+ objc_mutex_lock(__objc_runtime_mutex);
+
/* make sure the table is there */
assert(__objc_class_hash);
++class_number;
hash_add (&__objc_class_hash, class->name, class);
}
+
+ objc_mutex_unlock(__objc_runtime_mutex);
}
/* Get the class object for the class named NAME. If NAME does not
{
Class class;
+ objc_mutex_lock(__objc_runtime_mutex);
+
/* Make sure the class hash table exists. */
assert (__objc_class_hash);
class = hash_value_for_key (__objc_class_hash, name);
+ objc_mutex_unlock(__objc_runtime_mutex);
+
if (class)
return class;
{
Class class;
+ objc_mutex_lock(__objc_runtime_mutex);
+
/* Make sure the class hash table exists. */
assert (__objc_class_hash);
class = hash_value_for_key (__objc_class_hash, name);
+ objc_mutex_unlock(__objc_runtime_mutex);
+
if (class)
return class;
Class
objc_next_class(void **enum_state)
{
+ objc_mutex_lock(__objc_runtime_mutex);
+
/* make sure the table is there */
assert(__objc_class_hash);
*(node_ptr*)enum_state =
hash_next(__objc_class_hash, *(node_ptr*)enum_state);
+
+ objc_mutex_unlock(__objc_runtime_mutex);
+
if (*(node_ptr*)enum_state)
return (*(node_ptr*)enum_state)->value;
return (Class)0;
assert(object_class);
+ objc_mutex_lock(__objc_runtime_mutex);
+
/* Assign subclass links */
for (node = hash_next (__objc_class_hash, NULL); node;
node = hash_next (__objc_class_hash, node))
sub_class->class_pointer->super_class = class1->class_pointer;
}
}
+
+ objc_mutex_unlock(__objc_runtime_mutex);
}
what the keys of the hashtable is, change all values that are
superclass into impostor. */
+ objc_mutex_lock(__objc_runtime_mutex);
+
for (node = hash_next (__objc_class_hash, NULL); node;
node = hash_next (__objc_class_hash, node))
{
}
}
+ objc_mutex_unlock(__objc_runtime_mutex);
+
/* next, we update the dispatch tables... */
__objc_update_dispatch_table_for_class (CLASSOF (impostor));
__objc_update_dispatch_table_for_class (impostor);