1 /* Internal per-thread variables for the Hurd. 2 Copyright (C) 1994-2022 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, see 17 <https://www.gnu.org/licenses/>. */ 18 19 #ifndef _HURD_THREADVAR_H 20 #define _HURD_THREADVAR_H 21 22 #include <features.h> 23 #include <tls.h> 24 25 /* The per-thread variables are found by ANDing this mask 26 with the value of the stack pointer and then adding this offset. 27 28 In the multi-threaded case, cthreads initialization sets 29 __hurd_threadvar_stack_mask to ~(cthread_stack_size - 1), a mask which 30 finds the base of the fixed-size cthreads stack; and 31 __hurd_threadvar_stack_offset to a small offset that skips the data 32 cthreads itself maintains at the base of each thread's stack. 33 34 In the single-threaded or libpthread case, __hurd_threadvar_stack_mask is 35 zero, so the stack pointer is ignored. */ 36 37 extern unsigned long int __hurd_threadvar_stack_mask; 38 extern unsigned long int __hurd_threadvar_stack_offset; 39 40 /* The variables __hurd_sigthread_stack_base and 41 __hurd_sigthread_stack_end define the bounds of the stack used by the 42 signal thread, so that thread can always be specifically identified. */ 43 44 extern unsigned long int __hurd_sigthread_stack_base; 45 extern unsigned long int __hurd_sigthread_stack_end; 46 47 /* Store the MiG reply port reply port until we enable TLS. */ 48 extern mach_port_t __hurd_reply_port0; 49 50 /* This returns either the TLS reply port variable, or a single-thread variable 51 when TLS is not initialized yet. */ 52 #define __hurd_local_reply_port (*(__LIBC_NO_TLS () ? &__hurd_reply_port0 : &THREAD_SELF->reply_port)) 53 54 #endif /* hurd/threadvar.h */ 55