|
Packit Service |
82fcde |
/* Copyright (C) 2009-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
Contributed by Ulrich Drepper <drepper@redhat.com>, 2009.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sysdep.h>
|
|
Packit Service |
82fcde |
#include <tcb-offsets.h>
|
|
Packit Service |
82fcde |
#include <kernel-features.h>
|
|
Packit Service |
82fcde |
#include "lowlevellock.h"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define PTHREAD_UNWIND JUMPTARGET(__pthread_unwind)
|
|
Packit Service |
82fcde |
#if IS_IN (libpthread)
|
|
Packit Service |
82fcde |
# if defined SHARED && !defined NO_HIDDEN
|
|
Packit Service |
82fcde |
# undef PTHREAD_UNWIND
|
|
Packit Service |
82fcde |
# define PTHREAD_UNWIND __GI___pthread_unwind
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
# ifndef SHARED
|
|
Packit Service |
82fcde |
.weak __pthread_unwind
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define LOAD_PRIVATE_FUTEX_WAIT(reg) \
|
|
Packit Service |
82fcde |
movl $(FUTEX_WAIT | FUTEX_PRIVATE_FLAG), reg
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* It is crucial that the functions in this file don't modify registers
|
|
Packit Service |
82fcde |
other than %rax and %r11. The syscall wrapper code depends on this
|
|
Packit Service |
82fcde |
because it doesn't explicitly save the other registers which hold
|
|
Packit Service |
82fcde |
relevant values. */
|
|
Packit Service |
82fcde |
.text
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.hidden __pthread_enable_asynccancel
|
|
Packit Service |
82fcde |
ENTRY(__pthread_enable_asynccancel)
|
|
Packit Service |
82fcde |
movl %fs:CANCELHANDLING, %eax
|
|
Packit Service |
82fcde |
2: movl %eax, %r11d
|
|
Packit Service |
82fcde |
orl $TCB_CANCELTYPE_BITMASK, %r11d
|
|
Packit Service |
82fcde |
cmpl %eax, %r11d
|
|
Packit Service |
82fcde |
je 1f
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
lock
|
|
Packit Service |
82fcde |
cmpxchgl %r11d, %fs:CANCELHANDLING
|
|
Packit Service |
82fcde |
jnz 2b
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
andl $(TCB_CANCELSTATE_BITMASK|TCB_CANCELTYPE_BITMASK|TCB_CANCELED_BITMASK|TCB_EXITING_BITMASK|TCB_CANCEL_RESTMASK|TCB_TERMINATED_BITMASK), %r11d
|
|
Packit Service |
82fcde |
cmpl $(TCB_CANCELTYPE_BITMASK|TCB_CANCELED_BITMASK), %r11d
|
|
Packit Service |
82fcde |
je 3f
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
1: ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
3: subq $8, %rsp
|
|
Packit Service |
82fcde |
cfi_adjust_cfa_offset(8)
|
|
Packit Service |
82fcde |
LP_OP(mov) $TCB_PTHREAD_CANCELED, %fs:RESULT
|
|
Packit Service |
82fcde |
lock
|
|
Packit Service |
82fcde |
orl $TCB_EXITING_BITMASK, %fs:CANCELHANDLING
|
|
Packit Service |
82fcde |
mov %fs:CLEANUP_JMP_BUF, %RDI_LP
|
|
Packit Service |
82fcde |
call PTHREAD_UNWIND
|
|
Packit Service |
82fcde |
hlt
|
|
Packit Service |
82fcde |
END(__pthread_enable_asynccancel)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.hidden __pthread_disable_asynccancel
|
|
Packit Service |
82fcde |
ENTRY(__pthread_disable_asynccancel)
|
|
Packit Service |
82fcde |
testl $TCB_CANCELTYPE_BITMASK, %edi
|
|
Packit Service |
82fcde |
jnz 1f
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movl %fs:CANCELHANDLING, %eax
|
|
Packit Service |
82fcde |
2: movl %eax, %r11d
|
|
Packit Service |
82fcde |
andl $~TCB_CANCELTYPE_BITMASK, %r11d
|
|
Packit Service |
82fcde |
lock
|
|
Packit Service |
82fcde |
cmpxchgl %r11d, %fs:CANCELHANDLING
|
|
Packit Service |
82fcde |
jnz 2b
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
movl %r11d, %eax
|
|
Packit Service |
82fcde |
3: andl $(TCB_CANCELING_BITMASK|TCB_CANCELED_BITMASK), %eax
|
|
Packit Service |
82fcde |
cmpl $TCB_CANCELING_BITMASK, %eax
|
|
Packit Service |
82fcde |
je 4f
|
|
Packit Service |
82fcde |
1: ret
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Performance doesn't matter in this loop. We will
|
|
Packit Service |
82fcde |
delay until the thread is canceled. And we will unlikely
|
|
Packit Service |
82fcde |
enter the loop twice. */
|
|
Packit Service |
82fcde |
4: mov %fs:0, %RDI_LP
|
|
Packit Service |
82fcde |
movl $__NR_futex, %eax
|
|
Packit Service |
82fcde |
xorq %r10, %r10
|
|
Packit Service |
82fcde |
addq $CANCELHANDLING, %rdi
|
|
Packit Service |
82fcde |
LOAD_PRIVATE_FUTEX_WAIT (%esi)
|
|
Packit Service |
82fcde |
syscall
|
|
Packit Service |
82fcde |
movl %fs:CANCELHANDLING, %eax
|
|
Packit Service |
82fcde |
jmp 3b
|
|
Packit Service |
82fcde |
END(__pthread_disable_asynccancel)
|