__syscall_cp_asm:
mov ip,sp
stmfd sp!,{r4,r5,r6,r7,lr}
- stmfd sp!,{r0}
- bl 1f
-1: mov r4,#(1f-.)
- add r4,r4,lr
- str r4,[r0,#4]
- str sp,[r0]
+.global __cp_begin
+__cp_begin:
+ ld r0,[r0]
+ cmp r0,#0
+ blne __cancel
mov r7,r1
mov r0,r2
mov r1,r3
ldmfd ip,{r2,r3,r4,r5,r6}
-1: svc 0
- ldmfd sp!,{r1}
- mov r2,#0
- str r2,[r1]
+ svc 0
+.global __cp_end
+__cp_end:
ldmfd sp!,{r4,r5,r6,r7,lr}
tst lr,#1
moveq pc,lr
long (__syscall_cp)(long nr, long u, long v, long w, long x, long y, long z)
{
pthread_t self;
- uintptr_t old_sp, old_ip;
long r;
if (!libc.main_thread || (self = __pthread_self())->canceldisable)
return __syscall(nr, u, v, w, x, y, z);
- old_sp = self->cp_sp;
- old_ip = self->cp_ip;
- self->cp_sp = 0;
- self->cp_ip = 0;
- r = __syscall_cp_asm(&self->cp_sp, nr, u, v, w, x, y, z);
- self->cp_ip = old_ip;
- self->cp_sp = old_sp;
+ r = __syscall_cp_asm(&self->cancel, nr, u, v, w, x, y, z);
if (r==-EINTR && nr!=SYS_close && self->cancel && !self->canceldisable)
__cancel();
return r;
{
pthread_t self = __pthread_self();
ucontext_t *uc = ctx;
- uintptr_t sp = ((uintptr_t *)&uc->uc_mcontext)[CANCEL_REG_SP];
- uintptr_t ip = ((uintptr_t *)&uc->uc_mcontext)[CANCEL_REG_IP];
+ const char *ip = ((char **)&uc->uc_mcontext)[CANCEL_REG_IP];
+ extern const char __cp_begin[1], __cp_end[1];
if (!self->cancel || self->canceldisable) return;
_sigaddset(&uc->uc_sigmask, SIGCANCEL);
- if (self->cancelasync || sp == self->cp_sp && ip <= self->cp_ip) {
+ if (self->cancelasync || ip >= __cp_begin && ip < __cp_end) {
self->canceldisable = 1;
pthread_sigmask(SIG_SETMASK, &uc->uc_sigmask, 0);
__cancel();