Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
glibc
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
e51deae
abilist
aout
argp
assert
bits
catgets
conf
conform
crypt
csu
ctype
debug
dirent
dlfcn
elf
gmon
gnulib
grp
hesiod
hurd
iconv
iconvdata
include
inet
intl
io
libidn
libio
locale
localedata
login
mach
malloc
manual
math
misc
nis
nptl
sysdeps
ANNOUNCE
Banner
ChangeLog
DESIGN-barrier.txt
DESIGN-condvar.txt
DESIGN-rwlock.txt
DESIGN-sem.txt
Makeconfig
Makefile
TODO
TODO-kernel
TODO-testing
Versions
alloca_cutoff.c
allocatestack.c
cancellation.c
cleanup.c
cleanup_compat.c
cleanup_defer.c
cleanup_defer_compat.c
cleanup_routine.c
cond-perf.c
configure
descr.h
eintr.c
errno-loc.c
events.c
forward.c
herrno.c
init.c
libc-cancellation.c
lowlevellock.h
old_pthread_atfork.c
old_pthread_cond_broadcast.c
old_pthread_cond_destroy.c
old_pthread_cond_init.c
old_pthread_cond_signal.c
old_pthread_cond_timedwait.c
old_pthread_cond_wait.c
perf.c
pt-allocrtsig.c
pt-cleanup.c
pt-raise.c
pt-system.c
pthread-errnos.sym
pthreadP.h
pthread_atfork.c
pthread_attr_destroy.c
pthread_attr_getdetachstate.c
pthread_attr_getguardsize.c
pthread_attr_getinheritsched.c
pthread_attr_getschedparam.c
pthread_attr_getschedpolicy.c
pthread_attr_getscope.c
pthread_attr_getstack.c
pthread_attr_getstackaddr.c
pthread_attr_getstacksize.c
pthread_attr_init.c
pthread_attr_setdetachstate.c
pthread_attr_setguardsize.c
pthread_attr_setinheritsched.c
pthread_attr_setschedparam.c
pthread_attr_setschedpolicy.c
pthread_attr_setscope.c
pthread_attr_setstack.c
pthread_attr_setstackaddr.c
pthread_attr_setstacksize.c
pthread_barrier_destroy.c
pthread_barrier_init.c
pthread_barrier_wait.c
pthread_barrierattr_destroy.c
pthread_barrierattr_getpshared.c
pthread_barrierattr_init.c
pthread_barrierattr_setpshared.c
pthread_cancel.c
pthread_clock_gettime.c
pthread_clock_settime.c
pthread_cond_broadcast.c
pthread_cond_destroy.c
pthread_cond_init.c
pthread_cond_signal.c
pthread_cond_timedwait.c
pthread_cond_wait.c
pthread_condattr_destroy.c
pthread_condattr_getclock.c
pthread_condattr_getpshared.c
pthread_condattr_init.c
pthread_condattr_setclock.c
pthread_condattr_setpshared.c
pthread_create.c
pthread_detach.c
pthread_equal.c
pthread_exit.c
pthread_getattr_np.c
pthread_getconcurrency.c
pthread_getcpuclockid.c
pthread_getschedparam.c
pthread_getspecific.c
pthread_join.c
pthread_key_create.c
pthread_key_delete.c
pthread_kill_other_threads.c
pthread_mutex_consistent.c
pthread_mutex_destroy.c
pthread_mutex_getprioceiling.c
pthread_mutex_init.c
pthread_mutex_lock.c
pthread_mutex_setprioceiling.c
pthread_mutex_timedlock.c
pthread_mutex_trylock.c
pthread_mutex_unlock.c
pthread_mutexattr_destroy.c
pthread_mutexattr_getprioceiling.c
pthread_mutexattr_getprotocol.c
pthread_mutexattr_getpshared.c
pthread_mutexattr_getrobust.c
pthread_mutexattr_gettype.c
pthread_mutexattr_init.c
pthread_mutexattr_setprioceiling.c
pthread_mutexattr_setprotocol.c
pthread_mutexattr_setpshared.c
pthread_mutexattr_setrobust.c
pthread_mutexattr_settype.c
pthread_once.c
pthread_rwlock_destroy.c
pthread_rwlock_init.c
pthread_rwlock_rdlock.c
pthread_rwlock_timedrdlock.c
pthread_rwlock_timedwrlock.c
pthread_rwlock_tryrdlock.c
pthread_rwlock_trywrlock.c
pthread_rwlock_unlock.c
pthread_rwlock_wrlock.c
pthread_rwlockattr_destroy.c
pthread_rwlockattr_getkind_np.c
pthread_rwlockattr_getpshared.c
pthread_rwlockattr_init.c
pthread_rwlockattr_setkind_np.c
pthread_rwlockattr_setpshared.c
pthread_self.c
pthread_setcancelstate.c
pthread_setcanceltype.c
pthread_setconcurrency.c
pthread_setegid.c
pthread_seteuid.c
pthread_setgid.c
pthread_setregid.c
pthread_setresgid.c
pthread_setresuid.c
pthread_setreuid.c
pthread_setschedparam.c
pthread_setschedprio.c
pthread_setspecific.c
pthread_setuid.c
pthread_spin_destroy.c
pthread_spin_init.c
pthread_spin_unlock.c
pthread_testcancel.c
pthread_timedjoin.c
pthread_tryjoin.c
res.c
sem_close.c
sem_destroy.c
sem_getvalue.c
sem_init.c
sem_open.c
sem_unlink.c
semaphore.h
semaphoreP.h
shlib-versions
sigaction.c
sockperf.c
tpp.c
tst-_res1.c
tst-_res1mod1.c
tst-_res1mod2.c
tst-align.c
tst-align2.c
tst-align3.c
tst-atfork1.c
tst-atfork2.c
tst-atfork2mod.c
tst-attr1.c
tst-attr2.c
tst-attr3.c
tst-backtrace1.c
tst-barrier1.c
tst-barrier2.c
tst-barrier3.c
tst-barrier4.c
tst-basic1.c
tst-basic2.c
tst-basic3.c
tst-basic4.c
tst-basic5.c
tst-basic6.c
tst-cancel-wrappers.sh
tst-cancel1.c
tst-cancel10.c
tst-cancel11.c
tst-cancel12.c
tst-cancel13.c
tst-cancel14.c
tst-cancel15.c
tst-cancel16.c
tst-cancel17.c
tst-cancel18.c
tst-cancel19.c
tst-cancel2.c
tst-cancel20.c
tst-cancel21.c
tst-cancel22.c
tst-cancel23.c
tst-cancel24.cc
tst-cancel25.c
tst-cancel3.c
tst-cancel4.c
tst-cancel5.c
tst-cancel6.c
tst-cancel7.c
tst-cancel8.c
tst-cancel9.c
tst-cancelx1.c
tst-cancelx10.c
tst-cancelx11.c
tst-cancelx12.c
tst-cancelx13.c
tst-cancelx14.c
tst-cancelx15.c
tst-cancelx16.c
tst-cancelx17.c
tst-cancelx18.c
tst-cancelx2.c
tst-cancelx20.c
tst-cancelx21.c
tst-cancelx3.c
tst-cancelx4.c
tst-cancelx5.c
tst-cancelx6.c
tst-cancelx7.c
tst-cancelx8.c
tst-cancelx9.c
tst-cleanup0.c
tst-cleanup0.expect
tst-cleanup1.c
tst-cleanup2.c
tst-cleanup3.c
tst-cleanup4.c
tst-cleanup4aux.c
tst-cleanupx0.c
tst-cleanupx0.expect
tst-cleanupx1.c
tst-cleanupx2.c
tst-cleanupx3.c
tst-cleanupx4.c
tst-clock1.c
tst-clock2.c
tst-cond1.c
tst-cond10.c
tst-cond11.c
tst-cond12.c
tst-cond13.c
tst-cond14.c
tst-cond15.c
tst-cond16.c
tst-cond17.c
tst-cond18.c
tst-cond19.c
tst-cond2.c
tst-cond20.c
tst-cond21.c
tst-cond22.c
tst-cond3.c
tst-cond4.c
tst-cond5.c
tst-cond6.c
tst-cond7.c
tst-cond8.c
tst-cond9.c
tst-context1.c
tst-detach1.c
tst-dlsym1.c
tst-eintr1.c
tst-eintr2.c
tst-eintr3.c
tst-eintr4.c
tst-eintr5.c
tst-exec1.c
tst-exec2.c
tst-exec3.c
tst-exec4.c
tst-execstack-mod.c
tst-execstack.c
tst-exit1.c
tst-exit2.c
tst-exit3.c
tst-fini1.c
tst-fini1mod.c
tst-flock1.c
tst-flock2.c
tst-fork1.c
tst-fork2.c
tst-fork3.c
tst-fork4.c
tst-getpid1.c
tst-getpid2.c
tst-getpid3.c
tst-initializers1-c89.c
tst-initializers1-c99.c
tst-initializers1-gnu89.c
tst-initializers1-gnu99.c
tst-initializers1.c
tst-join1.c
tst-join2.c
tst-join3.c
tst-join4.c
tst-join5.c
tst-join6.c
tst-key1.c
tst-key2.c
tst-key3.c
tst-key4.c
tst-kill1.c
tst-kill2.c
tst-kill3.c
tst-kill4.c
tst-kill5.c
tst-kill6.c
tst-locale1.c
tst-locale2.c
tst-mutex1.c
tst-mutex2.c
tst-mutex3.c
tst-mutex4.c
tst-mutex5.c
tst-mutex5a.c
tst-mutex6.c
tst-mutex7.c
tst-mutex7a.c
tst-mutex8.c
tst-mutex9.c
tst-mutexpi1.c
tst-mutexpi2.c
tst-mutexpi3.c
tst-mutexpi4.c
tst-mutexpi5.c
tst-mutexpi5a.c
tst-mutexpi6.c
tst-mutexpi7.c
tst-mutexpi7a.c
tst-mutexpi8.c
tst-mutexpi9.c
tst-mutexpp1.c
tst-mutexpp10.c
tst-mutexpp6.c
tst-oddstacklimit.c
tst-once1.c
tst-once2.c
tst-once3.c
tst-once4.c
tst-oncex3.c
tst-oncex4.c
tst-popen1.c
tst-raise1.c
tst-robust1.c
tst-robust2.c
tst-robust3.c
tst-robust4.c
tst-robust5.c
tst-robust6.c
tst-robust7.c
tst-robust8.c
tst-robust9.c
tst-robustpi1.c
tst-robustpi2.c
tst-robustpi3.c
tst-robustpi4.c
tst-robustpi5.c
tst-robustpi6.c
tst-robustpi7.c
tst-robustpi8.c
tst-robustpi9.c
tst-rwlock1.c
tst-rwlock10.c
tst-rwlock11.c
tst-rwlock12.c
tst-rwlock13.c
tst-rwlock14.c
tst-rwlock2.c
tst-rwlock3.c
tst-rwlock4.c
tst-rwlock5.c
tst-rwlock6.c
tst-rwlock7.c
tst-rwlock8.c
tst-rwlock9.c
tst-sched1.c
tst-sem1.c
tst-sem10.c
tst-sem11.c
tst-sem12.c
tst-sem2.c
tst-sem3.c
tst-sem4.c
tst-sem5.c
tst-sem6.c
tst-sem7.c
tst-sem8.c
tst-sem9.c
tst-setuid1-static.c
tst-setuid1.c
tst-signal1.c
tst-signal2.c
tst-signal3.c
tst-signal4.c
tst-signal5.c
tst-signal6.c
tst-signal7.c
tst-spin1.c
tst-spin2.c
tst-spin3.c
tst-stack1.c
tst-stack2.c
tst-stack3.c
tst-stackguard1-static.c
tst-stackguard1.c
tst-stdio1.c
tst-stdio2.c
tst-sysconf.c
tst-tls1.c
tst-tls2.c
tst-tls3.c
tst-tls3mod.c
tst-tls4.c
tst-tls4moda.c
tst-tls4modb.c
tst-tls5.c
tst-tls5.h
tst-tls5mod.c
tst-tls5moda.c
tst-tls5modb.c
tst-tls5modc.c
tst-tls5modd.c
tst-tls5mode.c
tst-tls5modf.c
tst-tls6.sh
tst-tpp.h
tst-tsd1.c
tst-tsd2.c
tst-tsd3.c
tst-tsd4.c
tst-tsd5.c
tst-typesizes.c
tst-umask1.c
tst-unload.c
tst-vfork1.c
tst-vfork1x.c
tst-vfork2.c
tst-vfork2x.c
unwind.c
vars.c
version.c
nptl_db
nscd
nss
po
posix
pwd
resolv
resource
rt
scripts
setjmp
shadow
signal
socket
soft-fp
stdio-common
stdlib
streams
string
sunrpc
sysdeps
sysvipc
termios
time
timezone
wcsmbs
wctype
.cvsignore
BUGS
CANCEL-FCT-WAIVE
CANCEL-FILE-WAIVE
CONFORMANCE
COPYING
COPYING.LIB
ChangeLog
ChangeLog.1
ChangeLog.10
ChangeLog.11
ChangeLog.12
ChangeLog.13
ChangeLog.14
ChangeLog.15
ChangeLog.16
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
FAQ
FAQ.in
INSTALL
LICENSES
Makeconfig
Makefile
Makefile.in
Makerules
NAMESPACE
NEWS
NOTES
PROJECTS
README
README.libm
README.template
Rules
Versions.def
WUR-REPORT
abi-tags
aclocal.m4
config-name.in
config.h.in
config.make.in
configure
configure.in
cppflags-iterator.mk
extra-lib.mk
extra-modules.mk
o-iterator.mk
shlib-versions
test-skeleton.c
tls.make.c
version.h
Breadcrumbs
glibc
/
nptl
/
pthreadP.h
Blame
Blame
Latest commit
History
History
575 lines (486 loc) · 21.9 KB
Breadcrumbs
glibc
/
nptl
/
pthreadP.h
Top
File metadata and controls
Code
Blame
575 lines (486 loc) · 21.9 KB
Raw
/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #ifndef _PTHREADP_H #define _PTHREADP_H 1 #include <pthread.h> #include <setjmp.h> #include <stdbool.h> #include <sys/syscall.h> #include "descr.h" #include <tls.h> #include <lowlevellock.h> #include <stackinfo.h> #include <internaltypes.h> #include <pthread-functions.h> #include <atomic.h> #include <kernel-features.h> /* Atomic operations on TLS memory. */ #ifndef THREAD_ATOMIC_CMPXCHG_VAL # define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, new, old) \ atomic_compare_and_exchange_val_acq (&(descr)->member, new, old) #endif #ifndef THREAD_ATOMIC_BIT_SET # define THREAD_ATOMIC_BIT_SET(descr, member, bit) \ atomic_bit_set (&(descr)->member, bit) #endif /* Adaptive mutex definitions. */ #ifndef MAX_ADAPTIVE_COUNT # define MAX_ADAPTIVE_COUNT 100 #endif /* Magic cookie representing robust mutex with dead owner. */ #define PTHREAD_MUTEX_INCONSISTENT INT_MAX /* Magic cookie representing not recoverable robust mutex. */ #define PTHREAD_MUTEX_NOTRECOVERABLE (INT_MAX - 1) /* Internal mutex type value. */ enum { PTHREAD_MUTEX_KIND_MASK_NP = 3, PTHREAD_MUTEX_ROBUST_NORMAL_NP = 16, PTHREAD_MUTEX_ROBUST_RECURSIVE_NP = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ADAPTIVE_NP, PTHREAD_MUTEX_PRIO_INHERIT_NP = 32, PTHREAD_MUTEX_PI_NORMAL_NP = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_PI_RECURSIVE_NP = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_PI_ERRORCHECK_NP = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_PI_ADAPTIVE_NP = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ADAPTIVE_NP, PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP, PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_RECURSIVE_NP, PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP, PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP, PTHREAD_MUTEX_PRIO_PROTECT_NP = 64, PTHREAD_MUTEX_PP_NORMAL_NP = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_PP_RECURSIVE_NP = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_PP_ERRORCHECK_NP = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_PP_ADAPTIVE_NP = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP }; #define PTHREAD_MUTEX_TYPE(m) \ ((m)->__data.__kind) /* Ceiling in __data.__lock. __data.__lock is signed, so don't use the MSB bit in there, but in the mask also include that bit, so that the compiler can optimize & PTHREAD_MUTEX_PRIO_CEILING_MASK masking if the value is then shifted down by PTHREAD_MUTEX_PRIO_CEILING_SHIFT. */ #define PTHREAD_MUTEX_PRIO_CEILING_SHIFT 19 #define PTHREAD_MUTEX_PRIO_CEILING_MASK 0xfff80000 /* Flags in mutex attr. */ #define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT 28 #define PTHREAD_MUTEXATTR_PROTOCOL_MASK 0x30000000 #define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT 12 #define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK 0x00fff000 #define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000 #define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000 #define PTHREAD_MUTEXATTR_FLAG_BITS \ (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \ | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK) /* Check whether rwlock prefers readers. */ #define PTHREAD_RWLOCK_PREFER_READER_P(rwlock) \ ((rwlock)->__data.__flags == 0) /* Bits used in robust mutex implementation. */ #define FUTEX_WAITERS 0x80000000 #define FUTEX_OWNER_DIED 0x40000000 #define FUTEX_TID_MASK 0x3fffffff /* Internal variables. */ /* Default stack size. */ extern size_t __default_stacksize attribute_hidden; /* Size and alignment of static TLS block. */ extern size_t __static_tls_size attribute_hidden; extern size_t __static_tls_align_m1 attribute_hidden; /* Flag whether the machine is SMP or not. */ extern int __is_smp attribute_hidden; /* Thread descriptor handling. */ extern list_t __stack_user; hidden_proto (__stack_user) /* Attribute handling. */ extern struct pthread_attr *__attr_list attribute_hidden; extern int __attr_list_lock attribute_hidden; /* First available RT signal. */ extern int __current_sigrtmin attribute_hidden; /* Last available RT signal. */ extern int __current_sigrtmax attribute_hidden; /* Concurrency handling. */ extern int __concurrency_level attribute_hidden; /* Thread-local data key handling. */ extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX]; hidden_proto (__pthread_keys) /* Number of threads running. */ extern unsigned int __nptl_nthreads attribute_hidden; #ifndef __ASSUME_SET_ROBUST_LIST /* Negative if we do not have the system call and we can use it. */ extern int __set_robust_list_avail attribute_hidden; #endif /* Thread Priority Protection. */ extern int __sched_fifo_min_prio attribute_hidden; extern int __sched_fifo_max_prio attribute_hidden; extern void __init_sched_fifo_prio (void) attribute_hidden; extern int __pthread_tpp_change_priority (int prev_prio, int new_prio) attribute_hidden; extern int __pthread_current_priority (void) attribute_hidden; /* The library can run in debugging mode where it performs a lot more tests. */ extern int __pthread_debug attribute_hidden; /** For now disable debugging support. */ #if 0 # define DEBUGGING_P __builtin_expect (__pthread_debug, 0) # define INVALID_TD_P(pd) (DEBUGGING_P && __find_in_stack_list (pd) == NULL) # define INVALID_NOT_TERMINATED_TD_P(pd) INVALID_TD_P (pd) #else # define DEBUGGING_P 0 /* Simplified test. This will not catch all invalid descriptors but is better than nothing. And if the test triggers the thread descriptor is guaranteed to be invalid. */ # define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0) # define INVALID_NOT_TERMINATED_TD_P(pd) __builtin_expect ((pd)->tid < 0, 0) #endif /* Cancellation test. */ #define CANCELLATION_P(self) \ do { \ int cancelhandling = THREAD_GETMEM (self, cancelhandling); \ if (CANCEL_ENABLED_AND_CANCELED (cancelhandling)) \ { \ THREAD_SETMEM (self, result, PTHREAD_CANCELED); \ __do_cancel (); \ } \ } while (0) extern void __pthread_unwind (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute __attribute ((__noreturn__)) #if !defined SHARED && !defined IS_IN_libpthread weak_function #endif ; extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute __attribute ((__noreturn__)) #ifndef SHARED weak_function #endif ; extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute; extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute; #if defined NOT_IN_libc && defined IS_IN_libpthread hidden_proto (__pthread_unwind) hidden_proto (__pthread_unwind_next) hidden_proto (__pthread_register_cancel) hidden_proto (__pthread_unregister_cancel) # ifdef SHARED extern void attribute_hidden pthread_cancel_init (void); # endif #endif /* Called when a thread reacts on a cancellation request. */ static inline void __attribute ((noreturn, always_inline)) __do_cancel (void) { struct pthread *self = THREAD_SELF; /* Make sure we get no more cancellations. */ THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT); __pthread_unwind ((__pthread_unwind_buf_t *) THREAD_GETMEM (self, cleanup_jmp_buf)); } /* Set cancellation mode to asynchronous. */ #define CANCEL_ASYNC() \ __pthread_enable_asynccancel () /* Reset to previous cancellation mode. */ #define CANCEL_RESET(oldtype) \ __pthread_disable_asynccancel (oldtype) #if !defined NOT_IN_libc /* Same as CANCEL_ASYNC, but for use in libc.so. */ # define LIBC_CANCEL_ASYNC() \ __libc_enable_asynccancel () /* Same as CANCEL_RESET, but for use in libc.so. */ # define LIBC_CANCEL_RESET(oldtype) \ __libc_disable_asynccancel (oldtype) # define LIBC_CANCEL_HANDLED() \ __asm (".globl " __SYMBOL_PREFIX "__libc_enable_asynccancel"); \ __asm (".globl " __SYMBOL_PREFIX "__libc_disable_asynccancel") #elif defined NOT_IN_libc && defined IS_IN_libpthread # define LIBC_CANCEL_ASYNC() CANCEL_ASYNC () # define LIBC_CANCEL_RESET(val) CANCEL_RESET (val) # define LIBC_CANCEL_HANDLED() \ __asm (".globl " __SYMBOL_PREFIX "__pthread_enable_asynccancel"); \ __asm (".globl " __SYMBOL_PREFIX "__pthread_disable_asynccancel") #elif defined NOT_IN_libc && defined IS_IN_librt # define LIBC_CANCEL_ASYNC() \ __librt_enable_asynccancel () # define LIBC_CANCEL_RESET(val) \ __librt_disable_asynccancel (val) # define LIBC_CANCEL_HANDLED() \ __asm (".globl " __SYMBOL_PREFIX "__librt_enable_asynccancel"); \ __asm (".globl " __SYMBOL_PREFIX "__librt_disable_asynccancel") #else # define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ # define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ # define LIBC_CANCEL_HANDLED() /* Nothing. */ #endif /* The signal used for asynchronous cancelation. */ #define SIGCANCEL __SIGRTMIN /* Signal needed for the kernel-supported POSIX timer implementation. We can reuse the cancellation signal since we can distinguish cancellation from timer expirations. */ #define SIGTIMER SIGCANCEL /* Signal used to implement the setuid et.al. functions. */ #define SIGSETXID (__SIGRTMIN + 1) /* Used to communicate with signal handler. */ extern struct xid_command *__xidcmd attribute_hidden; /* Internal prototypes. */ /* Thread list handling. */ extern struct pthread *__find_in_stack_list (struct pthread *pd) attribute_hidden internal_function; /* Deallocate a thread's stack after optionally making sure the thread descriptor is still valid. */ extern void __free_tcb (struct pthread *pd) attribute_hidden internal_function; /* Free allocated stack. */ extern void __deallocate_stack (struct pthread *pd) attribute_hidden internal_function; /* Mark all the stacks except for the current one as available. This function also re-initializes the lock for the stack cache. */ extern void __reclaim_stacks (void) attribute_hidden; /* Make all threads's stacks executable. */ extern int __make_stacks_executable (void **stack_endp) internal_function attribute_hidden; /* longjmp handling. */ extern void __pthread_cleanup_upto (__jmp_buf target, char *targetframe); #if defined NOT_IN_libc && defined IS_IN_libpthread hidden_proto (__pthread_cleanup_upto) #endif /* Functions with versioned interfaces. */ extern int __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); extern int __pthread_create_2_0 (pthread_t *newthread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); extern int __pthread_attr_init_2_1 (pthread_attr_t *attr); extern int __pthread_attr_init_2_0 (pthread_attr_t *attr); /* Event handlers for libthread_db interface. */ extern void __nptl_create_event (void); extern void __nptl_death_event (void); hidden_proto (__nptl_create_event) hidden_proto (__nptl_death_event) /* Register the generation counter in the libpthread with the libc. */ #ifdef TLS_MULTIPLE_THREADS_IN_TCB extern void __libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void), const struct pthread_functions *functions) internal_function; #else extern int *__libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void), const struct pthread_functions *functions) internal_function; /* Variable set to a nonzero value if more than one thread runs or ran. */ extern int __pthread_multiple_threads attribute_hidden; /* Pointer to the corresponding variable in libc. */ extern int *__libc_multiple_threads_ptr attribute_hidden; #endif /* Find a thread given its TID. */ extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden #ifdef SHARED ; #else weak_function; #define __find_thread_by_id(tid) \ (__find_thread_by_id ? (__find_thread_by_id) (tid) : (struct pthread *) NULL) #endif extern void __pthread_init_static_tls (struct link_map *) attribute_hidden; /* Namespace save aliases. */ extern int __pthread_getschedparam (pthread_t thread_id, int *policy, struct sched_param *param); extern int __pthread_setschedparam (pthread_t thread_id, int policy, const struct sched_param *param); extern int __pthread_setcancelstate (int state, int *oldstate); extern int __pthread_mutex_init (pthread_mutex_t *__mutex, __const pthread_mutexattr_t *__mutexattr); extern int __pthread_mutex_init_internal (pthread_mutex_t *__mutex, __const pthread_mutexattr_t *__mutexattr) attribute_hidden; extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex); extern int __pthread_mutex_destroy_internal (pthread_mutex_t *__mutex) attribute_hidden; extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex); extern int __pthread_mutex_lock (pthread_mutex_t *__mutex); extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex) attribute_hidden; extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex) attribute_hidden internal_function; extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex); extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex) attribute_hidden; extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex, int __decr) attribute_hidden internal_function; extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr); extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr); extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind); extern int __pthread_attr_destroy (pthread_attr_t *attr); extern int __pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate); extern int __pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate); extern int __pthread_attr_getinheritsched (const pthread_attr_t *attr, int *inherit); extern int __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit); extern int __pthread_attr_getschedparam (const pthread_attr_t *attr, struct sched_param *param); extern int __pthread_attr_setschedparam (pthread_attr_t *attr, const struct sched_param *param); extern int __pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy); extern int __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy); extern int __pthread_attr_getscope (const pthread_attr_t *attr, int *scope); extern int __pthread_attr_setscope (pthread_attr_t *attr, int scope); extern int __pthread_attr_getstackaddr (__const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr); extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr, void *__stackaddr); extern int __pthread_attr_getstacksize (__const pthread_attr_t *__restrict __attr, size_t *__restrict __stacksize); extern int __pthread_attr_setstacksize (pthread_attr_t *__attr, size_t __stacksize); extern int __pthread_attr_getstack (__const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr, size_t *__restrict __stacksize); extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, size_t __stacksize); extern int __pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, __const pthread_rwlockattr_t *__restrict __attr); extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_rdlock_internal (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_wrlock_internal (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock); extern int __pthread_rwlock_unlock_internal (pthread_rwlock_t *__rwlock); extern int __pthread_cond_broadcast (pthread_cond_t *cond); extern int __pthread_cond_destroy (pthread_cond_t *cond); extern int __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *cond_attr); extern int __pthread_cond_signal (pthread_cond_t *cond); extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex); extern int __pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime); extern int __pthread_condattr_destroy (pthread_condattr_t *attr); extern int __pthread_condattr_init (pthread_condattr_t *attr); extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *)); extern int __pthread_key_create_internal (pthread_key_t *key, void (*destr) (void *)); extern void *__pthread_getspecific (pthread_key_t key); extern void *__pthread_getspecific_internal (pthread_key_t key); extern int __pthread_setspecific (pthread_key_t key, const void *value); extern int __pthread_setspecific_internal (pthread_key_t key, const void *value); extern int __pthread_once (pthread_once_t *once_control, void (*init_routine) (void)); extern int __pthread_once_internal (pthread_once_t *once_control, void (*init_routine) (void)); extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void), void (*child) (void)); extern pthread_t __pthread_self (void); extern int __pthread_equal (pthread_t thread1, pthread_t thread2); extern int __pthread_kill (pthread_t threadid, int signo); extern void __pthread_exit (void *value); extern int __pthread_setcanceltype (int type, int *oldtype); extern int __pthread_enable_asynccancel (void) attribute_hidden; extern void __pthread_disable_asynccancel (int oldtype) internal_function attribute_hidden; extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond); extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond); extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond, const pthread_condattr_t *cond_attr); extern int __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond); extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime); extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex); extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset); /* The two functions are in libc.so and not exported. */ extern int __libc_enable_asynccancel (void) attribute_hidden; extern void __libc_disable_asynccancel (int oldtype) internal_function attribute_hidden; /* The two functions are in librt.so and not exported. */ extern int __librt_enable_asynccancel (void) attribute_hidden; extern void __librt_disable_asynccancel (int oldtype) internal_function attribute_hidden; #ifdef IS_IN_libpthread /* Special versions which use non-exported functions. */ extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer, void (*routine) (void *), void *arg) attribute_hidden; # undef pthread_cleanup_push # define pthread_cleanup_push(routine,arg) \ { struct _pthread_cleanup_buffer _buffer; \ __pthread_cleanup_push (&_buffer, (routine), (arg)); extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer, int execute) attribute_hidden; # undef pthread_cleanup_pop # define pthread_cleanup_pop(execute) \ __pthread_cleanup_pop (&_buffer, (execute)); } #endif extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer, void (*routine) (void *), void *arg); extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer, int execute); /* Old cleanup interfaces, still used in libc.so. */ extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer, void (*routine) (void *), void *arg); extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer, int execute); extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer, void (*routine) (void *), void *arg); extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer, int execute); extern void __nptl_deallocate_tsd (void) attribute_hidden; extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden; extern void __free_stack_cache (void) attribute_hidden; extern void __wait_lookup_done (void) attribute_hidden; #ifdef SHARED # define PTHREAD_STATIC_FN_REQUIRE(name) #else # define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name); #endif #ifndef __NR_set_robust_list /* XXX For the time being... Once we can rely on the kernel headers having the definition remove these lines. */ # if defined __i386__ # define __NR_set_robust_list 311 # elif defined __x86_64__ # define __NR_set_robust_list 273 # endif #endif #endif /* pthreadP.h */
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
You can’t perform that action at this time.