52 tesla_global_store_sysinit(
__unused void *arg)
60 SYSINIT(tesla_global_store, SI_SUB_TESLA, SI_ORDER_FIRST,
61 tesla_global_store_sysinit, NULL);
74 store = &global_store;
79 store = curthread->td_tesla;
82 store = pthread_getspecific(key);
89 curthread->td_tesla = store;
91 __debug int err = pthread_setspecific(key, store);
108 assert(store->
classes != NULL);
118 uint32_t
classes, uint32_t instances)
121 assert(instances > 0);
129 for (uint32_t i = 0; i <
classes; i++) {
145 DEBUG(libtesla.store.free,
"tesla_store_free %tx\n", store);
147 for (uint32_t i = 0; i < store->
length; i++)
156 const char *name,
const char *description)
158 assert(store != NULL);
159 assert(tclassp != NULL);
165 assert(tclass != NULL);
173 tesla_class_acquire(tclass);
181 switch (class->tc_context) {
189 assert(0 &&
"unhandled TESLA context");
198 static pthread_key_t key;
199 static int key_initialised = 0;
200 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
205 if (key_initialised)
return key;
207 int error
__debug = pthread_mutex_lock(&lock);
208 assert(error == 0 &&
"failed to lock pthread key mutex");
212 if (key_initialised)
return key;
215 assert(error == 0 &&
"failed to create pthread_key_t");
219 error = pthread_mutex_unlock(&lock);
220 assert(error == 0 &&
"failed to unlock pthread key mutex");