OLD | NEW |
1 #define _GNU_SOURCE | 1 #define _GNU_SOURCE |
2 #include <string.h> | 2 #include <string.h> |
3 #include "pthread_impl.h" | 3 #include "pthread_impl.h" |
4 #include "syscall.h" | 4 #include "syscall.h" |
5 #include "libc.h" | 5 #include "libc.h" |
6 | 6 |
7 __attribute__((__visibility__("hidden"))) | 7 __attribute__((__visibility__("hidden"))) |
8 long __cancel(), __syscall_cp_asm(), __syscall_cp_c(); | 8 long __cancel(), __syscall_cp_asm(), __syscall_cp_c(); |
9 | 9 |
10 long __cancel() | 10 long __cancel() |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 { | 52 { |
53 pthread_t self = __pthread_self(); | 53 pthread_t self = __pthread_self(); |
54 ucontext_t *uc = ctx; | 54 ucontext_t *uc = ctx; |
55 uintptr_t pc = uc->uc_mcontext.MC_PC; | 55 uintptr_t pc = uc->uc_mcontext.MC_PC; |
56 | 56 |
57 a_barrier(); | 57 a_barrier(); |
58 if (!self->cancel || self->canceldisable == PTHREAD_CANCEL_DISABLE) retu
rn; | 58 if (!self->cancel || self->canceldisable == PTHREAD_CANCEL_DISABLE) retu
rn; |
59 | 59 |
60 _sigaddset(&uc->uc_sigmask, SIGCANCEL); | 60 _sigaddset(&uc->uc_sigmask, SIGCANCEL); |
61 | 61 |
62 » if (self->cancelasync || pc >= (uintptr_t)__cp_begin && pc < (uintptr_t)
__cp_end) { | 62 » if (self->cancelasync || (pc >= (uintptr_t)__cp_begin && pc < (uintptr_t
)__cp_end)) { |
63 uc->uc_mcontext.MC_PC = (uintptr_t)__cp_cancel; | 63 uc->uc_mcontext.MC_PC = (uintptr_t)__cp_cancel; |
64 return; | 64 return; |
65 } | 65 } |
66 | 66 |
67 __syscall(SYS_tkill, self->tid, SIGCANCEL); | 67 __syscall(SYS_tkill, self->tid, SIGCANCEL); |
68 } | 68 } |
69 | 69 |
70 void __testcancel() | 70 void __testcancel() |
71 { | 71 { |
72 pthread_t self = __pthread_self(); | 72 pthread_t self = __pthread_self(); |
(...skipping 14 matching lines...) Expand all Loading... |
87 int pthread_cancel(pthread_t t) | 87 int pthread_cancel(pthread_t t) |
88 { | 88 { |
89 static int init; | 89 static int init; |
90 if (!init) { | 90 if (!init) { |
91 init_cancellation(); | 91 init_cancellation(); |
92 init = 1; | 92 init = 1; |
93 } | 93 } |
94 a_store(&t->cancel, 1); | 94 a_store(&t->cancel, 1); |
95 return pthread_kill(t, SIGCANCEL); | 95 return pthread_kill(t, SIGCANCEL); |
96 } | 96 } |
OLD | NEW |