mirror of
https://github.com/fluencelabs/musl
synced 2025-06-28 14:11:56 +00:00
prepare cancellation syscall asm for possibility of __cancel returning
This commit is contained in:
@ -7,7 +7,7 @@ __syscall_cp_asm:
|
|||||||
__cp_begin:
|
__cp_begin:
|
||||||
ldr r0,[r0]
|
ldr r0,[r0]
|
||||||
cmp r0,#0
|
cmp r0,#0
|
||||||
blne __cancel
|
blne __cp_cancel
|
||||||
mov r7,r1
|
mov r7,r1
|
||||||
mov r0,r2
|
mov r0,r2
|
||||||
mov r1,r3
|
mov r1,r3
|
||||||
@ -19,3 +19,7 @@ __cp_end:
|
|||||||
tst lr,#1
|
tst lr,#1
|
||||||
moveq pc,lr
|
moveq pc,lr
|
||||||
bx lr
|
bx lr
|
||||||
|
.global __cp_cancel
|
||||||
|
__cp_cancel:
|
||||||
|
ldmfd sp!,{r4,r5,r6,r7,lr}
|
||||||
|
b __cancel
|
||||||
|
@ -11,7 +11,7 @@ __syscall_cp_asm:
|
|||||||
__cp_begin:
|
__cp_begin:
|
||||||
movl (%ecx),%eax
|
movl (%ecx),%eax
|
||||||
testl %eax,%eax
|
testl %eax,%eax
|
||||||
jnz __cancel
|
jnz __cp_cancel
|
||||||
movl 24(%esp),%eax
|
movl 24(%esp),%eax
|
||||||
movl 28(%esp),%ebx
|
movl 28(%esp),%ebx
|
||||||
movl 32(%esp),%ecx
|
movl 32(%esp),%ecx
|
||||||
@ -27,3 +27,10 @@ __cp_end:
|
|||||||
popl %esi
|
popl %esi
|
||||||
popl %ebx
|
popl %ebx
|
||||||
ret
|
ret
|
||||||
|
.global __cp_cancel
|
||||||
|
__cp_cancel:
|
||||||
|
popl %ebp
|
||||||
|
popl %edi
|
||||||
|
popl %esi
|
||||||
|
popl %ebx
|
||||||
|
jmp __cancel
|
||||||
|
@ -3,19 +3,19 @@
|
|||||||
.global __syscall_cp_asm
|
.global __syscall_cp_asm
|
||||||
.type __syscall_cp_asm,@function
|
.type __syscall_cp_asm,@function
|
||||||
__syscall_cp_asm:
|
__syscall_cp_asm:
|
||||||
|
subu $sp, $sp, 32
|
||||||
.global __cp_begin
|
.global __cp_begin
|
||||||
__cp_begin:
|
__cp_begin:
|
||||||
lw $4, 0($4)
|
lw $4, 0($4)
|
||||||
bne $4, $0, 2f
|
bne $4, $0, __cp_cancel
|
||||||
move $2, $5
|
move $2, $5
|
||||||
move $4, $6
|
move $4, $6
|
||||||
move $5, $7
|
move $5, $7
|
||||||
lw $6, 16($sp)
|
lw $6, 48($sp)
|
||||||
lw $7, 20($sp)
|
lw $7, 52($sp)
|
||||||
lw $8, 24($sp)
|
lw $8, 56($sp)
|
||||||
lw $9, 28($sp)
|
lw $9, 60($sp)
|
||||||
lw $10,32($sp)
|
lw $10,64($sp)
|
||||||
subu $sp, $sp, 32
|
|
||||||
sw $8, 16($sp)
|
sw $8, 16($sp)
|
||||||
sw $9, 20($sp)
|
sw $9, 20($sp)
|
||||||
sw $10,24($sp)
|
sw $10,24($sp)
|
||||||
@ -29,6 +29,10 @@ __cp_end:
|
|||||||
subu $2, $0, $2
|
subu $2, $0, $2
|
||||||
1: jr $ra
|
1: jr $ra
|
||||||
nop
|
nop
|
||||||
2: lw $25, %call16(__cancel)($gp)
|
|
||||||
|
.global __cp_cancel
|
||||||
|
__cp_cancel:
|
||||||
|
addu $sp, $sp, 32
|
||||||
|
lw $25, %call16(__cancel)($gp)
|
||||||
jr $25
|
jr $25
|
||||||
nop
|
nop
|
||||||
|
@ -31,7 +31,6 @@ __cp_begin:
|
|||||||
beq+ cr7, 1f #jump to label 1 if r0 was 0
|
beq+ cr7, 1f #jump to label 1 if r0 was 0
|
||||||
|
|
||||||
b __cancel #else call cancel
|
b __cancel #else call cancel
|
||||||
# (the return address is not needed, since __cancel never returns)
|
|
||||||
1:
|
1:
|
||||||
#ok, the cancel flag was not set
|
#ok, the cancel flag was not set
|
||||||
# syscall: number goes to r0, the rest 3-8
|
# syscall: number goes to r0, the rest 3-8
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
#include "pthread_impl.h"
|
#include "pthread_impl.h"
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
|
#include "libc.h"
|
||||||
|
|
||||||
void __cancel()
|
void __cancel()
|
||||||
{
|
{
|
||||||
pthread_exit(PTHREAD_CANCELED);
|
pthread_exit(PTHREAD_CANCELED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If __syscall_cp_asm has adjusted the stack pointer, it must provide a
|
||||||
|
* definition of __cp_cancel to undo those adjustments and call __cancel.
|
||||||
|
* Otherwise, __cancel provides a definition for __cp_cancel. */
|
||||||
|
|
||||||
|
weak_alias(__cancel, __cp_cancel);
|
||||||
|
|
||||||
long __syscall_cp_asm(volatile void *, syscall_arg_t,
|
long __syscall_cp_asm(volatile void *, syscall_arg_t,
|
||||||
syscall_arg_t, syscall_arg_t, syscall_arg_t,
|
syscall_arg_t, syscall_arg_t, syscall_arg_t,
|
||||||
syscall_arg_t, syscall_arg_t, syscall_arg_t);
|
syscall_arg_t, syscall_arg_t, syscall_arg_t);
|
||||||
|
Reference in New Issue
Block a user