1/* __get_pthread_stack_min (). Linux version.
2 Copyright (C) 2021-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/* Return sysconf (_SC_THREAD_STACK_MIN). */
20
21static inline long int
22__get_pthread_stack_min (void)
23{
24 /* sysconf (_SC_THREAD_STACK_MIN) >= sysconf (_SC_MINSIGSTKSZ). */
25 long int pthread_stack_min = GLRO(dl_minsigstacksize);
26 assert (pthread_stack_min != 0);
27 _Static_assert (__builtin_constant_p (PTHREAD_STACK_MIN),
28 "PTHREAD_STACK_MIN is constant");
29 /* Return MAX (PTHREAD_STACK_MIN, pthread_stack_min). */
30 if (pthread_stack_min < PTHREAD_STACK_MIN)
31 pthread_stack_min = PTHREAD_STACK_MIN;
32 /* We have a private interface, __pthread_get_minstack@GLIBC_PRIVATE
33 which returns a larger size that includes the required TLS variable
34 space which has been determined at startup. For sysconf here we are
35 conservative and don't include the space required for TLS access.
36 Eventually the TLS variable space will not be part of the stack
37 (Bug 11787). */
38 return pthread_stack_min;
39}
40

source code of glibc/sysdeps/unix/sysv/linux/sysconf-pthread_stack_min.h