- _spin_lock(&psaved_self_global_lock);
- psaved_self = pthread_self();
- _spin_lock(&psaved_self->lock);
+ struct pthread_atfork_entry *e;
+
+ _spin_lock(&pthread_atfork_lock);
+#ifdef TAILQ_FOREACH_REVERSE_LEGACY_ORDER
+ TAILQ_FOREACH_REVERSE(e, &pthread_atfork_queue, qentry, pthread_atfork_queue_head)
+#else /* !TAILQ_FOREACH_REVERSE_LEGACY_ORDER */
+ TAILQ_FOREACH_REVERSE(e, &pthread_atfork_queue, pthread_atfork_queue_head, qentry)
+#endif /* TAILQ_FOREACH_REVERSE_LEGACY_ORDER */
+ {
+ if (e->prepare != NULL)
+ e->prepare();
+ }
+
+ _spin_lock(&psaved_self_global_lock);
+ psaved_self = pthread_self();
+ _spin_lock(&psaved_self->lock);