+static void dummy_1(pthread_t self)
+{
+}
+weak_alias(dummy_1, __pthread_tsd_run_dtors);
+
+#ifdef __pthread_unwind_next
+#undef __pthread_unwind_next
+#define __pthread_unwind_next __pthread_unwind_next_3
+#endif
+
+void __pthread_unwind_next(struct __ptcb *cb)
+{
+ pthread_t self;
+
+ if (cb->__next) longjmp((void *)cb->__next->__jb, 1);
+
+ self = pthread_self();
+
+ LOCK(&self->exitlock);
+
+ __pthread_tsd_run_dtors(self);
+
+ /* Mark this thread dead before decrementing count */
+ self->dead = 1;
+
+ if (!a_fetch_add(&libc.threads_minus_1, -1))
+ exit(0);
+
+ if (self->detached && self->map_base) {
+ syscall(__NR_rt_sigprocmask, SIG_BLOCK, (long)(uint64_t[1]){-1},0,8);
+ __unmapself(self->map_base, self->map_size);
+ }
+
+ syscall(SYS_exit, 0);
+}