-void dyld_register_tlv_state_change_handler(enum dyld_tlv_states state, dyld_tlv_state_change_handler handler)
-{
- TLVHandler *h = malloc(sizeof(TLVHandler));
- h->state = state;
- h->handler = Block_copy(handler);
-
- TLVHandler *old;
- do {
- old = tlv_handlers;
- h->next = old;
- } while (! OSAtomicCompareAndSwapPtrBarrier(old, h, (void * volatile *)&tlv_handlers));
-}
-
-
-void dyld_enumerate_tlv_storage(dyld_tlv_state_change_handler handler)
-{
- pthread_mutex_lock(&tlv_live_image_lock);
- unsigned int count = tlv_live_image_used_count;
- void *list[count];
- for (unsigned int i = 0; i < count; ++i) {
- list[i] = pthread_getspecific(tlv_live_images[i].key);
- }
- pthread_mutex_unlock(&tlv_live_image_lock);
-
- for (unsigned int i = 0; i < count; ++i) {
- if (list[i]) {
- dyld_tlv_info info = { sizeof(info), list[i], malloc_size(list[i]) };
- handler(dyld_tlv_state_allocated, &info);
- }
- }
-}
-
-