initial check-in, version 0.5.0
[musl] / src / thread / cancellation.c
1 #include "pthread_impl.h"
2
3 void __pthread_register_cancel(struct __ptcb *cb)
4 {
5         struct pthread *self = pthread_self();
6         cb->__next = self->cancelbuf;
7         self->cancelbuf = cb;
8 }
9
10 #define pthread_self __pthread_self
11
12 void __pthread_unregister_cancel(struct __ptcb *cb)
13 {
14         struct pthread *self = pthread_self();
15         self->cancelbuf = self->cancelbuf->__next;
16 }
17
18 void __pthread_unwind_next(struct __ptcb *cb)
19 {
20         if (cb->__next) longjmp((void *)cb->__next->__jb, 1);
21         pthread_exit(PTHREAD_CANCELLED);
22 }