+
+void __pthread_tsd_run_dtors()
+{
+ pthread_t self = __pthread_self();
+ int i, j;
+ for (j=0; self->tsd_used && j<PTHREAD_DESTRUCTOR_ITERATIONS; j++) {
+ __pthread_rwlock_rdlock(&key_lock);
+ self->tsd_used = 0;
+ for (i=0; i<PTHREAD_KEYS_MAX; i++) {
+ void *val = self->tsd[i];
+ void (*dtor)(void *) = keys[i];
+ self->tsd[i] = 0;
+ if (val && dtor && dtor != nodtor) {
+ __pthread_rwlock_unlock(&key_lock);
+ dtor(val);
+ __pthread_rwlock_rdlock(&key_lock);
+ }
+ }
+ __pthread_rwlock_unlock(&key_lock);
+ }
+}
+
+weak_alias(__pthread_key_create, pthread_key_create);
+weak_alias(__pthread_key_delete, pthread_key_delete);